本文整理汇总了C++中XmlNode::GetChildren方法的典型用法代码示例。如果您正苦于以下问题:C++ XmlNode::GetChildren方法的具体用法?C++ XmlNode::GetChildren怎么用?C++ XmlNode::GetChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlNode
的用法示例。
在下文中一共展示了XmlNode::GetChildren方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadTutorialLevelNames
void LevelLoader::LoadTutorialLevelNames(std::vector<std::string>* levelsWithTutorials) {
FRAMEWORK->GetLogger()->dbglog("\nLoading tutorials from file: %s", tutorialXmlPath);
XmlParser* parser = new XmlParser();
parser->ParseXmlFile(FRAMEWORK->GetFileSystemUtils()->GetDeviceBaseResourcesPath() + tutorialXmlPath);
XmlTree* xmlTree = parser->GetXmlTree();
ASSERT(xmlTree != nullptr, "Got valid xmlTree from parser for level file %s", tutorialXmlPath);
XmlNode* rootTutorialsNode = xmlTree->GetRootNode();
ASSERT(rootTutorialsNode != nullptr, "Got valid tutoral node from xml tree for tutorial file %s", tutorialXmlPath);
for(XmlNode* tutorialNode : rootTutorialsNode->GetChildren()) {
FRAMEWORK->GetLogger()->dbglog("\n Loaded tutorial data for level: %s", tutorialNode->GetAttributeValueS(NAME_ATTRIBUTE).c_str());
levelsWithTutorials->push_back(tutorialNode->GetAttributeValueS(NAME_ATTRIBUTE));
}
delete parser;
}
示例2: LoadLevelData
void LevelLoader::LoadLevelData(std::vector<ContractData*>* contractData) {
// Load the tutorials
std::vector<std::string> levelsWithTutorials;
LevelLoader::LoadTutorialLevelNames(&levelsWithTutorials);
FRAMEWORK->GetLogger()->dbglog("\nLoading levelData from file: %s", levelListXmlPath);
XmlParser* parser = new XmlParser();
parser->ParseXmlFile(FRAMEWORK->GetFileSystemUtils()->GetDeviceBaseResourcesPath() + levelListXmlPath);
XmlTree* xmlTree = parser->GetXmlTree();
ASSERT(xmlTree != nullptr, "Got valid xmlTree from parser for level file %s", levelListXmlPath);
XmlNode* rootLevelListNode = xmlTree->GetRootNode();
ASSERT(rootLevelListNode != nullptr, "Got valid tutoral node from xml tree for tutorial file %s", levelListXmlPath);
// Get the saved data
VERIFY(FRAMEWORK->GetSavedDataManager()->HasBundle(PLAYER_BUNDLE_NAME), "The game has saved data");
Bundle* bundle = FRAMEWORK->GetSavedDataManager()->GetSavedBundle(PLAYER_BUNDLE_NAME);
ASSERT(bundle->HasKey(LEVEL_COMPLETION), "The saved data has level completion");
std::string levelCompletionData = bundle->GetString(LEVEL_COMPLETION);
int missionNum = 0;
int levelNum = 0;
for(XmlNode* contractNode : rootLevelListNode->GetChildren()) {
ContractData* cData = new ContractData();
cData->name = StringUtilities::ReplaceCharInString(contractNode->GetAttributeValueS("title"), '_', ' ');
for(XmlNode* missionNode : contractNode->GetChildren()) {
FRAMEWORK->GetLogger()->dbglog("\n Loaded mission data for game");
MissionData* mData = new MissionData();
mData->name = StringUtilities::ReplaceCharInString(missionNode->GetAttributeValueS("title"), '_', ' ');
for(XmlNode* levelDataNode : missionNode->GetChildren()) {
LevelData* lData = new LevelData();
lData->name = levelDataNode->GetAttributeValueS(NAME_PROPERTY);
lData->name = StringUtilities::ReplaceCharInString(lData->name, '_', ' ');
lData->path = levelDataNode->GetAttributeValueS(PATH_PROPERTY);
lData->type = LevelLoader::stringToLevelType(levelDataNode->GetAttributeValueS(TYPE_PROPERTY));
lData->bounty = StringUtilities::ConvertStringToInt(levelDataNode->GetAttributeValueS("bounty"));
lData->description = StringUtilities::StringToUpper(levelDataNode->GetAttributeValueS(TYPE_PROPERTY));
lData->completion = LevelLoader::charToCompletionData(levelCompletionData[levelNum]);
lData->hasTutorial = std::find(levelsWithTutorials.begin(), levelsWithTutorials.end(), lData->path) != levelsWithTutorials.end();
lData->levelNum = levelNum;
lData->bonus = LevelBonus::None;
for(XmlNode* child : levelDataNode->GetChildren()) {
if(child->GetName() == "missionScreen") {
lData->pinX = child->GetAttributeValueF("x");
lData->pinY = child->GetAttributeValueF("y");
lData->parallaxScreen = child->GetAttributeValueF("parallaxScreen");
} else if(child->GetName() == "bonus") {
lData->bonus = StringToLevelBonus(child->GetAttributeValueS("type"));
lData->bonusValue = child->GetAttributeValueI("value");
}
}
mData->levels.push_back(lData);
levelNum++;
}
cData->missions.push_back(mData);
missionNum++;
}
contractData->push_back(cData);
}
delete parser;
}