Skip to content

Commit bb1f675

Browse files
authored
Fix #3088: Resolve cursor being invisible with main menu open in certain scenarios (#3089)
Avoid race condition
1 parent 24a7be8 commit bb1f675

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

Client/core/CGUI.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -430,9 +430,7 @@ void CLocalGUI::SetMainMenuVisible(bool bVisible)
430430
pGUI->SelectInputHandlers(INPUT_MOD);
431431
}
432432

433-
if (bVisible)
434-
pGUI->SetCursorAlpha(1.0f);
435-
else
433+
if (!bVisible)
436434
pGUI->SetCursorAlpha(pGUI->GetCurrentServerCursorAlpha());
437435
}
438436
}

Client/core/CMainMenu.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ CMainMenu::CMainMenu(CGUI* pManager)
7676
m_bStarted = false;
7777
m_fFader = 0;
7878
m_ucFade = FADE_INVISIBLE;
79+
m_bCursorAlphaReset = false;
7980

8081
// Adjust window size to resolution
8182
CVector2D ScreenSize = m_pManager->GetResolution();
@@ -587,6 +588,17 @@ void CMainMenu::Update()
587588
if (m_fFader > 0.0f)
588589
{
589590
m_bIsVisible = true; // Make cursor appear faster
591+
592+
if (!m_bCursorAlphaReset)
593+
{
594+
CGUI* pGUI = g_pCore->GetGUI();
595+
596+
if (pGUI)
597+
{
598+
pGUI->SetCursorAlpha(1.0f);
599+
m_bCursorAlphaReset = true;
600+
}
601+
}
590602
}
591603

592604
// If the fade is complete
@@ -595,6 +607,7 @@ void CMainMenu::Update()
595607
m_ucFade = FADE_VISIBLE;
596608
m_bIsVisible = true;
597609
m_bIsFullyVisible = true;
610+
598611
}
599612
}
600613
// Fade out
@@ -608,7 +621,11 @@ void CMainMenu::Update()
608621
m_pBackground->SetAlpha(Clamp(0.f, m_fFader, CORE_MTA_BG_MAX_ALPHA));
609622

610623
if (m_fFader < 1.0f)
624+
{
611625
m_bIsVisible = false; // Make cursor disappear faster
626+
m_bCursorAlphaReset = false;
627+
}
628+
612629

613630
// If the fade is complete
614631
if (m_fFader <= 0)

Client/core/CMainMenu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ class CMainMenu
150150
// Fade variables
151151
unsigned char m_ucFade;
152152
float m_fFader;
153+
bool m_bCursorAlphaReset;
153154

154155
// Animation variables
155156
unsigned long ulPreviousTick;

0 commit comments

Comments
 (0)