Skip to content

Commit

Permalink
Fix #2944: Fix cursor alpha issues (#3034)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lpsd committed Jun 12, 2023
1 parent 6c1f318 commit 87e3dce
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Client/core/CGUI.cpp
Expand Up @@ -383,7 +383,7 @@ void CLocalGUI::SetConsoleVisible(bool bVisible)
CGUI* pGUI = CCore::GetSingleton().GetGUI();
if (bVisible)
pGUI->SetCursorAlpha(1.0f);
else
else if (!g_pCore->IsMenuVisible())
pGUI->SetCursorAlpha(pGUI->GetCurrentServerCursorAlpha());
}
}
Expand Down
5 changes: 5 additions & 0 deletions Client/core/CMessageLoopHook.cpp
Expand Up @@ -293,6 +293,11 @@ LRESULT CALLBACK CMessageLoopHook::ProcessMessage(HWND hwnd, UINT uMsg, WPARAM w
{
ms_bIgnoreNextEscapeCharacter = true;
pConsole->SetVisible(false);

CGUI* pGUI = g_pCore->GetGUI();
if (!g_pCore->IsMenuVisible())
pGUI->SetCursorAlpha(pGUI->GetCurrentServerCursorAlpha());

return true;
}

Expand Down
7 changes: 6 additions & 1 deletion Client/gui/CGUI_Impl.cpp
Expand Up @@ -499,7 +499,12 @@ void CGUI_Impl::SetCursorAlpha(float fAlpha, bool bOnlyCurrentServer)
CEGUI::MouseCursor::getSingleton().setAlpha(fAlpha);

if (bOnlyCurrentServer)
m_fCurrentServerCursorAlpha = fAlpha;
SetCurrentServerCursorAlpha(fAlpha);
}

void CGUI_Impl::SetCurrentServerCursorAlpha(float fAlpha)
{
m_fCurrentServerCursorAlpha = fAlpha;
}

float CGUI_Impl::GetCurrentServerCursorAlpha()
Expand Down
1 change: 1 addition & 0 deletions Client/gui/CGUI_Impl.h
Expand Up @@ -143,6 +143,7 @@ class CGUI_Impl : public CGUI, public CGUITabList
void SetCursorEnabled(bool bEnabled);
bool IsCursorEnabled();
void SetCursorAlpha(float fAlpha, bool bOnlyCurrentServer = false);
void SetCurrentServerCursorAlpha(float fAlpha);
float GetCurrentServerCursorAlpha();
eCursorType GetCursorType();

Expand Down
6 changes: 5 additions & 1 deletion Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp
Expand Up @@ -5030,7 +5030,11 @@ bool CStaticFunctionDefinitions::SetCursorAlpha(float fAlpha)
{
if (fAlpha >= 0.0f && fAlpha <= 1.0f)
{
m_pGUI->SetCursorAlpha(fAlpha, true);
if (!m_pCore->IsMenuVisible() && !m_pCore->GetConsole()->IsVisible())
m_pGUI->SetCursorAlpha(fAlpha, true);
else
m_pGUI->SetCurrentServerCursorAlpha(fAlpha);

return true;
}
return false;
Expand Down
1 change: 1 addition & 0 deletions Client/sdk/gui/CGUI.h
Expand Up @@ -126,6 +126,7 @@ class CGUI
virtual void SetCursorEnabled(bool bEnabled) = 0;
virtual bool IsCursorEnabled() = 0;
virtual void SetCursorAlpha(float fAlpha, bool bOnlyCurrentServer = false) = 0;
virtual void SetCurrentServerCursorAlpha(float fAlpha) = 0;
virtual float GetCurrentServerCursorAlpha() = 0;
virtual eCursorType GetCursorType() = 0;

Expand Down

0 comments on commit 87e3dce

Please sign in to comment.