From 721a55c60312a2a913263a947f0257b42f653c31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Sat, 30 Sep 2023 12:26:21 +0200 Subject: [PATCH] Remove game menus includes in engine Use config manager to reset `ui_page` to the default, instead of using `CMenus::PAGE_DDNET` directly (which is the default). Check current type of serverbrowser instead of checking the current `ui_page` against `CMenus::PAGE_DDNET` and `CMenus::PAGE_KOG`. --- src/engine/client/client.cpp | 25 +++++++++---------------- src/engine/client/serverbrowser.cpp | 5 ++--- src/engine/client/serverbrowser.h | 1 + 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 3908ba2f0..a116fa5f8 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -3,11 +3,6 @@ #define _WIN32_WINNT 0x0501 -#include -#include -#include -#include - #include #include #include @@ -16,9 +11,6 @@ #include -#include -#include - #include #include #include @@ -35,7 +27,6 @@ #include #include -#include #include #include #include @@ -52,13 +43,14 @@ #include #include +#include #include #include -#include - #include "client.h" +#include "demoedit.h" #include "friends.h" +#include "notifications.h" #include "serverbrowser.h" #if defined(CONF_VIDEORECORDER) @@ -71,7 +63,11 @@ #endif #include +#include +#include +#include #include +#include using namespace std::chrono_literals; @@ -2379,11 +2375,8 @@ void CClient::FinishDDNetInfo() { m_pStorage->RenameFile(m_aDDNetInfoTmp, DDNET_INFO, IStorage::TYPE_SAVE); LoadDDNetInfo(); - - if(g_Config.m_UiPage == CMenus::PAGE_DDNET) - m_ServerBrowser.Refresh(IServerBrowser::TYPE_DDNET); - else if(g_Config.m_UiPage == CMenus::PAGE_KOG) - m_ServerBrowser.Refresh(IServerBrowser::TYPE_KOG); + if(m_ServerBrowser.GetCurrentType() == IServerBrowser::TYPE_DDNET || m_ServerBrowser.GetCurrentType() == IServerBrowser::TYPE_KOG) + m_ServerBrowser.Refresh(m_ServerBrowser.GetCurrentType()); } else { diff --git a/src/engine/client/serverbrowser.cpp b/src/engine/client/serverbrowser.cpp index 7fcc19955..7f50493f5 100644 --- a/src/engine/client/serverbrowser.cpp +++ b/src/engine/client/serverbrowser.cpp @@ -26,8 +26,6 @@ #include #include -#include // PAGE_DDNET - class CSortWrap { typedef bool (CServerBrowser::*SortFunc)(int, int) const; @@ -91,6 +89,7 @@ void CServerBrowser::SetBaseInfo(class CNetClient *pClient, const char *pNetVers m_pNetClient = pClient; str_copy(m_aNetVersion, pNetVersion); m_pConsole = Kernel()->RequestInterface(); + m_pConfigManager = Kernel()->RequestInterface(); m_pEngine = Kernel()->RequestInterface(); m_pFavorites = Kernel()->RequestInterface(); m_pFriends = Kernel()->RequestInterface(); @@ -1334,7 +1333,7 @@ const char *CServerBrowser::GetTutorialServer() { // Use DDNet tab as default after joining tutorial, also makes sure Find() actually works // Note that when no server info has been loaded yet, this will not return a result immediately. - g_Config.m_UiPage = CMenus::PAGE_DDNET; + m_pConfigManager->Reset("ui_page"); Refresh(IServerBrowser::TYPE_DDNET); const CCommunity *pCommunity = Community(COMMUNITY_DDNET); diff --git a/src/engine/client/serverbrowser.h b/src/engine/client/serverbrowser.h index 49f8b97df..e339be4bd 100644 --- a/src/engine/client/serverbrowser.h +++ b/src/engine/client/serverbrowser.h @@ -88,6 +88,7 @@ public: private: CNetClient *m_pNetClient = nullptr; + IConfigManager *m_pConfigManager = nullptr; IConsole *m_pConsole = nullptr; IEngine *m_pEngine = nullptr; IFriends *m_pFriends = nullptr;