Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/simulation2/system/ParamNode.cpp
Show All 31 Lines | |||||
static CParamNode g_NullNode(false); | static CParamNode g_NullNode(false); | ||||
CParamNode::CParamNode(bool isOk) : | CParamNode::CParamNode(bool isOk) : | ||||
m_IsOk(isOk) | m_IsOk(isOk) | ||||
{ | { | ||||
} | } | ||||
void CParamNode::LoadXML(CParamNode& ret, const XMBFile& xmb, const wchar_t* sourceIdentifier /*= NULL*/) | void CParamNode::LoadXML(CParamNode& ret, const XMBData& xmb, const wchar_t* sourceIdentifier /*= NULL*/) | ||||
{ | { | ||||
ret.ApplyLayer(xmb, xmb.GetRoot(), sourceIdentifier); | ret.ApplyLayer(xmb, xmb.GetRoot(), sourceIdentifier); | ||||
} | } | ||||
void CParamNode::LoadXML(CParamNode& ret, const VfsPath& path, const std::string& validatorName) | void CParamNode::LoadXML(CParamNode& ret, const VfsPath& path, const std::string& validatorName) | ||||
{ | { | ||||
CXeromyces xero; | CXeromyces xero; | ||||
PSRETURN ok = xero.Load(g_VFS, path, validatorName); | PSRETURN ok = xero.Load(g_VFS, path, validatorName); | ||||
Show All 10 Lines | PSRETURN CParamNode::LoadXMLString(CParamNode& ret, const char* xml, const wchar_t* sourceIdentifier /*=NULL*/) | ||||
if (ok != PSRETURN_OK) | if (ok != PSRETURN_OK) | ||||
return ok; | return ok; | ||||
ret.ApplyLayer(xero, xero.GetRoot(), sourceIdentifier); | ret.ApplyLayer(xero, xero.GetRoot(), sourceIdentifier); | ||||
return PSRETURN_OK; | return PSRETURN_OK; | ||||
} | } | ||||
void CParamNode::ApplyLayer(const XMBFile& xmb, const XMBElement& element, const wchar_t* sourceIdentifier /*= NULL*/) | void CParamNode::ApplyLayer(const XMBData& xmb, const XMBElement& element, const wchar_t* sourceIdentifier /*= NULL*/) | ||||
{ | { | ||||
ResetScriptVal(); | ResetScriptVal(); | ||||
std::string name = xmb.GetElementString(element.GetNodeName()); // TODO: is GetElementString inefficient? | std::string name = xmb.GetElementString(element.GetNodeName()); | ||||
CStr value = element.GetText(); | CStr value = element.GetText(); | ||||
bool hasSetValue = false; | bool hasSetValue = false; | ||||
// Look for special attributes | // Look for special attributes | ||||
int at_disable = xmb.GetAttributeID("disable"); | int at_disable = xmb.GetAttributeID("disable"); | ||||
int at_replace = xmb.GetAttributeID("replace"); | int at_replace = xmb.GetAttributeID("replace"); | ||||
int at_filtered = xmb.GetAttributeID("filtered"); | int at_filtered = xmb.GetAttributeID("filtered"); | ||||
▲ Show 20 Lines • Show All 139 Lines • ▼ Show 20 Lines | void CParamNode::ApplyLayer(const XMBData& xmb, const XMBElement& element, const wchar_t* sourceIdentifier /*= NULL*/) | ||||
// Add the element's attributes, prefixing names with "@" | // Add the element's attributes, prefixing names with "@" | ||||
XERO_ITER_ATTR(element, attr) | XERO_ITER_ATTR(element, attr) | ||||
{ | { | ||||
// Skip special attributes | // Skip special attributes | ||||
if (attr.Name == at_replace || attr.Name == at_op || attr.Name == at_merge || attr.Name == at_filtered) | if (attr.Name == at_replace || attr.Name == at_op || attr.Name == at_merge || attr.Name == at_filtered) | ||||
continue; | continue; | ||||
// Add any others | // Add any others | ||||
std::string attrName = xmb.GetAttributeString(attr.Name); | const char* attrName(xmb.GetAttributeString(attr.Name)); | ||||
node.m_Childs["@" + attrName].m_Value = attr.Value; | node.m_Childs[CStr("@") + attrName].m_Value = attr.Value; | ||||
} | } | ||||
} | } | ||||
const CParamNode& CParamNode::GetChild(const char* name) const | const CParamNode& CParamNode::GetChild(const char* name) const | ||||
{ | { | ||||
ChildrenMap::const_iterator it = m_Childs.find(name); | ChildrenMap::const_iterator it = m_Childs.find(name); | ||||
if (it == m_Childs.end()) | if (it == m_Childs.end()) | ||||
return g_NullNode; | return g_NullNode; | ||||
▲ Show 20 Lines • Show All 199 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator