From 1347860b2c21dbad0c4953b6062874789890d0d5 Mon Sep 17 00:00:00 2001 From: ChillerDragon Date: Sat, 16 Jul 2022 15:32:06 +0200 Subject: [PATCH] Adapt upstreams CButtonContainer --- src/game/client/components/menus.cpp | 114 +++++++++--------- src/game/client/components/menus.h | 10 +- src/game/client/components/menus_browser.cpp | 16 +-- src/game/client/components/menus_demo.cpp | 38 +++--- src/game/client/components/menus_ingame.cpp | 48 ++++---- src/game/client/components/menus_settings.cpp | 73 +++++------ .../components/menus_settings_assets.cpp | 18 +-- src/game/client/components/menus_start.cpp | 26 ++-- src/game/client/ui.h | 4 + 9 files changed, 178 insertions(+), 169 deletions(-) diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 98bcbfd93..4c909efe5 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -130,7 +130,7 @@ int CMenus::DoButton_Toggle(const void *pID, int Checked, const CUIRect *pRect, return Active ? UI()->DoButtonLogic(pID, Checked, pRect) : 0; } -int CMenus::DoButton_Menu(const void *pID, const char *pText, int Checked, const CUIRect *pRect, const char *pImageName, int Corners, float r, float FontFactor, vec4 ColorHot, vec4 Color, int AlignVertically, bool CheckForActiveColorPicker) +int CMenus::DoButton_Menu(CButtonContainer *pButtonContainer, const char *pText, int Checked, const CUIRect *pRect, const char *pImageName, int Corners, float r, float FontFactor, vec4 ColorHot, vec4 Color, int AlignVertically, bool CheckForActiveColorPicker) { CUIRect Text = *pRect; @@ -151,7 +151,7 @@ int CMenus::DoButton_Menu(const void *pID, const char *pText, int Checked, const } if(!MouseInsideColorPicker) - Color.a *= UI()->ButtonColorMul(pID); + Color.a *= UI()->ButtonColorMul(pButtonContainer); RenderTools()->DrawUIRect(pRect, Color, Corners, r); if(pImageName) @@ -163,7 +163,7 @@ int CMenus::DoButton_Menu(const void *pID, const char *pText, int Checked, const const CMenuImage *pImage = FindMenuImage(pImageName); if(pImage) { - Graphics()->TextureSet(UI()->HotItem() == pID ? pImage->m_OrgTexture : pImage->m_GreyTexture); + Graphics()->TextureSet(UI()->HotItem() == pButtonContainer ? pImage->m_OrgTexture : pImage->m_GreyTexture); Graphics()->WrapClamp(); Graphics()->QuadsBegin(); Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f); @@ -183,7 +183,7 @@ int CMenus::DoButton_Menu(const void *pID, const char *pText, int Checked, const if(MouseInsideColorPicker) return 0; - return UI()->DoButtonLogic(pID, Checked, pRect); + return UI()->DoButtonLogic(pButtonContainer, Checked, pRect); } void CMenus::DoButton_KeySelect(const void *pID, const char *pText, int Checked, const CUIRect *pRect) @@ -194,7 +194,7 @@ void CMenus::DoButton_KeySelect(const void *pID, const char *pText, int Checked, UI()->DoLabel(&Temp, pText, Temp.h * CUI::ms_FontmodHeight, TEXTALIGN_CENTER); } -int CMenus::DoButton_MenuTab(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Corners, SUIAnimator *pAnimator, const ColorRGBA *pDefaultColor, const ColorRGBA *pActiveColor, const ColorRGBA *pHoverColor, float EdgeRounding, int AlignVertically) +int CMenus::DoButton_MenuTab(CButtonContainer *pButtonContainer, const char *pText, int Checked, const CUIRect *pRect, int Corners, SUIAnimator *pAnimator, const ColorRGBA *pDefaultColor, const ColorRGBA *pActiveColor, const ColorRGBA *pHoverColor, float EdgeRounding, int AlignVertically) { const bool MouseInside = UI()->MouseInside(pRect); CUIRect Rect = *pRect; @@ -273,7 +273,7 @@ int CMenus::DoButton_MenuTab(const void *pID, const char *pText, int Checked, co Props.m_AlignVertically = AlignVertically; UI()->DoLabel(&Temp, pText, Temp.h * CUI::ms_FontmodHeight, TEXTALIGN_CENTER, Props); - return UI()->DoButtonLogic(pID, Checked, pRect); + return UI()->DoButtonLogic(pButtonContainer, Checked, pRect); } int CMenus::DoButton_GridHeader(const void *pID, const char *pText, int Checked, const CUIRect *pRect) @@ -367,7 +367,7 @@ void CMenus::DoLaserPreview(const CUIRect *pRect, const ColorHSLA LaserOutlineCo Graphics()->QuadsEnd(); } -ColorHSLA CMenus::DoLine_ColorPicker(int *pResetID, const float LineSize, const float WantedPickerPosition, const float LabelSize, const float BottomMargin, CUIRect *pMainRect, const char *pText, unsigned int *pColorValue, const ColorRGBA DefaultColor, bool CheckBoxSpacing, bool UseCheckBox, int *pCheckBoxValue) +ColorHSLA CMenus::DoLine_ColorPicker(CButtonContainer *pResetID, const float LineSize, const float WantedPickerPosition, const float LabelSize, const float BottomMargin, CUIRect *pMainRect, const char *pText, unsigned int *pColorValue, const ColorRGBA DefaultColor, bool CheckBoxSpacing, bool UseCheckBox, int *pCheckBoxValue) { CUIRect Section, Button, Label; @@ -657,7 +657,7 @@ int CMenus::RenderMenubar(CUIRect r) if(Client()->State() == IClient::STATE_OFFLINE) { Box.VSplitLeft(33.0f, &Button, &Box); - static int s_StartButton = 0; + static CButtonContainer s_StartButton; TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT)); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE); @@ -703,7 +703,7 @@ int CMenus::RenderMenubar(CUIRect r) if(m_ActivePage == PAGE_NEWS) { Box.VSplitLeft(100.0f, &Button, &Box); - static int s_NewsButton = 0; + static CButtonContainer s_NewsButton; if(DoButton_MenuTab(&s_NewsButton, Localize("News"), m_ActivePage == PAGE_NEWS, &Button, CUI::CORNER_T, &m_aAnimatorsBigPage[BIG_TAB_NEWS])) { NewPage = PAGE_NEWS; @@ -713,7 +713,7 @@ int CMenus::RenderMenubar(CUIRect r) else if(m_ActivePage == PAGE_DEMOS) { Box.VSplitLeft(100.0f, &Button, &Box); - static int s_DemosButton = 0; + static CButtonContainer s_DemosButton; if(DoButton_MenuTab(&s_DemosButton, Localize("Demos"), m_ActivePage == PAGE_DEMOS, &Button, CUI::CORNER_T, &m_aAnimatorsBigPage[BIG_TAB_DEMOS])) { DemolistPopulate(); @@ -724,7 +724,7 @@ int CMenus::RenderMenubar(CUIRect r) else { Box.VSplitLeft(100.0f, &Button, &Box); - static int s_InternetButton = 0; + static CButtonContainer s_InternetButton; if(DoButton_MenuTab(&s_InternetButton, Localize("Internet"), m_ActivePage == PAGE_INTERNET, &Button, CUI::CORNER_T, &m_aAnimatorsBigPage[BIG_TAB_INTERNET])) { if(ServerBrowser()->GetCurrentType() != IServerBrowser::TYPE_INTERNET) @@ -734,7 +734,7 @@ int CMenus::RenderMenubar(CUIRect r) } Box.VSplitLeft(100.0f, &Button, &Box); - static int s_LanButton = 0; + static CButtonContainer s_LanButton; if(DoButton_MenuTab(&s_LanButton, Localize("LAN"), m_ActivePage == PAGE_LAN, &Button, CUI::CORNER_T, &m_aAnimatorsBigPage[BIG_TAB_LAN])) { if(ServerBrowser()->GetCurrentType() != IServerBrowser::TYPE_LAN) @@ -744,7 +744,7 @@ int CMenus::RenderMenubar(CUIRect r) } Box.VSplitLeft(100.0f, &Button, &Box); - static int s_FavoritesButton = 0; + static CButtonContainer s_FavoritesButton; if(DoButton_MenuTab(&s_FavoritesButton, Localize("Favorites"), m_ActivePage == PAGE_FAVORITES, &Button, CUI::CORNER_T, &m_aAnimatorsBigPage[BIG_TAB_FAVORITES])) { if(ServerBrowser()->GetCurrentType() != IServerBrowser::TYPE_FAVORITES) @@ -754,7 +754,7 @@ int CMenus::RenderMenubar(CUIRect r) } Box.VSplitLeft(90.0f, &Button, &Box); - static int s_DDNetButton = 0; + static CButtonContainer s_DDNetButton; if(DoButton_MenuTab(&s_DDNetButton, "DDNet", m_ActivePage == PAGE_DDNET, &Button, CUI::CORNER_T, &m_aAnimatorsBigPage[BIG_TAB_DDNET])) { if(ServerBrowser()->GetCurrentType() != IServerBrowser::TYPE_DDNET) @@ -767,7 +767,7 @@ int CMenus::RenderMenubar(CUIRect r) } Box.VSplitLeft(90.0f, &Button, &Box); - static int s_KoGButton = 0; + static CButtonContainer s_KoGButton; if(DoButton_MenuTab(&s_KoGButton, "KoG", m_ActivePage == PAGE_KOG, &Button, CUI::CORNER_T, &m_aAnimatorsBigPage[BIG_TAB_KOG])) { if(ServerBrowser()->GetCurrentType() != IServerBrowser::TYPE_KOG) @@ -784,27 +784,27 @@ int CMenus::RenderMenubar(CUIRect r) { // online menus Box.VSplitLeft(90.0f, &Button, &Box); - static int s_GameButton = 0; + static CButtonContainer s_GameButton; if(DoButton_MenuTab(&s_GameButton, Localize("Game"), m_ActivePage == PAGE_GAME, &Button, CUI::CORNER_TL)) NewPage = PAGE_GAME; Box.VSplitLeft(90.0f, &Button, &Box); - static int s_PlayersButton = 0; + static CButtonContainer s_PlayersButton; if(DoButton_MenuTab(&s_PlayersButton, Localize("Players"), m_ActivePage == PAGE_PLAYERS, &Button, 0)) NewPage = PAGE_PLAYERS; Box.VSplitLeft(130.0f, &Button, &Box); - static int s_ServerInfoButton = 0; + static CButtonContainer s_ServerInfoButton; if(DoButton_MenuTab(&s_ServerInfoButton, Localize("Server info"), m_ActivePage == PAGE_SERVER_INFO, &Button, 0)) NewPage = PAGE_SERVER_INFO; Box.VSplitLeft(90.0f, &Button, &Box); - static int s_NetworkButton = 0; + static CButtonContainer s_NetworkButton; if(DoButton_MenuTab(&s_NetworkButton, Localize("Browser"), m_ActivePage == PAGE_NETWORK, &Button, 0)) NewPage = PAGE_NETWORK; { - static int s_GhostButton = 0; + static CButtonContainer s_GhostButton; if(GameClient()->m_GameInfo.m_Race) { Box.VSplitLeft(90.0f, &Button, &Box); @@ -815,7 +815,7 @@ int CMenus::RenderMenubar(CUIRect r) Box.VSplitLeft(100.0f, &Button, &Box); Box.VSplitLeft(4.0f, 0, &Box); - static int s_CallVoteButton = 0; + static CButtonContainer s_CallVoteButton; if(DoButton_MenuTab(&s_CallVoteButton, Localize("Call vote"), m_ActivePage == PAGE_CALLVOTE, &Button, CUI::CORNER_TR)) { NewPage = PAGE_CALLVOTE; @@ -827,7 +827,7 @@ int CMenus::RenderMenubar(CUIRect r) TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE); Box.VSplitRight(33.0f, &Box, &Button); - static int s_QuitButton = 0; + static CButtonContainer s_QuitButton; ColorRGBA QuitColor(1, 0, 0, 0.5f); if(DoButton_MenuTab(&s_QuitButton, "\xEF\x80\x91", 0, &Button, CUI::CORNER_T, &m_aAnimatorsSmallPage[SMALL_TAB_QUIT], NULL, NULL, &QuitColor, 10.0f, 0)) { @@ -843,14 +843,14 @@ int CMenus::RenderMenubar(CUIRect r) Box.VSplitRight(10.0f, &Box, &Button); Box.VSplitRight(33.0f, &Box, &Button); - static int s_SettingsButton = 0; + static CButtonContainer s_SettingsButton; if(DoButton_MenuTab(&s_SettingsButton, "\xEF\x80\x93", m_ActivePage == PAGE_SETTINGS, &Button, CUI::CORNER_T, &m_aAnimatorsSmallPage[SMALL_TAB_SETTINGS], NULL, NULL, NULL, 10.0f, 0)) NewPage = PAGE_SETTINGS; Box.VSplitRight(10.0f, &Box, &Button); Box.VSplitRight(33.0f, &Box, &Button); - static int s_EditorButton = 0; + static CButtonContainer s_EditorButton; if(DoButton_MenuTab(&s_EditorButton, "\xEF\x81\x84", 0, &Button, CUI::CORNER_T, &m_aAnimatorsSmallPage[SMALL_TAB_EDITOR], NULL, NULL, NULL, 10.0f, 0)) { g_Config.m_ClEditor = 1; @@ -860,14 +860,14 @@ int CMenus::RenderMenubar(CUIRect r) { Box.VSplitRight(10.0f, &Box, &Button); Box.VSplitRight(33.0f, &Box, &Button); - static int s_DemoButton = 0; + static CButtonContainer s_DemoButton; if(DoButton_MenuTab(&s_DemoButton, "\xEE\x84\xB1", m_ActivePage == PAGE_DEMOS, &Button, CUI::CORNER_T, &m_aAnimatorsSmallPage[SMALL_TAB_DEMOBUTTON], NULL, NULL, NULL, 10.0f, 0)) NewPage = PAGE_DEMOS; Box.VSplitRight(10.0f, &Box, &Button); Box.VSplitRight(33.0f, &Box, &Button); - static int s_ServerButton = 0; + static CButtonContainer s_ServerButton; if(DoButton_MenuTab(&s_ServerButton, "\xEF\x95\xBD", m_ActivePage == g_Config.m_UiPage, &Button, CUI::CORNER_T, &m_aAnimatorsSmallPage[SMALL_TAB_SERVER], NULL, NULL, NULL, 10.0f, 0)) NewPage = g_Config.m_UiPage; @@ -1676,11 +1676,11 @@ int CMenus::Render() Yes.VMargin(20.0f, &Yes); No.VMargin(20.0f, &No); - static int s_ButtonAbort = 0; + static CButtonContainer s_ButtonAbort; if(DoButton_Menu(&s_ButtonAbort, Localize("No"), 0, &No) || m_EscapePressed) m_Popup = POPUP_NONE; - static int s_ButtonTryAgain = 0; + static CButtonContainer s_ButtonTryAgain; if(DoButton_Menu(&s_ButtonTryAgain, Localize("Yes"), 0, &Yes) || m_EnterPressed) { m_Popup = POPUP_NONE; @@ -1699,11 +1699,11 @@ int CMenus::Render() Yes.VMargin(20.0f, &Yes); No.VMargin(20.0f, &No); - static int s_ButtonAbort = 0; + static CButtonContainer s_ButtonAbort; if(DoButton_Menu(&s_ButtonAbort, Localize("No"), 0, &No) || m_EscapePressed) m_Popup = POPUP_NONE; - static int s_ButtonTryAgain = 0; + static CButtonContainer s_ButtonTryAgain; if(DoButton_Menu(&s_ButtonTryAgain, Localize("Yes"), 0, &Yes) || m_EnterPressed) Client()->Disconnect(); } @@ -1719,11 +1719,11 @@ int CMenus::Render() Yes.VMargin(20.0f, &Yes); No.VMargin(20.0f, &No); - static int s_ButtonAbort = 0; + static CButtonContainer s_ButtonAbort; if(DoButton_Menu(&s_ButtonAbort, Localize("No"), 0, &No) || m_EscapePressed) m_Popup = POPUP_NONE; - static int s_ButtonTryAgain = 0; + static CButtonContainer s_ButtonTryAgain; if(DoButton_Menu(&s_ButtonTryAgain, Localize("Yes"), 0, &Yes) || m_EnterPressed) { Client()->DummyDisconnect(0); @@ -1744,11 +1744,11 @@ int CMenus::Render() TryAgain.VMargin(20.0f, &TryAgain); Abort.VMargin(20.0f, &Abort); - static int s_ButtonAbort = 0; + static CButtonContainer s_ButtonAbort; if(DoButton_Menu(&s_ButtonAbort, Localize("Abort"), 0, &Abort) || m_EscapePressed) m_Popup = POPUP_NONE; - static int s_ButtonTryAgain = 0; + static CButtonContainer s_ButtonTryAgain; if(DoButton_Menu(&s_ButtonTryAgain, Localize("Try again"), 0, &TryAgain) || m_EnterPressed) { Client()->Connect(g_Config.m_UiServerAddress, g_Config.m_Password); @@ -1773,7 +1773,7 @@ int CMenus::Render() Box.HSplitBottom(24.f, &Box, &Part); Part.VMargin(120.0f, &Part); - static int s_Button = 0; + static CButtonContainer s_Button; if(DoButton_Menu(&s_Button, pButtonText, 0, &Part) || m_EscapePressed || (m_EnterPressed && m_Popup != POPUP_CONNECTING)) { Client()->Disconnect(); @@ -1843,7 +1843,7 @@ int CMenus::Render() RenderLanguageSelection(Box); Part.VMargin(120.0f, &Part); - static int s_Button = 0; + static CButtonContainer s_Button; if(DoButton_Menu(&s_Button, Localize("Ok"), 0, &Part) || m_EscapePressed || m_EnterPressed) m_Popup = POPUP_FIRST_LAUNCH; } @@ -1891,7 +1891,7 @@ int CMenus::Render() Part.VMargin(120.0f, &Part); - static int s_Button = 0; + static CButtonContainer s_Button; if(DoButton_Menu(&s_Button, Localize("Ok"), 0, &Part) || m_EnterPressed) { g_Config.m_BrFilterCountryIndex = CurSelection; @@ -1917,11 +1917,11 @@ int CMenus::Render() Yes.VMargin(20.0f, &Yes); No.VMargin(20.0f, &No); - static int s_ButtonAbort = 0; + static CButtonContainer s_ButtonAbort; if(DoButton_Menu(&s_ButtonAbort, Localize("No"), 0, &No) || m_EscapePressed) m_Popup = POPUP_NONE; - static int s_ButtonTryAgain = 0; + static CButtonContainer s_ButtonTryAgain; if(DoButton_Menu(&s_ButtonTryAgain, Localize("Yes"), 0, &Yes) || m_EnterPressed) { m_Popup = POPUP_NONE; @@ -1952,11 +1952,11 @@ int CMenus::Render() Ok.VMargin(20.0f, &Ok); Abort.VMargin(20.0f, &Abort); - static int s_ButtonAbort = 0; + static CButtonContainer s_ButtonAbort; if(DoButton_Menu(&s_ButtonAbort, Localize("Abort"), 0, &Abort) || m_EscapePressed) m_Popup = POPUP_NONE; - static int s_ButtonOk = 0; + static CButtonContainer s_ButtonOk; if(DoButton_Menu(&s_ButtonOk, Localize("Ok"), 0, &Ok) || m_EnterPressed) { m_Popup = POPUP_NONE; @@ -2011,11 +2011,11 @@ int CMenus::Render() Ok.VMargin(20.0f, &Ok); Abort.VMargin(20.0f, &Abort); - static int s_ButtonAbort = 0; + static CButtonContainer s_ButtonAbort; if(DoButton_Menu(&s_ButtonAbort, Localize("Abort"), 0, &Abort) || m_EscapePressed) m_Popup = POPUP_NONE; - static int s_ButtonOk = 0; + static CButtonContainer s_ButtonOk; if(DoButton_Menu(&s_ButtonOk, Localize("Ok"), 0, &Ok) || m_EnterPressed) { m_Popup = POPUP_NONE; @@ -2074,14 +2074,14 @@ int CMenus::Render() // slowdown Part.VSplitLeft(5.0f, 0, &Part); Part.VSplitLeft(ButtonSize, &Button, &Part); - static int s_SlowDownButton = 0; + static CButtonContainer s_SlowDownButton; if(DoButton_Sprite(&s_SlowDownButton, IMAGE_DEMOBUTTONS, SPRITE_DEMOBUTTON_SLOWER, 0, &Button, CUI::CORNER_ALL)) DecDemoSpeed = true; // fastforward Part.VSplitLeft(5.0f, 0, &Part); Part.VSplitLeft(ButtonSize, &Button, &Part); - static int s_FastForwardButton = 0; + static CButtonContainer s_FastForwardButton; if(DoButton_Sprite(&s_FastForwardButton, IMAGE_DEMOBUTTONS, SPRITE_DEMOBUTTON_FASTER, 0, &Button, CUI::CORNER_ALL)) IncDemoSpeed = true; @@ -2131,11 +2131,11 @@ int CMenus::Render() Yes.VMargin(20.0f, &Yes); No.VMargin(20.0f, &No); - static int s_ButtonAbort = 0; + static CButtonContainer s_ButtonAbort; if(DoButton_Menu(&s_ButtonAbort, Localize("No"), 0, &No) || m_EscapePressed) m_Popup = POPUP_RENDER_DEMO; - static int s_ButtonTryAgain = 0; + static CButtonContainer s_ButtonTryAgain; if(DoButton_Menu(&s_ButtonTryAgain, Localize("Yes"), 0, &Yes) || m_EnterPressed) { m_Popup = POPUP_NONE; @@ -2160,11 +2160,11 @@ int CMenus::Render() Yes.VMargin(20.0f, &Yes); No.VMargin(20.0f, &No); - static int s_ButtonAbort = 0; + static CButtonContainer s_ButtonAbort; if(DoButton_Menu(&s_ButtonAbort, Localize("No"), 0, &No) || m_EscapePressed) m_Popup = POPUP_NONE; - static int s_ButtonTryAgain = 0; + static CButtonContainer s_ButtonTryAgain; if(DoButton_Menu(&s_ButtonTryAgain, Localize("Yes"), 0, &Yes) || m_EnterPressed) { m_Popup = POPUP_NONE; @@ -2189,7 +2189,7 @@ int CMenus::Render() Skip.VMargin(20.0f, &Skip); Join.VMargin(20.0f, &Join); - static int s_JoinTutorialButton = 0; + static CButtonContainer s_JoinTutorialButton; if(DoButton_Menu(&s_JoinTutorialButton, Localize("Join Tutorial Server"), 0, &Join) || m_EnterPressed) { m_JoinTutorial = true; @@ -2197,7 +2197,7 @@ int CMenus::Render() m_Popup = g_Config.m_BrIndicateFinished ? POPUP_POINTS : POPUP_NONE; } - static int s_SkipTutorialButton = 0; + static CButtonContainer s_SkipTutorialButton; if(DoButton_Menu(&s_SkipTutorialButton, Localize("Skip Tutorial"), 0, &Skip) || m_EscapePressed) { m_JoinTutorial = false; @@ -2242,11 +2242,11 @@ int CMenus::Render() Yes.VMargin(20.0f, &Yes); No.VMargin(20.0f, &No); - static int s_ButtonNo = 0; + static CButtonContainer s_ButtonNo; if(DoButton_Menu(&s_ButtonNo, Localize("No"), 0, &No) || m_EscapePressed) m_Popup = POPUP_FIRST_LAUNCH; - static int s_ButtonYes = 0; + static CButtonContainer s_ButtonYes; if(DoButton_Menu(&s_ButtonYes, Localize("Yes"), 0, &Yes) || m_EnterPressed) m_Popup = POPUP_NONE; } @@ -2256,7 +2256,7 @@ int CMenus::Render() Box.HSplitBottom(24.f, &Box, &Part); Part.VMargin(120.0f, &Part); - static int s_Button = 0; + static CButtonContainer s_Button; if(DoButton_Menu(&s_Button, pButtonText, 0, &Part) || m_EscapePressed || m_EnterPressed || (time_get_nanoseconds() - m_PopupWarningLastTime >= m_PopupWarningDuration)) { m_Popup = POPUP_NONE; @@ -2275,14 +2275,14 @@ int CMenus::Render() Yes.VMargin(20.0f, &Yes); No.VMargin(20.0f, &No); - static int s_ButtonAbort = 0; + static CButtonContainer s_ButtonAbort; if(DoButton_Menu(&s_ButtonAbort, Localize("No"), 0, &No) || m_EscapePressed) { m_Popup = POPUP_NONE; m_aNextServer[0] = '\0'; } - static int s_ButtonTryAgain = 0; + static CButtonContainer s_ButtonTryAgain; if(DoButton_Menu(&s_ButtonTryAgain, Localize("Yes"), 0, &Yes) || m_EnterPressed) Client()->Connect(m_aNextServer); } @@ -2292,7 +2292,7 @@ int CMenus::Render() Box.HSplitBottom(24.f, &Box, &Part); Part.VMargin(120.0f, &Part); - static int s_Button = 0; + static CButtonContainer s_Button; if(DoButton_Menu(&s_Button, pButtonText, 0, &Part) || m_EscapePressed || m_EnterPressed) { if(m_Popup == POPUP_DISCONNECTED && Client()->m_ReconnectTime > 0) diff --git a/src/game/client/components/menus.h b/src/game/client/components/menus.h index 8fd1d3e62..4c6975f18 100644 --- a/src/game/client/components/menus.h +++ b/src/game/client/components/menus.h @@ -83,16 +83,16 @@ class CMenus : public CComponent CUIEx *UIEx() { return &m_UIEx; } int DoButton_DemoPlayer(const void *pID, const char *pText, int Checked, const CUIRect *pRect); - int DoButton_Sprite(const void *pID, int ImageID, int SpriteID, int Checked, const CUIRect *pRect, int Corners); + int DoButton_Sprite(CButtonContainer *pButtonContainer, int ImageID, int SpriteID, int Checked, const CUIRect *pRect, int Corners); int DoButton_Toggle(const void *pID, int Checked, const CUIRect *pRect, bool Active); - int DoButton_Menu(const void *pID, const char *pText, int Checked, const CUIRect *pRect, const char *pImageName = nullptr, int Corners = CUI::CORNER_ALL, float r = 5.0f, float FontFactor = 0.0f, vec4 ColorHot = vec4(1.0f, 1.0f, 1.0f, 0.75f), vec4 Color = vec4(1, 1, 1, 0.5f), int AlignVertically = 1, bool CheckForActiveColorPicker = false); - int DoButton_MenuTab(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Corners, SUIAnimator *pAnimator = nullptr, const ColorRGBA *pDefaultColor = nullptr, const ColorRGBA *pActiveColor = nullptr, const ColorRGBA *pHoverColor = nullptr, float EdgeRounding = 10, int AlignVertically = 1); + int DoButton_Menu(CButtonContainer *pButtonContainer, const char *pText, int Checked, const CUIRect *pRect, const char *pImageName = nullptr, int Corners = CUI::CORNER_ALL, float r = 5.0f, float FontFactor = 0.0f, vec4 ColorHot = vec4(1.0f, 1.0f, 1.0f, 0.75f), vec4 Color = vec4(1, 1, 1, 0.5f), int AlignVertically = 1, bool CheckForActiveColorPicker = false); + int DoButton_MenuTab(CButtonContainer *pButtonContainer, const char *pText, int Checked, const CUIRect *pRect, int Corners, SUIAnimator *pAnimator = nullptr, const ColorRGBA *pDefaultColor = nullptr, const ColorRGBA *pActiveColor = nullptr, const ColorRGBA *pHoverColor = nullptr, float EdgeRounding = 10, int AlignVertically = 1); int DoButton_CheckBox_Common(const void *pID, const char *pText, const char *pBoxText, const CUIRect *pRect); int DoButton_CheckBox(const void *pID, const char *pText, int Checked, const CUIRect *pRect); int DoButton_CheckBoxAutoVMarginAndSet(const void *pID, const char *pText, int *pValue, CUIRect *pRect, float VMargin); int DoButton_CheckBox_Number(const void *pID, const char *pText, int Checked, const CUIRect *pRect); - ColorHSLA DoLine_ColorPicker(int *pResetID, float LineSize, float WantedPickerPosition, float LabelSize, float BottomMargin, CUIRect *pMainRect, const char *pText, unsigned int *pColorValue, ColorRGBA DefaultColor, bool CheckBoxSpacing = true, bool UseCheckBox = false, int *pCheckBoxValue = nullptr); + ColorHSLA DoLine_ColorPicker(CButtonContainer *pResetID, float LineSize, float WantedPickerPosition, float LabelSize, float BottomMargin, CUIRect *pMainRect, const char *pText, unsigned int *pColorValue, ColorRGBA DefaultColor, bool CheckBoxSpacing = true, bool UseCheckBox = false, int *pCheckBoxValue = nullptr); void DoLaserPreview(const CUIRect *pRect, ColorHSLA OutlineColor, ColorHSLA InnerColor); int DoValueSelector(void *pID, CUIRect *pRect, const char *pLabel, bool UseScroll, int Current, int Min, int Max, int Step, float Scale, bool IsHex, float Round, ColorRGBA *pColor); int DoButton_GridHeader(const void *pID, const char *pText, int Checked, const CUIRect *pRect); @@ -723,7 +723,7 @@ private: ColorHSLA RenderHSLColorPicker(const CUIRect *pRect, unsigned int *pColor, bool Alpha); ColorHSLA RenderHSLScrollbars(CUIRect *pRect, unsigned int *pColor, bool Alpha = false, bool ClampedLight = false); - int RenderDropDown(int &CurDropDownState, CUIRect *pRect, int CurSelection, const void **pIDs, const char **pStr, int PickNum, const void *pID, float &ScrollVal); + int RenderDropDown(int &CurDropDownState, CUIRect *pRect, int CurSelection, const void **pIDs, const char **pStr, int PickNum, CButtonContainer *pButtonContainer, float &ScrollVal); CServerProcess m_ServerProcess; }; diff --git a/src/game/client/components/menus_browser.cpp b/src/game/client/components/menus_browser.cpp index 95adf11e1..a6dd54ef2 100644 --- a/src/game/client/components/menus_browser.cpp +++ b/src/game/client/components/menus_browser.cpp @@ -803,13 +803,13 @@ void CMenus::RenderServerbrowserFilters(CUIRect View) static int s_ActivePage = 0; - static int s_CountriesButton = 0; + static CButtonContainer s_CountriesButton; if(DoButton_MenuTab(&s_CountriesButton, Localize("Countries"), s_ActivePage == 0, &Button, CUI::CORNER_TL)) { s_ActivePage = 0; } - static int s_TypesButton = 0; + static CButtonContainer s_TypesButton; if(DoButton_MenuTab(&s_TypesButton, Localize("Types"), s_ActivePage == 1, &Button2, CUI::CORNER_TR)) { s_ActivePage = 1; @@ -1006,7 +1006,7 @@ void CMenus::RenderServerbrowserFilters(CUIRect View) } } - static int s_ClearButton = 0; + static CButtonContainer s_ClearButton; if(DoButton_Menu(&s_ClearButton, Localize("Reset filter"), 0, &ResetButton)) { g_Config.m_BrFilterString[0] = 0; @@ -1342,7 +1342,7 @@ void CMenus::RenderServerbrowserFriends(CUIRect View) ServerFriends.HSplitTop(20.0f, &Button, &ServerFriends); if(m_FriendlistSelectedIndex != -1) { - static int s_RemoveButton = 0; + static CButtonContainer s_RemoveButton; if(DoButton_Menu(&s_RemoveButton, Localize("Remove"), 0, &Button)) m_Popup = POPUP_REMOVE_FRIEND; } @@ -1371,7 +1371,7 @@ void CMenus::RenderServerbrowserFriends(CUIRect View) ServerFriends.HSplitTop(3.0f, 0, &ServerFriends); ServerFriends.HSplitTop(20.0f, &Button, &ServerFriends); - static int s_AddButton = 0; + static CButtonContainer s_AddButton; if(DoButton_Menu(&s_AddButton, Localize("Add Friend"), 0, &Button)) { m_pClient->Friends()->AddFriend(s_aName, s_aClan); @@ -1437,15 +1437,15 @@ void CMenus::RenderServerbrowser(CUIRect MainView) ms_ColorTabbarActive = ColorRGBA(0.0f, 0.0f, 0.0f, 0.3f); ms_ColorTabbarInactive = ColorRGBA(0.0f, 0.0f, 0.0f, 0.15f); - static int s_FiltersTab = 0; + static CButtonContainer s_FiltersTab; if(DoButton_MenuTab(&s_FiltersTab, Localize("Filter"), ToolboxPage == 0, &TabButton0, CUI::CORNER_BL, NULL, NULL, NULL, NULL, 4.0f)) ToolboxPage = 0; - static int s_InfoTab = 0; + static CButtonContainer s_InfoTab; if(DoButton_MenuTab(&s_InfoTab, Localize("Info"), ToolboxPage == 1, &TabButton1, 0, NULL, NULL, NULL, NULL, 4.0f)) ToolboxPage = 1; - static int s_FriendsTab = 0; + static CButtonContainer s_FriendsTab; if(DoButton_MenuTab(&s_FriendsTab, Localize("Friends"), ToolboxPage == 2, &TabButton2, CUI::CORNER_BR, NULL, NULL, NULL, NULL, 4.0f)) ToolboxPage = 2; diff --git a/src/game/client/components/menus_demo.cpp b/src/game/client/components/menus_demo.cpp index aca2f5415..9179ce54d 100644 --- a/src/game/client/components/menus_demo.cpp +++ b/src/game/client/components/menus_demo.cpp @@ -34,9 +34,9 @@ int CMenus::DoButton_DemoPlayer(const void *pID, const char *pText, int Checked, return UI()->DoButtonLogic(pID, Checked, pRect); } -int CMenus::DoButton_Sprite(const void *pID, int ImageID, int SpriteID, int Checked, const CUIRect *pRect, int Corners) +int CMenus::DoButton_Sprite(CButtonContainer *pButtonContainer, int ImageID, int SpriteID, int Checked, const CUIRect *pRect, int Corners) { - RenderTools()->DrawUIRect(pRect, ColorRGBA(1.0f, 1.0f, 1.0f, (Checked ? 0.10f : 0.5f) * UI()->ButtonColorMul(pID)), Corners, 5.0f); + RenderTools()->DrawUIRect(pRect, ColorRGBA(1.0f, 1.0f, 1.0f, (Checked ? 0.10f : 0.5f) * UI()->ButtonColorMul(pButtonContainer)), Corners, 5.0f); Graphics()->TextureSet(g_pData->m_aImages[ImageID].m_Id); Graphics()->QuadsBegin(); if(!Checked) @@ -46,7 +46,7 @@ int CMenus::DoButton_Sprite(const void *pID, int ImageID, int SpriteID, int Chec Graphics()->QuadsDrawTL(&QuadItem, 1); Graphics()->QuadsEnd(); - return UI()->DoButtonLogic(pID, Checked, pRect); + return UI()->DoButtonLogic(pButtonContainer, Checked, pRect); } bool CMenus::DemoFilterChat(const void *pData, int Size, void *pUser) @@ -110,11 +110,11 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) static int s_RemoveChat = 0; - static int s_ButtonAbort = 0; + static CButtonContainer s_ButtonAbort; if(DoButton_Menu(&s_ButtonAbort, Localize("Abort"), 0, &Abort) || m_EscapePressed) m_DemoPlayerState = DEMOPLAYER_NONE; - static int s_ButtonOk = 0; + static CButtonContainer s_ButtonOk; if(DoButton_Menu(&s_ButtonOk, Localize("Ok"), 0, &Ok) || m_EnterPressed) { if(str_comp(m_vDemos[m_DemolistSelectedIndex].m_aFilename, m_aCurrentDemoFile) == 0) @@ -392,7 +392,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) // combined play and pause button ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar); - static int s_PlayPauseButton = 0; + static CButtonContainer s_PlayPauseButton; if(DoButton_Sprite(&s_PlayPauseButton, IMAGE_DEMOBUTTONS, pInfo->m_Paused ? SPRITE_DEMOBUTTON_PLAY : SPRITE_DEMOBUTTON_PAUSE, false, &Button, CUI::CORNER_ALL)) { if(pInfo->m_Paused) @@ -409,7 +409,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) ButtonBar.VSplitLeft(Margins, 0, &ButtonBar); ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar); - static int s_ResetButton = 0; + static CButtonContainer s_ResetButton; if(DoButton_Sprite(&s_ResetButton, IMAGE_DEMOBUTTONS, SPRITE_DEMOBUTTON_STOP, false, &Button, CUI::CORNER_ALL)) { DemoPlayer()->Pause(); @@ -419,14 +419,14 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) // slowdown ButtonBar.VSplitLeft(Margins, 0, &ButtonBar); ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar); - static int s_SlowDownButton = 0; + static CButtonContainer s_SlowDownButton; if(DoButton_Sprite(&s_SlowDownButton, IMAGE_DEMOBUTTONS, SPRITE_DEMOBUTTON_SLOWER, 0, &Button, CUI::CORNER_ALL)) DecreaseDemoSpeed = true; // fastforward ButtonBar.VSplitLeft(Margins, 0, &ButtonBar); ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar); - static int s_FastForwardButton = 0; + static CButtonContainer s_FastForwardButton; if(DoButton_Sprite(&s_FastForwardButton, IMAGE_DEMOBUTTONS, SPRITE_DEMOBUTTON_FASTER, 0, &Button, CUI::CORNER_ALL)) IncreaseDemoSpeed = true; @@ -439,21 +439,21 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) // slice begin button ButtonBar.VSplitLeft(Margins * 10, 0, &ButtonBar); ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar); - static int s_SliceBeginButton = 0; + static CButtonContainer s_SliceBeginButton; if(DoButton_Sprite(&s_SliceBeginButton, IMAGE_DEMOBUTTONS2, SPRITE_DEMOBUTTON_SLICE_BEGIN, 0, &Button, CUI::CORNER_ALL)) Client()->DemoSliceBegin(); // slice end button ButtonBar.VSplitLeft(Margins, 0, &ButtonBar); ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar); - static int s_SliceEndButton = 0; + static CButtonContainer s_SliceEndButton; if(DoButton_Sprite(&s_SliceEndButton, IMAGE_DEMOBUTTONS2, SPRITE_DEMOBUTTON_SLICE_END, 0, &Button, CUI::CORNER_ALL)) Client()->DemoSliceEnd(); // slice save button ButtonBar.VSplitLeft(Margins, 0, &ButtonBar); ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar); - static int s_SliceSaveButton = 0; + static CButtonContainer s_SliceSaveButton; if(DoButton_Sprite(&s_SliceSaveButton, IMAGE_FILEICONS, SPRITE_FILE_DEMO2, 0, &Button, CUI::CORNER_ALL)) { str_copy(m_aCurrentDemoFile, m_vDemos[m_DemolistSelectedIndex].m_aFilename); @@ -473,7 +473,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) // toggle keyboard shortcuts button ButtonBar.VSplitRight(Margins * 3, &ButtonBar, 0); ButtonBar.VSplitRight(ButtonbarHeight, &ButtonBar, &Button); - static int s_KeyboardShortcutsButton = 0; + static CButtonContainer s_KeyboardShortcutsButton; int Sprite = g_Config.m_ClDemoKeyboardShortcuts ? SPRITE_DEMOBUTTON_SHORTCUTS_ENABLED : SPRITE_DEMOBUTTON_SHORTCUTS_DISABLED; if(DoButton_Sprite(&s_KeyboardShortcutsButton, IMAGE_DEMOBUTTONS2, Sprite, 0, &Button, CUI::CORNER_ALL)) { @@ -1203,7 +1203,7 @@ void CMenus::RenderDemoList(CUIRect MainView) Activated = true; } - static int s_RefreshButton = 0; + static CButtonContainer s_RefreshButton; if(DoButton_Menu(&s_RefreshButton, Localize("Refresh"), 0, &RefreshRect) || Input()->KeyPress(KEY_F5) || (Input()->KeyPress(KEY_R) && Input()->ModifierIsPressed())) { DemolistPopulate(); @@ -1217,7 +1217,7 @@ void CMenus::RenderDemoList(CUIRect MainView) FetchAllHeaders(); } - static int s_PlayButton = 0; + static CButtonContainer s_PlayButton; if(DoButton_Menu(&s_PlayButton, m_DemolistSelectedIsDir ? Localize("Open") : Localize("Play", "Demo browser"), 0, &PlayRect) || Activated || (Input()->KeyPress(KEY_P) && m_pClient->m_GameConsole.IsClosed() && m_DemoPlayerState == DEMOPLAYER_NONE)) { if(m_DemolistSelectedIndex >= 0) @@ -1252,7 +1252,7 @@ void CMenus::RenderDemoList(CUIRect MainView) } } - static int s_DirectoryButtonID = 0; + static CButtonContainer s_DirectoryButtonID; if(DoButton_Menu(&s_DirectoryButtonID, Localize("Demos directory"), 0, &DirectoryButton)) { char aBuf[IO_MAX_PATH_LENGTH]; @@ -1266,7 +1266,7 @@ void CMenus::RenderDemoList(CUIRect MainView) if(!m_DemolistSelectedIsDir) { - static int s_DeleteButton = 0; + static CButtonContainer s_DeleteButton; if(DoButton_Menu(&s_DeleteButton, Localize("Delete"), 0, &DeleteRect) || m_DeletePressed || (Input()->KeyPress(KEY_D) && m_pClient->m_GameConsole.IsClosed())) { if(m_DemolistSelectedIndex >= 0) @@ -1277,7 +1277,7 @@ void CMenus::RenderDemoList(CUIRect MainView) } } - static int s_RenameButton = 0; + static CButtonContainer s_RenameButton; if(DoButton_Menu(&s_RenameButton, Localize("Rename"), 0, &RenameRect)) { if(m_DemolistSelectedIndex >= 0) @@ -1290,7 +1290,7 @@ void CMenus::RenderDemoList(CUIRect MainView) } #if defined(CONF_VIDEORECORDER) - static int s_RenderButton = 0; + static CButtonContainer s_RenderButton; if(DoButton_Menu(&s_RenderButton, Localize("Render"), 0, &RenderRect) || (Input()->KeyPress(KEY_R) && m_pClient->m_GameConsole.IsClosed())) { if(m_DemolistSelectedIndex >= 0) diff --git a/src/game/client/components/menus_ingame.cpp b/src/game/client/components/menus_ingame.cpp index ddb353d07..5b15fd562 100644 --- a/src/game/client/components/menus_ingame.cpp +++ b/src/game/client/components/menus_ingame.cpp @@ -50,7 +50,7 @@ void CMenus::RenderGame(CUIRect MainView) ButtonBar.VSplitRight(120.0f, &ButtonBar, &Button); - static int s_DisconnectButton = 0; + static CButtonContainer s_DisconnectButton; if(DoButton_Menu(&s_DisconnectButton, Localize("Disconnect"), 0, &Button)) { if(Client()->GetCurrentRaceTime() / 60 >= g_Config.m_ClConfirmDisconnectTime && g_Config.m_ClConfirmDisconnectTime >= 0) @@ -67,7 +67,7 @@ void CMenus::RenderGame(CUIRect MainView) ButtonBar.VSplitRight(170.0f, &ButtonBar, &Button); bool DummyConnecting = Client()->DummyConnecting(); - static int s_DummyButton = 0; + static CButtonContainer s_DummyButton; if(!Client()->DummyAllowed()) { DoButton_Menu(&s_DummyButton, Localize("Connect Dummy"), 1, &Button, nullptr, CUI::CORNER_ALL, 5.0f, 0.0f, vec4(1.0f, 0.5f, 0.5f, 0.75f), vec4(1, 0.5f, 0.5f, 0.5f)); @@ -99,7 +99,7 @@ void CMenus::RenderGame(CUIRect MainView) ButtonBar.VSplitRight(5.0f, &ButtonBar, 0); ButtonBar.VSplitRight(140.0f, &ButtonBar, &Button); - static int s_DemoButton = 0; + static CButtonContainer s_DemoButton; bool Recording = DemoRecorder(RECORDER_MANUAL)->IsRecording(); if(DoButton_Menu(&s_DemoButton, Recording ? Localize("Stop record") : Localize("Record demo"), 0, &Button)) { @@ -109,9 +109,9 @@ void CMenus::RenderGame(CUIRect MainView) Client()->DemoRecorder_Stop(RECORDER_MANUAL); } - static int s_SpectateButton = 0; - static int s_JoinRedButton = 0; - static int s_JoinBlueButton = 0; + static CButtonContainer s_SpectateButton; + static CButtonContainer s_JoinRedButton; + static CButtonContainer s_JoinBlueButton; bool Paused = false; bool Spec = false; @@ -180,7 +180,7 @@ void CMenus::RenderGame(CUIRect MainView) ButtonBar.VSplitLeft(5.0f, 0, &ButtonBar); ButtonBar.VSplitLeft(65.0f, &Button, &ButtonBar); - static int s_KillButton = 0; + static CButtonContainer s_KillButton; if(DoButton_Menu(&s_KillButton, Localize("Kill"), 0, &Button)) { m_pClient->SendKill(-1); @@ -196,7 +196,7 @@ void CMenus::RenderGame(CUIRect MainView) ButtonBar.VSplitLeft(5.0f, 0, &ButtonBar); ButtonBar.VSplitLeft((!Paused && !Spec) ? 65.0f : 120.0f, &Button, &ButtonBar); - static int s_PauseButton = 0; + static CButtonContainer s_PauseButton; if(DoButton_Menu(&s_PauseButton, (!Paused && !Spec) ? Localize("Pause") : Localize("Join game"), 0, &Button)) { m_pClient->Console()->ExecuteLine("say /pause"); @@ -576,16 +576,16 @@ void CMenus::RenderServerControl(CUIRect MainView) // tab bar { TabBar.VSplitLeft(TabBar.w / 3, &Button, &TabBar); - static int s_Button0 = 0; + static CButtonContainer s_Button0; if(DoButton_MenuTab(&s_Button0, Localize("Change settings"), s_ControlPage == 0, &Button, 0)) s_ControlPage = 0; TabBar.VSplitMid(&Button, &TabBar); - static int s_Button1 = 0; + static CButtonContainer s_Button1; if(DoButton_MenuTab(&s_Button1, Localize("Kick player"), s_ControlPage == 1, &Button, 0)) s_ControlPage = 1; - static int s_Button2 = 0; + static CButtonContainer s_Button2; if(DoButton_MenuTab(&s_Button2, Localize("Move player to spectators"), s_ControlPage == 2, &TabBar, 0)) s_ControlPage = 2; } @@ -638,7 +638,7 @@ void CMenus::RenderServerControl(CUIRect MainView) Bottom.VSplitRight(120.0f, &Bottom, &Button); - static int s_CallVoteButton = 0; + static CButtonContainer s_CallVoteButton; if(DoButton_Menu(&s_CallVoteButton, Localize("Call vote"), 0, &Button) || Call) { if(s_ControlPage == 0) @@ -694,7 +694,7 @@ void CMenus::RenderServerControl(CUIRect MainView) Bottom.VSplitLeft(5.0f, 0, &Bottom); Bottom.VSplitLeft(120.0f, &Button, &Bottom); - static int s_ForceVoteButton = 0; + static CButtonContainer s_ForceVoteButton; if(DoButton_Menu(&s_ForceVoteButton, Localize("Force vote"), 0, &Button)) { if(s_ControlPage == 0) @@ -725,7 +725,7 @@ void CMenus::RenderServerControl(CUIRect MainView) // remove vote Bottom.VSplitRight(10.0f, &Bottom, 0); Bottom.VSplitRight(120.0f, 0, &Button); - static int s_RemoveVoteButton = 0; + static CButtonContainer s_RemoveVoteButton; if(DoButton_Menu(&s_RemoveVoteButton, Localize("Remove"), 0, &Button)) m_pClient->m_Voting.RemovevoteOption(m_CallvoteSelectedOption); @@ -743,7 +743,7 @@ void CMenus::RenderServerControl(CUIRect MainView) RconExtension.HSplitTop(20.0f, &Bottom, &RconExtension); Bottom.VSplitRight(10.0f, &Bottom, 0); Bottom.VSplitRight(120.0f, &Bottom, &Button); - static int s_AddVoteButton = 0; + static CButtonContainer s_AddVoteButton; if(DoButton_Menu(&s_AddVoteButton, Localize("Add"), 0, &Button)) if(s_aVoteDescription[0] != 0 && s_aVoteCommand[0] != 0) m_pClient->m_Voting.AddvoteOption(s_aVoteDescription, s_aVoteCommand); @@ -775,7 +775,7 @@ void CMenus::RenderInGameNetwork(CUIRect MainView) Box.HSplitTop(24.0f, &Box, &MainView); Box.VSplitLeft(100.0f, &Button, &Box); - static int s_InternetButton = 0; + static CButtonContainer s_InternetButton; if(DoButton_MenuTab(&s_InternetButton, Localize("Internet"), Page == PAGE_INTERNET, &Button, 0)) { if(Page != PAGE_INTERNET) @@ -784,7 +784,7 @@ void CMenus::RenderInGameNetwork(CUIRect MainView) } Box.VSplitLeft(80.0f, &Button, &Box); - static int s_LanButton = 0; + static CButtonContainer s_LanButton; if(DoButton_MenuTab(&s_LanButton, Localize("LAN"), Page == PAGE_LAN, &Button, 0)) { if(Page != PAGE_LAN) @@ -793,7 +793,7 @@ void CMenus::RenderInGameNetwork(CUIRect MainView) } Box.VSplitLeft(110.0f, &Button, &Box); - static int s_FavoritesButton = 0; + static CButtonContainer s_FavoritesButton; if(DoButton_MenuTab(&s_FavoritesButton, Localize("Favorites"), Page == PAGE_FAVORITES, &Button, 0)) { if(Page != PAGE_FAVORITES) @@ -802,7 +802,7 @@ void CMenus::RenderInGameNetwork(CUIRect MainView) } Box.VSplitLeft(110.0f, &Button, &Box); - static int s_DDNetButton = 0; + static CButtonContainer s_DDNetButton; if(DoButton_MenuTab(&s_DDNetButton, "DDNet", Page == PAGE_DDNET, &Button, 0) || Page < PAGE_INTERNET || Page > PAGE_KOG) { if(Page != PAGE_DDNET) @@ -814,7 +814,7 @@ void CMenus::RenderInGameNetwork(CUIRect MainView) } Box.VSplitLeft(110.0f, &Button, &Box); - static int s_KoGButton = 0; + static CButtonContainer s_KoGButton; if(DoButton_MenuTab(&s_KoGButton, "KoG", Page == PAGE_KOG, &Button, CUI::CORNER_BR)) { if(Page != PAGE_KOG) @@ -1086,7 +1086,7 @@ void CMenus::RenderGhost(CUIRect MainView) CUIRect Button; Status.VSplitLeft(120.0f, &Button, &Status); - static int s_ReloadButton = 0; + static CButtonContainer s_ReloadButton; if(DoButton_Menu(&s_ReloadButton, Localize("Reload"), 0, &Button) || Input()->KeyPress(KEY_F5)) { m_pClient->m_Ghost.UnloadAll(); @@ -1104,7 +1104,7 @@ void CMenus::RenderGhost(CUIRect MainView) { Status.VSplitRight(120.0f, &Status, &Button); - static int s_GhostButton = 0; + static CButtonContainer s_GhostButton; const char *pText = pGhost->Active() ? Localize("Deactivate") : Localize("Activate"); if(DoButton_Menu(&s_GhostButton, pText, 0, &Button) || (DoubleClicked && Input()->MouseDoubleClick())) { @@ -1122,7 +1122,7 @@ void CMenus::RenderGhost(CUIRect MainView) Status.VSplitRight(120.0f, &Status, &Button); - static int s_DeleteButton = 0; + static CButtonContainer s_DeleteButton; if(DoButton_Menu(&s_DeleteButton, Localize("Delete"), 0, &Button)) { if(pGhost->Active()) @@ -1135,7 +1135,7 @@ void CMenus::RenderGhost(CUIRect MainView) bool Recording = m_pClient->m_Ghost.GhostRecorder()->IsRecording(); if(!pGhost->HasFile() && !Recording && pGhost->Active()) { - static int s_SaveButton = 0; + static CButtonContainer s_SaveButton; Status.VSplitRight(120.0f, &Status, &Button); if(DoButton_Menu(&s_SaveButton, Localize("Save"), 0, &Button)) m_pClient->m_Ghost.SaveGhost(pGhost); diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index d961eb428..e6423e3c5 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -195,7 +195,7 @@ void CMenus::RenderSettingsGeneral(CUIRect MainView) Left.HSplitBottom(25.0f, &Left, &SettingsButton); SettingsButton.HSplitTop(5.0f, 0, &SettingsButton); - static int s_SettingsButtonID = 0; + static CButtonContainer s_SettingsButtonID; if(DoButton_Menu(&s_SettingsButtonID, Localize("Settings file"), 0, &SettingsButton)) { Storage()->GetCompletePath(IStorage::TYPE_SAVE, CONFIG_FILE, aBuf, sizeof(aBuf)); @@ -210,7 +210,7 @@ void CMenus::RenderSettingsGeneral(CUIRect MainView) Left.HSplitBottom(25.0f, &Left, &ConfigButton); ConfigButton.HSplitTop(5.0f, 0, &ConfigButton); - static int s_ConfigButtonID = 0; + static CButtonContainer s_ConfigButtonID; if(DoButton_Menu(&s_ConfigButtonID, Localize("Config directory"), 0, &ConfigButton)) { Storage()->GetCompletePath(IStorage::TYPE_SAVE, "", aBuf, sizeof(aBuf)); @@ -226,7 +226,7 @@ void CMenus::RenderSettingsGeneral(CUIRect MainView) RenderThemeSelection(Left); DirectoryButton.HSplitTop(5.0f, 0, &DirectoryButton); - static int s_ThemesButtonID = 0; + static CButtonContainer s_ThemesButtonID; if(DoButton_Menu(&s_ThemesButtonID, Localize("Themes directory"), 0, &DirectoryButton)) { Storage()->GetCompletePath(IStorage::TYPE_SAVE, "themes", aBuf, sizeof(aBuf)); @@ -511,7 +511,8 @@ void CMenus::RenderSettingsTee(CUIRect MainView) { SkinPrefix.HSplitTop(20.0f, &Button, &SkinPrefix); Button.HMargin(2.0f, &Button); - if(DoButton_Menu(&pPrefix, pPrefix, 0, &Button)) + static CButtonContainer s_PrefixButton; + if(DoButton_Menu(&s_PrefixButton, pPrefix, 0, &Button)) { str_copy(g_Config.m_ClSkinPrefix, pPrefix); } @@ -550,7 +551,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView) EyesLabel.HSplitTop(50.0f, &EyesLabel, &Eyes); float Highlight = 0.0f; - static int s_aEyeButtons[6]; + static CButtonContainer s_aEyeButtons[6]; static int s_aEyesToolTip[6]; for(int CurrentEyeEmote = 0; CurrentEyeEmote < 6; CurrentEyeEmote++) { @@ -745,7 +746,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView) SkinDB.VSplitLeft(150.0f, &SkinDB, &DirectoryButton); SkinDB.HSplitTop(5.0f, 0, &SkinDB); - static int s_SkinDBDirID = 0; + static CButtonContainer s_SkinDBDirID; if(DoButton_Menu(&s_SkinDBDirID, Localize("Skin Database"), 0, &SkinDB)) { if(!open_link("https://ddnet.tw/skins/")) @@ -758,7 +759,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView) DirectoryButton.VSplitRight(175.0f, 0, &DirectoryButton); DirectoryButton.VSplitRight(25.0f, &DirectoryButton, &RefreshButton); DirectoryButton.VSplitRight(10.0f, &DirectoryButton, 0); - static int s_DirectoryButtonID = 0; + static CButtonContainer s_DirectoryButtonID; if(DoButton_Menu(&s_DirectoryButtonID, Localize("Skins directory"), 0, &DirectoryButton)) { Storage()->GetCompletePath(IStorage::TYPE_SAVE, "skins", aBuf, sizeof(aBuf)); @@ -771,7 +772,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView) TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT)); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE); - static int s_SkinRefreshButtonID = 0; + static CButtonContainer s_SkinRefreshButtonID; if(DoButton_Menu(&s_SkinRefreshButtonID, "\xEF\x80\x9E", 0, &RefreshButton, nullptr, CUI::CORNER_ALL, 5, 0, vec4(1.0f, 1.0f, 1.0f, 0.75f), vec4(1, 1, 1, 0.5f), 0)) { // reset render flags for possible loading screen @@ -939,7 +940,7 @@ float CMenus::RenderSettingsControlsJoystick(CUIRect View) { View.HSplitTop(Spacing, 0, &View); View.HSplitTop(ButtonHeight, &Button, &View); - static int s_ButtonJoystickId; + static CButtonContainer s_ButtonJoystickId; char aBuf[96]; str_format(aBuf, sizeof(aBuf), Localize("Controller %d: %s"), Input()->GetActiveJoystick()->GetIndex(), Input()->GetActiveJoystick()->GetName()); if(DoButton_Menu(&s_ButtonJoystickId, aBuf, 0, &Button)) @@ -1187,8 +1188,8 @@ void CMenus::RenderSettingsControls(CUIRect MainView) ResetButton.HMargin(10.0f, &ResetButton); ResetButton.VMargin(30.0f, &ResetButton); ResetButton.HSplitTop(20.0f, &ResetButton, 0); - static int s_DefaultButton = 0; - if(DoButton_Menu((void *)&s_DefaultButton, Localize("Reset to defaults"), 0, &ResetButton)) + static CButtonContainer s_DefaultButton; + if(DoButton_Menu(&s_DefaultButton, Localize("Reset to defaults"), 0, &ResetButton)) { m_pClient->m_Binds.SetDefaults(); @@ -1261,14 +1262,14 @@ void CMenus::RenderSettingsControls(CUIRect MainView) UiDoListboxEnd(&s_ScrollValue, 0); } -int CMenus::RenderDropDown(int &CurDropDownState, CUIRect *pRect, int CurSelection, const void **pIDs, const char **pStr, int PickNum, const void *pID, float &ScrollVal) +int CMenus::RenderDropDown(int &CurDropDownState, CUIRect *pRect, int CurSelection, const void **pIDs, const char **pStr, int PickNum, CButtonContainer *pButtonContainer, float &ScrollVal) { if(CurDropDownState != 0) { CUIRect ListRect; pRect->HSplitTop(24.0f * PickNum, &ListRect, pRect); char aBuf[1024]; - UiDoListboxStart(&pID, &ListRect, 24.0f, "", aBuf, PickNum, 1, CurSelection, ScrollVal); + UiDoListboxStart(&pButtonContainer, &ListRect, 24.0f, "", aBuf, PickNum, 1, CurSelection, ScrollVal); for(int i = 0; i < PickNum; ++i) { CListboxItem Item = UiDoListboxNextItem(pIDs[i], CurSelection == i); @@ -1292,7 +1293,7 @@ int CMenus::RenderDropDown(int &CurDropDownState, CUIRect *pRect, int CurSelecti { CUIRect Button; pRect->HSplitTop(24.0f, &Button, pRect); - if(DoButton_MenuTab(pID, CurSelection > -1 ? pStr[CurSelection] : "", 0, &Button, CUI::CORNER_ALL, NULL, NULL, NULL, NULL, 4.0f)) + if(DoButton_MenuTab(pButtonContainer, CurSelection > -1 ? pStr[CurSelection] : "", 0, &Button, CUI::CORNER_ALL, NULL, NULL, NULL, NULL, 4.0f)) CurDropDownState = 1; CUIRect DropDownIcon = Button; @@ -1407,7 +1408,8 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView) OldSelected = (g_Config.m_GfxFullscreen ? (g_Config.m_GfxFullscreen == 1 ? 4 : (g_Config.m_GfxFullscreen == 2 ? 3 : 2)) : (g_Config.m_GfxBorderless ? 1 : 0)); - const int NewWindowMode = RenderDropDown(s_WindowModeDropDownState, &MainView, OldSelected, apWindowModeIDs, apWindowModes, s_NumWindowMode, &s_NumWindowMode, s_ScrollValueDrop); + static CButtonContainer s_WindowButton; + const int NewWindowMode = RenderDropDown(s_WindowModeDropDownState, &MainView, OldSelected, apWindowModeIDs, apWindowModes, s_NumWindowMode, &s_WindowButton, s_ScrollValueDrop); if(OldSelected != NewWindowMode) { if(NewWindowMode == 0) @@ -1636,7 +1638,8 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView) static int s_BackendCount = 0; s_BackendCount = BackendCount; - const int NewBackend = RenderDropDown(s_BackendDropDownState, &MainView, OldSelectedBackend, vBackendIDPtrs.data(), vBackendIDNamesCStr.data(), s_BackendCount, &s_BackendCount, s_ScrollValueDropBackend); + static CButtonContainer s_BackendButton; + const int NewBackend = RenderDropDown(s_BackendDropDownState, &MainView, OldSelectedBackend, vBackendIDPtrs.data(), vBackendIDNamesCStr.data(), s_BackendCount, &s_BackendButton, s_ScrollValueDropBackend); if(OldSelectedBackend != NewBackend) { str_copy(g_Config.m_GfxBackend, vBackendInfos[NewBackend].m_pBackendName); @@ -1702,7 +1705,8 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView) if(s_OldSelectedGPU == -1) s_OldSelectedGPU = OldSelectedGPU; - const int NewGPU = RenderDropDown(s_GPUDropDownState, &MainView, OldSelectedGPU, vGPUIDPtrs.data(), vGPUIDNames.data(), s_GPUCount, &s_GPUCount, s_ScrollValueDropGPU); + static CButtonContainer s_GpuButton; + const int NewGPU = RenderDropDown(s_GPUDropDownState, &MainView, OldSelectedGPU, vGPUIDPtrs.data(), vGPUIDNames.data(), s_GPUCount, &s_GpuButton, s_ScrollValueDropGPU); if(OldSelectedGPU != NewGPU) { if(NewGPU == 0) @@ -1993,6 +1997,7 @@ void CMenus::RenderSettings(CUIRect MainView) Localize("Sound"), Localize("DDNet"), Localize("Assets")}; + static CButtonContainer s_aTabButtons[sizeof(apTabs)]; int NumTabs = (int)std::size(apTabs); int PreviousPage = g_Config.m_UiSettingsPage; @@ -2001,7 +2006,7 @@ void CMenus::RenderSettings(CUIRect MainView) { TabBar.HSplitTop(10, &Button, &TabBar); TabBar.HSplitTop(26, &Button, &TabBar); - if(DoButton_MenuTab(apTabs[i], apTabs[i], g_Config.m_UiSettingsPage == i, &Button, CUI::CORNER_R, &m_aAnimatorsSettingsTab[i])) + if(DoButton_MenuTab(&s_aTabButtons[i], apTabs[i], g_Config.m_UiSettingsPage == i, &Button, CUI::CORNER_R, &m_aAnimatorsSettingsTab[i])) g_Config.m_UiSettingsPage = i; } @@ -2479,19 +2484,19 @@ void CMenus::RenderSettingsAppearance(CUIRect MainView) Page4Tab.VSplitLeft(TabsW / NUMBER_OF_APPEARANCE_TABS, &Page4Tab, &Page5Tab); Page5Tab.VSplitLeft(TabsW / NUMBER_OF_APPEARANCE_TABS, &Page5Tab, &Page6Tab); - static int s_aPageTabs[NUMBER_OF_APPEARANCE_TABS] = {}; + static CButtonContainer s_aPageTabs[NUMBER_OF_APPEARANCE_TABS] = {}; - if(DoButton_MenuTab((void *)&s_aPageTabs[APPEARANCE_TAB_HUD], Localize("HUD"), s_CurTab == APPEARANCE_TAB_HUD, &Page1Tab, CUI::CORNER_L, NULL, NULL, NULL, NULL, 4)) + if(DoButton_MenuTab(&s_aPageTabs[APPEARANCE_TAB_HUD], Localize("HUD"), s_CurTab == APPEARANCE_TAB_HUD, &Page1Tab, CUI::CORNER_L, NULL, NULL, NULL, NULL, 4)) s_CurTab = APPEARANCE_TAB_HUD; - if(DoButton_MenuTab((void *)&s_aPageTabs[APPEARANCE_TAB_CHAT], Localize("Chat"), s_CurTab == APPEARANCE_TAB_CHAT, &Page2Tab, 0, NULL, NULL, NULL, NULL, 4)) + if(DoButton_MenuTab(&s_aPageTabs[APPEARANCE_TAB_CHAT], Localize("Chat"), s_CurTab == APPEARANCE_TAB_CHAT, &Page2Tab, 0, NULL, NULL, NULL, NULL, 4)) s_CurTab = APPEARANCE_TAB_CHAT; - if(DoButton_MenuTab((void *)&s_aPageTabs[APPEARANCE_TAB_NAME_PLATE], Localize("Name Plate"), s_CurTab == APPEARANCE_TAB_NAME_PLATE, &Page3Tab, 0, NULL, NULL, NULL, NULL, 4)) + if(DoButton_MenuTab(&s_aPageTabs[APPEARANCE_TAB_NAME_PLATE], Localize("Name Plate"), s_CurTab == APPEARANCE_TAB_NAME_PLATE, &Page3Tab, 0, NULL, NULL, NULL, NULL, 4)) s_CurTab = APPEARANCE_TAB_NAME_PLATE; - if(DoButton_MenuTab((void *)&s_aPageTabs[APPEARANCE_TAB_HOOK_COLLISION], Localize("Hook Collisions"), s_CurTab == APPEARANCE_TAB_HOOK_COLLISION, &Page4Tab, 0, NULL, NULL, NULL, NULL, 4)) + if(DoButton_MenuTab(&s_aPageTabs[APPEARANCE_TAB_HOOK_COLLISION], Localize("Hook Collisions"), s_CurTab == APPEARANCE_TAB_HOOK_COLLISION, &Page4Tab, 0, NULL, NULL, NULL, NULL, 4)) s_CurTab = APPEARANCE_TAB_HOOK_COLLISION; - if(DoButton_MenuTab((void *)&s_aPageTabs[APPEARANCE_TAB_KILL_MESSAGES], Localize("Kill Messages"), s_CurTab == APPEARANCE_TAB_KILL_MESSAGES, &Page5Tab, 0, NULL, NULL, NULL, NULL, 4)) + if(DoButton_MenuTab(&s_aPageTabs[APPEARANCE_TAB_KILL_MESSAGES], Localize("Kill Messages"), s_CurTab == APPEARANCE_TAB_KILL_MESSAGES, &Page5Tab, 0, NULL, NULL, NULL, NULL, 4)) s_CurTab = APPEARANCE_TAB_KILL_MESSAGES; - if(DoButton_MenuTab((void *)&s_aPageTabs[APPEARANCE_TAB_LASER], Localize("Laser"), s_CurTab == APPEARANCE_TAB_LASER, &Page6Tab, CUI::CORNER_R, NULL, NULL, NULL, NULL, 4)) + if(DoButton_MenuTab(&s_aPageTabs[APPEARANCE_TAB_LASER], Localize("Laser"), s_CurTab == APPEARANCE_TAB_LASER, &Page6Tab, CUI::CORNER_R, NULL, NULL, NULL, NULL, 4)) s_CurTab = APPEARANCE_TAB_LASER; MainView.HSplitTop(10.0f, 0x0, &MainView); // Margin @@ -2620,7 +2625,7 @@ void CMenus::RenderSettingsAppearance(CUIRect MainView) Section.Margin(SectionMargin, &Section); int i = 0; - static int s_aResetIDs[24]; + static CButtonContainer s_aResetIDs[24]; DoLine_ColorPicker(&s_aResetIDs[i++], ColorPickerLineSize, LeftViewColorPickerPosition, ColorPickerLabelSize, ColorPickerLineSpacing, &Section, Localize("System message"), &g_Config.m_ClMessageSystemColor, ColorRGBA(1.0f, 1.0f, 0.5f), true, true, &g_Config.m_ClShowChatSystem); DoLine_ColorPicker(&s_aResetIDs[i++], ColorPickerLineSize, LeftViewColorPickerPosition, ColorPickerLabelSize, ColorPickerLineSpacing, &Section, Localize("Highlighted message"), &g_Config.m_ClMessageHighlightColor, ColorRGBA(1.0f, 0.5f, 0.5f)); @@ -2895,7 +2900,7 @@ void CMenus::RenderSettingsAppearance(CUIRect MainView) g_Config.m_ClHookCollAlpha = (int)(UIEx()->DoScrollbarH(&g_Config.m_ClHookCollAlpha, &Button, g_Config.m_ClHookCollAlpha / 100.0f) * 100.0f); } - static int HookCollNoCollResetID, HookCollHookableCollResetID, HookCollTeeCollResetID, HookCollToolTop; + static CButtonContainer HookCollNoCollResetID, HookCollHookableCollResetID, HookCollTeeCollResetID, HookCollToolTop; Section.HSplitTop(LineSize, &Label, &Section); UI()->DoLabel(&Label, Localize("Colors of the hook collision line, in case of a possible collision with:"), 13.0f, TEXTALIGN_LEFT); @@ -2916,7 +2921,7 @@ void CMenus::RenderSettingsAppearance(CUIRect MainView) LeftView.HSplitTop(SectionTotalMargin + 2 * ColorPickerLineSize, &Section, &LeftView); Section.Margin(SectionMargin, &Section); - static int KillMessageNormalColorID, KillMessageHighlightColorID; + static CButtonContainer KillMessageNormalColorID, KillMessageHighlightColorID; DoLine_ColorPicker(&KillMessageNormalColorID, ColorPickerLineSize, LeftViewColorPickerPosition, ColorPickerLabelSize, ColorPickerLineSpacing, &Section, Localize("Normal Color"), &g_Config.m_ClKillMessageNormalColor, ColorRGBA(1.0f, 1.0f, 1.0f), false); DoLine_ColorPicker(&KillMessageHighlightColorID, ColorPickerLineSize, LeftViewColorPickerPosition, ColorPickerLabelSize, ColorPickerLineSpacing, &Section, Localize("Highlight Color"), &g_Config.m_ClKillMessageHighlightColor, ColorRGBA(1.0f, 1.0f, 1.0f), false); @@ -2933,7 +2938,7 @@ void CMenus::RenderSettingsAppearance(CUIRect MainView) LeftView.HSplitTop(SectionTotalMargin + 2 * ColorPickerLineSize, &Section, &LeftView); Section.Margin(SectionMargin, &Section); - static int LaserOutResetID, LaserInResetID; + static CButtonContainer LaserOutResetID, LaserInResetID; ColorHSLA LaserOutlineColor = DoLine_ColorPicker(&LaserOutResetID, ColorPickerLineSize, LeftViewColorPickerPosition, ColorPickerLabelSize, ColorPickerLineSpacing, &Section, Localize("Laser Outline Color"), &g_Config.m_ClLaserOutlineColor, ColorRGBA(0.074402f, 0.074402f, 0.247166f, 1.0f), false); ColorHSLA LaserInnerColor = DoLine_ColorPicker(&LaserInResetID, ColorPickerLineSize, LeftViewColorPickerPosition, ColorPickerLabelSize, ColorPickerLineSpacing, &Section, Localize("Laser Inner Color"), &g_Config.m_ClLaserInnerColor, ColorRGBA(0.498039f, 0.498039f, 1.0f, 1.0f), false); @@ -3148,8 +3153,8 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView) UI()->DoLabel(&TempLabel, Localize("Miscellaneous"), 20.0f, TEXTALIGN_LEFT); - static int ResetID1 = 0; - static int ResetID2 = 0; + static CButtonContainer ResetID1; + static CButtonContainer ResetID2; ColorRGBA GreyDefault(0.5f, 0.5f, 0.5f, 1); DoLine_ColorPicker(&ResetID2, 25.0f, 194.0f, 13.0f, 5.0f, &Left, Localize("Entities Background color"), &g_Config.m_ClBackgroundEntitiesColor, GreyDefault, false); @@ -3183,7 +3188,7 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView) if(DoButton_CheckBox(&g_Config.m_ClHttpMapDownload, Localize("Try fast HTTP map download first"), g_Config.m_ClHttpMapDownload, &Button)) g_Config.m_ClHttpMapDownload ^= 1; - static int s_ButtonTimeout = 0; + static CButtonContainer s_ButtonTimeout; Right.HSplitTop(10.0f, 0x0, &Right); Right.HSplitTop(20.0f, &Button, &Right); if(DoButton_Menu(&s_ButtonTimeout, Localize("New random timeout code"), 0, &Button)) @@ -3216,7 +3221,7 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView) str_format(aBuf, sizeof(aBuf), Localize("DDNet %s is available:"), Client()->LatestVersion()); Label.VSplitLeft(TextRender()->TextWidth(0, 14.0f, aBuf, -1, -1.0f) + 10.0f, &Label, &Button); Button.VSplitLeft(100.0f, &Button, 0); - static int s_ButtonUpdate = 0; + static CButtonContainer s_ButtonUpdate; if(DoButton_Menu(&s_ButtonUpdate, Localize("Update now"), 0, &Button)) { Updater()->InitiateUpdate(); @@ -3234,7 +3239,7 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView) str_format(aBuf, sizeof(aBuf), Localize("No updates available")); Label.VSplitLeft(TextRender()->TextWidth(0, 14.0f, aBuf, -1, -1.0f) + 10.0f, &Label, &Button); Button.VSplitLeft(100.0f, &Button, 0); - static int s_ButtonUpdate = 0; + static CButtonContainer s_ButtonUpdate; if(DoButton_Menu(&s_ButtonUpdate, Localize("Check now"), 0, &Button)) { Client()->RequestDDNetInfo(); diff --git a/src/game/client/components/menus_settings_assets.cpp b/src/game/client/components/menus_settings_assets.cpp index 8fa8dd712..a388a1fda 100644 --- a/src/game/client/components/menus_settings_assets.cpp +++ b/src/game/client/components/menus_settings_assets.cpp @@ -394,19 +394,19 @@ void CMenus::RenderSettingsCustom(CUIRect MainView) Page4Tab.VSplitLeft(TabsW / NUMBER_OF_ASSETS_TABS, &Page4Tab, &Page5Tab); Page5Tab.VSplitLeft(TabsW / NUMBER_OF_ASSETS_TABS, &Page5Tab, &Page6Tab); - static int s_aPageTabs[NUMBER_OF_ASSETS_TABS] = {}; + static CButtonContainer s_aPageTabs[NUMBER_OF_ASSETS_TABS] = {}; - if(DoButton_MenuTab((void *)&s_aPageTabs[ASSETS_TAB_ENTITIES], Localize("Entities"), s_CurCustomTab == ASSETS_TAB_ENTITIES, &Page1Tab, CUI::CORNER_L, NULL, NULL, NULL, NULL, 4)) + if(DoButton_MenuTab((CButtonContainer *)&s_aPageTabs[ASSETS_TAB_ENTITIES], Localize("Entities"), s_CurCustomTab == ASSETS_TAB_ENTITIES, &Page1Tab, CUI::CORNER_L, NULL, NULL, NULL, NULL, 4)) s_CurCustomTab = ASSETS_TAB_ENTITIES; - if(DoButton_MenuTab((void *)&s_aPageTabs[ASSETS_TAB_GAME], Localize("Game"), s_CurCustomTab == ASSETS_TAB_GAME, &Page2Tab, 0, NULL, NULL, NULL, NULL, 4)) + if(DoButton_MenuTab((CButtonContainer *)&s_aPageTabs[ASSETS_TAB_GAME], Localize("Game"), s_CurCustomTab == ASSETS_TAB_GAME, &Page2Tab, 0, NULL, NULL, NULL, NULL, 4)) s_CurCustomTab = ASSETS_TAB_GAME; - if(DoButton_MenuTab((void *)&s_aPageTabs[ASSETS_TAB_EMOTICONS], Localize("Emoticons"), s_CurCustomTab == ASSETS_TAB_EMOTICONS, &Page3Tab, 0, NULL, NULL, NULL, NULL, 4)) + if(DoButton_MenuTab((CButtonContainer *)&s_aPageTabs[ASSETS_TAB_EMOTICONS], Localize("Emoticons"), s_CurCustomTab == ASSETS_TAB_EMOTICONS, &Page3Tab, 0, NULL, NULL, NULL, NULL, 4)) s_CurCustomTab = ASSETS_TAB_EMOTICONS; - if(DoButton_MenuTab((void *)&s_aPageTabs[ASSETS_TAB_PARTICLES], Localize("Particles"), s_CurCustomTab == ASSETS_TAB_PARTICLES, &Page4Tab, 0, NULL, NULL, NULL, NULL, 4)) + if(DoButton_MenuTab((CButtonContainer *)&s_aPageTabs[ASSETS_TAB_PARTICLES], Localize("Particles"), s_CurCustomTab == ASSETS_TAB_PARTICLES, &Page4Tab, 0, NULL, NULL, NULL, NULL, 4)) s_CurCustomTab = ASSETS_TAB_PARTICLES; - if(DoButton_MenuTab((void *)&s_aPageTabs[ASSETS_TAB_HUD], Localize("HUD"), s_CurCustomTab == ASSETS_TAB_HUD, &Page5Tab, 0, NULL, NULL, NULL, NULL, 4)) + if(DoButton_MenuTab((CButtonContainer *)&s_aPageTabs[ASSETS_TAB_HUD], Localize("HUD"), s_CurCustomTab == ASSETS_TAB_HUD, &Page5Tab, 0, NULL, NULL, NULL, NULL, 4)) s_CurCustomTab = ASSETS_TAB_HUD; - if(DoButton_MenuTab((void *)&s_aPageTabs[ASSETS_TAB_EXTRAS], Localize("Extras"), s_CurCustomTab == ASSETS_TAB_EXTRAS, &Page6Tab, CUI::CORNER_R, NULL, NULL, NULL, NULL, 4)) + if(DoButton_MenuTab((CButtonContainer *)&s_aPageTabs[ASSETS_TAB_EXTRAS], Localize("Extras"), s_CurCustomTab == ASSETS_TAB_EXTRAS, &Page6Tab, CUI::CORNER_R, NULL, NULL, NULL, NULL, 4)) s_CurCustomTab = ASSETS_TAB_EXTRAS; auto LoadStartTime = time_get_nanoseconds(); @@ -667,7 +667,7 @@ void CMenus::RenderSettingsCustom(CUIRect MainView) DirectoryButton.VSplitRight(175.0f, 0, &DirectoryButton); DirectoryButton.VSplitRight(25.0f, &DirectoryButton, &ReloadButton); DirectoryButton.VSplitRight(10.0f, &DirectoryButton, 0); - static int s_AssetsDirID = 0; + static CButtonContainer s_AssetsDirID; if(DoButton_Menu(&s_AssetsDirID, Localize("Assets directory"), 0, &DirectoryButton)) { char aBuf[IO_MAX_PATH_LENGTH]; @@ -695,7 +695,7 @@ void CMenus::RenderSettingsCustom(CUIRect MainView) TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT)); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE); - static int s_AssetsReloadBtnID = 0; + static CButtonContainer s_AssetsReloadBtnID; if(DoButton_Menu(&s_AssetsReloadBtnID, "\xEF\x80\x9E", 0, &ReloadButton, nullptr, CUI::CORNER_ALL, 5, 0, vec4(1.0f, 1.0f, 1.0f, 0.75f), vec4(1, 1, 1, 0.5f), 0)) { ClearCustomItems(s_CurCustomTab); diff --git a/src/game/client/components/menus_start.cpp b/src/game/client/components/menus_start.cpp index c4b833e5d..e21a4f23e 100644 --- a/src/game/client/components/menus_start.cpp +++ b/src/game/client/components/menus_start.cpp @@ -41,7 +41,7 @@ void CMenus::RenderStartMenu(CUIRect MainView) ExtMenu.VSplitLeft(100.0f, &ExtMenu, 0); ExtMenu.HSplitBottom(20.0f, &ExtMenu, &Button); - static int s_DiscordButton; + static CButtonContainer s_DiscordButton; if(DoButton_Menu(&s_DiscordButton, Localize("Discord"), 0, &Button, 0, CUI::CORNER_ALL, 5.0f, 0.0f, vec4(0.0f, 0.0f, 0.0f, 0.5f), vec4(0.0f, 0.0f, 0.0f, 0.25f))) { if(!open_link(Localize("https://ddnet.tw/discord"))) @@ -53,7 +53,7 @@ void CMenus::RenderStartMenu(CUIRect MainView) ExtMenu.HSplitBottom(5.0f, &ExtMenu, 0); // little space ExtMenu.HSplitBottom(20.0f, &ExtMenu, &Button); - static int s_LearnButton; + static CButtonContainer s_LearnButton; if(DoButton_Menu(&s_LearnButton, Localize("Learn"), 0, &Button, 0, CUI::CORNER_ALL, 5.0f, 0.0f, vec4(0.0f, 0.0f, 0.0f, 0.5f), vec4(0.0f, 0.0f, 0.0f, 0.25f))) { if(!open_link(Localize("https://wiki.ddnet.tw/"))) @@ -65,7 +65,7 @@ void CMenus::RenderStartMenu(CUIRect MainView) ExtMenu.HSplitBottom(5.0f, &ExtMenu, 0); // little space ExtMenu.HSplitBottom(20.0f, &ExtMenu, &Button); - static int s_TutorialButton; + static CButtonContainer s_TutorialButton; static float s_JoinTutorialTime = 0.0f; if(DoButton_Menu(&s_TutorialButton, Localize("Tutorial"), 0, &Button, 0, CUI::CORNER_ALL, 5.0f, 0.0f, vec4(0.0f, 0.0f, 0.0f, 0.5f), vec4(0.0f, 0.0f, 0.0f, 0.25f)) || (s_JoinTutorialTime != 0.0f && Client()->LocalTime() >= s_JoinTutorialTime)) @@ -91,7 +91,7 @@ void CMenus::RenderStartMenu(CUIRect MainView) ExtMenu.HSplitBottom(5.0f, &ExtMenu, 0); // little space ExtMenu.HSplitBottom(20.0f, &ExtMenu, &Button); - static int s_WebsiteButton; + static CButtonContainer s_WebsiteButton; if(DoButton_Menu(&s_WebsiteButton, Localize("Website"), 0, &Button, 0, CUI::CORNER_ALL, 5.0f, 0.0f, vec4(0.0f, 0.0f, 0.0f, 0.5f), vec4(0.0f, 0.0f, 0.0f, 0.25f))) { if(!open_link("https://ddnet.tw/")) @@ -103,7 +103,7 @@ void CMenus::RenderStartMenu(CUIRect MainView) ExtMenu.HSplitBottom(5.0f, &ExtMenu, 0); // little space ExtMenu.HSplitBottom(20.0f, &ExtMenu, &Button); - static int s_NewsButton; + static CButtonContainer s_NewsButton; if(DoButton_Menu(&s_NewsButton, Localize("News"), 0, &Button, 0, CUI::CORNER_ALL, 5.0f, 0.0f, vec4(0.0f, 0.0f, 0.0f, 0.5f), g_Config.m_UiUnreadNews ? vec4(0.0f, 1.0f, 0.0f, 0.25f) : vec4(0.0f, 0.0f, 0.0f, 0.25f)) || CheckHotKey(KEY_N)) NewPage = PAGE_NEWS; @@ -112,7 +112,7 @@ void CMenus::RenderStartMenu(CUIRect MainView) Menu.HSplitBottom(25.0f, &Menu, 0); Menu.HSplitBottom(40.0f, &Menu, &Button); - static int s_QuitButton; + static CButtonContainer s_QuitButton; if(DoButton_Menu(&s_QuitButton, Localize("Quit"), 0, &Button, 0, CUI::CORNER_ALL, Rounding, 0.5f, vec4(0.0f, 0.0f, 0.0f, 0.5f), vec4(0.0f, 0.0f, 0.0f, 0.25f)) || m_EscapePressed || CheckHotKey(KEY_Q)) { if(m_EscapePressed || m_pClient->Editor()->HasUnsavedData() || (Client()->GetCurrentRaceTime() / 60 >= g_Config.m_ClConfirmQuitTime && g_Config.m_ClConfirmQuitTime >= 0)) @@ -127,13 +127,13 @@ void CMenus::RenderStartMenu(CUIRect MainView) Menu.HSplitBottom(100.0f, &Menu, 0); Menu.HSplitBottom(40.0f, &Menu, &Button); - static int s_SettingsButton; + static CButtonContainer s_SettingsButton; if(DoButton_Menu(&s_SettingsButton, Localize("Settings"), 0, &Button, g_Config.m_ClShowStartMenuImages ? "settings" : 0, CUI::CORNER_ALL, Rounding, 0.5f, vec4(0.0f, 0.0f, 0.0f, 0.5f), vec4(0.0f, 0.0f, 0.0f, 0.25f)) || CheckHotKey(KEY_S)) NewPage = PAGE_SETTINGS; Menu.HSplitBottom(5.0f, &Menu, 0); // little space Menu.HSplitBottom(40.0f, &Menu, &Button); - static int s_LocalServerButton = 0; + static CButtonContainer s_LocalServerButton; if(DoButton_Menu(&s_LocalServerButton, m_ServerProcess.Process ? Localize("Stop server") : Localize("Run server"), 0, &Button, g_Config.m_ClShowStartMenuImages ? "local_server" : 0, CUI::CORNER_ALL, Rounding, 0.5f, vec4(0.0f, 0.0f, 0.0f, 0.5f), m_ServerProcess.Process ? vec4(0.0f, 1.0f, 0.0f, 0.25f) : vec4(0.0f, 0.0f, 0.0f, 0.25f)) || (CheckHotKey(KEY_R) && Input()->KeyPress(KEY_R))) { if(m_ServerProcess.Process) @@ -165,7 +165,7 @@ void CMenus::RenderStartMenu(CUIRect MainView) static float EditorHotKeyChecktime = 0.0f; Menu.HSplitBottom(5.0f, &Menu, 0); // little space Menu.HSplitBottom(40.0f, &Menu, &Button); - static int s_MapEditorButton; + static CButtonContainer s_MapEditorButton; if(DoButton_Menu(&s_MapEditorButton, Localize("Editor"), 0, &Button, g_Config.m_ClShowStartMenuImages ? "editor" : 0, CUI::CORNER_ALL, Rounding, 0.5f, vec4(0.0f, 0.0f, 0.0f, 0.5f), m_pClient->Editor()->HasUnsavedData() ? vec4(0.0f, 1.0f, 0.0f, 0.25f) : vec4(0.0f, 0.0f, 0.0f, 0.25f)) || (!EditorHotkeyWasPressed && Client()->LocalTime() - EditorHotKeyChecktime < 0.1f && CheckHotKey(KEY_E))) { g_Config.m_ClEditor = 1; @@ -180,7 +180,7 @@ void CMenus::RenderStartMenu(CUIRect MainView) Menu.HSplitBottom(5.0f, &Menu, 0); // little space Menu.HSplitBottom(40.0f, &Menu, &Button); - static int s_DemoButton; + static CButtonContainer s_DemoButton; if(DoButton_Menu(&s_DemoButton, Localize("Demos"), 0, &Button, g_Config.m_ClShowStartMenuImages ? "demos" : 0, CUI::CORNER_ALL, Rounding, 0.5f, vec4(0.0f, 0.0f, 0.0f, 0.5f), vec4(0.0f, 0.0f, 0.0f, 0.25f)) || CheckHotKey(KEY_D)) { NewPage = PAGE_DEMOS; @@ -188,7 +188,7 @@ void CMenus::RenderStartMenu(CUIRect MainView) Menu.HSplitBottom(5.0f, &Menu, 0); // little space Menu.HSplitBottom(40.0f, &Menu, &Button); - static int s_PlayButton; + static CButtonContainer s_PlayButton; if(DoButton_Menu(&s_PlayButton, Localize("Play", "Start menu"), 0, &Button, g_Config.m_ClShowStartMenuImages ? "play_game" : 0, CUI::CORNER_ALL, Rounding, 0.5f, vec4(0.0f, 0.0f, 0.0f, 0.5f), vec4(0.0f, 0.0f, 0.0f, 0.25f)) || m_EnterPressed || CheckHotKey(KEY_P)) { NewPage = g_Config.m_UiPage >= PAGE_INTERNET && g_Config.m_UiPage <= PAGE_KOG ? g_Config.m_UiPage : PAGE_DDNET; @@ -242,7 +242,7 @@ void CMenus::RenderStartMenu(CUIRect MainView) CUIRect Update; Part.VSplitLeft(100.0f, &Update, NULL); - static int s_VersionUpdate = 0; + static CButtonContainer s_VersionUpdate; if(DoButton_Menu(&s_VersionUpdate, Localize("Update now"), 0, &Update, 0, CUI::CORNER_ALL, 5.0f, 0.0f, vec4(0.0f, 0.0f, 0.0f, 0.5f), vec4(0.0f, 0.0f, 0.0f, 0.25f))) { Updater()->InitiateUpdate(); @@ -253,7 +253,7 @@ void CMenus::RenderStartMenu(CUIRect MainView) CUIRect Restart; Part.VSplitLeft(50.0f, &Restart, &Part); - static int s_VersionUpdate = 0; + static CButtonContainer s_VersionUpdate; if(DoButton_Menu(&s_VersionUpdate, Localize("Restart"), 0, &Restart, 0, CUI::CORNER_ALL, 5.0f, 0.0f, vec4(0.0f, 0.0f, 0.0f, 0.5f), vec4(0.0f, 0.0f, 0.0f, 0.25f))) { Client()->Restart(); diff --git a/src/game/client/ui.h b/src/game/client/ui.h index f834e1bda..bb5e08a69 100644 --- a/src/game/client/ui.h +++ b/src/game/client/ui.h @@ -187,6 +187,10 @@ struct SLabelProperties bool m_EnableWidthCheck = true; }; +class CButtonContainer +{ +}; + class CUI { bool m_Enabled;