Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/gui/GUIutil.h
Show All 31 Lines | |||||
#ifndef INCLUDED_GUIUTIL | #ifndef INCLUDED_GUIUTIL | ||||
#define INCLUDED_GUIUTIL | #define INCLUDED_GUIUTIL | ||||
#include "gui/CGUI.h" | #include "gui/CGUI.h" | ||||
#include "gui/CGUISprite.h" | #include "gui/CGUISprite.h" | ||||
#include "gui/GUIbase.h" | #include "gui/GUIbase.h" | ||||
#include "gui/IGUIObject.h" | #include "gui/IGUIObject.h" | ||||
#include <functional> | |||||
class CClientArea; | class CClientArea; | ||||
class CGUIString; | class CGUIString; | ||||
class CMatrix3D; | class CMatrix3D; | ||||
template <typename T> | template <typename T> | ||||
bool __ParseString(const CStrW& Value, T& tOutput); | bool __ParseString(const CStrW& Value, T& tOutput); | ||||
// Model-view-projection matrix with (0,0) in top-left of screen | // Model-view-projection matrix with (0,0) in top-left of screen | ||||
Show All 37 Lines | public: | ||||
static PSRETURN GetSetting(const IGUIObject* pObject, const CStr& Setting, T& Value); | static PSRETURN GetSetting(const IGUIObject* pObject, const CStr& Setting, T& Value); | ||||
/** | /** | ||||
* Sets a value by name using a real datatype as input. | * Sets a value by name using a real datatype as input. | ||||
* | * | ||||
* This is the official way of setting a setting, no other | * This is the official way of setting a setting, no other | ||||
* way should only cautiously be used! | * way should only cautiously be used! | ||||
* | * | ||||
* This variant will use the move-assignment. | |||||
* | |||||
* @param pObject Object pointer | * @param pObject Object pointer | ||||
* @param Setting Setting by name | * @param Setting Setting by name | ||||
* @param Value Sets value to this, note type T! | * @param Value Sets value to this, note type T! | ||||
* @param SkipMessage Does not send a GUIM_SETTINGS_UPDATED if true | * @param SkipMessage Does not send a GUIM_SETTINGS_UPDATED if true | ||||
*/ | */ | ||||
static PSRETURN SetSetting(IGUIObject* pObject, const CStr& Setting, T& Value, const bool& SkipMessage = false); | |||||
/** | |||||
* This variant will copy the value. | |||||
*/ | |||||
static PSRETURN SetSetting(IGUIObject* pObject, const CStr& Setting, const T& Value, const bool& SkipMessage = false); | static PSRETURN SetSetting(IGUIObject* pObject, const CStr& Setting, const T& Value, const bool& SkipMessage = false); | ||||
/** | /** | ||||
* This will return the value of the first sprite if it's not null, | * This will return the value of the first sprite if it's not null, | ||||
* if it is null, it will return the value of the second sprite, if | * if it is null, it will return the value of the second sprite, if | ||||
* that one is null, then null it is. | * that one is null, then null it is. | ||||
* | * | ||||
* @param prim Primary sprite that should be used | * @param prim Primary sprite that should be used | ||||
Show All 36 Lines | public: | ||||
{ | { | ||||
return __ParseString<T>(Value, tOutput); | return __ParseString<T>(Value, tOutput); | ||||
} | } | ||||
static bool ParseColor(const CStrW& Value, CGUIColor& tOutput, int DefaultAlpha); | static bool ParseColor(const CStrW& Value, CGUIColor& tOutput, int DefaultAlpha); | ||||
private: | private: | ||||
/** | |||||
* Changes the value of the setting by calling the valueSet functon that performs either a copy or move assignment. | |||||
* Updates some internal data depending on the setting changed. | |||||
*/ | |||||
static PSRETURN SetSettingWrap(IGUIObject* pObject, const CStr& Setting, const T& Value, const bool& SkipMessage, const std::function<void()>& valueSet); | |||||
// templated typedef of function pointer | // templated typedef of function pointer | ||||
typedef void (IGUIObject::*void_Object_pFunction_argT)(const T& arg); | typedef void (IGUIObject::*void_Object_pFunction_argT)(const T& arg); | ||||
typedef void (IGUIObject::*void_Object_pFunction_argRefT)(T& arg); | typedef void (IGUIObject::*void_Object_pFunction_argRefT)(T& arg); | ||||
typedef void (IGUIObject::*void_Object_pFunction)(); | typedef void (IGUIObject::*void_Object_pFunction)(); | ||||
typedef void (IGUIObject::*void_Object_pFunction_argTJS)(const T& arg, JS::HandleValueArray paramData); | typedef void (IGUIObject::*void_Object_pFunction_argTJS)(const T& arg, JS::HandleValueArray paramData); | ||||
/** | /** | ||||
* If you want to call a IGUIObject-function | * If you want to call a IGUIObject-function | ||||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | static void RecurseObject(int RR, IGUIObject* pObject, void_Object_pFunction pFunc) | ||||
(pObject->*pFunc)(); | (pObject->*pFunc)(); | ||||
// Iterate children | // Iterate children | ||||
for (IGUIObject* const& obj : *pObject) | for (IGUIObject* const& obj : *pObject) | ||||
RecurseObject(RR, obj, pFunc); | RecurseObject(RR, obj, pFunc); | ||||
} | } | ||||
private: | |||||
/** | /** | ||||
* Checks restrictions for the iteration, for instance if | * Checks restrictions for the iteration, for instance if | ||||
* you tell the recursor to avoid all hidden objects, it | * you tell the recursor to avoid all hidden objects, it | ||||
* will, and this function checks a certain object's | * will, and this function checks a certain object's | ||||
* restriction values. | * restriction values. | ||||
* | * | ||||
* @param RR What kind of restriction, for instance hidden or disabled | * @param RR What kind of restriction, for instance hidden or disabled | ||||
* @param pObject Object | * @param pObject Object | ||||
▲ Show 20 Lines • Show All 41 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator