From 9c2a471bc36b21125d17e0c3d7186c0a2022c868 Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Sun, 7 Jul 2024 22:02:31 +0300 Subject: [PATCH 01/26] cursor color function --- Client/core/CGUI.cpp | 19 +++++++++++++++++-- Client/core/CMessageLoopHook.cpp | 11 +++++++++-- Client/gui/CGUI_Impl.cpp | 14 ++++++++++++++ Client/gui/CGUI_Impl.h | 5 +++++ .../logic/luadefs/CLuaClientDefs.cpp | 10 +++++++++- .../deathmatch/logic/luadefs/CLuaClientDefs.h | 1 + Client/sdk/gui/CGUI.h | 2 ++ .../include/CEGUIMouseCursor.h | 1 + .../src/CEGUIMouseCursor.cpp | 8 +++++++- 9 files changed, 65 insertions(+), 6 deletions(-) diff --git a/Client/core/CGUI.cpp b/Client/core/CGUI.cpp index a64955ac79d..8cdd1c3b03a 100644 --- a/Client/core/CGUI.cpp +++ b/Client/core/CGUI.cpp @@ -381,10 +381,16 @@ void CLocalGUI::SetConsoleVisible(bool bVisible) m_pConsole->SetVisible(bVisible); CGUI* pGUI = CCore::GetSingleton().GetGUI(); + float r; + float g; + float b; + float a; + std::tie(r, b, g, a) = pGUI->GetCursorColor(); + if (bVisible) - pGUI->SetCursorAlpha(1.0f); + pGUI->SetCursorColor(r,b,g,a); else if (!g_pCore->IsMenuVisible()) - pGUI->SetCursorAlpha(pGUI->GetCurrentServerCursorAlpha()); + pGUI->SetCursorColor(r,b,g,a); } } @@ -431,7 +437,16 @@ void CLocalGUI::SetMainMenuVisible(bool bVisible) } if (!bVisible) + { + float r; + float g; + float b; + float a; pGUI->SetCursorAlpha(pGUI->GetCurrentServerCursorAlpha()); + std::tie(r, b, g, a) = pGUI->GetCursorColor(); + pGUI->SetCursorColor(r, g, b, a); + } + } } diff --git a/Client/core/CMessageLoopHook.cpp b/Client/core/CMessageLoopHook.cpp index 5424e23435c..ea61da5e3d2 100644 --- a/Client/core/CMessageLoopHook.cpp +++ b/Client/core/CMessageLoopHook.cpp @@ -295,9 +295,16 @@ LRESULT CALLBACK CMessageLoopHook::ProcessMessage(HWND hwnd, UINT uMsg, WPARAM w pConsole->SetVisible(false); CGUI* pGUI = g_pCore->GetGUI(); - if (!g_pCore->IsMenuVisible()) - pGUI->SetCursorAlpha(pGUI->GetCurrentServerCursorAlpha()); + float r; + float g; + float b; + float a; + if (!g_pCore->IsMenuVisible()) + { + std::tie(r, b, g, a) = pGUI->GetCursorColor(); + pGUI->SetCursorColor(r,g,b,a); + } return true; } diff --git a/Client/gui/CGUI_Impl.cpp b/Client/gui/CGUI_Impl.cpp index 67d625ed5ec..85423f43f4a 100644 --- a/Client/gui/CGUI_Impl.cpp +++ b/Client/gui/CGUI_Impl.cpp @@ -502,6 +502,20 @@ void CGUI_Impl::SetCursorAlpha(float fAlpha, bool bOnlyCurrentServer) SetCurrentServerCursorAlpha(fAlpha); } +void CGUI_Impl::SetCursorColor(float r, float g, float b, float alpha) +{ + CEGUI::MouseCursor::getSingleton().setColor(r,g,b,alpha); + m_fCurrentServerCursorRed = r; + m_fCurrentServerCursorGreen = g; + m_fCurrentServerCursorBlue = b; + m_fCurrentServerCursorAlpha = alpha; +} + +std::tuple CGUI_Impl::GetCursorColor() +{ + return std::make_tuple(m_fCurrentServerCursorRed, m_fCurrentServerCursorGreen, m_fCurrentServerCursorBlue, m_fCurrentServerCursorAlpha); +} + void CGUI_Impl::SetCurrentServerCursorAlpha(float fAlpha) { m_fCurrentServerCursorAlpha = fAlpha; diff --git a/Client/gui/CGUI_Impl.h b/Client/gui/CGUI_Impl.h index 30153808665..023d273f2a0 100644 --- a/Client/gui/CGUI_Impl.h +++ b/Client/gui/CGUI_Impl.h @@ -145,6 +145,8 @@ class CGUI_Impl : public CGUI, public CGUITabList void SetCursorAlpha(float fAlpha, bool bOnlyCurrentServer = false); void SetCurrentServerCursorAlpha(float fAlpha); float GetCurrentServerCursorAlpha(); + void SetCursorColor(float r, float g, float b, float alpha); + std::tuple GetCursorColor(); eCursorType GetCursorType(); void AddChild(CGUIElement_Impl* pChild); @@ -312,6 +314,9 @@ class CGUI_Impl : public CGUI, public CGUITabList CEGUI::DefaultWindow* m_pTop; const CEGUI::Image* m_pCursor; float m_fCurrentServerCursorAlpha; + float m_fCurrentServerCursorRed; + float m_fCurrentServerCursorGreen; + float m_fCurrentServerCursorBlue; CGUIFont_Impl* m_pDefaultFont; CGUIFont_Impl* m_pSmallFont; diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp index 2d9e72c340a..fdd6c192516 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp @@ -23,7 +23,8 @@ void CLuaClientDefs::LoadFunctions() {"isChatInputBlocked", ArgumentParser}, {"clearDebugBox", ArgumentParser}, {"isMTAWindowFocused", ArgumentParser}, - {"isCapsLockEnabled", ArgumentParser}}; + {"isCapsLockEnabled", ArgumentParser}, + {"setCursorColor", ArgumentParser}}; for (const auto& [name, func] : functions) CLuaCFunctions::AddFunction(name, func); @@ -80,3 +81,10 @@ bool CLuaClientDefs::IsCapsLockEnabled() { return ((::GetKeyState(VK_CAPITAL) & 0x0001) != 0); } + +bool CLuaClientDefs::SetCursorColor(float r, float g, float b, float alpha) +{ + CGUI* pGUI = g_pCore->GetGUI(); + pGUI->SetCursorColor(r, b, g, alpha); + return true; +} diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.h b/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.h index 7b3b276b83e..9fea69a88a9 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.h +++ b/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.h @@ -17,6 +17,7 @@ class CLuaClientDefs : public CLuaDefs { public: static void LoadFunctions(); + static bool SetCursorColor(float r, float g, float b, float alpha); private: static bool SetTransferBoxVisible(bool visible); diff --git a/Client/sdk/gui/CGUI.h b/Client/sdk/gui/CGUI.h index d6e27bd3da5..526861f87b9 100644 --- a/Client/sdk/gui/CGUI.h +++ b/Client/sdk/gui/CGUI.h @@ -126,6 +126,8 @@ class CGUI virtual void SetCursorEnabled(bool bEnabled) = 0; virtual bool IsCursorEnabled() = 0; virtual void SetCursorAlpha(float fAlpha, bool bOnlyCurrentServer = false) = 0; + virtual void SetCursorColor(float r, float g, float b, float alpha) = 0; + virtual std::tuple GetCursorColor() = 0; virtual void SetCurrentServerCursorAlpha(float fAlpha) = 0; virtual float GetCurrentServerCursorAlpha() = 0; virtual eCursorType GetCursorType() = 0; diff --git a/vendor/cegui-0.4.0-custom/include/CEGUIMouseCursor.h b/vendor/cegui-0.4.0-custom/include/CEGUIMouseCursor.h index 27682e2efd1..2e9d03a1572 100644 --- a/vendor/cegui-0.4.0-custom/include/CEGUIMouseCursor.h +++ b/vendor/cegui-0.4.0-custom/include/CEGUIMouseCursor.h @@ -188,6 +188,7 @@ class CEGUIEXPORT MouseCursor : public EventSet, public Singleton Nothing. */ void setAlpha(float alpha); + void setColor(float r, float g, float b, float alpha); /*! \brief diff --git a/vendor/cegui-0.4.0-custom/src/CEGUIMouseCursor.cpp b/vendor/cegui-0.4.0-custom/src/CEGUIMouseCursor.cpp index 5c8b12db41e..183a620b5ec 100644 --- a/vendor/cegui-0.4.0-custom/src/CEGUIMouseCursor.cpp +++ b/vendor/cegui-0.4.0-custom/src/CEGUIMouseCursor.cpp @@ -154,7 +154,13 @@ void MouseCursor::setAlpha(float alpha) d_colourRect.setColours(colour(1.0f, 1.0f, 1.0f, alpha)); } - +/************************************************************************* + Set the mouse cursor's color +*************************************************************************/ +void MouseCursor::setColor(float r, float g, float b, float alpha) +{ + d_colourRect.setColours(colour(r/255.f, g/255.f, b/255.f, alpha)); +} /************************************************************************* Checks the mouse cursor position is within the current 'constrain' Rect and adjusts as required. From dc4f25d42568f5827a8897cdc5ca8e73c609448d Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Sun, 7 Jul 2024 22:09:03 +0300 Subject: [PATCH 02/26] fix wrong swap --- Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp index fdd6c192516..388f19e7e38 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp @@ -85,6 +85,6 @@ bool CLuaClientDefs::IsCapsLockEnabled() bool CLuaClientDefs::SetCursorColor(float r, float g, float b, float alpha) { CGUI* pGUI = g_pCore->GetGUI(); - pGUI->SetCursorColor(r, b, g, alpha); + pGUI->SetCursorColor(r, g, b, alpha); return true; } From db2d63a2156c497d8f6eba34c11579e1300a9eaf Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Sun, 7 Jul 2024 22:14:49 +0300 Subject: [PATCH 03/26] fixes swap parameters --- Client/core/CGUI.cpp | 2 +- Client/core/CMessageLoopHook.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Client/core/CGUI.cpp b/Client/core/CGUI.cpp index 8cdd1c3b03a..dbe76a627d7 100644 --- a/Client/core/CGUI.cpp +++ b/Client/core/CGUI.cpp @@ -443,7 +443,7 @@ void CLocalGUI::SetMainMenuVisible(bool bVisible) float b; float a; pGUI->SetCursorAlpha(pGUI->GetCurrentServerCursorAlpha()); - std::tie(r, b, g, a) = pGUI->GetCursorColor(); + std::tie(r,g,b,a) = pGUI->GetCursorColor(); pGUI->SetCursorColor(r, g, b, a); } diff --git a/Client/core/CMessageLoopHook.cpp b/Client/core/CMessageLoopHook.cpp index ea61da5e3d2..27f0169017d 100644 --- a/Client/core/CMessageLoopHook.cpp +++ b/Client/core/CMessageLoopHook.cpp @@ -302,7 +302,7 @@ LRESULT CALLBACK CMessageLoopHook::ProcessMessage(HWND hwnd, UINT uMsg, WPARAM w if (!g_pCore->IsMenuVisible()) { - std::tie(r, b, g, a) = pGUI->GetCursorColor(); + std::tie(r, g, b, a) = pGUI->GetCursorColor(); pGUI->SetCursorColor(r,g,b,a); } return true; From f5382f3709bd25b2bcf25bc9bb2b313683f69abb Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Mon, 8 Jul 2024 16:47:18 +0300 Subject: [PATCH 04/26] fixes , add getCursorColor --- Client/core/CGUI.cpp | 19 ++----------------- Client/core/CMessageLoopHook.cpp | 9 +++------ Client/gui/CGUI_Impl.cpp | 7 +++++-- Client/gui/CGUI_Impl.h | 10 +++++----- .../logic/luadefs/CLuaClientDefs.cpp | 11 ++++++++++- .../deathmatch/logic/luadefs/CLuaClientDefs.h | 1 + Client/sdk/gui/CGUI.h | 2 +- 7 files changed, 27 insertions(+), 32 deletions(-) diff --git a/Client/core/CGUI.cpp b/Client/core/CGUI.cpp index dbe76a627d7..52b190c59e6 100644 --- a/Client/core/CGUI.cpp +++ b/Client/core/CGUI.cpp @@ -380,17 +380,6 @@ void CLocalGUI::SetConsoleVisible(bool bVisible) // Set the visible state m_pConsole->SetVisible(bVisible); - CGUI* pGUI = CCore::GetSingleton().GetGUI(); - float r; - float g; - float b; - float a; - std::tie(r, b, g, a) = pGUI->GetCursorColor(); - - if (bVisible) - pGUI->SetCursorColor(r,b,g,a); - else if (!g_pCore->IsMenuVisible()) - pGUI->SetCursorColor(r,b,g,a); } } @@ -438,12 +427,8 @@ void CLocalGUI::SetMainMenuVisible(bool bVisible) if (!bVisible) { - float r; - float g; - float b; - float a; - pGUI->SetCursorAlpha(pGUI->GetCurrentServerCursorAlpha()); - std::tie(r,g,b,a) = pGUI->GetCursorColor(); + float r,g,b,a; + pGUI->GetCursorColor(r,g,b,a); pGUI->SetCursorColor(r, g, b, a); } diff --git a/Client/core/CMessageLoopHook.cpp b/Client/core/CMessageLoopHook.cpp index 27f0169017d..7cf247cb377 100644 --- a/Client/core/CMessageLoopHook.cpp +++ b/Client/core/CMessageLoopHook.cpp @@ -295,15 +295,12 @@ LRESULT CALLBACK CMessageLoopHook::ProcessMessage(HWND hwnd, UINT uMsg, WPARAM w pConsole->SetVisible(false); CGUI* pGUI = g_pCore->GetGUI(); - float r; - float g; - float b; - float a; + float r, g, b, alpha; if (!g_pCore->IsMenuVisible()) { - std::tie(r, g, b, a) = pGUI->GetCursorColor(); - pGUI->SetCursorColor(r,g,b,a); + pGUI->GetCursorColor(r, g, b, alpha); + pGUI->SetCursorColor(r, g, b, alpha); } return true; } diff --git a/Client/gui/CGUI_Impl.cpp b/Client/gui/CGUI_Impl.cpp index 85423f43f4a..dc4f26b50ce 100644 --- a/Client/gui/CGUI_Impl.cpp +++ b/Client/gui/CGUI_Impl.cpp @@ -511,9 +511,12 @@ void CGUI_Impl::SetCursorColor(float r, float g, float b, float alpha) m_fCurrentServerCursorAlpha = alpha; } -std::tuple CGUI_Impl::GetCursorColor() +void CGUI_Impl::GetCursorColor(float &r, float &g, float &b, float &alpha) { - return std::make_tuple(m_fCurrentServerCursorRed, m_fCurrentServerCursorGreen, m_fCurrentServerCursorBlue, m_fCurrentServerCursorAlpha); + r = m_fCurrentServerCursorRed; + g = m_fCurrentServerCursorGreen; + b = m_fCurrentServerCursorBlue; + alpha = m_fCurrentServerCursorAlpha; } void CGUI_Impl::SetCurrentServerCursorAlpha(float fAlpha) diff --git a/Client/gui/CGUI_Impl.h b/Client/gui/CGUI_Impl.h index 023d273f2a0..0f1f83f2f7b 100644 --- a/Client/gui/CGUI_Impl.h +++ b/Client/gui/CGUI_Impl.h @@ -146,7 +146,7 @@ class CGUI_Impl : public CGUI, public CGUITabList void SetCurrentServerCursorAlpha(float fAlpha); float GetCurrentServerCursorAlpha(); void SetCursorColor(float r, float g, float b, float alpha); - std::tuple GetCursorColor(); + void GetCursorColor(float &r,float &g,float &b,float &alpha); eCursorType GetCursorType(); void AddChild(CGUIElement_Impl* pChild); @@ -313,10 +313,10 @@ class CGUI_Impl : public CGUI, public CGUITabList CEGUI::DefaultWindow* m_pTop; const CEGUI::Image* m_pCursor; - float m_fCurrentServerCursorAlpha; - float m_fCurrentServerCursorRed; - float m_fCurrentServerCursorGreen; - float m_fCurrentServerCursorBlue; + float m_fCurrentServerCursorAlpha =1.0f; + float m_fCurrentServerCursorRed= 1.0f; + float m_fCurrentServerCursorGreen=1.0f; + float m_fCurrentServerCursorBlue= 1.0f; CGUIFont_Impl* m_pDefaultFont; CGUIFont_Impl* m_pSmallFont; diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp index 388f19e7e38..665fdde2cb4 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp @@ -24,7 +24,8 @@ void CLuaClientDefs::LoadFunctions() {"clearDebugBox", ArgumentParser}, {"isMTAWindowFocused", ArgumentParser}, {"isCapsLockEnabled", ArgumentParser}, - {"setCursorColor", ArgumentParser}}; + {"setCursorColor", ArgumentParser}, + {"getCursorColor", ArgumentParser}}; for (const auto& [name, func] : functions) CLuaCFunctions::AddFunction(name, func); @@ -88,3 +89,11 @@ bool CLuaClientDefs::SetCursorColor(float r, float g, float b, float alpha) pGUI->SetCursorColor(r, g, b, alpha); return true; } + +CLuaMultiReturn CLuaClientDefs::GetCursorColor() +{ + float r, g, b, alpha; + CGUI* pGUI = g_pCore->GetGUI(); + pGUI->GetCursorColor(r,g,b,alpha); + return {r, g, b, alpha}; +} diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.h b/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.h index 9fea69a88a9..d1d4b2a81f2 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.h +++ b/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.h @@ -18,6 +18,7 @@ class CLuaClientDefs : public CLuaDefs public: static void LoadFunctions(); static bool SetCursorColor(float r, float g, float b, float alpha); + static CLuaMultiReturn GetCursorColor(); private: static bool SetTransferBoxVisible(bool visible); diff --git a/Client/sdk/gui/CGUI.h b/Client/sdk/gui/CGUI.h index 526861f87b9..d88e93dd37b 100644 --- a/Client/sdk/gui/CGUI.h +++ b/Client/sdk/gui/CGUI.h @@ -127,7 +127,7 @@ class CGUI virtual bool IsCursorEnabled() = 0; virtual void SetCursorAlpha(float fAlpha, bool bOnlyCurrentServer = false) = 0; virtual void SetCursorColor(float r, float g, float b, float alpha) = 0; - virtual std::tuple GetCursorColor() = 0; + virtual void GetCursorColor(float &r, float &g, float &b, float &alpha) = 0; virtual void SetCurrentServerCursorAlpha(float fAlpha) = 0; virtual float GetCurrentServerCursorAlpha() = 0; virtual eCursorType GetCursorType() = 0; From 425e3441120a59a82cf46810f3b35591c3125513 Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Mon, 8 Jul 2024 16:55:51 +0300 Subject: [PATCH 05/26] on reconnect reset values --- Client/core/CGUI.cpp | 1 - Client/gui/CGUI_Impl.cpp | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Client/core/CGUI.cpp b/Client/core/CGUI.cpp index 52b190c59e6..069f660a5ce 100644 --- a/Client/core/CGUI.cpp +++ b/Client/core/CGUI.cpp @@ -379,7 +379,6 @@ void CLocalGUI::SetConsoleVisible(bool bVisible) // Set the visible state m_pConsole->SetVisible(bVisible); - } } diff --git a/Client/gui/CGUI_Impl.cpp b/Client/gui/CGUI_Impl.cpp index dc4f26b50ce..6a3d84faf7a 100644 --- a/Client/gui/CGUI_Impl.cpp +++ b/Client/gui/CGUI_Impl.cpp @@ -522,6 +522,9 @@ void CGUI_Impl::GetCursorColor(float &r, float &g, float &b, float &alpha) void CGUI_Impl::SetCurrentServerCursorAlpha(float fAlpha) { m_fCurrentServerCursorAlpha = fAlpha; + m_fCurrentServerCursorRed = 1.0f; + m_fCurrentServerCursorGreen = 1.0f; + m_fCurrentServerCursorBlue = 1.0f; } float CGUI_Impl::GetCurrentServerCursorAlpha() From 0e98917e742409e6e55d261ac5cbdda9faacb844 Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Tue, 9 Jul 2024 15:57:11 +0300 Subject: [PATCH 06/26] review fixes --- Client/core/CGUI.cpp | 4 ++-- Client/gui/CGUI_Impl.cpp | 8 ++++---- Client/gui/CGUI_Impl.h | 10 +++++----- Client/mods/deathmatch/logic/CClientGame.cpp | 3 +++ .../mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp | 6 ++---- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/Client/core/CGUI.cpp b/Client/core/CGUI.cpp index 069f660a5ce..0f226c1837a 100644 --- a/Client/core/CGUI.cpp +++ b/Client/core/CGUI.cpp @@ -426,8 +426,8 @@ void CLocalGUI::SetMainMenuVisible(bool bVisible) if (!bVisible) { - float r,g,b,a; - pGUI->GetCursorColor(r,g,b,a); + float r, g, b, a; + pGUI->GetCursorColor(r, g, b, a); //restore the cursor color when we close the main menu pGUI->SetCursorColor(r, g, b, a); } diff --git a/Client/gui/CGUI_Impl.cpp b/Client/gui/CGUI_Impl.cpp index 6a3d84faf7a..cb318691be6 100644 --- a/Client/gui/CGUI_Impl.cpp +++ b/Client/gui/CGUI_Impl.cpp @@ -504,7 +504,7 @@ void CGUI_Impl::SetCursorAlpha(float fAlpha, bool bOnlyCurrentServer) void CGUI_Impl::SetCursorColor(float r, float g, float b, float alpha) { - CEGUI::MouseCursor::getSingleton().setColor(r,g,b,alpha); + CEGUI::MouseCursor::getSingleton().setColor(r, g, b, alpha); m_fCurrentServerCursorRed = r; m_fCurrentServerCursorGreen = g; m_fCurrentServerCursorBlue = b; @@ -522,9 +522,9 @@ void CGUI_Impl::GetCursorColor(float &r, float &g, float &b, float &alpha) void CGUI_Impl::SetCurrentServerCursorAlpha(float fAlpha) { m_fCurrentServerCursorAlpha = fAlpha; - m_fCurrentServerCursorRed = 1.0f; - m_fCurrentServerCursorGreen = 1.0f; - m_fCurrentServerCursorBlue = 1.0f; + m_fCurrentServerCursorRed = 255.0f; + m_fCurrentServerCursorGreen = 255.0f; + m_fCurrentServerCursorBlue = 255.0f; } float CGUI_Impl::GetCurrentServerCursorAlpha() diff --git a/Client/gui/CGUI_Impl.h b/Client/gui/CGUI_Impl.h index 0f1f83f2f7b..19971eeec76 100644 --- a/Client/gui/CGUI_Impl.h +++ b/Client/gui/CGUI_Impl.h @@ -146,7 +146,7 @@ class CGUI_Impl : public CGUI, public CGUITabList void SetCurrentServerCursorAlpha(float fAlpha); float GetCurrentServerCursorAlpha(); void SetCursorColor(float r, float g, float b, float alpha); - void GetCursorColor(float &r,float &g,float &b,float &alpha); + void GetCursorColor(float &r, float &g, float &b, float &alpha); eCursorType GetCursorType(); void AddChild(CGUIElement_Impl* pChild); @@ -313,10 +313,10 @@ class CGUI_Impl : public CGUI, public CGUITabList CEGUI::DefaultWindow* m_pTop; const CEGUI::Image* m_pCursor; - float m_fCurrentServerCursorAlpha =1.0f; - float m_fCurrentServerCursorRed= 1.0f; - float m_fCurrentServerCursorGreen=1.0f; - float m_fCurrentServerCursorBlue= 1.0f; + float m_fCurrentServerCursorAlpha = 1.0f; + float m_fCurrentServerCursorRed = 255.0f; + float m_fCurrentServerCursorGreen = 255.0f; + float m_fCurrentServerCursorBlue = 255.0f; CGUIFont_Impl* m_pDefaultFont; CGUIFont_Impl* m_pSmallFont; diff --git a/Client/mods/deathmatch/logic/CClientGame.cpp b/Client/mods/deathmatch/logic/CClientGame.cpp index b07cf64564a..d8889feaf15 100644 --- a/Client/mods/deathmatch/logic/CClientGame.cpp +++ b/Client/mods/deathmatch/logic/CClientGame.cpp @@ -3424,6 +3424,9 @@ void CClientGame::Event_OnIngame() g_pGame->ResetAlphaTransparencies(); g_pGame->ResetModelTimes(); + //reset cursor color + g_pCore->GetGUI()->SetCursorColor(255.0f, 255.0f, 255.0f, 1.0f); + // Make sure we can access all areas g_pGame->GetStats()->ModifyStat(CITIES_PASSED, 2.0); diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp index 665fdde2cb4..67f8e161620 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp @@ -85,15 +85,13 @@ bool CLuaClientDefs::IsCapsLockEnabled() bool CLuaClientDefs::SetCursorColor(float r, float g, float b, float alpha) { - CGUI* pGUI = g_pCore->GetGUI(); - pGUI->SetCursorColor(r, g, b, alpha); + g_pCore->GetGUI()->SetCursorColor(r, g, b, alpha); return true; } CLuaMultiReturn CLuaClientDefs::GetCursorColor() { float r, g, b, alpha; - CGUI* pGUI = g_pCore->GetGUI(); - pGUI->GetCursorColor(r,g,b,alpha); + g_pCore->GetGUI()->GetCursorColor(r, g, b, alpha); return {r, g, b, alpha}; } From f1e256d3a24c1e1339e6c7eae37eab9e2c1f4976 Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Tue, 9 Jul 2024 16:34:10 +0300 Subject: [PATCH 07/26] bug fix when using setCursorAlpha and start resource using F8 won't refresh i setCursorAlpha(150) when you open up the F8 and start the resource it won't refresh the image due to a check if F8 console is open it or not --- Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp b/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp index 0bda456827d..e92a44f20d3 100644 --- a/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp +++ b/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp @@ -5096,7 +5096,7 @@ bool CStaticFunctionDefinitions::SetCursorAlpha(float fAlpha) { if (fAlpha >= 0.0f && fAlpha <= 1.0f) { - if (!m_pCore->IsMenuVisible() && !m_pCore->GetConsole()->IsVisible()) + if (!m_pCore->IsMenuVisible()) m_pGUI->SetCursorAlpha(fAlpha, true); else m_pGUI->SetCurrentServerCursorAlpha(fAlpha); From 3cf01a20aed3d537c6615e0d4eec9c6173aec758 Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Tue, 9 Jul 2024 17:08:56 +0300 Subject: [PATCH 08/26] refactor setCursorAlpha --- Client/core/CMainMenu.cpp | 2 +- Client/gui/CGUI_Impl.cpp | 5 +---- vendor/cegui-0.4.0-custom/include/CEGUIMouseCursor.h | 2 +- vendor/cegui-0.4.0-custom/src/CEGUIMouseCursor.cpp | 4 ++-- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Client/core/CMainMenu.cpp b/Client/core/CMainMenu.cpp index 7d1c2740a85..3296afa0c2b 100644 --- a/Client/core/CMainMenu.cpp +++ b/Client/core/CMainMenu.cpp @@ -606,7 +606,7 @@ void CMainMenu::Update() if (pGUI) { - pGUI->SetCursorAlpha(1.0f); + pGUI->SetCursorAlpha(1.0f); //set alpha of cursor color when we open up main menu m_bCursorAlphaReset = true; } } diff --git a/Client/gui/CGUI_Impl.cpp b/Client/gui/CGUI_Impl.cpp index cb318691be6..25f312592e7 100644 --- a/Client/gui/CGUI_Impl.cpp +++ b/Client/gui/CGUI_Impl.cpp @@ -496,7 +496,7 @@ bool CGUI_Impl::IsCursorEnabled() void CGUI_Impl::SetCursorAlpha(float fAlpha, bool bOnlyCurrentServer) { - CEGUI::MouseCursor::getSingleton().setAlpha(fAlpha); + CEGUI::MouseCursor::getSingleton().setAlpha(m_fCurrentServerCursorRed, m_fCurrentServerCursorGreen, m_fCurrentServerCursorBlue, fAlpha); if (bOnlyCurrentServer) SetCurrentServerCursorAlpha(fAlpha); @@ -522,9 +522,6 @@ void CGUI_Impl::GetCursorColor(float &r, float &g, float &b, float &alpha) void CGUI_Impl::SetCurrentServerCursorAlpha(float fAlpha) { m_fCurrentServerCursorAlpha = fAlpha; - m_fCurrentServerCursorRed = 255.0f; - m_fCurrentServerCursorGreen = 255.0f; - m_fCurrentServerCursorBlue = 255.0f; } float CGUI_Impl::GetCurrentServerCursorAlpha() diff --git a/vendor/cegui-0.4.0-custom/include/CEGUIMouseCursor.h b/vendor/cegui-0.4.0-custom/include/CEGUIMouseCursor.h index 2e9d03a1572..5217f20a6f4 100644 --- a/vendor/cegui-0.4.0-custom/include/CEGUIMouseCursor.h +++ b/vendor/cegui-0.4.0-custom/include/CEGUIMouseCursor.h @@ -187,7 +187,7 @@ class CEGUIEXPORT MouseCursor : public EventSet, public Singleton \return Nothing. */ - void setAlpha(float alpha); + void setAlpha(float r, float g, float b, float alpha); void setColor(float r, float g, float b, float alpha); /*! diff --git a/vendor/cegui-0.4.0-custom/src/CEGUIMouseCursor.cpp b/vendor/cegui-0.4.0-custom/src/CEGUIMouseCursor.cpp index 183a620b5ec..33c362c9d39 100644 --- a/vendor/cegui-0.4.0-custom/src/CEGUIMouseCursor.cpp +++ b/vendor/cegui-0.4.0-custom/src/CEGUIMouseCursor.cpp @@ -149,9 +149,9 @@ void MouseCursor::offsetPosition(const Point& offset) /************************************************************************* Set the mouse cursor's alpha *************************************************************************/ -void MouseCursor::setAlpha(float alpha) +void MouseCursor::setAlpha(float r, float g, float b, float alpha) { - d_colourRect.setColours(colour(1.0f, 1.0f, 1.0f, alpha)); + d_colourRect.setColours(colour(r/255, g/255, b/255, alpha)); } /************************************************************************* From 2b8febc73f81a4c06bda492444bf198dbd883b74 Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Thu, 11 Jul 2024 15:47:53 +0300 Subject: [PATCH 09/26] menu cursor color fix --- Client/core/CMainMenu.cpp | 2 +- Client/gui/CGUI_Impl.cpp | 5 +++++ Client/gui/CGUI_Impl.h | 1 + Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp | 8 ++++++-- Client/sdk/gui/CGUI.h | 1 + 5 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Client/core/CMainMenu.cpp b/Client/core/CMainMenu.cpp index 3296afa0c2b..51df445ac11 100644 --- a/Client/core/CMainMenu.cpp +++ b/Client/core/CMainMenu.cpp @@ -606,7 +606,7 @@ void CMainMenu::Update() if (pGUI) { - pGUI->SetCursorAlpha(1.0f); //set alpha of cursor color when we open up main menu + pGUI->ResetMenuCursorColor(); // Rest cursor menu color when we open up main menu m_bCursorAlphaReset = true; } } diff --git a/Client/gui/CGUI_Impl.cpp b/Client/gui/CGUI_Impl.cpp index 25f312592e7..00b587c7b86 100644 --- a/Client/gui/CGUI_Impl.cpp +++ b/Client/gui/CGUI_Impl.cpp @@ -519,6 +519,11 @@ void CGUI_Impl::GetCursorColor(float &r, float &g, float &b, float &alpha) alpha = m_fCurrentServerCursorAlpha; } +void CGUI_Impl::ResetMenuCursorColor() +{ + CEGUI::MouseCursor::getSingleton().setColor(255, 255, 255, 1); +} + void CGUI_Impl::SetCurrentServerCursorAlpha(float fAlpha) { m_fCurrentServerCursorAlpha = fAlpha; diff --git a/Client/gui/CGUI_Impl.h b/Client/gui/CGUI_Impl.h index 19971eeec76..bd1fbda1ac3 100644 --- a/Client/gui/CGUI_Impl.h +++ b/Client/gui/CGUI_Impl.h @@ -147,6 +147,7 @@ class CGUI_Impl : public CGUI, public CGUITabList float GetCurrentServerCursorAlpha(); void SetCursorColor(float r, float g, float b, float alpha); void GetCursorColor(float &r, float &g, float &b, float &alpha); + void ResetMenuCursorColor(); eCursorType GetCursorType(); void AddChild(CGUIElement_Impl* pChild); diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp index 67f8e161620..babc4eec000 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp @@ -85,8 +85,12 @@ bool CLuaClientDefs::IsCapsLockEnabled() bool CLuaClientDefs::SetCursorColor(float r, float g, float b, float alpha) { - g_pCore->GetGUI()->SetCursorColor(r, g, b, alpha); - return true; + if (!g_pCore->IsMenuVisible()) + { + g_pCore->GetGUI()->SetCursorColor(r, g, b, alpha); + return true; + } + return false; } CLuaMultiReturn CLuaClientDefs::GetCursorColor() diff --git a/Client/sdk/gui/CGUI.h b/Client/sdk/gui/CGUI.h index d88e93dd37b..62103e74a2e 100644 --- a/Client/sdk/gui/CGUI.h +++ b/Client/sdk/gui/CGUI.h @@ -128,6 +128,7 @@ class CGUI virtual void SetCursorAlpha(float fAlpha, bool bOnlyCurrentServer = false) = 0; virtual void SetCursorColor(float r, float g, float b, float alpha) = 0; virtual void GetCursorColor(float &r, float &g, float &b, float &alpha) = 0; + virtual void ResetMenuCursorColor() = 0; virtual void SetCurrentServerCursorAlpha(float fAlpha) = 0; virtual float GetCurrentServerCursorAlpha() = 0; virtual eCursorType GetCursorType() = 0; From b05c646a77f0216e00981ac0633dca568a314223 Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Thu, 11 Jul 2024 16:05:20 +0300 Subject: [PATCH 10/26] reset color correctly --- Client/core/CModManager.cpp | 2 +- Client/gui/CGUI_Impl.cpp | 9 +++++++++ Client/gui/CGUI_Impl.h | 1 + Client/mods/deathmatch/logic/CClientGame.cpp | 2 +- Client/sdk/gui/CGUI.h | 1 + 5 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Client/core/CModManager.cpp b/Client/core/CModManager.cpp index d1e15b10b9d..2a84430f329 100644 --- a/Client/core/CModManager.cpp +++ b/Client/core/CModManager.cpp @@ -218,7 +218,7 @@ void CModManager::Unload() CCore::GetSingleton().GetCommands()->SetExecuteHandler(NULL); // Reset cursor alpha - CCore::GetSingleton().GetGUI()->SetCursorAlpha(1.0f, true); + CCore::GetSingleton().GetGUI()->RestCursorColor(); // Reset the modules CCore::GetSingleton().GetGame()->Reset(); diff --git a/Client/gui/CGUI_Impl.cpp b/Client/gui/CGUI_Impl.cpp index 00b587c7b86..d60857ece85 100644 --- a/Client/gui/CGUI_Impl.cpp +++ b/Client/gui/CGUI_Impl.cpp @@ -524,6 +524,15 @@ void CGUI_Impl::ResetMenuCursorColor() CEGUI::MouseCursor::getSingleton().setColor(255, 255, 255, 1); } +void CGUI_Impl::RestCursorColor() +{ + CEGUI::MouseCursor::getSingleton().setColor(255, 255, 255, 1); + m_fCurrentServerCursorRed = 255; + m_fCurrentServerCursorGreen = 255; + m_fCurrentServerCursorBlue = 255; + m_fCurrentServerCursorAlpha = 255; +} + void CGUI_Impl::SetCurrentServerCursorAlpha(float fAlpha) { m_fCurrentServerCursorAlpha = fAlpha; diff --git a/Client/gui/CGUI_Impl.h b/Client/gui/CGUI_Impl.h index bd1fbda1ac3..90d95971410 100644 --- a/Client/gui/CGUI_Impl.h +++ b/Client/gui/CGUI_Impl.h @@ -148,6 +148,7 @@ class CGUI_Impl : public CGUI, public CGUITabList void SetCursorColor(float r, float g, float b, float alpha); void GetCursorColor(float &r, float &g, float &b, float &alpha); void ResetMenuCursorColor(); + void RestCursorColor(); eCursorType GetCursorType(); void AddChild(CGUIElement_Impl* pChild); diff --git a/Client/mods/deathmatch/logic/CClientGame.cpp b/Client/mods/deathmatch/logic/CClientGame.cpp index d8889feaf15..292b8282509 100644 --- a/Client/mods/deathmatch/logic/CClientGame.cpp +++ b/Client/mods/deathmatch/logic/CClientGame.cpp @@ -3425,7 +3425,7 @@ void CClientGame::Event_OnIngame() g_pGame->ResetModelTimes(); //reset cursor color - g_pCore->GetGUI()->SetCursorColor(255.0f, 255.0f, 255.0f, 1.0f); + g_pCore->GetGUI()->RestCursorColor(); // Make sure we can access all areas g_pGame->GetStats()->ModifyStat(CITIES_PASSED, 2.0); diff --git a/Client/sdk/gui/CGUI.h b/Client/sdk/gui/CGUI.h index 62103e74a2e..7f503e4a72c 100644 --- a/Client/sdk/gui/CGUI.h +++ b/Client/sdk/gui/CGUI.h @@ -129,6 +129,7 @@ class CGUI virtual void SetCursorColor(float r, float g, float b, float alpha) = 0; virtual void GetCursorColor(float &r, float &g, float &b, float &alpha) = 0; virtual void ResetMenuCursorColor() = 0; + virtual void RestCursorColor() = 0; virtual void SetCurrentServerCursorAlpha(float fAlpha) = 0; virtual float GetCurrentServerCursorAlpha() = 0; virtual eCursorType GetCursorType() = 0; From 2a536056d5621dfbd97456c612b6a8de1cecf5ce Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Thu, 11 Jul 2024 16:10:52 +0300 Subject: [PATCH 11/26] clean up --- Client/gui/CGUI_Impl.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Client/gui/CGUI_Impl.cpp b/Client/gui/CGUI_Impl.cpp index d60857ece85..d0248335a88 100644 --- a/Client/gui/CGUI_Impl.cpp +++ b/Client/gui/CGUI_Impl.cpp @@ -526,7 +526,6 @@ void CGUI_Impl::ResetMenuCursorColor() void CGUI_Impl::RestCursorColor() { - CEGUI::MouseCursor::getSingleton().setColor(255, 255, 255, 1); m_fCurrentServerCursorRed = 255; m_fCurrentServerCursorGreen = 255; m_fCurrentServerCursorBlue = 255; From 0303d574319411839bf8232c29fdfde99ba31769 Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Thu, 11 Jul 2024 16:32:01 +0300 Subject: [PATCH 12/26] bug fix of values --- Client/gui/CGUI_Impl.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Client/gui/CGUI_Impl.cpp b/Client/gui/CGUI_Impl.cpp index d0248335a88..c0c3cf9ad5a 100644 --- a/Client/gui/CGUI_Impl.cpp +++ b/Client/gui/CGUI_Impl.cpp @@ -526,10 +526,10 @@ void CGUI_Impl::ResetMenuCursorColor() void CGUI_Impl::RestCursorColor() { - m_fCurrentServerCursorRed = 255; - m_fCurrentServerCursorGreen = 255; - m_fCurrentServerCursorBlue = 255; - m_fCurrentServerCursorAlpha = 255; + m_fCurrentServerCursorRed = 255.0f; + m_fCurrentServerCursorGreen = 255.0f; + m_fCurrentServerCursorBlue = 255.0f; + m_fCurrentServerCursorAlpha = 1.0f; } void CGUI_Impl::SetCurrentServerCursorAlpha(float fAlpha) From 4279002fdf78d743aba2d8b67f19a32d6a71edc3 Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Thu, 11 Jul 2024 20:08:42 +0300 Subject: [PATCH 13/26] float fixes --- Client/gui/CGUI_Impl.cpp | 2 +- vendor/cegui-0.4.0-custom/src/CEGUIMouseCursor.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Client/gui/CGUI_Impl.cpp b/Client/gui/CGUI_Impl.cpp index c0c3cf9ad5a..a7645f1cd3f 100644 --- a/Client/gui/CGUI_Impl.cpp +++ b/Client/gui/CGUI_Impl.cpp @@ -521,7 +521,7 @@ void CGUI_Impl::GetCursorColor(float &r, float &g, float &b, float &alpha) void CGUI_Impl::ResetMenuCursorColor() { - CEGUI::MouseCursor::getSingleton().setColor(255, 255, 255, 1); + CEGUI::MouseCursor::getSingleton().setColor(255.0f, 255.0f, 255.0f, 1.0f); } void CGUI_Impl::RestCursorColor() diff --git a/vendor/cegui-0.4.0-custom/src/CEGUIMouseCursor.cpp b/vendor/cegui-0.4.0-custom/src/CEGUIMouseCursor.cpp index 33c362c9d39..864900bc25a 100644 --- a/vendor/cegui-0.4.0-custom/src/CEGUIMouseCursor.cpp +++ b/vendor/cegui-0.4.0-custom/src/CEGUIMouseCursor.cpp @@ -151,7 +151,7 @@ void MouseCursor::offsetPosition(const Point& offset) *************************************************************************/ void MouseCursor::setAlpha(float r, float g, float b, float alpha) { - d_colourRect.setColours(colour(r/255, g/255, b/255, alpha)); + d_colourRect.setColours(colour(r/255.f, g/255.f, b/255.f, alpha)); } /************************************************************************* From f62c1613873633c5a44759260b020bed749c8ae1 Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Sat, 13 Jul 2024 16:18:39 +0300 Subject: [PATCH 14/26] tederis review fixes --- Client/core/CModManager.cpp | 4 ++-- Client/gui/CGUI_Impl.cpp | 10 +++++----- Client/gui/CGUI_Impl.h | 2 +- Client/mods/deathmatch/logic/CClientGame.cpp | 4 ++-- .../mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp | 7 +++++-- Client/sdk/gui/CGUI.h | 2 +- 6 files changed, 16 insertions(+), 13 deletions(-) diff --git a/Client/core/CModManager.cpp b/Client/core/CModManager.cpp index 2a84430f329..d05250c1f02 100644 --- a/Client/core/CModManager.cpp +++ b/Client/core/CModManager.cpp @@ -217,8 +217,8 @@ void CModManager::Unload() CCore::GetSingleton().SetClientMessageProcessor(NULL); CCore::GetSingleton().GetCommands()->SetExecuteHandler(NULL); - // Reset cursor alpha - CCore::GetSingleton().GetGUI()->RestCursorColor(); + // Reset cursor color + CCore::GetSingleton().GetGUI()->ResetCursorColor(255.f, 255.f, 255.f, 1.f); // Reset the modules CCore::GetSingleton().GetGame()->Reset(); diff --git a/Client/gui/CGUI_Impl.cpp b/Client/gui/CGUI_Impl.cpp index a7645f1cd3f..8ad3f4d2515 100644 --- a/Client/gui/CGUI_Impl.cpp +++ b/Client/gui/CGUI_Impl.cpp @@ -524,12 +524,12 @@ void CGUI_Impl::ResetMenuCursorColor() CEGUI::MouseCursor::getSingleton().setColor(255.0f, 255.0f, 255.0f, 1.0f); } -void CGUI_Impl::RestCursorColor() +void CGUI_Impl::ResetCursorColor(float r, float g, float b, float alpha) { - m_fCurrentServerCursorRed = 255.0f; - m_fCurrentServerCursorGreen = 255.0f; - m_fCurrentServerCursorBlue = 255.0f; - m_fCurrentServerCursorAlpha = 1.0f; + m_fCurrentServerCursorRed = r; + m_fCurrentServerCursorGreen = g; + m_fCurrentServerCursorBlue = b; + m_fCurrentServerCursorAlpha = alpha; } void CGUI_Impl::SetCurrentServerCursorAlpha(float fAlpha) diff --git a/Client/gui/CGUI_Impl.h b/Client/gui/CGUI_Impl.h index 90d95971410..23b449a81cc 100644 --- a/Client/gui/CGUI_Impl.h +++ b/Client/gui/CGUI_Impl.h @@ -148,7 +148,7 @@ class CGUI_Impl : public CGUI, public CGUITabList void SetCursorColor(float r, float g, float b, float alpha); void GetCursorColor(float &r, float &g, float &b, float &alpha); void ResetMenuCursorColor(); - void RestCursorColor(); + void ResetCursorColor(float r, float g, float b, float alpha); eCursorType GetCursorType(); void AddChild(CGUIElement_Impl* pChild); diff --git a/Client/mods/deathmatch/logic/CClientGame.cpp b/Client/mods/deathmatch/logic/CClientGame.cpp index 292b8282509..20cb95631a6 100644 --- a/Client/mods/deathmatch/logic/CClientGame.cpp +++ b/Client/mods/deathmatch/logic/CClientGame.cpp @@ -3424,8 +3424,8 @@ void CClientGame::Event_OnIngame() g_pGame->ResetAlphaTransparencies(); g_pGame->ResetModelTimes(); - //reset cursor color - g_pCore->GetGUI()->RestCursorColor(); + // Reset cursor color + g_pCore->GetGUI()->ResetCursorColor(255.f, 255.f, 255.f, 1.f); // Make sure we can access all areas g_pGame->GetStats()->ModifyStat(CITIES_PASSED, 2.0); diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp index babc4eec000..6d26128a964 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp @@ -88,9 +88,12 @@ bool CLuaClientDefs::SetCursorColor(float r, float g, float b, float alpha) if (!g_pCore->IsMenuVisible()) { g_pCore->GetGUI()->SetCursorColor(r, g, b, alpha); - return true; } - return false; + else + { + g_pCore->GetGUI()->ResetCursorColor(r, g, b, alpha); // Force values to be updated + } + return true; } CLuaMultiReturn CLuaClientDefs::GetCursorColor() diff --git a/Client/sdk/gui/CGUI.h b/Client/sdk/gui/CGUI.h index 7f503e4a72c..93e32f983c8 100644 --- a/Client/sdk/gui/CGUI.h +++ b/Client/sdk/gui/CGUI.h @@ -129,7 +129,7 @@ class CGUI virtual void SetCursorColor(float r, float g, float b, float alpha) = 0; virtual void GetCursorColor(float &r, float &g, float &b, float &alpha) = 0; virtual void ResetMenuCursorColor() = 0; - virtual void RestCursorColor() = 0; + virtual void ResetCursorColor(float r, float g, float b, float alpha) = 0; virtual void SetCurrentServerCursorAlpha(float fAlpha) = 0; virtual float GetCurrentServerCursorAlpha() = 0; virtual eCursorType GetCursorType() = 0; From b645694c323dff78ce8a36d4fb4713a0b2c1160a Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Sat, 13 Jul 2024 16:27:18 +0300 Subject: [PATCH 15/26] review 2 tracer --- Client/gui/CGUI_Impl.cpp | 8 ++++---- Client/gui/CGUI_Impl.h | 8 ++++---- Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp | 2 +- Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.h | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Client/gui/CGUI_Impl.cpp b/Client/gui/CGUI_Impl.cpp index 8ad3f4d2515..3b8880d696d 100644 --- a/Client/gui/CGUI_Impl.cpp +++ b/Client/gui/CGUI_Impl.cpp @@ -502,7 +502,7 @@ void CGUI_Impl::SetCursorAlpha(float fAlpha, bool bOnlyCurrentServer) SetCurrentServerCursorAlpha(fAlpha); } -void CGUI_Impl::SetCursorColor(float r, float g, float b, float alpha) +void CGUI_Impl::SetCursorColor(float r, float g, float b, float alpha) noexcept { CEGUI::MouseCursor::getSingleton().setColor(r, g, b, alpha); m_fCurrentServerCursorRed = r; @@ -511,7 +511,7 @@ void CGUI_Impl::SetCursorColor(float r, float g, float b, float alpha) m_fCurrentServerCursorAlpha = alpha; } -void CGUI_Impl::GetCursorColor(float &r, float &g, float &b, float &alpha) +void CGUI_Impl::GetCursorColor(float& r, float& g, float& b, float& alpha) noexcept { r = m_fCurrentServerCursorRed; g = m_fCurrentServerCursorGreen; @@ -519,12 +519,12 @@ void CGUI_Impl::GetCursorColor(float &r, float &g, float &b, float &alpha) alpha = m_fCurrentServerCursorAlpha; } -void CGUI_Impl::ResetMenuCursorColor() +void CGUI_Impl::ResetMenuCursorColor() noexcept { CEGUI::MouseCursor::getSingleton().setColor(255.0f, 255.0f, 255.0f, 1.0f); } -void CGUI_Impl::ResetCursorColor(float r, float g, float b, float alpha) +void CGUI_Impl::ResetCursorColor(float r, float g, float b, float alpha) noexcept { m_fCurrentServerCursorRed = r; m_fCurrentServerCursorGreen = g; diff --git a/Client/gui/CGUI_Impl.h b/Client/gui/CGUI_Impl.h index 23b449a81cc..ca576f390e7 100644 --- a/Client/gui/CGUI_Impl.h +++ b/Client/gui/CGUI_Impl.h @@ -145,10 +145,10 @@ class CGUI_Impl : public CGUI, public CGUITabList void SetCursorAlpha(float fAlpha, bool bOnlyCurrentServer = false); void SetCurrentServerCursorAlpha(float fAlpha); float GetCurrentServerCursorAlpha(); - void SetCursorColor(float r, float g, float b, float alpha); - void GetCursorColor(float &r, float &g, float &b, float &alpha); - void ResetMenuCursorColor(); - void ResetCursorColor(float r, float g, float b, float alpha); + void SetCursorColor(float r, float g, float b, float alpha) noexcept; + void GetCursorColor(float& r, float& g, float& b, float& alpha) noexcept; + void ResetMenuCursorColor() noexcept; + void ResetCursorColor(float r, float g, float b, float alpha) noexcept; eCursorType GetCursorType(); void AddChild(CGUIElement_Impl* pChild); diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp index 6d26128a964..454c965e318 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp @@ -96,7 +96,7 @@ bool CLuaClientDefs::SetCursorColor(float r, float g, float b, float alpha) return true; } -CLuaMultiReturn CLuaClientDefs::GetCursorColor() +CLuaMultiReturn CLuaClientDefs::GetCursorColor() noexcept { float r, g, b, alpha; g_pCore->GetGUI()->GetCursorColor(r, g, b, alpha); diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.h b/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.h index d1d4b2a81f2..bf8eab513cd 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.h +++ b/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.h @@ -18,7 +18,7 @@ class CLuaClientDefs : public CLuaDefs public: static void LoadFunctions(); static bool SetCursorColor(float r, float g, float b, float alpha); - static CLuaMultiReturn GetCursorColor(); + static CLuaMultiReturn GetCursorColor() noexcept; private: static bool SetTransferBoxVisible(bool visible); From 58f2b023a185d0b63f22f6bfa251330e607d2eb8 Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Sat, 13 Jul 2024 17:13:30 +0300 Subject: [PATCH 16/26] small fix for useless if condition --- Client/core/CGUI.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/Client/core/CGUI.cpp b/Client/core/CGUI.cpp index 0f226c1837a..59d6cd47bfd 100644 --- a/Client/core/CGUI.cpp +++ b/Client/core/CGUI.cpp @@ -422,15 +422,10 @@ void CLocalGUI::SetMainMenuVisible(bool bVisible) else { pGUI->SelectInputHandlers(INPUT_MOD); - } - - if (!bVisible) - { - float r, g, b, a; - pGUI->GetCursorColor(r, g, b, a); //restore the cursor color when we close the main menu + float r, g, b, a; + pGUI->GetCursorColor(r, g, b, a); // Restore the cursor color when we close the main menu pGUI->SetCursorColor(r, g, b, a); - } - + } } } From 127efaa1b0192a7c3f14754b55d4789df742c4f1 Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Sat, 13 Jul 2024 18:18:52 +0300 Subject: [PATCH 17/26] simplify --- Client/core/CGUI.cpp | 4 +--- Client/core/CMessageLoopHook.cpp | 3 +-- Client/gui/CGUI_Impl.cpp | 5 +++++ Client/gui/CGUI_Impl.h | 1 + Client/sdk/gui/CGUI.h | 1 + 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Client/core/CGUI.cpp b/Client/core/CGUI.cpp index 59d6cd47bfd..f15ff67c571 100644 --- a/Client/core/CGUI.cpp +++ b/Client/core/CGUI.cpp @@ -422,9 +422,7 @@ void CLocalGUI::SetMainMenuVisible(bool bVisible) else { pGUI->SelectInputHandlers(INPUT_MOD); - float r, g, b, a; - pGUI->GetCursorColor(r, g, b, a); // Restore the cursor color when we close the main menu - pGUI->SetCursorColor(r, g, b, a); + pGUI->RestorCurrentServerCursorColor(); // Restore the cursor color when we close the main menu } } } diff --git a/Client/core/CMessageLoopHook.cpp b/Client/core/CMessageLoopHook.cpp index 7cf247cb377..ef5d80fe748 100644 --- a/Client/core/CMessageLoopHook.cpp +++ b/Client/core/CMessageLoopHook.cpp @@ -299,8 +299,7 @@ LRESULT CALLBACK CMessageLoopHook::ProcessMessage(HWND hwnd, UINT uMsg, WPARAM w if (!g_pCore->IsMenuVisible()) { - pGUI->GetCursorColor(r, g, b, alpha); - pGUI->SetCursorColor(r, g, b, alpha); + pGUI->RestorCurrentServerCursorColor(); } return true; } diff --git a/Client/gui/CGUI_Impl.cpp b/Client/gui/CGUI_Impl.cpp index 3b8880d696d..27a001ada83 100644 --- a/Client/gui/CGUI_Impl.cpp +++ b/Client/gui/CGUI_Impl.cpp @@ -532,6 +532,11 @@ void CGUI_Impl::ResetCursorColor(float r, float g, float b, float alpha) noexcep m_fCurrentServerCursorAlpha = alpha; } +void CGUI_Impl::RestorCurrentServerCursorColor() +{ + CEGUI::MouseCursor::getSingleton().setColor(m_fCurrentServerCursorRed, m_fCurrentServerCursorGreen, m_fCurrentServerCursorBlue, m_fCurrentServerCursorAlpha); +} + void CGUI_Impl::SetCurrentServerCursorAlpha(float fAlpha) { m_fCurrentServerCursorAlpha = fAlpha; diff --git a/Client/gui/CGUI_Impl.h b/Client/gui/CGUI_Impl.h index ca576f390e7..98c40267b37 100644 --- a/Client/gui/CGUI_Impl.h +++ b/Client/gui/CGUI_Impl.h @@ -148,6 +148,7 @@ class CGUI_Impl : public CGUI, public CGUITabList void SetCursorColor(float r, float g, float b, float alpha) noexcept; void GetCursorColor(float& r, float& g, float& b, float& alpha) noexcept; void ResetMenuCursorColor() noexcept; + void RestorCurrentServerCursorColor(); void ResetCursorColor(float r, float g, float b, float alpha) noexcept; eCursorType GetCursorType(); diff --git a/Client/sdk/gui/CGUI.h b/Client/sdk/gui/CGUI.h index 93e32f983c8..0b9e2cad094 100644 --- a/Client/sdk/gui/CGUI.h +++ b/Client/sdk/gui/CGUI.h @@ -130,6 +130,7 @@ class CGUI virtual void GetCursorColor(float &r, float &g, float &b, float &alpha) = 0; virtual void ResetMenuCursorColor() = 0; virtual void ResetCursorColor(float r, float g, float b, float alpha) = 0; + virtual void RestorCurrentServerCursorColor() = 0; virtual void SetCurrentServerCursorAlpha(float fAlpha) = 0; virtual float GetCurrentServerCursorAlpha() = 0; virtual eCursorType GetCursorType() = 0; From 24e5809de4e43651acb0ef0bf36a2157fa1f69f9 Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Sat, 13 Jul 2024 20:32:47 +0300 Subject: [PATCH 18/26] typos --- Client/core/CGUI.cpp | 2 +- Client/core/CMainMenu.cpp | 2 +- Client/core/CMessageLoopHook.cpp | 3 +-- Client/gui/CGUI_Impl.cpp | 2 +- Client/gui/CGUI_Impl.h | 2 +- Client/sdk/gui/CGUI.h | 2 +- 6 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Client/core/CGUI.cpp b/Client/core/CGUI.cpp index f15ff67c571..f7664fb5453 100644 --- a/Client/core/CGUI.cpp +++ b/Client/core/CGUI.cpp @@ -422,7 +422,7 @@ void CLocalGUI::SetMainMenuVisible(bool bVisible) else { pGUI->SelectInputHandlers(INPUT_MOD); - pGUI->RestorCurrentServerCursorColor(); // Restore the cursor color when we close the main menu + pGUI->RestoreCurrentServerCursorColor(); // Restore the cursor color when we close the main menu } } } diff --git a/Client/core/CMainMenu.cpp b/Client/core/CMainMenu.cpp index 51df445ac11..11e794dbe31 100644 --- a/Client/core/CMainMenu.cpp +++ b/Client/core/CMainMenu.cpp @@ -606,7 +606,7 @@ void CMainMenu::Update() if (pGUI) { - pGUI->ResetMenuCursorColor(); // Rest cursor menu color when we open up main menu + pGUI->ResetMenuCursorColor(); // Reset cursor menu color when we open up main menu m_bCursorAlphaReset = true; } } diff --git a/Client/core/CMessageLoopHook.cpp b/Client/core/CMessageLoopHook.cpp index ef5d80fe748..10a886fc8f6 100644 --- a/Client/core/CMessageLoopHook.cpp +++ b/Client/core/CMessageLoopHook.cpp @@ -295,11 +295,10 @@ LRESULT CALLBACK CMessageLoopHook::ProcessMessage(HWND hwnd, UINT uMsg, WPARAM w pConsole->SetVisible(false); CGUI* pGUI = g_pCore->GetGUI(); - float r, g, b, alpha; if (!g_pCore->IsMenuVisible()) { - pGUI->RestorCurrentServerCursorColor(); + pGUI->RestoreCurrentServerCursorColor(); } return true; } diff --git a/Client/gui/CGUI_Impl.cpp b/Client/gui/CGUI_Impl.cpp index 27a001ada83..153b018c96b 100644 --- a/Client/gui/CGUI_Impl.cpp +++ b/Client/gui/CGUI_Impl.cpp @@ -532,7 +532,7 @@ void CGUI_Impl::ResetCursorColor(float r, float g, float b, float alpha) noexcep m_fCurrentServerCursorAlpha = alpha; } -void CGUI_Impl::RestorCurrentServerCursorColor() +void CGUI_Impl::RestoreCurrentServerCursorColor() { CEGUI::MouseCursor::getSingleton().setColor(m_fCurrentServerCursorRed, m_fCurrentServerCursorGreen, m_fCurrentServerCursorBlue, m_fCurrentServerCursorAlpha); } diff --git a/Client/gui/CGUI_Impl.h b/Client/gui/CGUI_Impl.h index 98c40267b37..f588da0e03d 100644 --- a/Client/gui/CGUI_Impl.h +++ b/Client/gui/CGUI_Impl.h @@ -148,7 +148,7 @@ class CGUI_Impl : public CGUI, public CGUITabList void SetCursorColor(float r, float g, float b, float alpha) noexcept; void GetCursorColor(float& r, float& g, float& b, float& alpha) noexcept; void ResetMenuCursorColor() noexcept; - void RestorCurrentServerCursorColor(); + void RestoreCurrentServerCursorColor(); void ResetCursorColor(float r, float g, float b, float alpha) noexcept; eCursorType GetCursorType(); diff --git a/Client/sdk/gui/CGUI.h b/Client/sdk/gui/CGUI.h index 0b9e2cad094..3f9501c4c72 100644 --- a/Client/sdk/gui/CGUI.h +++ b/Client/sdk/gui/CGUI.h @@ -130,7 +130,7 @@ class CGUI virtual void GetCursorColor(float &r, float &g, float &b, float &alpha) = 0; virtual void ResetMenuCursorColor() = 0; virtual void ResetCursorColor(float r, float g, float b, float alpha) = 0; - virtual void RestorCurrentServerCursorColor() = 0; + virtual void RestoreCurrentServerCursorColor() = 0; virtual void SetCurrentServerCursorAlpha(float fAlpha) = 0; virtual float GetCurrentServerCursorAlpha() = 0; virtual eCursorType GetCursorType() = 0; From c61f033617d370dafe947825d0ce4df89905b0ad Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Tue, 16 Jul 2024 17:25:47 +0300 Subject: [PATCH 19/26] review fixes --- Client/core/CMessageLoopHook.cpp | 5 ++--- Client/gui/CGUI_Impl.cpp | 2 +- Client/gui/CGUI_Impl.h | 2 +- Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp | 9 +++------ Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.h | 3 ++- Client/sdk/gui/CGUI.h | 8 ++++---- vendor/cegui-0.4.0-custom/include/CEGUIMouseCursor.h | 4 ++-- vendor/cegui-0.4.0-custom/src/CEGUIMouseCursor.cpp | 4 ++-- 8 files changed, 17 insertions(+), 20 deletions(-) diff --git a/Client/core/CMessageLoopHook.cpp b/Client/core/CMessageLoopHook.cpp index 10a886fc8f6..841bb6fc832 100644 --- a/Client/core/CMessageLoopHook.cpp +++ b/Client/core/CMessageLoopHook.cpp @@ -296,10 +296,9 @@ LRESULT CALLBACK CMessageLoopHook::ProcessMessage(HWND hwnd, UINT uMsg, WPARAM w CGUI* pGUI = g_pCore->GetGUI(); - if (!g_pCore->IsMenuVisible()) - { + if (!g_pCore->IsMenuVisible()) pGUI->RestoreCurrentServerCursorColor(); - } + return true; } diff --git a/Client/gui/CGUI_Impl.cpp b/Client/gui/CGUI_Impl.cpp index 153b018c96b..ccbdf7b18f3 100644 --- a/Client/gui/CGUI_Impl.cpp +++ b/Client/gui/CGUI_Impl.cpp @@ -532,7 +532,7 @@ void CGUI_Impl::ResetCursorColor(float r, float g, float b, float alpha) noexcep m_fCurrentServerCursorAlpha = alpha; } -void CGUI_Impl::RestoreCurrentServerCursorColor() +void CGUI_Impl::RestoreCurrentServerCursorColor() noexcept { CEGUI::MouseCursor::getSingleton().setColor(m_fCurrentServerCursorRed, m_fCurrentServerCursorGreen, m_fCurrentServerCursorBlue, m_fCurrentServerCursorAlpha); } diff --git a/Client/gui/CGUI_Impl.h b/Client/gui/CGUI_Impl.h index f588da0e03d..4d9062ad7d4 100644 --- a/Client/gui/CGUI_Impl.h +++ b/Client/gui/CGUI_Impl.h @@ -148,7 +148,7 @@ class CGUI_Impl : public CGUI, public CGUITabList void SetCursorColor(float r, float g, float b, float alpha) noexcept; void GetCursorColor(float& r, float& g, float& b, float& alpha) noexcept; void ResetMenuCursorColor() noexcept; - void RestoreCurrentServerCursorColor(); + void RestoreCurrentServerCursorColor() noexcept; void ResetCursorColor(float r, float g, float b, float alpha) noexcept; eCursorType GetCursorType(); diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp index 454c965e318..18506807431 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp @@ -83,16 +83,13 @@ bool CLuaClientDefs::IsCapsLockEnabled() return ((::GetKeyState(VK_CAPITAL) & 0x0001) != 0); } -bool CLuaClientDefs::SetCursorColor(float r, float g, float b, float alpha) +bool CLuaClientDefs::SetCursorColor(float r, float g, float b, float alpha) noexcept { if (!g_pCore->IsMenuVisible()) - { g_pCore->GetGUI()->SetCursorColor(r, g, b, alpha); - } else - { - g_pCore->GetGUI()->ResetCursorColor(r, g, b, alpha); // Force values to be updated - } + g_pCore->GetGUI()->ResetCursorColor(r, g, b, alpha); // Force values to be updated + return true; } diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.h b/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.h index bf8eab513cd..58eaddc205a 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.h +++ b/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.h @@ -17,7 +17,8 @@ class CLuaClientDefs : public CLuaDefs { public: static void LoadFunctions(); - static bool SetCursorColor(float r, float g, float b, float alpha); + + static bool SetCursorColor(float r, float g, float b, float alpha) noexcept; static CLuaMultiReturn GetCursorColor() noexcept; private: diff --git a/Client/sdk/gui/CGUI.h b/Client/sdk/gui/CGUI.h index 3f9501c4c72..8263ef68c93 100644 --- a/Client/sdk/gui/CGUI.h +++ b/Client/sdk/gui/CGUI.h @@ -126,11 +126,11 @@ class CGUI virtual void SetCursorEnabled(bool bEnabled) = 0; virtual bool IsCursorEnabled() = 0; virtual void SetCursorAlpha(float fAlpha, bool bOnlyCurrentServer = false) = 0; - virtual void SetCursorColor(float r, float g, float b, float alpha) = 0; - virtual void GetCursorColor(float &r, float &g, float &b, float &alpha) = 0; + virtual void SetCursorColor(float r, float g, float b, float alpha) noexcept = 0; + virtual void GetCursorColor(float& r, float& g, float& b, float& alpha) noexcept = 0; virtual void ResetMenuCursorColor() = 0; - virtual void ResetCursorColor(float r, float g, float b, float alpha) = 0; - virtual void RestoreCurrentServerCursorColor() = 0; + virtual void ResetCursorColor(float r, float g, float b, float alpha) noexcept = 0; + virtual void RestoreCurrentServerCursorColor() noexcept = 0; virtual void SetCurrentServerCursorAlpha(float fAlpha) = 0; virtual float GetCurrentServerCursorAlpha() = 0; virtual eCursorType GetCursorType() = 0; diff --git a/vendor/cegui-0.4.0-custom/include/CEGUIMouseCursor.h b/vendor/cegui-0.4.0-custom/include/CEGUIMouseCursor.h index 5217f20a6f4..d713bcd53db 100644 --- a/vendor/cegui-0.4.0-custom/include/CEGUIMouseCursor.h +++ b/vendor/cegui-0.4.0-custom/include/CEGUIMouseCursor.h @@ -187,8 +187,8 @@ class CEGUIEXPORT MouseCursor : public EventSet, public Singleton \return Nothing. */ - void setAlpha(float r, float g, float b, float alpha); - void setColor(float r, float g, float b, float alpha); + void setAlpha(float r, float g, float b, float alpha) noexcept; + void setColor(float r, float g, float b, float alpha) noexcept; /*! \brief diff --git a/vendor/cegui-0.4.0-custom/src/CEGUIMouseCursor.cpp b/vendor/cegui-0.4.0-custom/src/CEGUIMouseCursor.cpp index 864900bc25a..442afbd77dd 100644 --- a/vendor/cegui-0.4.0-custom/src/CEGUIMouseCursor.cpp +++ b/vendor/cegui-0.4.0-custom/src/CEGUIMouseCursor.cpp @@ -149,7 +149,7 @@ void MouseCursor::offsetPosition(const Point& offset) /************************************************************************* Set the mouse cursor's alpha *************************************************************************/ -void MouseCursor::setAlpha(float r, float g, float b, float alpha) +void MouseCursor::setAlpha(float r, float g, float b, float alpha) noexcept { d_colourRect.setColours(colour(r/255.f, g/255.f, b/255.f, alpha)); } @@ -157,7 +157,7 @@ void MouseCursor::setAlpha(float r, float g, float b, float alpha) /************************************************************************* Set the mouse cursor's color *************************************************************************/ -void MouseCursor::setColor(float r, float g, float b, float alpha) +void MouseCursor::setColor(float r, float g, float b, float alpha) noexcept { d_colourRect.setColours(colour(r/255.f, g/255.f, b/255.f, alpha)); } From 1f5aae98307533ea8593a30fa807f29e56a46ba7 Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Tue, 16 Jul 2024 17:30:42 +0300 Subject: [PATCH 20/26] noexcept --- Client/sdk/gui/CGUI.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Client/sdk/gui/CGUI.h b/Client/sdk/gui/CGUI.h index 8263ef68c93..0d3324dcb43 100644 --- a/Client/sdk/gui/CGUI.h +++ b/Client/sdk/gui/CGUI.h @@ -128,7 +128,7 @@ class CGUI virtual void SetCursorAlpha(float fAlpha, bool bOnlyCurrentServer = false) = 0; virtual void SetCursorColor(float r, float g, float b, float alpha) noexcept = 0; virtual void GetCursorColor(float& r, float& g, float& b, float& alpha) noexcept = 0; - virtual void ResetMenuCursorColor() = 0; + virtual void ResetMenuCursorColor() noexcept = 0; virtual void ResetCursorColor(float r, float g, float b, float alpha) noexcept = 0; virtual void RestoreCurrentServerCursorColor() noexcept = 0; virtual void SetCurrentServerCursorAlpha(float fAlpha) = 0; From e384afd6d3f8ab4a54856b9be1e82d7b3af0c1b4 Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Sun, 5 Jan 2025 14:50:08 +0300 Subject: [PATCH 21/26] make arguments optional reset cursor via setCursorColor() --- Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp | 8 ++++---- Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp index 18506807431..8d206d312b1 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp @@ -83,12 +83,12 @@ bool CLuaClientDefs::IsCapsLockEnabled() return ((::GetKeyState(VK_CAPITAL) & 0x0001) != 0); } -bool CLuaClientDefs::SetCursorColor(float r, float g, float b, float alpha) noexcept +bool CLuaClientDefs::SetCursorColor(std::optional r, std::optional g, std::optional b, std::optional alpha) noexcept { - if (!g_pCore->IsMenuVisible()) - g_pCore->GetGUI()->SetCursorColor(r, g, b, alpha); + if (!g_pCore->IsMenuVisible()) + g_pCore->GetGUI()->SetCursorColor(r.value_or(255.0f), g.value_or(255.0f), b.value_or(255.0f), alpha.value_or(1.0f)); else - g_pCore->GetGUI()->ResetCursorColor(r, g, b, alpha); // Force values to be updated + g_pCore->GetGUI()->ResetCursorColor(r.value_or(255.0f), g.value_or(255.0f), b.value_or(255.0f), alpha.value_or(1.0f)); // Force variables to be updated when close the main menu it will set the new color return true; } diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.h b/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.h index 58eaddc205a..36ac8b0fd68 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.h +++ b/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.h @@ -18,7 +18,7 @@ class CLuaClientDefs : public CLuaDefs public: static void LoadFunctions(); - static bool SetCursorColor(float r, float g, float b, float alpha) noexcept; + static bool SetCursorColor(std::optional r, std::optional g, std::optional b, std::optional alpha) noexcept; static CLuaMultiReturn GetCursorColor() noexcept; private: From 97b3e66a3c4fd5635edd0e40f1560dcb0559f73d Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Sun, 5 Jan 2025 15:56:55 +0300 Subject: [PATCH 22/26] alpha to work with range 0 to 255 --- Client/core/CModManager.cpp | 2 +- Client/gui/CGUI_Impl.cpp | 2 +- Client/gui/CGUI_Impl.h | 2 +- Client/mods/deathmatch/logic/CClientGame.cpp | 2 +- Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp | 4 ++-- vendor/cegui-0.4.0-custom/src/CEGUIMouseCursor.cpp | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Client/core/CModManager.cpp b/Client/core/CModManager.cpp index d05250c1f02..cb97ccda669 100644 --- a/Client/core/CModManager.cpp +++ b/Client/core/CModManager.cpp @@ -218,7 +218,7 @@ void CModManager::Unload() CCore::GetSingleton().GetCommands()->SetExecuteHandler(NULL); // Reset cursor color - CCore::GetSingleton().GetGUI()->ResetCursorColor(255.f, 255.f, 255.f, 1.f); + CCore::GetSingleton().GetGUI()->ResetCursorColor(255.f, 255.f, 255.f, 255.f); // Reset the modules CCore::GetSingleton().GetGame()->Reset(); diff --git a/Client/gui/CGUI_Impl.cpp b/Client/gui/CGUI_Impl.cpp index ccbdf7b18f3..ec6f875dc78 100644 --- a/Client/gui/CGUI_Impl.cpp +++ b/Client/gui/CGUI_Impl.cpp @@ -521,7 +521,7 @@ void CGUI_Impl::GetCursorColor(float& r, float& g, float& b, float& alpha) noexc void CGUI_Impl::ResetMenuCursorColor() noexcept { - CEGUI::MouseCursor::getSingleton().setColor(255.0f, 255.0f, 255.0f, 1.0f); + CEGUI::MouseCursor::getSingleton().setColor(255.0f, 255.0f, 255.0f, 255.0f); } void CGUI_Impl::ResetCursorColor(float r, float g, float b, float alpha) noexcept diff --git a/Client/gui/CGUI_Impl.h b/Client/gui/CGUI_Impl.h index 4d9062ad7d4..d14f5d702fd 100644 --- a/Client/gui/CGUI_Impl.h +++ b/Client/gui/CGUI_Impl.h @@ -316,7 +316,7 @@ class CGUI_Impl : public CGUI, public CGUITabList CEGUI::DefaultWindow* m_pTop; const CEGUI::Image* m_pCursor; - float m_fCurrentServerCursorAlpha = 1.0f; + float m_fCurrentServerCursorAlpha = 255.0f; float m_fCurrentServerCursorRed = 255.0f; float m_fCurrentServerCursorGreen = 255.0f; float m_fCurrentServerCursorBlue = 255.0f; diff --git a/Client/mods/deathmatch/logic/CClientGame.cpp b/Client/mods/deathmatch/logic/CClientGame.cpp index 2ceb8bb5fa9..3d5293fe698 100644 --- a/Client/mods/deathmatch/logic/CClientGame.cpp +++ b/Client/mods/deathmatch/logic/CClientGame.cpp @@ -3445,7 +3445,7 @@ void CClientGame::Event_OnIngame() g_pGame->SetWeaponRenderEnabled(true); // Reset cursor color - g_pCore->GetGUI()->ResetCursorColor(255.f, 255.f, 255.f, 1.f); + g_pCore->GetGUI()->ResetCursorColor(255.f, 255.f, 255.f, 255.f); // Make sure we can access all areas g_pGame->GetStats()->ModifyStat(CITIES_PASSED, 2.0); diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp index 8d206d312b1..4b3254549bd 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp @@ -86,9 +86,9 @@ bool CLuaClientDefs::IsCapsLockEnabled() bool CLuaClientDefs::SetCursorColor(std::optional r, std::optional g, std::optional b, std::optional alpha) noexcept { if (!g_pCore->IsMenuVisible()) - g_pCore->GetGUI()->SetCursorColor(r.value_or(255.0f), g.value_or(255.0f), b.value_or(255.0f), alpha.value_or(1.0f)); + g_pCore->GetGUI()->SetCursorColor(r.value_or(255.0f), g.value_or(255.0f), b.value_or(255.0f), alpha.value_or(255.0f)); else - g_pCore->GetGUI()->ResetCursorColor(r.value_or(255.0f), g.value_or(255.0f), b.value_or(255.0f), alpha.value_or(1.0f)); // Force variables to be updated when close the main menu it will set the new color + g_pCore->GetGUI()->ResetCursorColor(r.value_or(255.0f), g.value_or(255.0f), b.value_or(255.0f), alpha.value_or(255.0f)); // Force variables to be updated when close the main menu it will set the new color return true; } diff --git a/vendor/cegui-0.4.0-custom/src/CEGUIMouseCursor.cpp b/vendor/cegui-0.4.0-custom/src/CEGUIMouseCursor.cpp index 442afbd77dd..4dc8db2cdd4 100644 --- a/vendor/cegui-0.4.0-custom/src/CEGUIMouseCursor.cpp +++ b/vendor/cegui-0.4.0-custom/src/CEGUIMouseCursor.cpp @@ -159,7 +159,7 @@ void MouseCursor::setAlpha(float r, float g, float b, float alpha) noexcept *************************************************************************/ void MouseCursor::setColor(float r, float g, float b, float alpha) noexcept { - d_colourRect.setColours(colour(r/255.f, g/255.f, b/255.f, alpha)); + d_colourRect.setColours(colour(r/255.f, g/255.f, b/255.f, alpha/255.f)); } /************************************************************************* Checks the mouse cursor position is within the current 'constrain' From e505b75d7c7fde059c0cb894e25648c8be0d2c02 Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Sun, 5 Jan 2025 17:42:33 +0300 Subject: [PATCH 23/26] remove setAlpha --- Client/gui/CGUI_Impl.cpp | 2 +- vendor/cegui-0.4.0-custom/include/CEGUIMouseCursor.h | 2 +- vendor/cegui-0.4.0-custom/src/CEGUIMouseCursor.cpp | 8 -------- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/Client/gui/CGUI_Impl.cpp b/Client/gui/CGUI_Impl.cpp index ec6f875dc78..21b279d5f8d 100644 --- a/Client/gui/CGUI_Impl.cpp +++ b/Client/gui/CGUI_Impl.cpp @@ -496,7 +496,7 @@ bool CGUI_Impl::IsCursorEnabled() void CGUI_Impl::SetCursorAlpha(float fAlpha, bool bOnlyCurrentServer) { - CEGUI::MouseCursor::getSingleton().setAlpha(m_fCurrentServerCursorRed, m_fCurrentServerCursorGreen, m_fCurrentServerCursorBlue, fAlpha); + CEGUI::MouseCursor::getSingleton().setColor(m_fCurrentServerCursorRed, m_fCurrentServerCursorGreen, m_fCurrentServerCursorBlue, fAlpha); if (bOnlyCurrentServer) SetCurrentServerCursorAlpha(fAlpha); diff --git a/vendor/cegui-0.4.0-custom/include/CEGUIMouseCursor.h b/vendor/cegui-0.4.0-custom/include/CEGUIMouseCursor.h index d713bcd53db..a51a3aca854 100644 --- a/vendor/cegui-0.4.0-custom/include/CEGUIMouseCursor.h +++ b/vendor/cegui-0.4.0-custom/include/CEGUIMouseCursor.h @@ -187,7 +187,7 @@ class CEGUIEXPORT MouseCursor : public EventSet, public Singleton \return Nothing. */ - void setAlpha(float r, float g, float b, float alpha) noexcept; + void setColor(float r, float g, float b, float alpha) noexcept; /*! diff --git a/vendor/cegui-0.4.0-custom/src/CEGUIMouseCursor.cpp b/vendor/cegui-0.4.0-custom/src/CEGUIMouseCursor.cpp index 4dc8db2cdd4..119da7b8147 100644 --- a/vendor/cegui-0.4.0-custom/src/CEGUIMouseCursor.cpp +++ b/vendor/cegui-0.4.0-custom/src/CEGUIMouseCursor.cpp @@ -146,14 +146,6 @@ void MouseCursor::offsetPosition(const Point& offset) } -/************************************************************************* - Set the mouse cursor's alpha -*************************************************************************/ -void MouseCursor::setAlpha(float r, float g, float b, float alpha) noexcept -{ - d_colourRect.setColours(colour(r/255.f, g/255.f, b/255.f, alpha)); -} - /************************************************************************* Set the mouse cursor's color *************************************************************************/ From 81d0a4d78d2a84f69ed6536d4ac4a1e3bce8484c Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Sun, 5 Jan 2025 18:04:07 +0300 Subject: [PATCH 24/26] part 2 fix noexcept and Hungarian notation --- Client/gui/CGUI_Impl.cpp | 34 +++++++++---------- Client/gui/CGUI_Impl.h | 8 ++--- .../include/CEGUIColourRect.h | 2 +- .../src/CEGUIColourRect.cpp | 2 +- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Client/gui/CGUI_Impl.cpp b/Client/gui/CGUI_Impl.cpp index 21b279d5f8d..786b7b21993 100644 --- a/Client/gui/CGUI_Impl.cpp +++ b/Client/gui/CGUI_Impl.cpp @@ -30,7 +30,7 @@ using std::list; #define CGUI_SA_GOTHIC_SIZE 47 #define CGUI_MTA_SANS_FONT_SIZE 9 -CGUI_Impl::CGUI_Impl(IDirect3DDevice9* pDevice) : m_HasSchemeLoaded(false), m_fCurrentServerCursorAlpha(1.0f) +CGUI_Impl::CGUI_Impl(IDirect3DDevice9* pDevice) : m_HasSchemeLoaded(false), CurrentServerCursorAlpha(255.0f) { m_RenderOkTimer.SetMaxIncrement(100); @@ -496,7 +496,7 @@ bool CGUI_Impl::IsCursorEnabled() void CGUI_Impl::SetCursorAlpha(float fAlpha, bool bOnlyCurrentServer) { - CEGUI::MouseCursor::getSingleton().setColor(m_fCurrentServerCursorRed, m_fCurrentServerCursorGreen, m_fCurrentServerCursorBlue, fAlpha); + CEGUI::MouseCursor::getSingleton().setColor(CurrentServerCursorRed, CurrentServerCursorGreen, CurrentServerCursorBlue, fAlpha); if (bOnlyCurrentServer) SetCurrentServerCursorAlpha(fAlpha); @@ -505,18 +505,18 @@ void CGUI_Impl::SetCursorAlpha(float fAlpha, bool bOnlyCurrentServer) void CGUI_Impl::SetCursorColor(float r, float g, float b, float alpha) noexcept { CEGUI::MouseCursor::getSingleton().setColor(r, g, b, alpha); - m_fCurrentServerCursorRed = r; - m_fCurrentServerCursorGreen = g; - m_fCurrentServerCursorBlue = b; - m_fCurrentServerCursorAlpha = alpha; + CurrentServerCursorRed = r; + CurrentServerCursorGreen = g; + CurrentServerCursorBlue = b; + CurrentServerCursorAlpha = alpha; } void CGUI_Impl::GetCursorColor(float& r, float& g, float& b, float& alpha) noexcept { - r = m_fCurrentServerCursorRed; - g = m_fCurrentServerCursorGreen; - b = m_fCurrentServerCursorBlue; - alpha = m_fCurrentServerCursorAlpha; + r = CurrentServerCursorRed; + g = CurrentServerCursorGreen; + b = CurrentServerCursorBlue; + alpha = CurrentServerCursorAlpha; } void CGUI_Impl::ResetMenuCursorColor() noexcept @@ -526,25 +526,25 @@ void CGUI_Impl::ResetMenuCursorColor() noexcept void CGUI_Impl::ResetCursorColor(float r, float g, float b, float alpha) noexcept { - m_fCurrentServerCursorRed = r; - m_fCurrentServerCursorGreen = g; - m_fCurrentServerCursorBlue = b; - m_fCurrentServerCursorAlpha = alpha; + CurrentServerCursorRed = r; + CurrentServerCursorGreen = g; + CurrentServerCursorBlue = b; + CurrentServerCursorAlpha = alpha; } void CGUI_Impl::RestoreCurrentServerCursorColor() noexcept { - CEGUI::MouseCursor::getSingleton().setColor(m_fCurrentServerCursorRed, m_fCurrentServerCursorGreen, m_fCurrentServerCursorBlue, m_fCurrentServerCursorAlpha); + CEGUI::MouseCursor::getSingleton().setColor(CurrentServerCursorRed, CurrentServerCursorGreen, CurrentServerCursorBlue, CurrentServerCursorAlpha); } void CGUI_Impl::SetCurrentServerCursorAlpha(float fAlpha) { - m_fCurrentServerCursorAlpha = fAlpha; + CurrentServerCursorAlpha = fAlpha; } float CGUI_Impl::GetCurrentServerCursorAlpha() { - return m_fCurrentServerCursorAlpha; + return CurrentServerCursorAlpha; } eCursorType CGUI_Impl::GetCursorType() diff --git a/Client/gui/CGUI_Impl.h b/Client/gui/CGUI_Impl.h index d14f5d702fd..136c3814583 100644 --- a/Client/gui/CGUI_Impl.h +++ b/Client/gui/CGUI_Impl.h @@ -316,10 +316,10 @@ class CGUI_Impl : public CGUI, public CGUITabList CEGUI::DefaultWindow* m_pTop; const CEGUI::Image* m_pCursor; - float m_fCurrentServerCursorAlpha = 255.0f; - float m_fCurrentServerCursorRed = 255.0f; - float m_fCurrentServerCursorGreen = 255.0f; - float m_fCurrentServerCursorBlue = 255.0f; + float CurrentServerCursorAlpha = 255.0f; + float CurrentServerCursorRed = 255.0f; + float CurrentServerCursorGreen = 255.0f; + float CurrentServerCursorBlue = 255.0f; CGUIFont_Impl* m_pDefaultFont; CGUIFont_Impl* m_pSmallFont; diff --git a/vendor/cegui-0.4.0-custom/include/CEGUIColourRect.h b/vendor/cegui-0.4.0-custom/include/CEGUIColourRect.h index abd814a5cc4..13457e350a9 100644 --- a/vendor/cegui-0.4.0-custom/include/CEGUIColourRect.h +++ b/vendor/cegui-0.4.0-custom/include/CEGUIColourRect.h @@ -176,7 +176,7 @@ class CEGUIEXPORT ColourRect \param col colour that is to be set for all four corners of the ColourRect; */ - void setColours(const colour& col); + void setColours(const colour& col) noexcept; /*! diff --git a/vendor/cegui-0.4.0-custom/src/CEGUIColourRect.cpp b/vendor/cegui-0.4.0-custom/src/CEGUIColourRect.cpp index a30077f911f..031d18aebdd 100644 --- a/vendor/cegui-0.4.0-custom/src/CEGUIColourRect.cpp +++ b/vendor/cegui-0.4.0-custom/src/CEGUIColourRect.cpp @@ -154,7 +154,7 @@ ColourRect ColourRect::getSubRectangle( float left, float right, float top, floa /************************************************************************* Set the colour of all four corners simultaneously. *************************************************************************/ -void ColourRect::setColours(const colour& col) +void ColourRect::setColours(const colour& col) noexcept { d_top_left = d_top_right = d_bottom_left = d_bottom_right = col; } From 4727877194a78cc1985d26dd42e806799255f694 Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Sun, 5 Jan 2025 19:02:29 +0300 Subject: [PATCH 25/26] override and fixes --- Client/core/CModManager.cpp | 2 +- Client/gui/CGUI_Impl.cpp | 10 +++++----- Client/gui/CGUI_Impl.h | 14 +++++++------- Client/mods/deathmatch/logic/CClientGame.cpp | 2 +- .../deathmatch/logic/luadefs/CLuaClientDefs.cpp | 2 +- Client/sdk/gui/CGUI.h | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Client/core/CModManager.cpp b/Client/core/CModManager.cpp index cb97ccda669..50821674d01 100644 --- a/Client/core/CModManager.cpp +++ b/Client/core/CModManager.cpp @@ -218,7 +218,7 @@ void CModManager::Unload() CCore::GetSingleton().GetCommands()->SetExecuteHandler(NULL); // Reset cursor color - CCore::GetSingleton().GetGUI()->ResetCursorColor(255.f, 255.f, 255.f, 255.f); + CCore::GetSingleton().GetGUI()->ResetCursorColorVariables(); // Reset the modules CCore::GetSingleton().GetGame()->Reset(); diff --git a/Client/gui/CGUI_Impl.cpp b/Client/gui/CGUI_Impl.cpp index 786b7b21993..d5afc95ace1 100644 --- a/Client/gui/CGUI_Impl.cpp +++ b/Client/gui/CGUI_Impl.cpp @@ -524,12 +524,12 @@ void CGUI_Impl::ResetMenuCursorColor() noexcept CEGUI::MouseCursor::getSingleton().setColor(255.0f, 255.0f, 255.0f, 255.0f); } -void CGUI_Impl::ResetCursorColor(float r, float g, float b, float alpha) noexcept +void CGUI_Impl::ResetCursorColorVariables() noexcept { - CurrentServerCursorRed = r; - CurrentServerCursorGreen = g; - CurrentServerCursorBlue = b; - CurrentServerCursorAlpha = alpha; + CurrentServerCursorRed = 255.f; + CurrentServerCursorGreen = 255.f; + CurrentServerCursorBlue = 255.f; + CurrentServerCursorAlpha = 255.f; } void CGUI_Impl::RestoreCurrentServerCursorColor() noexcept diff --git a/Client/gui/CGUI_Impl.h b/Client/gui/CGUI_Impl.h index 136c3814583..102d3a3378f 100644 --- a/Client/gui/CGUI_Impl.h +++ b/Client/gui/CGUI_Impl.h @@ -142,14 +142,14 @@ class CGUI_Impl : public CGUI, public CGUITabList void SetCursorEnabled(bool bEnabled); bool IsCursorEnabled(); - void SetCursorAlpha(float fAlpha, bool bOnlyCurrentServer = false); - void SetCurrentServerCursorAlpha(float fAlpha); + void SetCursorAlpha(float fAlpha, bool bOnlyCurrentServer = false) override; + void SetCurrentServerCursorAlpha(float fAlpha) override; float GetCurrentServerCursorAlpha(); - void SetCursorColor(float r, float g, float b, float alpha) noexcept; - void GetCursorColor(float& r, float& g, float& b, float& alpha) noexcept; - void ResetMenuCursorColor() noexcept; - void RestoreCurrentServerCursorColor() noexcept; - void ResetCursorColor(float r, float g, float b, float alpha) noexcept; + void SetCursorColor(float r, float g, float b, float alpha) noexcept override; + void GetCursorColor(float& r, float& g, float& b, float& alpha) noexcept override; + void ResetMenuCursorColor() noexcept override; + void RestoreCurrentServerCursorColor() noexcept override; + void ResetCursorColorVariables() noexcept override; eCursorType GetCursorType(); void AddChild(CGUIElement_Impl* pChild); diff --git a/Client/mods/deathmatch/logic/CClientGame.cpp b/Client/mods/deathmatch/logic/CClientGame.cpp index 3d5293fe698..72238fdf074 100644 --- a/Client/mods/deathmatch/logic/CClientGame.cpp +++ b/Client/mods/deathmatch/logic/CClientGame.cpp @@ -3445,7 +3445,7 @@ void CClientGame::Event_OnIngame() g_pGame->SetWeaponRenderEnabled(true); // Reset cursor color - g_pCore->GetGUI()->ResetCursorColor(255.f, 255.f, 255.f, 255.f); + g_pCore->GetGUI()->ResetCursorColorVariables(); // Make sure we can access all areas g_pGame->GetStats()->ModifyStat(CITIES_PASSED, 2.0); diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp index 4b3254549bd..1a0ae36d43f 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaClientDefs.cpp @@ -88,7 +88,7 @@ bool CLuaClientDefs::SetCursorColor(std::optional r, std::optional if (!g_pCore->IsMenuVisible()) g_pCore->GetGUI()->SetCursorColor(r.value_or(255.0f), g.value_or(255.0f), b.value_or(255.0f), alpha.value_or(255.0f)); else - g_pCore->GetGUI()->ResetCursorColor(r.value_or(255.0f), g.value_or(255.0f), b.value_or(255.0f), alpha.value_or(255.0f)); // Force variables to be updated when close the main menu it will set the new color + g_pCore->GetGUI()->ResetCursorColorVariables(); // Force variables to be updated when close the main menu it will set the new color return true; } diff --git a/Client/sdk/gui/CGUI.h b/Client/sdk/gui/CGUI.h index 0d3324dcb43..dbf6ffed15a 100644 --- a/Client/sdk/gui/CGUI.h +++ b/Client/sdk/gui/CGUI.h @@ -129,7 +129,7 @@ class CGUI virtual void SetCursorColor(float r, float g, float b, float alpha) noexcept = 0; virtual void GetCursorColor(float& r, float& g, float& b, float& alpha) noexcept = 0; virtual void ResetMenuCursorColor() noexcept = 0; - virtual void ResetCursorColor(float r, float g, float b, float alpha) noexcept = 0; + virtual void ResetCursorColorVariables() noexcept = 0; virtual void RestoreCurrentServerCursorColor() noexcept = 0; virtual void SetCurrentServerCursorAlpha(float fAlpha) = 0; virtual float GetCurrentServerCursorAlpha() = 0; From 23b2b6f71f2cf735cb427bfe69b406154887c70d Mon Sep 17 00:00:00 2001 From: Proxy-99 <77501848+Proxy-99@users.noreply.github.com> Date: Mon, 6 Jan 2025 05:18:31 +0300 Subject: [PATCH 26/26] review --- Client/core/CCore.cpp | 2 +- Client/core/CCore.h | 2 +- Client/core/CMainMenu.cpp | 2 +- Client/core/CMainMenu.h | 2 +- Client/gui/CGUI_Impl.h | 8 ++++---- Client/sdk/core/CCoreInterface.h | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Client/core/CCore.cpp b/Client/core/CCore.cpp index 12e8cf81d54..6cdfc38b9bf 100644 --- a/Client/core/CCore.cpp +++ b/Client/core/CCore.cpp @@ -588,7 +588,7 @@ bool CCore::IsSettingsVisible() return false; } -bool CCore::IsMenuVisible() +bool CCore::IsMenuVisible() const noexcept { if (m_pLocalGUI) { diff --git a/Client/core/CCore.h b/Client/core/CCore.h index 3439a484ded..acef17b3e8d 100644 --- a/Client/core/CCore.h +++ b/Client/core/CCore.h @@ -138,7 +138,7 @@ class CCore : public CCoreInterface, public CSingleton // GUI bool IsSettingsVisible(); - bool IsMenuVisible(); + bool IsMenuVisible() const noexcept; bool IsCursorForcedVisible(); bool IsCursorControlsToggled() { return m_bCursorToggleControls; } void HideMainMenu(); diff --git a/Client/core/CMainMenu.cpp b/Client/core/CMainMenu.cpp index ca2dc90e027..b3007a3b07b 100644 --- a/Client/core/CMainMenu.cpp +++ b/Client/core/CMainMenu.cpp @@ -792,7 +792,7 @@ void CMainMenu::SetVisible(bool bVisible, bool bOverlay, bool bFrameDelay) m_bHideGame = !bOverlay; } -bool CMainMenu::IsVisible() +bool CMainMenu::IsVisible() const noexcept { return m_bIsVisible; } diff --git a/Client/core/CMainMenu.h b/Client/core/CMainMenu.h index 72b549f01ee..c005a04ad5d 100644 --- a/Client/core/CMainMenu.h +++ b/Client/core/CMainMenu.h @@ -51,7 +51,7 @@ class CMainMenu void Hide(); void SetVisible(bool bVisible, bool bOverlay = true, bool bFrameDelay = true); - bool IsVisible(); + bool IsVisible() const noexcept; bool IsFading() { return m_ucFade == FADE_IN || m_ucFade == FADE_OUT; } void SetIsIngame(bool bIsIngame); diff --git a/Client/gui/CGUI_Impl.h b/Client/gui/CGUI_Impl.h index 102d3a3378f..d4ce2000f0d 100644 --- a/Client/gui/CGUI_Impl.h +++ b/Client/gui/CGUI_Impl.h @@ -316,10 +316,10 @@ class CGUI_Impl : public CGUI, public CGUITabList CEGUI::DefaultWindow* m_pTop; const CEGUI::Image* m_pCursor; - float CurrentServerCursorAlpha = 255.0f; - float CurrentServerCursorRed = 255.0f; - float CurrentServerCursorGreen = 255.0f; - float CurrentServerCursorBlue = 255.0f; + float CurrentServerCursorAlpha = {255.0f}; + float CurrentServerCursorRed = {255.0f}; + float CurrentServerCursorGreen = {255.0f}; + float CurrentServerCursorBlue = {255.0f}; CGUIFont_Impl* m_pDefaultFont; CGUIFont_Impl* m_pSmallFont; diff --git a/Client/sdk/core/CCoreInterface.h b/Client/sdk/core/CCoreInterface.h index c591d546e5e..1a31048f014 100644 --- a/Client/sdk/core/CCoreInterface.h +++ b/Client/sdk/core/CCoreInterface.h @@ -100,7 +100,7 @@ class CCoreInterface virtual void EnableChatInput(char* szCommand, DWORD dwColor) = 0; virtual bool IsChatInputEnabled() = 0; virtual bool IsSettingsVisible() = 0; - virtual bool IsMenuVisible() = 0; + virtual bool IsMenuVisible() const noexcept = 0; virtual bool IsCursorForcedVisible() = 0; virtual bool IsCursorControlsToggled() = 0; virtual void CallSetCursorPos(int X, int Y) = 0;