Index: source/gui/CButton.cpp =================================================================== --- source/gui/CButton.cpp +++ source/gui/CButton.cpp @@ -20,7 +20,7 @@ #include "CButton.h" #include "gui/CGUIColor.h" -#include "lib/ogl.h" +#include "gui/CGUIText.h" CButton::CButton(CGUI& pGUI) : IGUIObject(pGUI), IGUIButtonBehavior(pGUI), IGUITextOwner(pGUI) Index: source/gui/CChart.h =================================================================== --- source/gui/CChart.h +++ source/gui/CChart.h @@ -18,6 +18,8 @@ #ifndef INCLUDED_CCHART #define INCLUDED_CCHART +#include "graphics/ShaderProgramPtr.h" +#include "gui/CGUIColor.h" #include "gui/IGUITextOwner.h" #include "maths/Vector2D.h" Index: source/gui/CChart.cpp =================================================================== --- source/gui/CChart.cpp +++ source/gui/CChart.cpp @@ -19,18 +19,14 @@ #include "CChart.h" -#include "gui/CGUIColor.h" +#include "graphics/ShaderManager.h" #include "gui/CGUIList.h" #include "gui/CGUISeries.h" #include "gui/CGUIString.h" #include "gui/GUIMatrix.h" -#include "graphics/ShaderManager.h" -#include "i18n/L10n.h" -#include "lib/ogl.h" #include "ps/CLogger.h" #include "ps/Profile.h" #include "renderer/Renderer.h" -#include "third_party/cppformat/format.h" #include Index: source/gui/CDropDown.h =================================================================== --- source/gui/CDropDown.h +++ source/gui/CDropDown.h @@ -28,9 +28,7 @@ #ifndef INCLUDED_CDROPDOWN #define INCLUDED_CDROPDOWN -#include "gui/CGUIList.h" #include "gui/CList.h" -#include "gui/IGUIScrollBar.h" #include Index: source/gui/CDropDown.cpp =================================================================== --- source/gui/CDropDown.cpp +++ source/gui/CDropDown.cpp @@ -21,8 +21,9 @@ #include "gui/CGUI.h" #include "gui/CGUIColor.h" +#include "gui/CGUIList.h" +#include "gui/IGUIScrollBar.h" #include "lib/external_libraries/libsdl.h" -#include "lib/ogl.h" #include "lib/timer.h" #include "ps/Profile.h" Index: source/gui/CGUI.h =================================================================== --- source/gui/CGUI.h +++ source/gui/CGUI.h @@ -23,9 +23,10 @@ #ifndef INCLUDED_CGUI #define INCLUDED_CGUI -#include "gui/GUITooltip.h" -#include "gui/GUIbase.h" +#include "gui/CGUIColor.h" #include "gui/CGUIDummyObject.h" +#include "gui/GUIbase.h" +#include "gui/GUITooltip.h" #include "lib/input.h" #include "ps/Shapes.h" #include "ps/XML/Xeromyces.h" @@ -53,10 +54,6 @@ }; class CGUISpriteInstance; -struct CGUIColor; -class CGUIText; -struct SGUIIcon; -class CGUIString; class CGUISprite; struct SGUIImageEffects; struct SGUIScrollBarStyle; @@ -166,16 +163,16 @@ bool ObjectExists(const CStr& Name) const; /** - * Returns the GUI object with the desired name, or NULL + * Returns the GUI object with the desired name, or nullptr * if no match is found, * * @param Name String name of object - * @return Matching object, or NULL + * @return Matching object, or nullptr */ IGUIObject* FindObjectByName(const CStr& Name) const; /** - * Returns the GUI object under the mouse, or NULL if none. + * Returns the GUI object under the mouse, or nullptr if none. */ IGUIObject* FindObjectUnderMouse(); @@ -222,7 +219,7 @@ /** * Check if an icon exists */ - bool HasIcon(const CStr& name) const { return (m_Icons.count(name) != 0); } + bool HasIcon(const CStr& name) const { return (m_Icons.find(name) != m_Icons.end()); } /** * Get Icon (a const reference, can never be changed) @@ -232,7 +229,7 @@ /** * Check if a style exists */ - bool HasStyle(const CStr& name) const { return (m_Styles.count(name) != 0); } + bool HasStyle(const CStr& name) const { return (m_Styles.find(name) != m_Styles.end()); } /** * Get Style if it exists, otherwise throws an exception. @@ -242,7 +239,7 @@ /** * Check if a predefined color of that name exists. */ - bool HasPreDefinedColor(const CStr& name) const { return (m_PreDefinedColors.count(name) != 0); } + bool HasPreDefinedColor(const CStr& name) const { return (m_PreDefinedColors.find(name) != m_PreDefinedColors.end()); } /** * Resolve the predefined color if it exists, otherwise throws an exception. @@ -293,7 +290,7 @@ /** * Change focus to new object. * Will send LOST_FOCUS/GOT_FOCUS messages as appropriate. - * pObject can be NULL to remove all focus. + * pObject can be nullptr to remove all focus. */ void SetFocusedObject(IGUIObject* pObject); @@ -624,7 +621,7 @@ * IGUIObjects by name... For instance m_ObjectTypes["button"] * is filled with a function that will "return new CButton();" */ - std::map m_ObjectTypes; + std::map m_ObjectTypes; /** * Map from hotkey names to objects that listen to the hotkey. Index: source/gui/CGUI.cpp =================================================================== --- source/gui/CGUI.cpp +++ source/gui/CGUI.cpp @@ -17,9 +17,6 @@ #include "precompiled.h" -#include -#include - #include "CGUI.h" // Types - when including them into the engine. @@ -38,8 +35,7 @@ #include "CTooltip.h" #include "MiniMap.h" -#include "graphics/FontMetrics.h" -#include "graphics/ShaderManager.h" +#include "gui/IGUIScrollBar.h" #include "i18n/L10n.h" #include "lib/bits.h" #include "lib/input.h" @@ -58,6 +54,8 @@ #include "scripting/ScriptFunctions.h" #include "scriptinterface/ScriptInterface.h" +#include + extern int g_yres; const double SELECT_DBLCLICK_RATE = 0.5; @@ -71,7 +69,7 @@ { const char* hotkey = static_cast(ev->ev.user.data1); - if (m_GlobalHotkeys.count(hotkey) && ev->ev.type == SDL_HOTKEYDOWN) + if (m_GlobalHotkeys.find(hotkey) != m_GlobalHotkeys.end() && ev->ev.type == SDL_HOTKEYDOWN) { ret = IN_HANDLED; @@ -127,7 +125,7 @@ } // Only one object can be hovered - IGUIObject* pNearest = NULL; + IGUIObject* pNearest = nullptr; // TODO Gee: (2004-09-08) Big TODO, don't do the below if the SDL_Event is something like a keypress! try @@ -136,7 +134,7 @@ // TODO Gee: Optimizations needed! // these two recursive function are quite overhead heavy. - // pNearest will after this point at the hovered object, possibly NULL + // pNearest will after this point at the hovered object, possibly nullptr pNearest = FindObjectUnderMouse(); // Now we'll call UpdateMouseOver on *all* objects, @@ -304,8 +302,9 @@ IGUIObject* CGUI::ConstructObject(const CStr& str) { - if (m_ObjectTypes.count(str) > 0) - return (*m_ObjectTypes[str])(*this); + std::map::iterator it = m_ObjectTypes.find(str); + if (it != m_ObjectTypes.end()) + return (*it->second)(*this); // Error reporting will be handled with the nullptr return. return nullptr; @@ -405,21 +404,22 @@ bool CGUI::ObjectExists(const CStr& Name) const { - return m_pAllObjects.count(Name) != 0; + return m_pAllObjects.find(Name) != m_pAllObjects.end(); } IGUIObject* CGUI::FindObjectByName(const CStr& Name) const { map_pObjects::const_iterator it = m_pAllObjects.find(Name); + if (it == m_pAllObjects.end()) - return NULL; - else - return it->second; + return nullptr; + + return it->second; } IGUIObject* CGUI::FindObjectUnderMouse() { - IGUIObject* pNearest = NULL; + IGUIObject* pNearest = nullptr; m_BaseObject.RecurseObject(&IGUIObject::IsHiddenOrGhost, &IGUIObject::ChooseMouseOverAndClosest, pNearest); return pNearest; } @@ -645,12 +645,12 @@ // CStr argStyle(attributes.GetNamedItem(attr_style)); - if (m_Styles.count("default") == 1) + if (m_Styles.find("default") != m_Styles.end()) object->LoadStyle("default"); if (!argStyle.empty()) { - if (m_Styles.count(argStyle) == 0) + if (m_Styles.find(argStyle) == m_Styles.end()) LOGERROR("GUI: Trying to use style '%s' that doesn't exist.", argStyle.c_str()); else object->LoadStyle(argStyle); Index: source/gui/CGUIColor.cpp =================================================================== --- source/gui/CGUIColor.cpp +++ source/gui/CGUIColor.cpp @@ -18,8 +18,9 @@ #include "precompiled.h" #include "CGUIColor.h" -#include "ps/CStr.h" + #include "gui/CGUI.h" +#include "ps/CStr.h" bool CGUIColor::ParseString(const CGUI& pGUI, const CStr& value, int defaultAlpha) { Index: source/gui/CGUIScrollBarVertical.cpp =================================================================== --- source/gui/CGUIScrollBarVertical.cpp +++ source/gui/CGUIScrollBarVertical.cpp @@ -22,7 +22,6 @@ #include "gui/CGUI.h" #include "ps/CLogger.h" - CGUIScrollBarVertical::CGUIScrollBarVertical(CGUI& pGUI) : IGUIScrollBar(pGUI) { Index: source/gui/CGUISprite.h =================================================================== --- source/gui/CGUISprite.h +++ source/gui/CGUISprite.h @@ -23,10 +23,8 @@ #ifndef INCLUDED_CGUISPRITE #define INCLUDED_CGUISPRITE -#include "GUIbase.h" - +#include "gui/GUIbase.h" #include "gui/GUIRenderer.h" -#include "lib/res/graphics/ogl_tex.h" #include #include @@ -55,41 +53,41 @@ } // Filename of the texture - VfsPath m_TextureName; + VfsPath m_TextureName; // Image placement (relative to object) - CClientArea m_Size; + CClientArea m_Size; // Texture placement (relative to image placement) - CClientArea m_TextureSize; + CClientArea m_TextureSize; // Because OpenGL wants textures in squares with a power of 2 (64x64, 256x256) // it's sometimes tedious to adjust this. So this value simulates which area // is the real texture - CRect m_TexturePlacementInFile; + CRect m_TexturePlacementInFile; // For textures that contain a collection of icons (e.g. unit portraits), this // will be set to the size of one icon. An object's cell-id will determine // which part of the texture is used. // Equal to CSize(0,0) for non-celled textures. - CSize m_CellSize; + CSize m_CellSize; /** * If non-zero, then the image's width will be adjusted when rendering so that * the width:height ratio equals this value. */ - float m_FixedHAspectRatio; + float m_FixedHAspectRatio; /** * If true, the image's coordinates will be rounded to integer pixels when * rendering, to avoid blurry filtering. */ - bool m_RoundCoordinates; + bool m_RoundCoordinates; /** * Texture wrapping mode (GL_REPEAT, GL_CLAMP_TO_EDGE, etc) */ - GLint m_WrapMode; + GLint m_WrapMode; // Visual effects (e.g. color modulation) std::shared_ptr m_Effects; @@ -99,14 +97,14 @@ CGUIColor m_BorderColor; // 0 or 1 pixel border is the only option - bool m_Border; + bool m_Border; /** * Z value modification of the image. * Inputted in XML as x-level, although it just an easier and safer * way of declaring delta-z. */ - float m_DeltaZ; + float m_DeltaZ; }; /** Index: source/gui/CGUIString.h =================================================================== --- source/gui/CGUIString.h +++ source/gui/CGUIString.h @@ -18,7 +18,6 @@ #ifndef INCLUDED_CGUISTRING #define INCLUDED_CGUISTRING -#include "gui/CGUISprite.h" #include "gui/CGUIText.h" #include "ps/CStrIntern.h" @@ -188,12 +187,12 @@ * @param from From character n, * @param to to character n. * @param FirstLine Whether this is the first line of text, to calculate its height correctly - * @param pObject Only for Error outputting, optional! If NULL + * @param pObject Only for Error outputting, optional! If nullptr * then no Errors will be reported! Useful when you need * to make several GenerateTextCall in different phases, * it avoids duplicates. */ - void GenerateTextCall(const CGUI& pGUI, SFeedback& Feedback, CStrIntern DefaultFont, const int& from, const int& to, const bool FirstLine, const IGUIObject* pObject = NULL) const; + void GenerateTextCall(const CGUI& pGUI, SFeedback& Feedback, CStrIntern DefaultFont, const int& from, const int& to, const bool FirstLine, const IGUIObject* pObject = nullptr) const; /** * Words Index: source/gui/CGUIText.h =================================================================== --- source/gui/CGUIText.h +++ source/gui/CGUIText.h @@ -20,7 +20,6 @@ #include "gui/CGUIColor.h" #include "gui/CGUISprite.h" -#include "graphics/TextRenderer.h" #include "ps/CStrIntern.h" #include "ps/Shapes.h" @@ -96,7 +95,7 @@ STextCall() : m_UseCustomColor(false), m_Bold(false), m_Italic(false), m_Underlined(false), - m_pSpriteCall(NULL) {} + m_pSpriteCall(nullptr) {} /** * Position @@ -135,7 +134,7 @@ bool m_Bold, m_Italic, m_Underlined; /** - * *IF* an icon, then this is not NULL. + * *IF* an icon, then this is not nullptr. */ std::list::pointer m_pSpriteCall; }; Index: source/gui/CGUIText.cpp =================================================================== --- source/gui/CGUIText.cpp +++ source/gui/CGUIText.cpp @@ -19,11 +19,12 @@ #include "CGUIText.h" +#include "graphics/FontMetrics.h" +#include "graphics/ShaderManager.h" +#include "graphics/TextRenderer.h" #include "gui/CGUI.h" #include "gui/CGUIString.h" #include "gui/IGUIObject.h" -#include "graphics/FontMetrics.h" -#include "graphics/ShaderManager.h" #include "renderer/Renderer.h" #include Index: source/gui/CImage.cpp =================================================================== --- source/gui/CImage.cpp +++ source/gui/CImage.cpp @@ -20,7 +20,6 @@ #include "CImage.h" #include "gui/CGUI.h" -#include "lib/ogl.h" CImage::CImage(CGUI& pGUI) : IGUIObject(pGUI) Index: source/gui/CInput.h =================================================================== --- source/gui/CInput.h +++ source/gui/CInput.h @@ -146,8 +146,11 @@ // pointer should be placed when the input control is pressed. struct SRow { - int m_ListStart; /// Where does the Row starts - std::vector m_ListOfX; /// List of X values for each character. + // Where the Row starts + int m_ListStart; + + // List of X values for each character. + std::vector m_ListOfX; }; /** Index: source/gui/CInput.cpp =================================================================== --- source/gui/CInput.cpp +++ source/gui/CInput.cpp @@ -24,7 +24,6 @@ #include "graphics/FontMetrics.h" #include "graphics/ShaderManager.h" #include "graphics/TextRenderer.h" -#include "lib/ogl.h" #include "lib/sysdep/clipboard.h" #include "lib/timer.h" #include "lib/utf8.h" Index: source/gui/COList.h =================================================================== --- source/gui/COList.h +++ source/gui/COList.h @@ -18,6 +18,7 @@ #define INCLUDED_COLIST #include "CList.h" +#include "gui/CGUIColor.h" #include Index: source/gui/CProgressBar.cpp =================================================================== --- source/gui/CProgressBar.cpp +++ source/gui/CProgressBar.cpp @@ -20,7 +20,6 @@ #include "CProgressBar.h" #include "gui/CGUI.h" -#include "lib/ogl.h" CProgressBar::CProgressBar(CGUI& pGUI) : IGUIObject(pGUI) Index: source/gui/CSlider.cpp =================================================================== --- source/gui/CSlider.cpp +++ source/gui/CSlider.cpp @@ -20,7 +20,6 @@ #include "CSlider.h" #include "gui/CGUI.h" -#include "lib/ogl.h" CSlider::CSlider(CGUI& pGUI) : IGUIObject(pGUI), m_IsPressed(false), m_ButtonSide(0) Index: source/gui/CText.cpp =================================================================== --- source/gui/CText.cpp +++ source/gui/CText.cpp @@ -21,7 +21,7 @@ #include "gui/CGUI.h" #include "gui/CGUIScrollBarVertical.h" -#include "lib/ogl.h" +#include "gui/CGUIText.h" CText::CText(CGUI& pGUI) : IGUIObject(pGUI), IGUIScrollBarOwner(pGUI), IGUITextOwner(pGUI) Index: source/gui/CTooltip.cpp =================================================================== --- source/gui/CTooltip.cpp +++ source/gui/CTooltip.cpp @@ -20,6 +20,7 @@ #include "CTooltip.h" #include "gui/CGUI.h" +#include "gui/CGUIText.h" #include Index: source/gui/GUIManager.h =================================================================== --- source/gui/GUIManager.h +++ source/gui/GUIManager.h @@ -18,23 +18,17 @@ #ifndef INCLUDED_GUIMANAGER #define INCLUDED_GUIMANAGER -#include -#include - -#include "lib/input.h" #include "lib/file/vfs/vfs_path.h" +#include "lib/input.h" #include "ps/CStr.h" #include "ps/TemplateLoader.h" -#include "scriptinterface/ScriptVal.h" #include "scriptinterface/ScriptInterface.h" +#include #include +#include class CGUI; -class JSObject; -class IGUIObject; -struct CGUIColor; -struct SGUIIcon; /** * External interface to the GUI system. Index: source/gui/GUIManager.cpp =================================================================== --- source/gui/GUIManager.cpp +++ source/gui/GUIManager.cpp @@ -21,15 +21,15 @@ #include "gui/CGUI.h" #include "lib/timer.h" -#include "ps/Filesystem.h" #include "ps/CLogger.h" +#include "ps/Filesystem.h" +#include "ps/GameSetup/Config.h" #include "ps/Profile.h" #include "ps/XML/Xeromyces.h" -#include "ps/GameSetup/Config.h" #include "scriptinterface/ScriptInterface.h" #include "scriptinterface/ScriptRuntime.h" -CGUIManager* g_GUI = NULL; +CGUIManager* g_GUI = nullptr; // General TODOs: @@ -266,7 +266,7 @@ Status CGUIManager::ReloadChangedFile(const VfsPath& path) { for (SGUIPage& p : m_PageStack) - if (p.inputs.count(path)) + if (p.inputs.find(path) != p.inputs.end()) { LOGMESSAGE("GUI file '%s' changed - reloading page '%s'", path.string8(), utf8_from_wstring(p.name)); p.LoadPage(m_ScriptRuntime); Index: source/gui/GUIRenderer.h =================================================================== --- source/gui/GUIRenderer.h +++ source/gui/GUIRenderer.h @@ -29,7 +29,6 @@ #include class CGUISprite; -struct SGUIImageEffects; struct SGUIImage; namespace GUIRenderer Index: source/gui/GUIRenderer.cpp =================================================================== --- source/gui/GUIRenderer.cpp +++ source/gui/GUIRenderer.cpp @@ -27,17 +27,15 @@ #include "gui/GUIMatrix.h" #include "i18n/L10n.h" #include "lib/ogl.h" -#include "lib/utf8.h" #include "lib/res/h_mgr.h" #include "lib/tex/tex.h" +#include "lib/utf8.h" #include "ps/CLogger.h" #include "ps/Filesystem.h" #include "renderer/Renderer.h" - using namespace GUIRenderer; - DrawCalls::DrawCalls() { } Index: source/gui/GUITooltip.cpp =================================================================== --- source/gui/GUITooltip.cpp +++ source/gui/GUITooltip.cpp @@ -75,7 +75,7 @@ }; GUITooltip::GUITooltip() -: m_State(ST_IN_MOTION), m_PreviousObject(NULL), m_PreviousTooltipName() +: m_State(ST_IN_MOTION), m_PreviousObject(nullptr), m_PreviousTooltipName() { } Index: source/gui/GUIbase.h =================================================================== --- source/gui/GUIbase.h +++ source/gui/GUIbase.h @@ -25,7 +25,6 @@ #ifndef INCLUDED_GUIBASE #define INCLUDED_GUIBASE -#include "gui/CGUIColor.h" #include "ps/CStr.h" #include "ps/Errors.h" #include "ps/Shapes.h" @@ -34,6 +33,7 @@ #include #include +class CGUI; class IGUIObject; #define GUI_OBJECT(obj) \ Index: source/gui/IGUIObject.h =================================================================== --- source/gui/IGUIObject.h +++ source/gui/IGUIObject.h @@ -34,14 +34,8 @@ #include #include -struct SGUIStyle; -class JSObject; class IGUISetting; -template class GUI; - -ERROR_TYPE(GUI, UnableToParse); - /** * GUI object such as a button or an input-box. * Abstract data type ! @@ -49,8 +43,6 @@ class IGUIObject { friend class CGUI; - friend class IGUIScrollBar; - friend class GUITooltip; // Allow getProperty to access things like GetParent() friend bool JSI_IGUIObject::getProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp); @@ -339,7 +331,7 @@ * NOTE! This will not just return m_pParent, when that is * need use it! There is one exception to it, when the parent is * the top-node (the object that isn't a real object), this - * will return NULL, so that the top-node's children are + * will return nullptr, so that the top-node's children are * seemingly parentless. * * @return Pointer to parent @@ -400,8 +392,7 @@ * updates this object accordingly (i.e. if it's the object * being inputted one thing happens, and not, another). * - * @param pMouseOver Object that is currently hovered, - * can OF COURSE be NULL too! + * @param pMouseOver Object that is currently hovered, can be nullptr too! */ void UpdateMouseOver(IGUIObject* const& pMouseOver); @@ -428,9 +419,9 @@ * if hovered, if so, then check if this's Z value is greater * than the inputted object... If so then the object is closer * and we'll replace the pointer with this. - * Also Notice input can be NULL, which means the Z value demand - * is out. NOTICE you can't input NULL as const so you'll have - * to set an object to NULL. + * Also Notice input can be nullptr, which means the Z value demand + * is out. NOTICE you can't input nullptr as const so you'll have + * to set an object to nullptr. * * @param pObject Object pointer, can be either the old one, or * the new one. @@ -454,18 +445,16 @@ void TraceMember(JSTracer* trc); - // Variables - +// Variables protected: // Name of object - CStr m_Name; + CStr m_Name; - // Constructed on the heap, will be destroyed along with the the object - // TODO Gee: really the above? - vector_pObjects m_Children; + // Constructed on the heap, will be destroyed along with the the CGUI + vector_pObjects m_Children; // Pointer to parent - IGUIObject *m_pParent; + IGUIObject* m_pParent; //This represents the last click time for each mouse button double m_LastClickTime[6]; @@ -485,7 +474,7 @@ // More variables // Is mouse hovering the object? used with the function IsMouseOver() - bool m_MouseHovering; + bool m_MouseHovering; /** * Settings pool, all an object's settings are located here @@ -503,10 +492,10 @@ CGUI& m_pGUI; // Internal storage for registered script handlers. - std::map > m_ScriptHandlers; + std::map > m_ScriptHandlers; // Cached JSObject representing this GUI object - JS::PersistentRootedObject m_JSObject; + JS::PersistentRootedObject m_JSObject; }; #endif // INCLUDED_IGUIOBJECT Index: source/gui/IGUIObject.cpp =================================================================== --- source/gui/IGUIObject.cpp +++ source/gui/IGUIObject.cpp @@ -17,18 +17,20 @@ #include "precompiled.h" +#include "gui/IGUIObject.h" + #include "gui/CGUI.h" #include "gui/CGUISetting.h" #include "gui/scripting/JSInterface_GUITypes.h" #include "gui/scripting/JSInterface_IGUIObject.h" -#include "ps/GameSetup/Config.h" #include "ps/CLogger.h" +#include "ps/GameSetup/Config.h" #include "ps/Profile.h" #include "scriptinterface/ScriptInterface.h" #include "soundmanager/ISoundManager.h" IGUIObject::IGUIObject(CGUI& pGUI) - : m_pGUI(pGUI), m_pParent(NULL), m_MouseHovering(false), m_LastClickTime() + : m_pGUI(pGUI), m_pParent(nullptr), m_MouseHovering(false), m_LastClickTime() { AddSetting("enabled"); AddSetting("hidden"); @@ -93,7 +95,7 @@ void IGUIObject::AddToPointersMap(map_pObjects& ObjectMap) { // Just don't do anything about the top node - if (m_pParent == NULL) + if (m_pParent == nullptr) return; // Now actually add this one @@ -103,7 +105,8 @@ { throw PSERROR_GUI_ObjectNeedsName(); } - if (ObjectMap.count(m_Name) > 0) + + if (ObjectMap.find(m_Name) != ObjectMap.end()) { throw PSERROR_GUI_NameAmbiguity(m_Name.c_str()); } @@ -124,7 +127,7 @@ bool IGUIObject::SettingExists(const CStr& Setting) const { - return m_Settings.count(Setting) == 1; + return m_Settings.find(Setting) != m_Settings.end(); } template @@ -232,7 +235,7 @@ return; // Check if we've got competition at all - if (pObject == NULL) + if (pObject == nullptr) { pObject = this; return; @@ -250,11 +253,8 @@ { // Important, we're not using GetParent() for these // checks, that could screw it up - if (m_pParent) - { - if (m_pParent->m_pParent == NULL) - return NULL; - } + if (m_pParent && m_pParent->m_pParent == nullptr) + return nullptr; return m_pParent; } Index: source/gui/IGUIScrollBar.cpp =================================================================== --- source/gui/IGUIScrollBar.cpp +++ source/gui/IGUIScrollBar.cpp @@ -69,7 +69,7 @@ const SGUIScrollBarStyle* IGUIScrollBar::GetStyle() const { if (!m_pHostObject) - return NULL; + return nullptr; return m_pHostObject->GetScrollBarStyle(m_ScrollBarStyle); } Index: source/gui/IGUITextOwner.h =================================================================== --- source/gui/IGUITextOwner.h +++ source/gui/IGUITextOwner.h @@ -30,12 +30,15 @@ #ifndef INCLUDED_IGUITEXTOWNER #define INCLUDED_IGUITEXTOWNER -#include "gui/CGUIText.h" #include "gui/IGUIObject.h" #include "gui/scripting/JSInterface_IGUITextOwner.h" #include +struct CGUIColor; +class CGUIText; +class CGUIString; + /** * Framework for handling Output text. */ Index: source/gui/IGUITextOwner.cpp =================================================================== --- source/gui/IGUITextOwner.cpp +++ source/gui/IGUITextOwner.cpp @@ -20,6 +20,7 @@ #include "IGUITextOwner.h" #include "gui/CGUI.h" +#include "gui/CGUIString.h" #include "gui/scripting/JSInterface_IGUITextOwner.h" #include Index: source/gui/MiniMap.cpp =================================================================== --- source/gui/MiniMap.cpp +++ source/gui/MiniMap.cpp @@ -17,8 +17,6 @@ #include "precompiled.h" -#include - #include "MiniMap.h" #include "graphics/GameView.h" @@ -46,10 +44,12 @@ #include "renderer/RenderingOptions.h" #include "renderer/WaterManager.h" #include "scriptinterface/ScriptInterface.h" -#include "simulation2/Simulation2.h" #include "simulation2/components/ICmpMinimap.h" +#include "simulation2/Simulation2.h" #include "simulation2/system/ParamNode.h" +#include + extern bool g_GameRestarted; // Set max drawn entities to UINT16_MAX for now, which is more than enough Index: source/gui/scripting/GuiScriptConversions.cpp =================================================================== --- source/gui/scripting/GuiScriptConversions.cpp +++ source/gui/scripting/GuiScriptConversions.cpp @@ -123,7 +123,7 @@ template<> void ScriptInterface::ToJSVal(JSContext* UNUSED(cx), JS::MutableHandleValue ret, IGUIObject* const& val) { - if (val == NULL) + if (val == nullptr) ret.setNull(); else ret.setObject(*val->GetJSObject()); Index: source/gui/scripting/JSInterface_GUITypes.cpp =================================================================== --- source/gui/scripting/JSInterface_GUITypes.cpp +++ source/gui/scripting/JSInterface_GUITypes.cpp @@ -121,5 +121,5 @@ void JSI_GUITypes::init(ScriptInterface& scriptInterface) { - scriptInterface.DefineCustomObjectType(&JSI_GUISize::JSI_class, JSI_GUISize::construct, 1, nullptr, JSI_GUISize::JSI_methods, NULL, NULL); + scriptInterface.DefineCustomObjectType(&JSI_GUISize::JSI_class, JSI_GUISize::construct, 1, nullptr, JSI_GUISize::JSI_methods, nullptr, nullptr); } Index: source/gui/scripting/ScriptFunctions.cpp =================================================================== --- source/gui/scripting/ScriptFunctions.cpp +++ source/gui/scripting/ScriptFunctions.cpp @@ -17,7 +17,7 @@ #include "precompiled.h" -#include "scriptinterface/ScriptInterface.h" +#include "ScriptFunctions.h" #include "graphics/scripting/JSInterface_GameView.h" #include "gui/IGUIObject.h" @@ -38,6 +38,7 @@ #include "ps/scripting/JSInterface_VFS.h" #include "ps/scripting/JSInterface_VisualReplay.h" #include "renderer/scripting/JSInterface_Renderer.h" +#include "scriptinterface/ScriptInterface.h" #include "simulation2/scripting/JSInterface_Simulation.h" #include "soundmanager/scripting/JSInterface_Sound.h" Index: source/ps/Errors.cpp =================================================================== --- source/ps/Errors.cpp +++ source/ps/Errors.cpp @@ -40,7 +40,6 @@ class PSERROR_GUI_NameAmbiguity : public PSERROR_GUI { public: PSERROR_GUI_NameAmbiguity(); PSERROR_GUI_NameAmbiguity(const char* msg); PSRETURN getCode() const; }; class PSERROR_GUI_ObjectNeedsName : public PSERROR_GUI { public: PSERROR_GUI_ObjectNeedsName(); PSERROR_GUI_ObjectNeedsName(const char* msg); PSRETURN getCode() const; }; class PSERROR_GUI_OperationNeedsGUIObject : public PSERROR_GUI { public: PSERROR_GUI_OperationNeedsGUIObject(); PSERROR_GUI_OperationNeedsGUIObject(const char* msg); PSRETURN getCode() const; }; -class PSERROR_GUI_UnableToParse : public PSERROR_GUI { public: PSERROR_GUI_UnableToParse(); PSERROR_GUI_UnableToParse(const char* msg); PSRETURN getCode() const; }; class PSERROR_Game_World_MapLoadFailed : public PSERROR_Game_World { public: PSERROR_Game_World_MapLoadFailed(); PSERROR_Game_World_MapLoadFailed(const char* msg); PSRETURN getCode() const; }; class PSERROR_Scripting_CallFunctionFailed : public PSERROR_Scripting { public: PSERROR_Scripting_CallFunctionFailed(); PSERROR_Scripting_CallFunctionFailed(const char* msg); PSRETURN getCode() const; }; class PSERROR_Scripting_CreateObjectFailed : public PSERROR_Scripting { public: PSERROR_Scripting_CreateObjectFailed(); PSERROR_Scripting_CreateObjectFailed(const char* msg); PSRETURN getCode() const; }; @@ -83,7 +82,6 @@ extern const PSRETURN PSRETURN_GUI_NameAmbiguity = 0x06000003; extern const PSRETURN PSRETURN_GUI_ObjectNeedsName = 0x06000004; extern const PSRETURN PSRETURN_GUI_OperationNeedsGUIObject = 0x06000005; -extern const PSRETURN PSRETURN_GUI_UnableToParse = 0x06000006; extern const PSRETURN PSRETURN_Game_World_MapLoadFailed = 0x07030001; extern const PSRETURN PSRETURN_Scripting_DefineType_AlreadyExists = 0x08010001; extern const PSRETURN PSRETURN_Scripting_DefineType_CreationFailed = 0x08010002; @@ -175,8 +173,6 @@ extern const PSRETURN CODE__PSRETURN_GUI_ObjectNeedsName = 0x06000004; extern const PSRETURN MASK__PSRETURN_GUI_OperationNeedsGUIObject = 0xffffffff; extern const PSRETURN CODE__PSRETURN_GUI_OperationNeedsGUIObject = 0x06000005; -extern const PSRETURN MASK__PSRETURN_GUI_UnableToParse = 0xffffffff; -extern const PSRETURN CODE__PSRETURN_GUI_UnableToParse = 0x06000006; extern const PSRETURN MASK__PSRETURN_Game_World_MapLoadFailed = 0xffffffff; extern const PSRETURN CODE__PSRETURN_Game_World_MapLoadFailed = 0x07030001; extern const PSRETURN MASK__PSRETURN_Scripting_DefineType_AlreadyExists = 0xffffffff; @@ -315,10 +311,6 @@ PSERROR_GUI_OperationNeedsGUIObject::PSERROR_GUI_OperationNeedsGUIObject(const char* msg) : PSERROR_GUI(msg) { } PSRETURN PSERROR_GUI_OperationNeedsGUIObject::getCode() const { return 0x06000005; } -PSERROR_GUI_UnableToParse::PSERROR_GUI_UnableToParse() : PSERROR_GUI(NULL) { } -PSERROR_GUI_UnableToParse::PSERROR_GUI_UnableToParse(const char* msg) : PSERROR_GUI(msg) { } -PSRETURN PSERROR_GUI_UnableToParse::getCode() const { return 0x06000006; } - PSERROR_Game_World_MapLoadFailed::PSERROR_Game_World_MapLoadFailed() : PSERROR_Game_World(NULL) { } PSERROR_Game_World_MapLoadFailed::PSERROR_Game_World_MapLoadFailed(const char* msg) : PSERROR_Game_World(msg) { } PSRETURN PSERROR_Game_World_MapLoadFailed::getCode() const { return 0x07030001; } @@ -435,7 +427,6 @@ case 0x06000003: return "GUI_NameAmbiguity"; case 0x06000004: return "GUI_ObjectNeedsName"; case 0x06000005: return "GUI_OperationNeedsGUIObject"; - case 0x06000006: return "GUI_UnableToParse"; case 0x07030001: return "Game_World_MapLoadFailed"; case 0x08010001: return "Scripting_DefineType_AlreadyExists"; case 0x08010002: return "Scripting_DefineType_CreationFailed"; @@ -486,7 +477,6 @@ case 0x06000003: throw PSERROR_GUI_NameAmbiguity(); break; case 0x06000004: throw PSERROR_GUI_ObjectNeedsName(); break; case 0x06000005: throw PSERROR_GUI_OperationNeedsGUIObject(); break; - case 0x06000006: throw PSERROR_GUI_UnableToParse(); break; case 0x07030001: throw PSERROR_Game_World_MapLoadFailed(); break; case 0x08010001: throw PSERROR_Scripting_DefineType_AlreadyExists(); break; case 0x08010002: throw PSERROR_Scripting_DefineType_CreationFailed(); break;