Changeset View
Changeset View
Standalone View
Standalone View
source/gui/CGUI.h
Show All 37 Lines | |||||
#include <unordered_map> | #include <unordered_map> | ||||
#include <unordered_set> | #include <unordered_set> | ||||
#include <vector> | #include <vector> | ||||
extern const double SELECT_DBLCLICK_RATE; | extern const double SELECT_DBLCLICK_RATE; | ||||
class CGUISpriteInstance; | class CGUISpriteInstance; | ||||
class CGUISprite; | class CGUISprite; | ||||
class CParamNode; | |||||
class IGUIObject; | class IGUIObject; | ||||
struct SGUIImageEffects; | struct SGUIImageEffects; | ||||
struct SGUIScrollBarStyle; | struct SGUIScrollBarStyle; | ||||
namespace js { class BaseProxyHandler; } | namespace js { class BaseProxyHandler; } | ||||
class GUIProxyProps; | class GUIProxyProps; | ||||
using map_pObjects = std::map<CStr, IGUIObject*>; | using map_pObjects = std::map<CStr, IGUIObject*>; | ||||
▲ Show 20 Lines • Show All 192 Lines • ▼ Show 20 Lines | public: | ||||
* Resolve the predefined color if it exists, otherwise throws an exception. | * Resolve the predefined color if it exists, otherwise throws an exception. | ||||
*/ | */ | ||||
const CGUIColor& GetPreDefinedColor(const CStr& name) const { return m_PreDefinedColors.at(name); } | const CGUIColor& GetPreDefinedColor(const CStr& name) const { return m_PreDefinedColors.at(name); } | ||||
GUIProxyProps* GetProxyData(const js::BaseProxyHandler* ptr) { return m_ProxyData.at(ptr).get(); } | GUIProxyProps* GetProxyData(const js::BaseProxyHandler* ptr) { return m_ProxyData.at(ptr).get(); } | ||||
shared_ptr<ScriptInterface> GetScriptInterface() { return m_ScriptInterface; }; | shared_ptr<ScriptInterface> GetScriptInterface() { return m_ScriptInterface; }; | ||||
/** | |||||
* The CGUI creates the object and adds it as a child to parent. | |||||
* To the created object, this is the same as being created on page open (same events, etc.) | |||||
*/ | |||||
IGUIObject* CreateChildFromParamNode(const CParamNode& paramNode, IGUIObject* parent, std::vector<std::pair<CStr, CStr>>& nameSubst, u32 depth); | |||||
/** | |||||
* Detach the object from its parent and delete it. | |||||
* The object must have a parent - use PopPage to delete the root page object. | |||||
*/ | |||||
void DetachAndDeleteChild(IGUIObject* child); | |||||
private: | private: | ||||
/** | /** | ||||
* The CGUI takes ownership of the child object and links the parent with the child. | * The CGUI takes ownership of the child object and links the parent with the child. | ||||
* Returns false on failure to take over ownership of the child object. | * Returns false on failure to take over ownership of the child object. | ||||
*/ | */ | ||||
bool AddObject(IGUIObject& parent, IGUIObject& child); | bool AddObject(IGUIObject& parent, IGUIObject& child); | ||||
/** | /** | ||||
▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | /* | ||||
| | | | ||||
+-<color> (ReadColor) | +-<color> (ReadColor) | ||||
*/ | */ | ||||
//@{ | //@{ | ||||
// Read Roots | // Read Roots | ||||
/** | /** | ||||
* Reads in the root element \<objects\> (the DOMElement). | * Reads in the "objects" root element | ||||
* | * | ||||
* @param Element The Xeromyces object that represents | * @param paramNode input data. | ||||
* the objects-tag. | * @param Paths Collects the set of all files that are loaded | ||||
* @param pFile The Xeromyces object for the file being read | |||||
* @param Paths Collects the set of all XML/JS files that are loaded | |||||
* | |||||
* @see LoadXmlFile() | |||||
*/ | */ | ||||
void Xeromyces_ReadRootObjects(XMBElement Element, CXeromyces* pFile, std::unordered_set<VfsPath>& Paths); | void ReadRootObjects(const CParamNode& paramNode, std::unordered_set<VfsPath>& Paths); | ||||
/** | /** | ||||
* Reads in the root element \<sprites\> (the DOMElement). | * Reads in the root element \<sprites\> (the DOMElement). | ||||
* | * | ||||
* @param Element The Xeromyces object that represents | * @param Element The Xeromyces object that represents | ||||
* the sprites-tag. | * the sprites-tag. | ||||
* @param pFile The Xeromyces object for the file being read | * @param pFile The Xeromyces object for the file being read | ||||
* | * | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | private: | ||||
* @param pParent Parent to add this object as child in. | * @param pParent Parent to add this object as child in. | ||||
* @param NameSubst A set of substitution strings that will be | * @param NameSubst A set of substitution strings that will be | ||||
* applied to all object names within this object. | * applied to all object names within this object. | ||||
* @param Paths Output set of file paths that this GUI object | * @param Paths Output set of file paths that this GUI object | ||||
* relies on. | * relies on. | ||||
* | * | ||||
* @see LoadXmlFile() | * @see LoadXmlFile() | ||||
*/ | */ | ||||
void Xeromyces_ReadObject(XMBElement Element, CXeromyces* pFile, IGUIObject* pParent, std::vector<std::pair<CStr, CStr> >& NameSubst, std::unordered_set<VfsPath>& Paths, u32 nesting_depth); | IGUIObject* ReadObject(const CParamNode& paramNode, IGUIObject* pParent, std::vector<std::pair<CStr, CStr> >& NameSubst, std::unordered_set<VfsPath>& Paths, u32 nesting_depth); | ||||
/** | /** | ||||
* Reads in the element \<repeat\>, which repeats its child \<object\>s | * Reads in the element \<repeat\>, which repeats its child \<object\>s | ||||
* 'count' times, replacing the string "[n]" (or the value of the attribute | * 'count' times, replacing the string "[n]" (or the value of the attribute | ||||
* 'var' enclosed in square brackets) in its descendants' names with "[0]", | * 'var' enclosed in square brackets) in its descendants' names with "[0]", | ||||
* "[1]", etc. | * "[1]", etc. | ||||
*/ | */ | ||||
void Xeromyces_ReadRepeat(XMBElement Element, CXeromyces* pFile, IGUIObject* pParent, std::vector<std::pair<CStr, CStr> >& NameSubst, std::unordered_set<VfsPath>& Paths, u32 nesting_depth); | void ReadRepeat(const CParamNode& paramNode, IGUIObject* pParent, std::vector<std::pair<CStr, CStr> >& NameSubst, std::unordered_set<VfsPath>& Paths, u32 nesting_depth); | ||||
/** | /** | ||||
* Reads in the element \<script\> (the XMBElement) and executes | * Reads in the element \<script\> (the XMBElement) and executes | ||||
* the script's code. | * the script's code. | ||||
* | * | ||||
* @param Element The Xeromyces object that represents | * @param Element The Xeromyces object that represents | ||||
* the script-tag. | * the script-tag. | ||||
* @param pFile The Xeromyces object for the file being read | * @param pFile The Xeromyces object for the file being read | ||||
* @param Paths Output set of file paths that this script is loaded from. | * @param Paths Output set of file paths that this script is loaded from. | ||||
* | * | ||||
* @see LoadXmlFile() | * @see LoadXmlFile() | ||||
*/ | */ | ||||
void Xeromyces_ReadScript(XMBElement Element, CXeromyces* pFile, std::unordered_set<VfsPath>& Paths); | void ReadScript(const CParamNode& paramNode, std::unordered_set<VfsPath>& Paths); | ||||
/** | /** | ||||
* Reads in the element \<sprite\> (the XMBElement) and stores the | * Reads in the element \<sprite\> (the XMBElement) and stores the | ||||
* result in a new CGUISprite. | * result in a new CGUISprite. | ||||
* | * | ||||
* @param Element The Xeromyces object that represents | * @param Element The Xeromyces object that represents | ||||
* the sprite-tag. | * the sprite-tag. | ||||
* @param pFile The Xeromyces object for the file being read | * @param pFile The Xeromyces object for the file being read | ||||
▲ Show 20 Lines • Show All 237 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator