Skip to content

Commit

Permalink
Fix cursor disappearing after 9e4a07d (#943)
Browse files Browse the repository at this point in the history
Also restored cursor show/hide code in StartMenu/StopMenu that was removed.
It fits there.
  • Loading branch information
Xottab-DUTY committed Dec 22, 2024
1 parent 0dfcfae commit ca697e8
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/xrGame/Level.h
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,8 @@ class CLevel : public IGame_Level, public IPureClient

void IR_OnControllerAttitudeChange(Fvector change) override;

void IR_OnActivate(void) override;
void IR_OnActivate() override;
void IR_OnDeactivate() override;

// Returns respawn point ID
int get_RPID(LPCSTR name); // Xottab_DUTY: Seems to be deprecated
Expand Down
9 changes: 9 additions & 0 deletions src/xrGame/Level_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,9 @@ void CLevel::IR_OnControllerAttitudeChange(Fvector change)

void CLevel::IR_OnActivate()
{
if (CUIGameCustom* ui = CurrentGameUI())
ui->MarkForemost(true);

if (!pInput)
return;

Expand Down Expand Up @@ -715,3 +718,9 @@ void CLevel::IR_OnActivate()
};
}
}

void CLevel::IR_OnDeactivate()
{
if (CUIGameCustom* ui = CurrentGameUI())
ui->MarkForemost(false);
}
10 changes: 10 additions & 0 deletions src/xrGame/MainMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,16 @@ bool CMainMenu::ReloadUI()
bool CMainMenu::IsActive() const { return m_Flags.test(flActive); }
bool CMainMenu::CanSkipSceneRendering() { return IsActive() && !m_Flags.test(flGameSaveScreenshot); }

void CMainMenu::IR_OnActivate()
{
MarkForemost(true);
}

void CMainMenu::IR_OnDeactivate()
{
MarkForemost(false);
}

// IInputReceiver
void CMainMenu::IR_OnMousePress(int btn)
{
Expand Down
3 changes: 3 additions & 0 deletions src/xrGame/MainMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ class CMainMenu : public IMainMenu,

bool IgnorePause() override { return true; }

void IR_OnActivate() override;
void IR_OnDeactivate() override;

void IR_OnMousePress(int btn) override;
void IR_OnMouseRelease(int btn) override;
void IR_OnMouseHold(int btn) override;
Expand Down
11 changes: 10 additions & 1 deletion src/xrGame/UIDialogHolder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ void CDialogHolder::StartMenu(CUIDialogWnd* pDialog, bool bDoHideIndicators)
SetFocused(nullptr);
pDialog->SetHolder(this);

if (pDialog->NeedCursor())
{
GetUICursor().Show();
m_become_visible_time = Device.dwTimeContinual;
}

if (g_pGameLevel)
{
CActor* A = smart_cast<CActor*>(Level().CurrentViewEntity());
Expand Down Expand Up @@ -94,6 +100,9 @@ void CDialogHolder::StopMenu(CUIDialogWnd* pDialog)

RemoveDialogToRender(pDialog);
pDialog->SetHolder(NULL);

if (!TopInputReceiver() || !TopInputReceiver()->NeedCursor())
GetUICursor().Hide();
}

void CDialogHolder::AddDialogToRender(CUIWindow* pDialog)
Expand Down Expand Up @@ -224,7 +233,7 @@ void CDialogHolder::OnFrame()

m_b_in_update = true;

if (!GEnv.isDedicatedServer)
if (m_is_foremost && !GEnv.isDedicatedServer)
{
auto& cursor = GetUICursor();
const bool need_cursor = TopInputReceiver() && TopInputReceiver()->NeedCursor();
Expand Down
3 changes: 3 additions & 0 deletions src/xrGame/UIDialogHolder.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class CDialogHolder : public pureFrame, public CUIDebuggable, public CUIFocusSys
xr_vector<dlgItem> m_dialogsToRender_new;
u32 m_become_visible_time{};
bool m_b_in_update;
bool m_is_foremost{};

void StartMenu(CUIDialogWnd* pDialog, bool bDoHideIndicators);
void StopMenu(CUIDialogWnd* pDialog);
Expand Down Expand Up @@ -78,6 +79,8 @@ class CDialogHolder : public pureFrame, public CUIDebuggable, public CUIFocusSys
virtual bool IR_UIOnControllerRelease(int dik, float x, float y);
virtual bool IR_UIOnControllerHold(int dik, float x, float y);

void MarkForemost(bool foremost) { m_is_foremost = foremost; }

pcstr GetDebugType() override { return "CDialogHolder"; }
bool FillDebugTree(const CUIDebugState& debugState) override;
void FillDebugInfo() override;
Expand Down

0 comments on commit ca697e8

Please sign in to comment.