From 4919a6185e6c520688eae376299ddf70fee453ef Mon Sep 17 00:00:00 2001 From: elexis Date: Sun, 25 Aug 2019 08:57:36 +0000 Subject: [PATCH] Remove unused GUIUtil functions, unused GUI includes and some tails in GUIUtil. HasSetting from 3dfa23cd25 is actually redundant with IGUIObject::SettingExists. GetSettingPointer from 8f4f8e240f is superseded by GetSetting reference following 3dfa23cd25 and 040624acff. Deregister copying SetSetting variants for CStr and CStrW following copy removal in 040624acff. The default template from c2a71e41bf can be removed following FallBackSprite/FallBackColor removal in 9985fcf5bd and RecurseObject unification in d4d5187c9d. Delete all unused GUI includes, refs D1478. Remove GUIUtil friend class following something. Differential Revision: https://code.wildfiregames.com/D2225 Tested on: gcc 9.1.0, Jenkins This was SVN commit r22779. --- source/graphics/CinemaManager.cpp | 6 +--- source/gui/GUIRenderer.cpp | 1 + source/gui/GUItypes.h | 4 +-- source/gui/GUIutil.cpp | 34 +------------------ source/gui/GUIutil.h | 26 ++------------ source/lobby/scripting/JSInterface_Lobby.cpp | 3 +- source/network/NetClientTurnManager.cpp | 1 - source/ps/GameSetup/GameSetup.cpp | 1 - source/ps/SavedGame.cpp | 1 - source/ps/VisualReplay.cpp | 1 - source/renderer/PostprocManager.cpp | 1 - .../Handlers/GraphicsSetupHandlers.cpp | 1 - 12 files changed, 9 insertions(+), 71 deletions(-) diff --git a/source/graphics/CinemaManager.cpp b/source/graphics/CinemaManager.cpp index 4627d646bc..6b12743ffa 100644 --- a/source/graphics/CinemaManager.cpp +++ b/source/graphics/CinemaManager.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -24,10 +24,6 @@ #include "graphics/Camera.h" #include "graphics/GameView.h" -#include "gui/CGUI.h" -#include "gui/GUIutil.h" -#include "gui/GUIManager.h" -#include "gui/IGUIObject.h" #include "lib/ogl.h" #include "maths/MathUtil.h" #include "maths/Quaternion.h" diff --git a/source/gui/GUIRenderer.cpp b/source/gui/GUIRenderer.cpp index 3a7902d6a1..682202fa0c 100644 --- a/source/gui/GUIRenderer.cpp +++ b/source/gui/GUIRenderer.cpp @@ -22,6 +22,7 @@ #include "graphics/ShaderManager.h" #include "graphics/TextureManager.h" #include "gui/CGUIColor.h" +#include "gui/CGUISprite.h" #include "gui/GUIutil.h" #include "gui/GUIMatrix.h" #include "i18n/L10n.h" diff --git a/source/gui/GUItypes.h b/source/gui/GUItypes.h index 3ae23be4c2..6c90f3af1e 100644 --- a/source/gui/GUItypes.h +++ b/source/gui/GUItypes.h @@ -30,8 +30,6 @@ TYPE(bool) TYPE(i32) TYPE(u32) TYPE(float) -TYPE(CStr) -TYPE(CStrW) TYPE(EAlign) TYPE(EVAlign) TYPE(CPos) @@ -44,4 +42,6 @@ TYPE(CGUIList) TYPE(CGUISeries) TYPE(CGUISpriteInstance) TYPE(CGUIString) +TYPE(CStr) +TYPE(CStrW) #endif diff --git a/source/gui/GUIutil.cpp b/source/gui/GUIutil.cpp index 975f154816..d77a11c8df 100644 --- a/source/gui/GUIutil.cpp +++ b/source/gui/GUIutil.cpp @@ -20,7 +20,6 @@ #include "GUIutil.h" #include "gui/GUI.h" -#include "gui/GUIManager.h" #include "ps/CLogger.h" template @@ -81,35 +80,6 @@ void CGUISetting::ToJSVal(JSContext* cx, JS::MutableHandleValue Value) ScriptInterface::ToJSVal(cx, Value, m_pSetting); }; -template -PSRETURN GUI::GetSettingPointer(const IGUIObject* pObject, const CStr& Setting, T*& Value) -{ - ENSURE(pObject != NULL); - - std::map::const_iterator it = pObject->m_Settings.find(Setting); - if (it == pObject->m_Settings.end()) - { - LOGWARNING("setting %s was not found on object %s", - Setting.c_str(), - pObject->GetPresentableName().c_str()); - return PSRETURN_GUI_InvalidSetting; - } - - if (it->second == nullptr) - return PSRETURN_GUI_InvalidSetting; - - // Get value - Value = &(static_cast* >(it->second)->m_pSetting); - - return PSRETURN_OK; -} - -template -bool GUI::HasSetting(const IGUIObject* pObject, const CStr& Setting) -{ - return pObject->m_Settings.count(Setting) != 0; -} - template T& GUI::GetSetting(const IGUIObject* pObject, const CStr& Setting) { @@ -173,11 +143,9 @@ PSRETURN GUI::SetSettingWrap(IGUIObject* pObject, const CStr& Setting, const } // Instantiate templated functions: -// These functions avoid copies by working with a pointer and move semantics. +// These functions avoid copies by working with a reference and move semantics. #define TYPE(T) \ - template bool GUI::HasSetting(const IGUIObject* pObject, const CStr& Setting); \ template T& GUI::GetSetting(const IGUIObject* pObject, const CStr& Setting); \ - template PSRETURN GUI::GetSettingPointer(const IGUIObject* pObject, const CStr& Setting, T*& Value); \ template PSRETURN GUI::SetSetting(IGUIObject* pObject, const CStr& Setting, T& Value, const bool& SkipMessage); \ template class CGUISetting; \ diff --git a/source/gui/GUIutil.h b/source/gui/GUIutil.h index fc13d8d6a9..4032621098 100644 --- a/source/gui/GUIutil.h +++ b/source/gui/GUIutil.h @@ -23,15 +23,11 @@ #ifndef INCLUDED_GUIUTIL #define INCLUDED_GUIUTIL -#include "gui/CGUI.h" -#include "gui/CGUISprite.h" -#include "gui/GUIbase.h" #include "gui/IGUIObject.h" #include -class CClientArea; -class CGUIString; +class CGUI; template class GUI; class IGUISetting @@ -101,42 +97,26 @@ private: T m_pSetting; }; -struct SGUIMessage; - /** * Includes static functions that needs one template * argument. - * - * int is only to please functions that doesn't even use T - * and are only within this class because it's convenient */ -template +template class GUI { - // Private functions further ahead - friend class CGUI; - friend class IGUIObject; - public: NONCOPYABLE(GUI); - /** - * Determines whether a setting with the given name is registered. - * This function may be used as a safeguard for GetSetting. - */ - static bool HasSetting(const IGUIObject* pObject, const CStr& Setting); - /** * Get a mutable reference to the setting. * If no such setting exists, an exception of type std::out_of_range is thrown. + * Use SettingExists if a safeguard is needed. * * If the value is modified, there is no GUIM_SETTINGS_UPDATED message sent. * SetSetting should be used to modify the value if there is a use for the message. */ static T& GetSetting(const IGUIObject* pObject, const CStr& Setting); - static PSRETURN GetSettingPointer(const IGUIObject* pObject, const CStr& Setting, T*& Value); - /** * Sets a value by name using a real datatype as input. * This variant will use the move-assignment. diff --git a/source/lobby/scripting/JSInterface_Lobby.cpp b/source/lobby/scripting/JSInterface_Lobby.cpp index e3a90f2ad9..94a3c27f77 100644 --- a/source/lobby/scripting/JSInterface_Lobby.cpp +++ b/source/lobby/scripting/JSInterface_Lobby.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2018 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -19,7 +19,6 @@ #include "JSInterface_Lobby.h" -#include "gui/GUIManager.h" #include "lib/utf8.h" #include "lobby/IXmppClient.h" #include "network/NetServer.h" diff --git a/source/network/NetClientTurnManager.cpp b/source/network/NetClientTurnManager.cpp index 4ce71e7d1e..5c8433b49b 100644 --- a/source/network/NetClientTurnManager.cpp +++ b/source/network/NetClientTurnManager.cpp @@ -20,7 +20,6 @@ #include "NetClientTurnManager.h" #include "NetClient.h" -#include "gui/GUIManager.h" #include "ps/CLogger.h" #include "ps/Pyrogenesis.h" #include "ps/Replay.h" diff --git a/source/ps/GameSetup/GameSetup.cpp b/source/ps/GameSetup/GameSetup.cpp index 3297093898..b83f839aa2 100644 --- a/source/ps/GameSetup/GameSetup.cpp +++ b/source/ps/GameSetup/GameSetup.cpp @@ -37,7 +37,6 @@ #include "graphics/TerrainTextureManager.h" #include "gui/GUI.h" #include "gui/GUIManager.h" -#include "gui/scripting/ScriptFunctions.h" #include "i18n/L10n.h" #include "maths/MathUtil.h" #include "network/NetServer.h" diff --git a/source/ps/SavedGame.cpp b/source/ps/SavedGame.cpp index 0a8d76e51d..f8524df20d 100644 --- a/source/ps/SavedGame.cpp +++ b/source/ps/SavedGame.cpp @@ -20,7 +20,6 @@ #include "SavedGame.h" #include "graphics/GameView.h" -#include "gui/GUIManager.h" #include "i18n/L10n.h" #include "lib/allocators/shared_ptr.h" #include "lib/file/archive/archive_zip.h" diff --git a/source/ps/VisualReplay.cpp b/source/ps/VisualReplay.cpp index b3dea66e6d..0c0a05ac45 100644 --- a/source/ps/VisualReplay.cpp +++ b/source/ps/VisualReplay.cpp @@ -19,7 +19,6 @@ #include "VisualReplay.h" #include "graphics/GameView.h" -#include "gui/GUIManager.h" #include "lib/allocators/shared_ptr.h" #include "lib/external_libraries/libsdl.h" #include "lib/utf8.h" diff --git a/source/renderer/PostprocManager.cpp b/source/renderer/PostprocManager.cpp index bb50cab0c9..047d6ab7e5 100644 --- a/source/renderer/PostprocManager.cpp +++ b/source/renderer/PostprocManager.cpp @@ -22,7 +22,6 @@ #include "graphics/GameView.h" #include "graphics/LightEnv.h" #include "graphics/ShaderManager.h" -#include "gui/GUIutil.h" #include "lib/bits.h" #include "lib/ogl.h" #include "maths/MathUtil.h" diff --git a/source/tools/atlas/GameInterface/Handlers/GraphicsSetupHandlers.cpp b/source/tools/atlas/GameInterface/Handlers/GraphicsSetupHandlers.cpp index 33fb52f6e1..c57ef463ea 100644 --- a/source/tools/atlas/GameInterface/Handlers/GraphicsSetupHandlers.cpp +++ b/source/tools/atlas/GameInterface/Handlers/GraphicsSetupHandlers.cpp @@ -25,7 +25,6 @@ #include "graphics/GameView.h" #include "graphics/ObjectManager.h" -#include "gui/GUIManager.h" #include "lib/external_libraries/libsdl.h" #include "lib/ogl.h" #include "maths/MathUtil.h"