From 0ebaed430ad5cd2523d78d2e2c051576e948fe13 Mon Sep 17 00:00:00 2001 From: Loic Blot Date: Wed, 3 Jan 2018 14:28:55 +0100 Subject: GameUI refactor (part 1/X): GameUI object creation + GameUIFlags move to GameUI Game class is too huge and has too specialization on various subjects, like UI, formspecs, client, renderer. Start to move UI related things to GameUI object and cleanup them Other improvements: * updateChat: more performance on error messages by remove string copies * Initialize all game class members in definition instead of constructor (with nullptr instead of NULL) * Drop unused Client::show{GameChat,GameHud,Profiler,GameFog} * Add GameUI unittests --- src/client.cpp | 32 ++++---------------------------- 1 file changed, 4 insertions(+), 28 deletions(-) (limited to 'src/client.cpp') diff --git a/src/client.cpp b/src/client.cpp index 6e29607ca..e6af5c324 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -28,6 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "network/networkpacket.h" #include "threading/mutex_auto_lock.h" #include "client/clientevent.h" +#include "client/gameui.h" #include "client/renderingengine.h" #include "client/tile.h" #include "util/auth.h" @@ -74,7 +75,7 @@ Client::Client( ISoundManager *sound, MtEventManager *event, bool ipv6, - GameUIFlags *game_ui_flags + GameUI *game_ui ): m_tsrc(tsrc), m_shsrc(shsrc), @@ -96,7 +97,7 @@ Client::Client( m_chosen_auth_mech(AUTH_MECHANISM_NONE), m_media_downloader(new ClientMediaDownloader()), m_state(LC_Created), - m_game_ui_flags(game_ui_flags), + m_game_ui(game_ui), m_modchannel_mgr(new ModChannelMgr()) { // Add local player @@ -1771,34 +1772,9 @@ void Client::pushToEventQueue(ClientEvent *event) m_client_event_queue.push(event); } -void Client::showGameChat(const bool show) -{ - m_game_ui_flags->show_chat = show; -} - -void Client::showGameHud(const bool show) -{ - m_game_ui_flags->show_hud = show; -} - void Client::showMinimap(const bool show) { - m_game_ui_flags->show_minimap = show; -} - -void Client::showProfiler(const bool show) -{ - m_game_ui_flags->show_profiler_graph = show; -} - -void Client::showGameFog(const bool show) -{ - m_game_ui_flags->force_fog_off = !show; -} - -void Client::showGameDebug(const bool show) -{ - m_game_ui_flags->show_debug = show; + m_game_ui->showMinimap(show); } // IGameDef interface -- cgit v1.2.3