Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/system/ParamNode.h
Show All 16 Lines | |||||
#ifndef INCLUDED_PARAMNODE | #ifndef INCLUDED_PARAMNODE | ||||
#define INCLUDED_PARAMNODE | #define INCLUDED_PARAMNODE | ||||
#include "lib/file/vfs/vfs_path.h" | #include "lib/file/vfs/vfs_path.h" | ||||
#include "maths/Fixed.h" | #include "maths/Fixed.h" | ||||
#include "ps/CStrIntern.h" | #include "ps/CStrIntern.h" | ||||
#include "ps/Errors.h" | #include "ps/Errors.h" | ||||
#include "scriptinterface/ScriptInterface.h" | #include "scriptinterface/ScriptTypes.h" | ||||
#include <map> | #include <map> | ||||
#include <set> | #include <set> | ||||
class XMBFile; | class XMBFile; | ||||
class XMBElement; | class XMBElement; | ||||
struct ScriptRequest; | |||||
/** | /** | ||||
* An entity initialisation parameter node. | * An entity initialisation parameter node. | ||||
* Each node has a text value, plus a number of named child nodes (in a tree structure). | * Each node has a text value, plus a number of named child nodes (in a tree structure). | ||||
* Child nodes are unordered, and there cannot be more than one with the same name. | * Child nodes are unordered, and there cannot be more than one with the same name. | ||||
* Nodes are immutable. | * Nodes are immutable. | ||||
* | * | ||||
* Nodes can be initialised from XML files. Child elements are mapped onto child nodes. | * Nodes can be initialised from XML files. Child elements are mapped onto child nodes. | ||||
* Attributes are mapped onto child nodes with names prefixed by "@" | * Attributes are mapped onto child nodes with names prefixed by "@" | ||||
▲ Show 20 Lines • Show All 202 Lines • ▼ Show 20 Lines | public: | ||||
* Returns a JS::Value representation of this node and its children. | * Returns a JS::Value representation of this node and its children. | ||||
* If @p cacheValue is true, then the same JS::Value will be returned each time | * If @p cacheValue is true, then the same JS::Value will be returned each time | ||||
* this is called (regardless of whether you passed the same @p cx - be careful | * this is called (regardless of whether you passed the same @p cx - be careful | ||||
* to only use the cache in one context). | * to only use the cache in one context). | ||||
* When caching, the lifetime of @p cx must be longer than the lifetime of this node. | * When caching, the lifetime of @p cx must be longer than the lifetime of this node. | ||||
* The cache will be reset if *this* node is modified (e.g. by LoadXML), | * The cache will be reset if *this* node is modified (e.g. by LoadXML), | ||||
* but *not* if any child nodes are modified (so don't do that). | * but *not* if any child nodes are modified (so don't do that). | ||||
*/ | */ | ||||
void ToJSVal(const ScriptInterface::Request& rq, bool cacheValue, JS::MutableHandleValue ret) const; | void ToJSVal(const ScriptRequest& rq, bool cacheValue, JS::MutableHandleValue ret) const; | ||||
/** | /** | ||||
* Returns the names/nodes of the children of this node, ordered by name | * Returns the names/nodes of the children of this node, ordered by name | ||||
*/ | */ | ||||
const ChildrenMap& GetChildren() const; | const ChildrenMap& GetChildren() const; | ||||
/** | /** | ||||
* Escapes a string so that it is well-formed XML content/attribute text. | * Escapes a string so that it is well-formed XML content/attribute text. | ||||
Show All 10 Lines | private: | ||||
* @param element Element inside the specified @p xmb file containing the data to apply. | * @param element Element inside the specified @p xmb file containing the data to apply. | ||||
* @param sourceIdentifier Optional; string you can pass along to indicate the source of | * @param sourceIdentifier Optional; string you can pass along to indicate the source of | ||||
* the data getting applied. Used for output to log messages if an error occurs. | * the data getting applied. Used for output to log messages if an error occurs. | ||||
*/ | */ | ||||
void ApplyLayer(const XMBFile& xmb, const XMBElement& element, const wchar_t* sourceIdentifier = NULL); | void ApplyLayer(const XMBFile& xmb, const XMBElement& element, const wchar_t* sourceIdentifier = NULL); | ||||
void ResetScriptVal(); | void ResetScriptVal(); | ||||
void ConstructJSVal(const ScriptInterface::Request& rq, JS::MutableHandleValue ret) const; | void ConstructJSVal(const ScriptRequest& rq, JS::MutableHandleValue ret) const; | ||||
std::wstring m_Value; | std::wstring m_Value; | ||||
ChildrenMap m_Childs; | ChildrenMap m_Childs; | ||||
bool m_IsOk; | bool m_IsOk; | ||||
/** | /** | ||||
* Caches the ToJSVal script representation of this node. | * Caches the ToJSVal script representation of this node. | ||||
*/ | */ | ||||
mutable std::shared_ptr<JS::PersistentRootedValue> m_ScriptVal; | mutable std::shared_ptr<JS::PersistentRootedValue> m_ScriptVal; | ||||
}; | }; | ||||
#endif // INCLUDED_PARAMNODE | #endif // INCLUDED_PARAMNODE |
Wildfire Games · Phabricator