Cleanup GUI includes, whitespace, map iterators, nullptr.
Remove TODO comment about m_Children deletion frome21ebb37f5
, refse05f939fab
/ D2311. Differential Revision: https://code.wildfiregames.com/D2321 Tested on: clang 8.0.1, Jenkins This was SVN commit r22976.
This commit is contained in:
parent
e67f364887
commit
b9d413852b
@ -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)
|
||||
|
@ -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 <cmath>
|
||||
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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"
|
||||
|
||||
|
@ -28,9 +28,7 @@ GUI Object - Drop Down (list)
|
||||
#ifndef INCLUDED_CDROPDOWN
|
||||
#define INCLUDED_CDROPDOWN
|
||||
|
||||
#include "gui/CGUIList.h"
|
||||
#include "gui/CList.h"
|
||||
#include "gui/IGUIScrollBar.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
|
@ -17,9 +17,6 @@
|
||||
|
||||
#include "precompiled.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <string>
|
||||
|
||||
#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 <string>
|
||||
|
||||
extern int g_yres;
|
||||
|
||||
const double SELECT_DBLCLICK_RATE = 0.5;
|
||||
@ -71,7 +69,7 @@ InReaction CGUI::HandleEvent(const SDL_Event_* ev)
|
||||
{
|
||||
const char* hotkey = static_cast<const char*>(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 @@ InReaction CGUI::HandleEvent(const SDL_Event_* ev)
|
||||
}
|
||||
|
||||
// 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 @@ InReaction CGUI::HandleEvent(const SDL_Event_* ev)
|
||||
// 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 @@ CGUI::~CGUI()
|
||||
|
||||
IGUIObject* CGUI::ConstructObject(const CStr& str)
|
||||
{
|
||||
if (m_ObjectTypes.count(str) > 0)
|
||||
return (*m_ObjectTypes[str])(*this);
|
||||
std::map<CStr, ConstructObjectFunction>::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 @@ void CGUI::UpdateObjects()
|
||||
|
||||
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 @@ void CGUI::Xeromyces_ReadObject(XMBElement Element, CXeromyces* pFile, IGUIObjec
|
||||
//
|
||||
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);
|
||||
|
@ -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 @@ struct SGUIStyle
|
||||
};
|
||||
|
||||
class CGUISpriteInstance;
|
||||
struct CGUIColor;
|
||||
class CGUIText;
|
||||
struct SGUIIcon;
|
||||
class CGUIString;
|
||||
class CGUISprite;
|
||||
struct SGUIImageEffects;
|
||||
struct SGUIScrollBarStyle;
|
||||
@ -166,16 +163,16 @@ public:
|
||||
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 @@ public:
|
||||
/**
|
||||
* 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 @@ public:
|
||||
/**
|
||||
* 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 @@ public:
|
||||
/**
|
||||
* 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 @@ public:
|
||||
/**
|
||||
* 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 @@ private:
|
||||
* IGUIObjects by name... For instance m_ObjectTypes["button"]
|
||||
* is filled with a function that will "return new CButton();"
|
||||
*/
|
||||
std::map<CStr, ConstructObjectFunction> m_ObjectTypes;
|
||||
std::map<CStr, ConstructObjectFunction> m_ObjectTypes;
|
||||
|
||||
/**
|
||||
* Map from hotkey names to objects that listen to the hotkey.
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include "gui/CGUI.h"
|
||||
#include "ps/CLogger.h"
|
||||
|
||||
|
||||
CGUIScrollBarVertical::CGUIScrollBarVertical(CGUI& pGUI)
|
||||
: IGUIScrollBar(pGUI)
|
||||
{
|
||||
|
@ -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 <map>
|
||||
#include <memory>
|
||||
@ -55,41 +53,41 @@ public:
|
||||
}
|
||||
|
||||
// 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<SGUIImageEffects> m_Effects;
|
||||
@ -99,14 +97,14 @@ public:
|
||||
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;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -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 @@ public:
|
||||
* @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
|
||||
|
@ -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 <math.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 @@ public:
|
||||
STextCall() :
|
||||
m_UseCustomColor(false),
|
||||
m_Bold(false), m_Italic(false), m_Underlined(false),
|
||||
m_pSpriteCall(NULL) {}
|
||||
m_pSpriteCall(nullptr) {}
|
||||
|
||||
/**
|
||||
* Position
|
||||
@ -135,7 +134,7 @@ public:
|
||||
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<SSpriteCall>::pointer m_pSpriteCall;
|
||||
};
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include "CImage.h"
|
||||
|
||||
#include "gui/CGUI.h"
|
||||
#include "lib/ogl.h"
|
||||
|
||||
CImage::CImage(CGUI& pGUI)
|
||||
: IGUIObject(pGUI)
|
||||
|
@ -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"
|
||||
|
@ -146,8 +146,11 @@ protected:
|
||||
// pointer should be placed when the input control is pressed.
|
||||
struct SRow
|
||||
{
|
||||
int m_ListStart; /// Where does the Row starts
|
||||
std::vector<float> 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<float> m_ListOfX;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -18,6 +18,7 @@
|
||||
#define INCLUDED_COLIST
|
||||
|
||||
#include "CList.h"
|
||||
#include "gui/CGUIColor.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include "CProgressBar.h"
|
||||
|
||||
#include "gui/CGUI.h"
|
||||
#include "lib/ogl.h"
|
||||
|
||||
CProgressBar::CProgressBar(CGUI& pGUI)
|
||||
: IGUIObject(pGUI)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "CTooltip.h"
|
||||
|
||||
#include "gui/CGUI.h"
|
||||
#include "gui/CGUIText.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
|
@ -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 @@ void CGUIManager::SGUIPage::PerformCallbackFunction(shared_ptr<ScriptInterface::
|
||||
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);
|
||||
|
@ -18,23 +18,17 @@
|
||||
#ifndef INCLUDED_GUIMANAGER
|
||||
#define INCLUDED_GUIMANAGER
|
||||
|
||||
#include <boost/unordered_set.hpp>
|
||||
#include <set>
|
||||
|
||||
#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 <boost/unordered_set.hpp>
|
||||
#include <string>
|
||||
#include <set>
|
||||
|
||||
class CGUI;
|
||||
class JSObject;
|
||||
class IGUIObject;
|
||||
struct CGUIColor;
|
||||
struct SGUIIcon;
|
||||
|
||||
/**
|
||||
* External interface to the GUI system.
|
||||
|
@ -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()
|
||||
{
|
||||
}
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include <vector>
|
||||
|
||||
class CGUISprite;
|
||||
struct SGUIImageEffects;
|
||||
struct SGUIImage;
|
||||
|
||||
namespace GUIRenderer
|
||||
|
@ -75,7 +75,7 @@ enum
|
||||
};
|
||||
|
||||
GUITooltip::GUITooltip()
|
||||
: m_State(ST_IN_MOTION), m_PreviousObject(NULL), m_PreviousTooltipName()
|
||||
: m_State(ST_IN_MOTION), m_PreviousObject(nullptr), m_PreviousTooltipName()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,6 @@ GUI Core, stuff that the whole GUI uses
|
||||
#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 @@ GUI Core, stuff that the whole GUI uses
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
class CGUI;
|
||||
class IGUIObject;
|
||||
|
||||
#define GUI_OBJECT(obj) \
|
||||
|
@ -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<bool>("enabled");
|
||||
AddSetting<bool>("hidden");
|
||||
@ -93,7 +95,7 @@ void IGUIObject::AddChild(IGUIObject* pChild)
|
||||
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 @@ void IGUIObject::AddToPointersMap(map_pObjects& ObjectMap)
|
||||
{
|
||||
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 @@ void IGUIObject::AddSetting(const CStr& Name)
|
||||
|
||||
bool IGUIObject::SettingExists(const CStr& Setting) const
|
||||
{
|
||||
return m_Settings.count(Setting) == 1;
|
||||
return m_Settings.find(Setting) != m_Settings.end();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@ -232,7 +235,7 @@ void IGUIObject::ChooseMouseOverAndClosest(IGUIObject*& pObject)
|
||||
return;
|
||||
|
||||
// Check if we've got competition at all
|
||||
if (pObject == NULL)
|
||||
if (pObject == nullptr)
|
||||
{
|
||||
pObject = this;
|
||||
return;
|
||||
@ -250,11 +253,8 @@ IGUIObject* IGUIObject::GetParent() const
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
|
@ -34,14 +34,8 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
struct SGUIStyle;
|
||||
class JSObject;
|
||||
class IGUISetting;
|
||||
|
||||
template <typename T> class GUI;
|
||||
|
||||
ERROR_TYPE(GUI, UnableToParse);
|
||||
|
||||
/**
|
||||
* GUI object such as a button or an input-box.
|
||||
* Abstract data type !
|
||||
@ -49,8 +43,6 @@ ERROR_TYPE(GUI, UnableToParse);
|
||||
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 @@ protected:
|
||||
* <b>NOTE!</b> 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 @@ protected:
|
||||
* 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 @@ private:
|
||||
* 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 @@ private:
|
||||
|
||||
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 @@ protected:
|
||||
// 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 @@ protected:
|
||||
CGUI& m_pGUI;
|
||||
|
||||
// Internal storage for registered script handlers.
|
||||
std::map<CStr, JS::Heap<JSObject*> > m_ScriptHandlers;
|
||||
std::map<CStr, JS::Heap<JSObject*> > m_ScriptHandlers;
|
||||
|
||||
// Cached JSObject representing this GUI object
|
||||
JS::PersistentRootedObject m_JSObject;
|
||||
JS::PersistentRootedObject m_JSObject;
|
||||
};
|
||||
|
||||
#endif // INCLUDED_IGUIOBJECT
|
||||
|
@ -69,7 +69,7 @@ void IGUIScrollBar::SetupBarSize()
|
||||
const SGUIScrollBarStyle* IGUIScrollBar::GetStyle() const
|
||||
{
|
||||
if (!m_pHostObject)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
return m_pHostObject->GetScrollBarStyle(m_ScrollBarStyle);
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "IGUITextOwner.h"
|
||||
|
||||
#include "gui/CGUI.h"
|
||||
#include "gui/CGUIString.h"
|
||||
#include "gui/scripting/JSInterface_IGUITextOwner.h"
|
||||
|
||||
#include <math.h>
|
||||
|
@ -30,12 +30,15 @@ GUI Object Base - Text Owner
|
||||
#ifndef INCLUDED_IGUITEXTOWNER
|
||||
#define INCLUDED_IGUITEXTOWNER
|
||||
|
||||
#include "gui/CGUIText.h"
|
||||
#include "gui/IGUIObject.h"
|
||||
#include "gui/scripting/JSInterface_IGUITextOwner.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
struct CGUIColor;
|
||||
class CGUIText;
|
||||
class CGUIString;
|
||||
|
||||
/**
|
||||
* Framework for handling Output text.
|
||||
*/
|
||||
|
@ -17,8 +17,6 @@
|
||||
|
||||
#include "precompiled.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#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 <math.h>
|
||||
|
||||
extern bool g_GameRestarted;
|
||||
|
||||
// Set max drawn entities to UINT16_MAX for now, which is more than enough
|
||||
|
@ -123,7 +123,7 @@ template<> void ScriptInterface::ToJSVal<SDL_Event_>(JSContext* cx, JS::MutableH
|
||||
|
||||
template<> void ScriptInterface::ToJSVal<IGUIObject*>(JSContext* UNUSED(cx), JS::MutableHandleValue ret, IGUIObject* const& val)
|
||||
{
|
||||
if (val == NULL)
|
||||
if (val == nullptr)
|
||||
ret.setNull();
|
||||
else
|
||||
ret.setObject(*val->GetJSObject());
|
||||
|
@ -121,5 +121,5 @@ bool JSI_GUISize::toString(JSContext* cx, uint argc, JS::Value* vp)
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -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
|
||||
@ -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"
|
||||
|
||||
|
@ -40,7 +40,6 @@ class PSERROR_GUI_JSOpenFailed : public PSERROR_GUI { public: PSERROR_GUI_JSOpen
|
||||
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_JSOpenFailed = 0x06000002;
|
||||
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 MASK__PSRETURN_GUI_ObjectNeedsName = 0xffffffff;
|
||||
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() : PSE
|
||||
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 @@ const char* GetErrorString(PSRETURN code)
|
||||
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 @@ void ThrowError(PSRETURN code)
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user