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`.
This commit is contained in:
Robert Müller 2023-09-30 12:26:21 +02:00
parent 6753e37772
commit 721a55c603
3 changed files with 12 additions and 19 deletions

View file

@ -3,11 +3,6 @@
#define _WIN32_WINNT 0x0501
#include <climits>
#include <new>
#include <stack>
#include <tuple>
#include <base/hash.h>
#include <base/hash_ctxt.h>
#include <base/logger.h>
@ -16,9 +11,6 @@
#include <engine/external/json-parser/json.h>
#include <game/client/components/menus.h>
#include <game/generated/protocol.h>
#include <engine/config.h>
#include <engine/console.h>
#include <engine/discord.h>
@ -35,7 +27,6 @@
#include <engine/storage.h>
#include <engine/textrender.h>
#include <engine/client/notifications.h>
#include <engine/shared/assertion_logger.h>
#include <engine/shared/compression.h>
#include <engine/shared/config.h>
@ -52,13 +43,14 @@
#include <engine/shared/snapshot.h>
#include <engine/shared/uuid_manager.h>
#include <game/generated/protocol.h>
#include <game/localization.h>
#include <game/version.h>
#include <engine/client/demoedit.h>
#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 <chrono>
#include <climits>
#include <new>
#include <stack>
#include <thread>
#include <tuple>
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
{

View file

@ -26,8 +26,6 @@
#include <engine/friends.h>
#include <engine/storage.h>
#include <game/client/components/menus.h> // 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<IConsole>();
m_pConfigManager = Kernel()->RequestInterface<IConfigManager>();
m_pEngine = Kernel()->RequestInterface<IEngine>();
m_pFavorites = Kernel()->RequestInterface<IFavorites>();
m_pFriends = Kernel()->RequestInterface<IFriends>();
@ -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);

View file

@ -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;