forked from 0ad/0ad
Allow nesting repeat tags in the GUI.
This was SVN commit r16034.
This commit is contained in:
parent
fd93e4ae74
commit
622614de02
@ -1068,7 +1068,7 @@ void CGUI::Xeromyces_ReadRootSetup(XMBElement Element, CXeromyces* pFile)
|
||||
}
|
||||
}
|
||||
|
||||
void CGUI::Xeromyces_ReadObject(XMBElement Element, CXeromyces* pFile, IGUIObject *pParent, const std::vector<std::pair<CStr, CStr> >& NameSubst, boost::unordered_set<VfsPath>& Paths, u32 nesting_depth)
|
||||
void CGUI::Xeromyces_ReadObject(XMBElement Element, CXeromyces* pFile, IGUIObject *pParent, std::vector<std::pair<CStr, CStr> >& NameSubst, boost::unordered_set<VfsPath>& Paths, u32 nesting_depth)
|
||||
{
|
||||
ENSURE(pParent);
|
||||
int i;
|
||||
@ -1285,7 +1285,7 @@ void CGUI::Xeromyces_ReadObject(XMBElement Element, CXeromyces* pFile, IGUIObjec
|
||||
}
|
||||
else if (element_name == elmt_repeat)
|
||||
{
|
||||
Xeromyces_ReadRepeat(child, pFile, object, Paths, nesting_depth);
|
||||
Xeromyces_ReadRepeat(child, pFile, object, NameSubst, Paths, nesting_depth);
|
||||
}
|
||||
else if (element_name == elmt_translatableAttribute)
|
||||
{
|
||||
@ -1446,29 +1446,33 @@ void CGUI::Xeromyces_ReadObject(XMBElement Element, CXeromyces* pFile, IGUIObjec
|
||||
}
|
||||
}
|
||||
|
||||
void CGUI::Xeromyces_ReadRepeat(XMBElement Element, CXeromyces* pFile, IGUIObject *pParent, boost::unordered_set<VfsPath>& Paths, u32 nesting_depth)
|
||||
void CGUI::Xeromyces_ReadRepeat(XMBElement Element, CXeromyces* pFile, IGUIObject *pParent, std::vector<std::pair<CStr, CStr> >& NameSubst, boost::unordered_set<VfsPath>& Paths, u32 nesting_depth)
|
||||
{
|
||||
#define ELMT(x) int elmt_##x = pFile->GetElementID(#x)
|
||||
#define ATTR(x) int attr_##x = pFile->GetAttributeID(#x)
|
||||
ELMT(object);
|
||||
ATTR(count);
|
||||
ATTR(var);
|
||||
|
||||
XMBAttributeList attributes = Element.GetAttributes();
|
||||
|
||||
int count = CStr(attributes.GetNamedItem(attr_count)).ToInt();
|
||||
CStr var("["+attributes.GetNamedItem(attr_var)+"]");
|
||||
if (var.size() < 3)
|
||||
var = "[n]";
|
||||
|
||||
for (int n = 0; n < count; ++n)
|
||||
{
|
||||
std::vector<std::pair<CStr, CStr> > subst;
|
||||
subst.push_back(std::make_pair(CStr("[n]"), "[" + CStr::FromInt(n) + "]"));
|
||||
NameSubst.push_back(std::make_pair(var, "[" + CStr::FromInt(n) + "]"));
|
||||
|
||||
XERO_ITER_EL(Element, child)
|
||||
{
|
||||
if (child.GetNodeName() == elmt_object)
|
||||
{
|
||||
Xeromyces_ReadObject(child, pFile, pParent, subst, Paths, nesting_depth);
|
||||
Xeromyces_ReadObject(child, pFile, pParent, NameSubst, Paths, nesting_depth);
|
||||
}
|
||||
}
|
||||
NameSubst.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2013 Wildfire Games.
|
||||
/* Copyright (C) 2014 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -444,14 +444,15 @@ private:
|
||||
*
|
||||
* @see LoadXmlFile()
|
||||
*/
|
||||
void Xeromyces_ReadObject(XMBElement Element, CXeromyces* pFile, IGUIObject *pParent, const std::vector<std::pair<CStr, CStr> >& NameSubst, boost::unordered_set<VfsPath>& Paths, u32 nesting_depth);
|
||||
void Xeromyces_ReadObject(XMBElement Element, CXeromyces* pFile, IGUIObject *pParent, std::vector<std::pair<CStr, CStr> >& NameSubst, boost::unordered_set<VfsPath>& Paths, u32 nesting_depth);
|
||||
|
||||
/**
|
||||
* Reads in the element \<repeat\>, which repeats its child \<object\>s
|
||||
* 'count' times, replacing the string "[n]" in its descendants' names
|
||||
* with "[0]", "[1]", etc.
|
||||
* 'count' times, replacing the string "[n]" (or the value of the attribute
|
||||
* 'var' enclosed in square brackets) in its descendants' names with "[0]",
|
||||
* "[1]", etc.
|
||||
*/
|
||||
void Xeromyces_ReadRepeat(XMBElement Element, CXeromyces* pFile, IGUIObject *pParent, boost::unordered_set<VfsPath>& Paths, u32 nesting_depth);
|
||||
void Xeromyces_ReadRepeat(XMBElement Element, CXeromyces* pFile, IGUIObject *pParent, std::vector<std::pair<CStr, CStr> >& NameSubst, boost::unordered_set<VfsPath>& Paths, u32 nesting_depth);
|
||||
|
||||
/**
|
||||
* Reads in the element \<script\> (the XMBElement) and executes
|
||||
|
Loading…
Reference in New Issue
Block a user