本文整理汇总了C++中TdfParser::GetSectionList方法的典型用法代码示例。如果您正苦于以下问题:C++ TdfParser::GetSectionList方法的具体用法?C++ TdfParser::GetSectionList怎么用?C++ TdfParser::GetSectionList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TdfParser
的用法示例。
在下文中一共展示了TdfParser::GetSectionList方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: catch
CWeaponDefHandler::CWeaponDefHandler()
{
std::vector<std::string> tafiles = CFileHandler::FindFiles("weapons/", "*.tdf");
//std::cout << " getting files from weapons/*.tdf ... " << std::endl;
TdfParser tasunparser;
for(unsigned int i=0; i<tafiles.size(); i++)
{
try {
tasunparser.LoadFile(tafiles[i]);
}catch( TdfParser::parse_error const& e) {
std::cout << "Exception:" << e.what() << std::endl;
} catch(...) {
std::cout << "Unknown exception in parse process of " << tafiles[i] <<" caught." << std::endl;
}
}
std::vector<std::string> weaponlist = tasunparser.GetSectionList("");
weaponDefs = SAFE_NEW WeaponDef[weaponlist.size()+1];
for(std::size_t taid=0; taid<weaponlist.size(); taid++)
{
ParseTAWeapon(&tasunparser, weaponlist[taid], taid);
}
}
示例2: FindTABuildOpt
void CUnitDefHandler::FindTABuildOpt()
{
TdfParser tdfparser;
tdfparser.LoadFile("gamedata/SIDEDATA.TDF");
std::vector<std::string> sideunits = tdfparser.GetSectionList("CANBUILD");
for(unsigned int i=0; i<sideunits.size(); i++)
{
std::map<std::string, std::string>::iterator it;
UnitDef *builder=NULL;
std::transform(sideunits[i].begin(), sideunits[i].end(), sideunits[i].begin(), (int (*)(int))std::tolower);
std::map<std::string, int>::iterator it1 = unitID.find(sideunits[i]);
if(it1!= unitID.end())
builder = &unitDefs[it1->second];
if(builder)
{
std::map<std::string, std::string> buildoptlist = tdfparser.GetAllValues("CANBUILD\\" + sideunits[i]);
for(it=buildoptlist.begin(); it!=buildoptlist.end(); it++)
{
UnitDef *buildopt=0;
std::transform(it->second.begin(),it->second.end(), it->second.begin(), (int (*)(int))std::tolower);
if(unitID.find(it->second)!= unitID.end()){
int num=atoi(it->first.substr(8).c_str());
builder->buildOptions[num]=it->second;
}
}
}
}
std::vector<std::string> files = CFileHandler::FindFiles("download/*.tdf");
for(unsigned int i=0; i<files.size(); i++)
{
TdfParser dparser(files[i]);
std::vector<std::string> sectionlist = dparser.GetSectionList("");
for(unsigned int j=0; j<sectionlist.size(); j++)
{
UnitDef *builder=NULL;
std::string un1 = dparser.SGetValueDef("", sectionlist[j] + "\\UNITMENU");
std::transform(un1.begin(), un1.end(), un1.begin(), (int (*)(int))std::tolower);
std::map<std::string, int>::iterator it1 = unitID.find(un1);
if(it1!= unitID.end())
builder = &unitDefs[it1->second];
if(builder)
{
UnitDef *buildopt=NULL;
string un2 = dparser.SGetValueDef("", sectionlist[j] + "\\UNITNAME");
std::transform(un2.begin(), un2.end(), un2.begin(), (int (*)(int))std::tolower);
if(unitID.find(un2)!= unitID.end()){
int menu=atoi(dparser.SGetValueDef("", sectionlist[j] + "\\MENU").c_str());
int button=atoi(dparser.SGetValueDef("", sectionlist[j] + "\\BUTTON").c_str());
int num=(menu-2)*6+button+1;
builder->buildOptions[num]=un2;
} else {
info->AddLine("couldnt find unit %s",un2.c_str());
}
}
}
}
}
示例3: CreateUIElement
//.........这里部分代码省略.........
{
frame=new GUIlabel((int)x, (int)y, (int)w, (int)h, caption);
}
else if(type=="state")
{
vector<string> options;
map<string, string> vals=parser.GetAllValues(path + "\\states");
map<string, string>::iterator i=vals.begin();
map<string, string>::iterator e=vals.end();
for(; i!=e; i++)
options.push_back(i->second);
frame = new GUIstateButton((int)x, (int)y, (int)w, options, makeFunctor((Functor2<GUIstateButton*, int>*)0, *this, &GUIdialogController::StateChanged));
}
else if(type=="input")
{
GUIinput *input=new GUIinput((int)x, (int)y, (int)w, (int)h, makeFunctor((Functor1<const string&>*)0, *this, &GUIdialogController::ConsoleInput));
input->SetCaption(caption);
frame=input;
}
else if(type=="resourcebar")
{
GUIpane *pane=new GUIresourceBar((int)x, (int)y, (int)w, (int)h);
pane->SetDraggable(parser.SGetValueDef("no", path+"\\draggable")=="yes");
pane->SetFrame(parser.SGetValueDef("yes", path+"\\frame")=="yes");
pane->SetResizeable(parser.SGetValueDef("no", path+"\\resizeable")=="yes");
frame=pane;
}
else if(type=="allyresourcebar")
{
GUIpane *pane=new GUIallyResourceBar((int)x, (int)y, (int)w, (int)h);
pane->SetDraggable(parser.SGetValueDef("no", path+"\\draggable")=="yes");
pane->SetFrame(parser.SGetValueDef("yes", path+"\\frame")=="yes");
frame=pane;
}
else if(type=="infoselection")
{
GUIinfoSelection *infoSelection=new GUIinfoSelection((int)x, (int)y, (int)w, (int)h);
infoSelection->SetDraggable(parser.SGetValueDef("no", path+"\\draggable")=="yes");
infoSelection->SetFrame(parser.SGetValueDef("yes", path+"\\frame")=="yes");
infoSelection->SetResizeable(parser.SGetValueDef("no", path+"\\resizeable")=="no");
float num=atof(parser.SGetValueDef("64", path+"\\buildpicsize").c_str());
ScaleX(num);
infoSelection->SetBuildPicSize((int)num);
frame=infoSelection;
}
if(!frame)
frame=CreateControl(type, (int)x, (int)y, (int)w, (int)h, parser);
if(!frame)
{
printf("unknown control definition %s\n", type.c_str());
return;
}
if(parser.SGetValueDef("no", path+"\\hidden")=="yes")
frame->ToggleHidden();
if(!tooltip.empty())
frame->SetTooltip(tooltip);
if(frame!=parent)
{
frame->SetIdentifier(identifier);
// add to parent
GUIswitchBar *bar=dynamic_cast<GUIswitchBar*>(parent);
if(bar)
{
// if it's a switchbar, look if child has a title for switchbars
string switchName=parser.SGetValueDef(caption, path+"\\switch");
bar->AddSwitchableChild(frame, switchName);
}
else
{
parent->AddChild(frame);
}
if(identifier!="")
controls[identifier]=frame;
}
// add children
vector<string> sects=parser.GetSectionList(path);
for(int i=0; i<sects.size(); i++)
{
printf("found section %s\n", sects[i].c_str());
if(!sects[i].compare(0, 6, "gadget"))
CreateUIElement(parser, frame, path+"\\"+sects[i]);
if(!sects[i].compare(0, 6, "dialog"))
{
string id=parser.SGetValueDef("", path+"\\"+sects[i]+"\\id");
GUIdialogController *controller=dialogControllers[id];
if(controller)
controller->CreateUIElement(parser, frame, path+"\\"+sects[i]);
}
}
}