From d9b5a8c3c4dde35ba0b50a281dceb0247fd6544b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Sun, 28 May 2023 20:53:04 +0200 Subject: [PATCH] Use X icon for demo close button, remove `DoButton_DemoPlayer` --- src/game/client/components/menus.h | 3 +-- src/game/client/components/menus_demo.cpp | 14 ++++---------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/game/client/components/menus.h b/src/game/client/components/menus.h index f7d393243..f4b187c4c 100644 --- a/src/game/client/components/menus.h +++ b/src/game/client/components/menus.h @@ -74,8 +74,7 @@ class CMenus : public CComponent static SColorPicker ms_ColorPicker; static bool ms_ValueSelectorTextMode; - int DoButton_DemoPlayer(const void *pID, const char *pText, int Checked, const CUIRect *pRect); - int DoButton_FontIcon(CButtonContainer *pButtonContainer, const char *pText, int Checked, const CUIRect *pRect, int Corners, bool Enabled = true); + int DoButton_FontIcon(CButtonContainer *pButtonContainer, const char *pText, int Checked, const CUIRect *pRect, int Corners = IGraphics::CORNER_ALL, bool Enabled = true); int DoButton_Toggle(const void *pID, int Checked, const CUIRect *pRect, bool Active); int DoButton_Menu(CButtonContainer *pButtonContainer, const char *pText, int Checked, const CUIRect *pRect, const char *pImageName = nullptr, int Corners = IGraphics::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), 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); diff --git a/src/game/client/components/menus_demo.cpp b/src/game/client/components/menus_demo.cpp index 8054b1d42..64cf9366c 100644 --- a/src/game/client/components/menus_demo.cpp +++ b/src/game/client/components/menus_demo.cpp @@ -28,13 +28,6 @@ using namespace FontIcons; using namespace std::chrono_literals; -int CMenus::DoButton_DemoPlayer(const void *pID, const char *pText, int Checked, const CUIRect *pRect) -{ - pRect->Draw(ColorRGBA(1, 1, 1, (Checked ? 0.10f : 0.5f) * UI()->ButtonColorMul(pID)), IGraphics::CORNER_ALL, 5.0f); - UI()->DoLabel(pRect, pText, 14.0f, TEXTALIGN_MC); - return UI()->DoButtonLogic(pID, Checked, pRect); -} - int CMenus::DoButton_FontIcon(CButtonContainer *pButtonContainer, const char *pText, int Checked, const CUIRect *pRect, int Corners, bool Enabled) { pRect->Draw(ColorRGBA(1.0f, 1.0f, 1.0f, (Checked ? 0.10f : 0.5f) * UI()->ButtonColorMul(pButtonContainer)), Corners, 5.0f); @@ -508,13 +501,14 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) GameClient()->m_Tooltips.DoToolTip(&s_OneMarkerForwardButton, &Button, Localize("Go forward one marker")); // close button - ButtonBar.VSplitRight(ButtonbarHeight * 3, &ButtonBar, &Button); - static int s_ExitButton = 0; - if(DoButton_DemoPlayer(&s_ExitButton, Localize("Close"), 0, &Button) || (Input()->KeyPress(KEY_C) && m_pClient->m_GameConsole.IsClosed() && m_DemoPlayerState == DEMOPLAYER_NONE)) + ButtonBar.VSplitRight(ButtonbarHeight, &ButtonBar, &Button); + static CButtonContainer s_ExitButton; + if(DoButton_FontIcon(&s_ExitButton, FONT_ICON_XMARK, 0, &Button) || (Input()->KeyPress(KEY_C) && m_pClient->m_GameConsole.IsClosed() && m_DemoPlayerState == DEMOPLAYER_NONE)) { Client()->Disconnect(); DemolistOnUpdate(false); } + GameClient()->m_Tooltips.DoToolTip(&s_ExitButton, &Button, Localize("Close the demo player")); // toggle keyboard shortcuts button ButtonBar.VSplitRight(Margins, &ButtonBar, nullptr);