From c89509bc4b65f810d1d2b89ab2adfed4d611a08e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Mon, 26 Aug 2024 20:49:40 +0200 Subject: [PATCH] Add icon button to open console in bottom right of start menu Add a button with the "terminal" icon in the bottom right of the start menu to open the local console to ensure that the local console is usable also when no physical keyboard (with F-keys) is available. --- src/engine/textrender.h | 1 + src/game/client/components/console.h | 3 +-- src/game/client/components/menus_start.cpp | 26 +++++++++++++++++----- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/engine/textrender.h b/src/engine/textrender.h index 06f950ded..3b0ca218e 100644 --- a/src/engine/textrender.h +++ b/src/engine/textrender.h @@ -93,6 +93,7 @@ MAYBE_UNUSED static const char *FONT_ICON_EARTH_AMERICAS = "\xEF\x95\xBD"; MAYBE_UNUSED static const char *FONT_ICON_NETWORK_WIRED = "\xEF\x9B\xBF"; MAYBE_UNUSED static const char *FONT_ICON_LIST_UL = "\xEF\x83\x8A"; MAYBE_UNUSED static const char *FONT_ICON_INFO = "\xEF\x84\xA9"; +MAYBE_UNUSED static const char *FONT_ICON_TERMINAL = "\xEF\x84\xA0"; MAYBE_UNUSED static const char *FONT_ICON_SLASH = "\xEF\x9C\x95"; MAYBE_UNUSED static const char *FONT_ICON_PLAY = "\xEF\x81\x8B"; diff --git a/src/game/client/components/console.h b/src/game/client/components/console.h index 4dbdc4767..e8ab47900 100644 --- a/src/game/client/components/console.h +++ b/src/game/client/components/console.h @@ -160,8 +160,6 @@ class CGameConsole : public CComponent static const ColorRGBA ms_SearchHighlightColor; static const ColorRGBA ms_SearchSelectedColor; - void Toggle(int Type); - static void PossibleCommandsRenderCallback(int Index, const char *pStr, void *pUser); static void ConToggleLocalConsole(IConsole::IResult *pResult, void *pUserData); static void ConToggleRemoteConsole(IConsole::IResult *pResult, void *pUserData); @@ -196,6 +194,7 @@ public: virtual bool OnInput(const IInput::CEvent &Event) override; void Prompt(char (&aPrompt)[32]); + void Toggle(int Type); bool IsClosed() { return m_ConsoleState == CONSOLE_CLOSED; } }; #endif diff --git a/src/game/client/components/menus_start.cpp b/src/game/client/components/menus_start.cpp index 31f343906..de7520404 100644 --- a/src/game/client/components/menus_start.cpp +++ b/src/game/client/components/menus_start.cpp @@ -17,6 +17,8 @@ #include "menus.h" +using namespace FontIcons; + void CMenus::RenderStartMenu(CUIRect MainView) { GameClient()->m_MenuBackground.ChangePosition(CMenuBackground::POS_START); @@ -186,13 +188,27 @@ void CMenus::RenderStartMenu(CUIRect MainView) } // render version - CUIRect VersionUpdate, CurVersion; - MainView.HSplitBottom(20.0f, nullptr, &VersionUpdate); - VersionUpdate.VSplitRight(50.0f, &CurVersion, nullptr); - VersionUpdate.VMargin(VMargin, &VersionUpdate); - + CUIRect CurVersion, ConsoleButton; + MainView.HSplitBottom(45.0f, nullptr, &CurVersion); + CurVersion.VSplitRight(40.0f, &CurVersion, nullptr); + CurVersion.HSplitTop(20.0f, &ConsoleButton, &CurVersion); + CurVersion.HSplitTop(5.0f, nullptr, &CurVersion); + ConsoleButton.VSplitRight(40.0f, nullptr, &ConsoleButton); Ui()->DoLabel(&CurVersion, GAME_RELEASE_VERSION, 14.0f, TEXTALIGN_MR); + static CButtonContainer s_ConsoleButton; + TextRender()->SetFontPreset(EFontPreset::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); + if(DoButton_Menu(&s_ConsoleButton, FONT_ICON_TERMINAL, 0, &ConsoleButton, nullptr, IGraphics::CORNER_ALL, 5.0f, 0.0f, ColorRGBA(0.0f, 0.0f, 0.0f, 0.1f))) + { + GameClient()->m_GameConsole.Toggle(CGameConsole::CONSOLETYPE_LOCAL); + } + TextRender()->SetRenderFlags(0); + TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT); + + CUIRect VersionUpdate; + MainView.HSplitBottom(20.0f, nullptr, &VersionUpdate); + VersionUpdate.VMargin(VMargin, &VersionUpdate); #if defined(CONF_AUTOUPDATE) CUIRect UpdateButton; VersionUpdate.VSplitRight(100.0f, &VersionUpdate, &UpdateButton);