From 8abb320248c04b069fa9e34302d55cc80c7b73d1 Mon Sep 17 00:00:00 2001 From: oy Date: Thu, 10 Jan 2019 17:30:23 +0100 Subject: [PATCH] added settings button to the internet/lan/demo browser. pressing esc or back button returns to previous menu page. --- src/game/client/components/menus.cpp | 25 ++++++++++++++++++++----- src/game/client/components/menus.h | 1 + 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 09a72ad42..9a03d9d2b 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -63,6 +63,7 @@ CMenus::CMenus() m_UseMouseButtons = true; SetMenuPage(PAGE_START); + m_MenuPageOld = PAGE_START; m_PopupActive = false; @@ -1396,7 +1397,8 @@ void CMenus::RenderBackButton(CUIRect MainView) static CButtonContainer s_MenuButton; if(DoButton_Menu(&s_MenuButton, Localize("Back"), 0, &Button) || m_EscapePressed) { - SetMenuPage(PAGE_START); + SetMenuPage(m_MenuPageOld); + m_MenuPageOld = PAGE_START; } } @@ -1687,12 +1689,12 @@ int CMenus::Render() m_MenuPage = PAGE_INTERNET; }*/ - // quit button { - CUIRect Button; + // quit button + CUIRect Button, Row; float TopOffset = 27.0f; - Screen.HSplitTop(TopOffset, &Button, 0); - Button.VSplitRight(TopOffset/* - 3.0f*/, 0, &Button); + Screen.HSplitTop(TopOffset, &Row, 0); + Row.VSplitRight(TopOffset/* - 3.0f*/, &Row, &Button); static CButtonContainer s_QuitButton; // draw red-blending button @@ -1707,6 +1709,19 @@ int CMenus::Render() if(UI()->DoButtonLogic(s_QuitButton.GetID(), "\xE2\x9C\x95", 0, &Button)) // if(DoButton_SpriteCleanID(&s_QuitButton, IMAGE_FRIENDICONS, SPRITE_FRIEND_X_A, &Button, false)) m_Popup = POPUP_QUIT; + + // settings button + if(Client()->State() == IClient::STATE_OFFLINE && (m_MenuPage == PAGE_INTERNET || m_MenuPage == PAGE_LAN || m_MenuPage == PAGE_DEMOS)) + { + Row.VSplitRight(5.0f, &Row, 0); + Row.VSplitRight(TopOffset, &Row, &Button); + static CButtonContainer s_SettingsButton; + if(DoButton_MenuTabTop(&s_SettingsButton, "\xE2\x9A\x99", false, &Button, 1.0f, 1.0f, CUI::CORNER_B)) + { + m_MenuPageOld = m_MenuPage; + m_MenuPage = PAGE_SETTINGS; + } + } } // render current page diff --git a/src/game/client/components/menus.h b/src/game/client/components/menus.h index 7f32e2d24..4522e9150 100644 --- a/src/game/client/components/menus.h +++ b/src/game/client/components/menus.h @@ -187,6 +187,7 @@ private: int m_Popup; int m_ActivePage; int m_MenuPage; + int m_MenuPageOld; bool m_MenuActive; int m_SidebarTab; bool m_SidebarActive;