Skip to content

Commit

Permalink
Avoid race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
Lpsd authored and sbx320 committed Jul 2, 2023
1 parent 24a7be8 commit 18a3d32
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
4 changes: 1 addition & 3 deletions Client/core/CGUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,9 +430,7 @@ void CLocalGUI::SetMainMenuVisible(bool bVisible)
pGUI->SelectInputHandlers(INPUT_MOD);
}

if (bVisible)
pGUI->SetCursorAlpha(1.0f);
else
if (!bVisible)
pGUI->SetCursorAlpha(pGUI->GetCurrentServerCursorAlpha());
}
}
Expand Down
17 changes: 17 additions & 0 deletions Client/core/CMainMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ CMainMenu::CMainMenu(CGUI* pManager)
m_bStarted = false;
m_fFader = 0;
m_ucFade = FADE_INVISIBLE;
m_bCursorAlphaReset = false;

// Adjust window size to resolution
CVector2D ScreenSize = m_pManager->GetResolution();
Expand Down Expand Up @@ -587,6 +588,17 @@ void CMainMenu::Update()
if (m_fFader > 0.0f)
{
m_bIsVisible = true; // Make cursor appear faster

if (!m_bCursorAlphaReset)
{
CGUI* pGUI = g_pCore->GetGUI();

if (pGUI)
{
pGUI->SetCursorAlpha(1.0f);
m_bCursorAlphaReset = true;
}
}
}

// If the fade is complete
Expand All @@ -595,6 +607,7 @@ void CMainMenu::Update()
m_ucFade = FADE_VISIBLE;
m_bIsVisible = true;
m_bIsFullyVisible = true;

}
}
// Fade out
Expand All @@ -608,7 +621,11 @@ void CMainMenu::Update()
m_pBackground->SetAlpha(Clamp(0.f, m_fFader, CORE_MTA_BG_MAX_ALPHA));

if (m_fFader < 1.0f)
{
m_bIsVisible = false; // Make cursor disappear faster
m_bCursorAlphaReset = false;
}


// If the fade is complete
if (m_fFader <= 0)
Expand Down
1 change: 1 addition & 0 deletions Client/core/CMainMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ class CMainMenu
// Fade variables
unsigned char m_ucFade;
float m_fFader;
bool m_bCursorAlphaReset;

// Animation variables
unsigned long ulPreviousTick;
Expand Down

0 comments on commit 18a3d32

Please sign in to comment.