Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/gui/IGUIObject.h
Show All 27 Lines | |||||
#include "IGUIObject.h" | #include "IGUIObject.h" | ||||
#include "gui/CGUI.h" | #include "gui/CGUI.h" | ||||
#include "gui/GUIbase.h" | #include "gui/GUIbase.h" | ||||
#include "gui/scripting/JSInterface_IGUIObject.h" | #include "gui/scripting/JSInterface_IGUIObject.h" | ||||
#include "lib/input.h" // just for IN_PASS | #include "lib/input.h" // just for IN_PASS | ||||
#include "ps/XML/Xeromyces.h" | #include "ps/XML/Xeromyces.h" | ||||
#include <functional> | |||||
#include <string> | #include <string> | ||||
#include <vector> | #include <vector> | ||||
struct SGUIStyle; | struct SGUIStyle; | ||||
class JSObject; | class JSObject; | ||||
class IGUISetting; | class IGUISetting; | ||||
template <typename T> class GUI; | template <typename T> class GUI; | ||||
▲ Show 20 Lines • Show All 110 Lines • ▼ Show 20 Lines | public: | ||||
*/ | */ | ||||
template <typename T> | template <typename T> | ||||
T& GetSetting(const CStr& Setting); | T& GetSetting(const CStr& Setting); | ||||
template <typename T> | template <typename T> | ||||
const T& GetSetting(const CStr& Setting) const; | const T& GetSetting(const CStr& Setting) const; | ||||
/** | /** | ||||
* Set a setting by string, regardless of what type it is. | |||||
* Used to parse setting values from XML files. | |||||
* For example a CRect(10,10,20,20) is created from "10 10 20 20". | |||||
* Returns false if the conversion fails, otherwise true. | |||||
*/ | |||||
bool SetSettingFromString(const CStr& Setting, const CStrW& Value, const bool SendMessage); | |||||
/** | |||||
* Assigns the given value to the setting identified by the given name. | |||||
* Uses move semantics, so do not read from Value after this call. | |||||
* | |||||
* @param SendMessage If true, a GUIM_SETTINGS_UPDATED message will be broadcasted to all GUI objects. | |||||
*/ | |||||
template <typename T> | |||||
void SetSetting(const CStr& Setting, T& Value, const bool SendMessage); | |||||
/** | |||||
* This variant will copy the value. | |||||
*/ | |||||
template <typename T> | |||||
void SetSetting(const CStr& Setting, const T& Value, const bool SendMessage); | |||||
/** | |||||
* Returns whether this is object is set to be hidden. | * Returns whether this is object is set to be hidden. | ||||
*/ | */ | ||||
bool IsHidden() const; | bool IsHidden() const; | ||||
/** | /** | ||||
* Returns whether this object is set to be hidden or ghost. | * Returns whether this object is set to be hidden or ghost. | ||||
*/ | */ | ||||
bool IsHiddenOrGhost() const; | bool IsHiddenOrGhost() const; | ||||
/** | /** | ||||
* All sizes are relative to resolution, and the calculation | * All sizes are relative to resolution, and the calculation | ||||
* is not wanted in real time, therefore it is cached, update | * is not wanted in real time, therefore it is cached, update | ||||
* the cached size with this function. | * the cached size with this function. | ||||
*/ | */ | ||||
virtual void UpdateCachedSize(); | virtual void UpdateCachedSize(); | ||||
/** | /** | ||||
* Reset internal state of this object. | * Reset internal state of this object. | ||||
*/ | */ | ||||
virtual void ResetStates(); | virtual void ResetStates(); | ||||
/** | /** | ||||
* Set a setting by string, regardless of what type it is. | |||||
* | |||||
* example a CRect(10,10,20,20) would be "10 10 20 20" | |||||
* | |||||
* @param Setting Setting by name | |||||
* @param Value Value to set to | |||||
* @param SkipMessage Does not send a GUIM_SETTINGS_UPDATED if true | |||||
* | |||||
* @return PSRETURN (PSRETURN_OK if successful) | |||||
*/ | |||||
PSRETURN SetSetting(const CStr& Setting, const CStrW& Value, const bool& SkipMessage = false); | |||||
/** | |||||
* Set the script handler for a particular object-specific action | * Set the script handler for a particular object-specific action | ||||
* | * | ||||
* @param Action Name of action | * @param Action Name of action | ||||
* @param Code Javascript code to execute when the action occurs | * @param Code Javascript code to execute when the action occurs | ||||
* @param pGUI GUI instance to associate the script with | * @param pGUI GUI instance to associate the script with | ||||
*/ | */ | ||||
void RegisterScriptHandler(const CStr& Action, const CStr& Code, CGUI& pGUI); | void RegisterScriptHandler(const CStr& Action, const CStr& Code, CGUI& pGUI); | ||||
▲ Show 20 Lines • Show All 206 Lines • ▼ Show 20 Lines | protected: | ||||
//@} | //@} | ||||
private: | private: | ||||
//-------------------------------------------------------- | //-------------------------------------------------------- | ||||
/** @name Internal functions */ | /** @name Internal functions */ | ||||
//-------------------------------------------------------- | //-------------------------------------------------------- | ||||
//@{ | //@{ | ||||
/** | /** | ||||
* Updates some internal data depending on the setting changed. | |||||
*/ | |||||
void SettingChanged(const CStr& Setting, const bool SendMessage); | |||||
/** | |||||
* Inputs a reference pointer, checks if the new inputted object | * Inputs a reference pointer, checks if the new inputted object | ||||
* if hovered, if so, then check if this's Z value is greater | * if hovered, if so, then check if this's Z value is greater | ||||
* than the inputted object... If so then the object is closer | * than the inputted object... If so then the object is closer | ||||
* and we'll replace the pointer with this. | * and we'll replace the pointer with this. | ||||
* Also Notice input can be NULL, which means the Z value demand | * 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 | * is out. NOTICE you can't input NULL as const so you'll have | ||||
* to set an object to NULL. | * to set an object to NULL. | ||||
* | * | ||||
▲ Show 20 Lines • Show All 90 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator