本文整理汇总了C++中XMBElement::GetChildNodes方法的典型用法代码示例。如果您正苦于以下问题:C++ XMBElement::GetChildNodes方法的具体用法?C++ XMBElement::GetChildNodes怎么用?C++ XMBElement::GetChildNodes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMBElement
的用法示例。
在下文中一共展示了XMBElement::GetChildNodes方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Xeromyces_ReadRootStyles
void CGUI::Xeromyces_ReadRootStyles(XMBElement Element, CXeromyces* pFile)
{
// Iterate main children
// they should all be <styles> elements
XMBElementList children = Element.GetChildNodes();
for (int i=0; i<children.Count; ++i)
{
XMBElement child = children.Item(i);
// Read in this whole object into the GUI
Xeromyces_ReadStyle(child, pFile);
}
}
示例2: Xeromyces_ReadRootSetup
void CGUI::Xeromyces_ReadRootSetup(XMBElement Element, CXeromyces* pFile)
{
for (XMBElement child : Element.GetChildNodes())
{
CStr name(pFile->GetElementString(child.GetNodeName()));
if (name == "scrollbar")
Xeromyces_ReadScrollBarStyle(child, pFile);
else if (name == "icon")
Xeromyces_ReadIcon(child, pFile);
else if (name == "tooltip")
Xeromyces_ReadTooltip(child, pFile);
else if (name == "color")
Xeromyces_ReadColor(child, pFile);
else
debug_warn(L"Invalid data - DTD shouldn't allow this");
}
}
示例3: Xeromyces_ReadRootObjects
void CGUI::Xeromyces_ReadRootObjects(XMBElement Element, CXeromyces* pFile, boost::unordered_set<VfsPath>& Paths)
{
int el_script = pFile->GetElementID("script");
std::vector<std::pair<CStr, CStr> > subst;
// Iterate main children
// they should all be <object> or <script> elements
for (XMBElement child : Element.GetChildNodes())
{
if (child.GetNodeName() == el_script)
// Execute the inline script
Xeromyces_ReadScript(child, pFile, Paths);
else
// Read in this whole object into the GUI
Xeromyces_ReadObject(child, pFile, m_BaseObject, subst, Paths, 0);
}
}
示例4: Xeromyces_ReadSprite
void CGUI::Xeromyces_ReadSprite(XMBElement Element, CXeromyces* pFile)
{
CGUISprite* Sprite = new CGUISprite;
// Get name, we know it exists because of DTD requirements
CStr name = Element.GetAttributes().GetNamedItem(pFile->GetAttributeID("name"));
if (m_Sprites.find(name) != m_Sprites.end())
LOGWARNING("GUI sprite name '%s' used more than once; first definition will be discarded", name.c_str());
SGUIImageEffects* effects = NULL;
for (XMBElement child : Element.GetChildNodes())
{
CStr ElementName(pFile->GetElementString(child.GetNodeName()));
if (ElementName == "image")
Xeromyces_ReadImage(child, pFile, *Sprite);
else if (ElementName == "effect")
{
if (effects)
LOGERROR("GUI <sprite> must not have more than one <effect>");
else
{
effects = new SGUIImageEffects;
Xeromyces_ReadEffects(child, pFile, *effects);
}
}
else
debug_warn(L"Invalid data - DTD shouldn't allow this");
}
// Apply the effects to every image (unless the image overrides it with
// different effects)
if (effects)
for (SGUIImage* const& img : Sprite->m_Images)
if (!img->m_Effects)
img->m_Effects = new SGUIImageEffects(*effects); // do a copy just so it can be deleted correctly later
delete effects;
m_Sprites[name] = Sprite;
}
示例5: Xeromyces_ReadRootObjects
void CGUI::Xeromyces_ReadRootObjects(XMBElement Element, CXeromyces* pFile, boost::unordered_set<VfsPath>& Paths)
{
int el_script = pFile->GetElementID("script");
std::vector<std::pair<CStr, CStr> > subst;
// Iterate main children
// they should all be <object> or <script> elements
XMBElementList children = Element.GetChildNodes();
for (int i=0; i<children.Count; ++i)
{
//debug_printf(L"Object %d\n", i);
XMBElement child = children.Item(i);
if (child.GetNodeName() == el_script)
// Execute the inline script
Xeromyces_ReadScript(child, pFile, Paths);
else
// Read in this whole object into the GUI
Xeromyces_ReadObject(child, pFile, m_BaseObject, subst, Paths);
}
}
示例6: Xeromyces_ReadRootSetup
void CGUI::Xeromyces_ReadRootSetup(XMBElement Element, CXeromyces* pFile)
{
// Iterate main children
// they should all be <icon>, <scrollbar> or <tooltip>.
XMBElementList children = Element.GetChildNodes();
for (int i=0; i<children.Count; ++i)
{
XMBElement child = children.Item(i);
// Read in this whole object into the GUI
CStr name (pFile->GetElementString(child.GetNodeName()));
if (name == "scrollbar")
{
Xeromyces_ReadScrollBarStyle(child, pFile);
}
else
if (name == "icon")
{
Xeromyces_ReadIcon(child, pFile);
}
else
if (name == "tooltip")
{
Xeromyces_ReadTooltip(child, pFile);
}
else
if (name == "color")
{
Xeromyces_ReadColor(child, pFile);
}
else
{
debug_warn(L"Invalid data - DTD shouldn't allow this");
}
}
}
示例7: Xeromyces_ReadImage
//.........这里部分代码省略.........
if (!GUI<CSize>::ParseString(attr_value, size))
LOGERROR(L"GUI: Error parsing '%hs' (\"%ls\")", attr_name.c_str(), attr_value.c_str());
else Image->m_CellSize = size;
}
else
if (attr_name == "fixed_h_aspect_ratio")
{
float val;
if (!GUI<float>::ParseString(attr_value, val))
LOGERROR(L"GUI: Error parsing '%hs' (\"%ls\")", attr_name.c_str(), attr_value.c_str());
else Image->m_FixedHAspectRatio = val;
}
else
if (attr_name == "round_coordinates")
{
bool b;
if (!GUI<bool>::ParseString(attr_value, b))
LOGERROR(L"GUI: Error parsing '%hs' (\"%ls\")", attr_name.c_str(), attr_value.c_str());
else Image->m_RoundCoordinates = b;
}
else
if (attr_name == "wrap_mode")
{
if (attr_value == L"repeat")
Image->m_WrapMode = GL_REPEAT;
else if (attr_value == L"mirrored_repeat")
Image->m_WrapMode = GL_MIRRORED_REPEAT;
else if (attr_value == L"clamp_to_edge")
Image->m_WrapMode = GL_CLAMP_TO_EDGE;
else
LOGERROR(L"GUI: Error parsing '%hs' (\"%ls\")", attr_name.c_str(), attr_value.c_str());
}
else
if (attr_name == "z_level")
{
float z_level;
if (!GUI<float>::ParseString(attr_value, z_level))
LOGERROR(L"GUI: Error parsing '%hs' (\"%ls\")", attr_name.c_str(), attr_value.c_str());
else Image->m_DeltaZ = z_level/100.f;
}
else
if (attr_name == "backcolor")
{
CColor color;
if (!GUI<CColor>::ParseString(attr_value, color))
LOGERROR(L"GUI: Error parsing '%hs' (\"%ls\")", attr_name.c_str(), attr_value.c_str());
else Image->m_BackColor = color;
}
else
if (attr_name == "bordercolor")
{
CColor color;
if (!GUI<CColor>::ParseString(attr_value, color))
LOGERROR(L"GUI: Error parsing '%hs' (\"%ls\")", attr_name.c_str(), attr_value.c_str());
else Image->m_BorderColor = color;
}
else
if (attr_name == "border")
{
bool b;
if (!GUI<bool>::ParseString(attr_value, b))
LOGERROR(L"GUI: Error parsing '%hs' (\"%ls\")", attr_name.c_str(), attr_value.c_str());
else Image->m_Border = b;
}
else
{
debug_warn(L"Invalid data - DTD shouldn't allow this");
}
}
// Look for effects
XMBElementList children = Element.GetChildNodes();
for (int i=0; i<children.Count; ++i)
{
XMBElement child = children.Item(i);
CStr ElementName (pFile->GetElementString(child.GetNodeName()));
if (ElementName == "effect")
{
if (Image->m_Effects)
{
LOGERROR(L"GUI <image> must not have more than one <effect>");
}
else
{
Image->m_Effects = new SGUIImageEffects;
Xeromyces_ReadEffects(child, pFile, *Image->m_Effects);
}
}
else
{
debug_warn(L"Invalid data - DTD shouldn't allow this");
}
}
//
// Input
//
parent.AddImage(Image);
}
示例8: Xeromyces_ReadSprite
void CGUI::Xeromyces_ReadSprite(XMBElement Element, CXeromyces* pFile)
{
// Sprite object we're adding
CGUISprite* Sprite = new CGUISprite;
// and what will be its reference name
CStr name;
//
// Read Attributes
//
// Get name, we know it exists because of DTD requirements
name = Element.GetAttributes().GetNamedItem( pFile->GetAttributeID("name") );
if (m_Sprites.find(name) != m_Sprites.end())
LOGWARNING(L"GUI sprite name '%hs' used more than once; first definition will be discarded", name.c_str());
//
// Read Children (the images)
//
SGUIImageEffects* effects = NULL;
// Iterate children
XMBElementList children = Element.GetChildNodes();
for (int i=0; i<children.Count; ++i)
{
// Get node
XMBElement child = children.Item(i);
CStr ElementName (pFile->GetElementString(child.GetNodeName()));
if (ElementName == "image")
{
Xeromyces_ReadImage(child, pFile, *Sprite);
}
else if (ElementName == "effect")
{
if (effects)
{
LOGERROR(L"GUI <sprite> must not have more than one <effect>");
}
else
{
effects = new SGUIImageEffects;
Xeromyces_ReadEffects(child, pFile, *effects);
}
}
else
{
debug_warn(L"Invalid data - DTD shouldn't allow this");
}
}
// Apply the effects to every image (unless the image overrides it with
// different effects)
if (effects)
for (std::vector<SGUIImage*>::iterator it = Sprite->m_Images.begin(); it != Sprite->m_Images.end(); ++it)
if (! (*it)->m_Effects)
(*it)->m_Effects = new SGUIImageEffects(*effects); // do a copy just so it can be deleted correctly later
delete effects;
//
// Add Sprite
//
m_Sprites[name] = Sprite;
}
示例9: Xeromyces_ReadObject
//.........这里部分代码省略.........
{
LOGERROR(L"GUI: (object: %hs) Can't set \"%hs\" to \"%ls\"", object->GetPresentableName().c_str(), pFile->GetAttributeString(attr.Name).c_str(), attr.Value.FromUTF8().c_str());
// This is not a fatal error
}
}
// Check if name isn't set, generate an internal name in that case.
if (!NameSet)
{
object->SetName("__internal(" + CStr::FromInt(m_InternalNameNumber) + ")");
++m_InternalNameNumber;
}
// Attempt to register the hotkey tag, if one was provided
if (! hotkeyTag.empty())
m_HotkeyObjects[hotkeyTag].push_back(object);
CStrW caption (Element.GetText().FromUTF8());
if (! caption.empty())
{
// Set the setting caption to this
object->SetSetting("caption", caption, true);
// There is no harm if the object didn't have a "caption"
}
//
// Read Children
//
// Iterate children
XMBElementList children = Element.GetChildNodes();
for (i=0; i<children.Count; ++i)
{
// Get node
XMBElement child = children.Item(i);
// Check what name the elements got
int element_name = child.GetNodeName();
if (element_name == elmt_object)
{
// Call this function on the child
Xeromyces_ReadObject(child, pFile, object, NameSubst, Paths);
}
else if (element_name == elmt_action)
{
// Scripted <action> element
// Check for a 'file' parameter
CStrW filename (child.GetAttributes().GetNamedItem(attr_file).FromUTF8());
CStr code;
// If there is a file, open it and use it as the code
if (! filename.empty())
{
Paths.insert(filename);
CVFSFile scriptfile;
if (scriptfile.Load(g_VFS, filename) != PSRETURN_OK)
{
LOGERROR(L"Error opening GUI script action file '%ls'", filename.c_str());
throw PSERROR_GUI_JSOpenFailed();
示例10: value
CMaterial& CMaterialManager::LoadMaterial(const VfsPath& pathname)
{
if(pathname.empty())
return NullMaterial;
std::map<VfsPath, CMaterial*>::iterator iter = m_Materials.find(pathname);
if(iter != m_Materials.end())
{
if((*iter).second)
return *(*iter).second;
}
CXeromyces xeroFile;
if(xeroFile.Load(g_VFS, pathname) != PSRETURN_OK)
return NullMaterial;
#define EL(x) int el_##x = xeroFile.GetElementID(#x)
#define AT(x) int at_##x = xeroFile.GetAttributeID(#x)
EL(texture);
EL(alpha);
AT(usage);
#undef AT
#undef EL
CMaterial *material = NULL;
try
{
XMBElement root = xeroFile.GetRoot();
XMBElementList childNodes = root.GetChildNodes();
material = new CMaterial();
for(int i = 0; i < childNodes.Count; i++)
{
XMBElement node = childNodes.Item(i);
int token = node.GetNodeName();
XMBAttributeList attrs = node.GetAttributes();
CStr temp;
if(token == el_texture)
{
CStr value(node.GetText());
material->SetTexture(value);
}
else if(token == el_alpha)
{
temp = CStr(attrs.GetNamedItem(at_usage));
// Determine whether the alpha is used for basic transparency or player color
if (temp == "playercolor")
material->SetUsePlayerColor(true);
else if (temp == "objectcolor")
material->SetUseTextureColor(true);
else
material->SetUsesAlpha(ParseUsage(temp));
}
}
m_Materials[pathname] = material;
}
catch(...)
{
SAFE_DELETE(material);
throw;
}
return *material;
}
示例11: Xeromyces_ReadObject
//.........这里部分代码省略.........
for (const std::pair<CStr, CStr>& sub : NameSubst)
name.Replace(sub.first, sub.second);
object->SetName(name);
NameSet = true;
continue;
}
if (attr.Name == attr_hotkey)
hotkeyTag = attr.Value;
if (attr.Name == attr_z)
ManuallySetZ = true;
if (object->SetSetting(pFile->GetAttributeString(attr.Name), attr.Value.FromUTF8(), true) != PSRETURN_OK)
LOGERROR("GUI: (object: %s) Can't set \"%s\" to \"%s\"", object->GetPresentableName(), pFile->GetAttributeString(attr.Name), attr.Value);
}
// Check if name isn't set, generate an internal name in that case.
if (!NameSet)
{
object->SetName("__internal(" + CStr::FromInt(m_InternalNameNumber) + ")");
++m_InternalNameNumber;
}
if (!hotkeyTag.empty())
m_HotkeyObjects[hotkeyTag].push_back(object);
CStrW caption(Element.GetText().FromUTF8());
if (!caption.empty())
object->SetSetting("caption", caption, true);
for (XMBElement child : Element.GetChildNodes())
{
// Check what name the elements got
int element_name = child.GetNodeName();
if (element_name == elmt_object)
{
// Call this function on the child
Xeromyces_ReadObject(child, pFile, object, NameSubst, Paths, nesting_depth);
}
else if (element_name == elmt_action)
{
// Scripted <action> element
// Check for a 'file' parameter
CStrW filename(child.GetAttributes().GetNamedItem(attr_file).FromUTF8());
CStr code;
// If there is a file, open it and use it as the code
if (!filename.empty())
{
Paths.insert(filename);
CVFSFile scriptfile;
if (scriptfile.Load(g_VFS, filename) != PSRETURN_OK)
{
LOGERROR("Error opening GUI script action file '%s'", utf8_from_wstring(filename));
throw PSERROR_GUI_JSOpenFailed();
}
code = scriptfile.DecodeUTF8(); // assume it's UTF-8
}
示例12: Xeromyces_ReadRootStyles
void CGUI::Xeromyces_ReadRootStyles(XMBElement Element, CXeromyces* pFile)
{
for (XMBElement child : Element.GetChildNodes())
Xeromyces_ReadStyle(child, pFile);
}