本文整理汇总了C++中TdfParser::GetAllValues方法的典型用法代码示例。如果您正苦于以下问题:C++ TdfParser::GetAllValues方法的具体用法?C++ TdfParser::GetAllValues怎么用?C++ TdfParser::GetAllValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TdfParser
的用法示例。
在下文中一共展示了TdfParser::GetAllValues方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadSkirmishAIs
void CGameSetup::LoadSkirmishAIs(const TdfParser& file, std::set<std::string>& nameList)
{
// i = AI index in game (no gaps), a = AI index in script
for (int a = 0; a < MAX_PLAYERS; ++a) {
char section[50];
sprintf(section, "GAME\\AI%i\\", a);
string s(section);
if (!file.SectionExist(s.substr(0, s.length() - 1))) {
continue;
}
SkirmishAIData data;
data.team = atoi(file.SGetValueDef("-1", s + "Team").c_str());
if (data.team == -1) {
throw content_error("missing AI.Team in GameSetup script");
}
data.hostPlayer = atoi(file.SGetValueDef("-1", s + "Host").c_str());
if (data.hostPlayer == -1) {
throw content_error("missing AI.Host in GameSetup script");
}
data.shortName = file.SGetValueDef("", s + "ShortName");
if (data.shortName == "") {
throw content_error("missing AI.ShortName in GameSetup script");
}
data.version = file.SGetValueDef("", s + "Version");
if (file.SectionExist(s + "Options")) {
data.options = file.GetAllValues(s + "Options");
std::map<std::string, std::string>::const_iterator kv;
for (kv = data.options.begin(); kv != data.options.end(); ++kv) {
data.optionKeys.push_back(kv->first);
}
}
// get the visible name (comparable to player-name)
std::string name = file.SGetValueDef(data.shortName, s + "Name");
int instanceIndex = 0;
std::string name_unique = name;
while (nameList.find(name_unique) != nameList.end()) {
name_unique = name + "_" + IntToString(instanceIndex++);
// so we possibly end up with something like myBot_0, or RAI_2
}
data.name = name_unique;
nameList.insert(data.name);
skirmishAIStartingData.push_back(data);
}
}
示例2: LoadAllyTeams
void CGameSetup::LoadAllyTeams(const TdfParser& file)
{
// i = allyteam index in game (no gaps), a = allyteam index in script
int i = 0;
for (int a = 0; a < MAX_TEAMS; ++a) {
char section[50];
sprintf(section,"GAME\\ALLYTEAM%i",a);
string s(section);
if (!file.SectionExist(s))
continue;
AllyTeam data;
std::map<std::string, std::string> setup = file.GetAllValues(s);
for (std::map<std::string, std::string>::const_iterator it = setup.begin(); it != setup.end(); ++it)
data.SetValue(it->first, it->second);
allyStartingData.push_back(data);
allyteamRemap[a] = i;
++i;
}
{
const size_t numAllyTeams = allyStartingData.size();
for (size_t a = 0; a < numAllyTeams; ++a) {
allyStartingData[a].allies.resize(numAllyTeams, false);
allyStartingData[a].allies[a] = true; // each team is allied with itself
std::ostringstream section;
section << "GAME\\ALLYTEAM" << a << "\\";
const size_t numAllies = atoi(file.SGetValueDef("0", section.str() + "NumAllies").c_str());
for (size_t b = 0; b < numAllies; ++b) {
std::ostringstream key;
key << "GAME\\ALLYTEAM" << a << "\\Ally" << b;
const int other = atoi(file.SGetValueDef("0",key.str()).c_str());
allyStartingData[a].allies[allyteamRemap[other]] = true;
}
}
}
unsigned allyCount = 0;
if (file.GetValue(allyCount, "GAME\\NumAllyTeams") && (allyStartingData.size() != allyCount)) {
LOG_L(L_WARNING, "Incorrect number of ally teams in GameSetup script");
}
}
示例3: LoadPlayers
void CGameSetup::LoadPlayers(const TdfParser& file, std::set<std::string>& nameList)
{
numDemoPlayers = 0;
// i = player index in game (no gaps), a = player index in script
int i = 0;
for (int a = 0; a < MAX_PLAYERS; ++a) {
char section[50];
sprintf(section, "GAME\\PLAYER%i", a);
string s(section);
if (!file.SectionExist(s)) {
continue;
}
PlayerBase data;
// expects lines of form team=x rather than team=TEAMx
// team field is relocated in RemapTeams
std::map<std::string, std::string> setup = file.GetAllValues(s);
for (std::map<std::string, std::string>::const_iterator it = setup.begin(); it != setup.end(); ++it)
data.SetValue(it->first, it->second);
// do checks for sanity
if (data.name.empty())
throw content_error(str( boost::format("GameSetup: No name given for Player %i") %a ));
if (nameList.find(data.name) != nameList.end())
throw content_error(str(boost::format("GameSetup: Player %i has name %s which is already taken") %a %data.name.c_str() ));
nameList.insert(data.name);
if (data.isFromDemo)
numDemoPlayers++;
playerStartingData.push_back(data);
playerRemap[a] = i;
++i;
}
unsigned playerCount = 0;
if (file.GetValue(playerCount, "GAME\\NumPlayers") && playerStartingData.size() != playerCount) {
LOG_L(L_WARNING,
_STPF_ " players in GameSetup script (NumPlayers says %i)",
playerStartingData.size(), playerCount);
}
}
示例4: Load
void ClassAliasList::Load(TdfParser& parser, const string& location)
{
const map<string,string>& lst = parser.GetAllValues (location);
aliases.insert(lst.begin(), lst.end());
}
示例5: 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());
}
}
}
}
}
示例6: CreateUIElement
//.........这里部分代码省略.........
GUItable *table=new GUItable((int)x, (int)y, (int)w, (int)h, NULL, makeFunctor((Functor3<GUItable*, int, int>*)0, *this, &GUIdialogController::TableSelection));
frame=table;
}
else if(type=="pane")
{
GUIpane *pane=new GUIpane((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=="button")
{
GUIbutton* b=new GUIbutton((int)x, (int)y, caption, makeFunctor((Functor1<GUIbutton*>*)0, *this, &GUIdialogController::ButtonPressed));
b->SetSize((int)w, (int)h);
frame=b;
}
else if(type=="switchbar")
{
frame=new GUIswitchBar();
}
else if(type=="image")
{
frame=new GUIimage((int)x, (int)y, (int)w, (int)h, caption);
}
else if(type=="label")
{
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");