本文整理汇总了C++中XmlNode::next_sibling方法的典型用法代码示例。如果您正苦于以下问题:C++ XmlNode::next_sibling方法的具体用法?C++ XmlNode::next_sibling怎么用?C++ XmlNode::next_sibling使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlNode
的用法示例。
在下文中一共展示了XmlNode::next_sibling方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadNewGameSettings
void CreateGameScreen::LoadNewGameSettings()
{
if(_newGameSettingsLoaded == false)
{
_newGameSettingsLoaded = true;
// Get new game settings config file
RefPtr<Configuration> mainConfig = ConfigurationManager::Instance()->GetConfiguration("Main");
string filepath = mainConfig->FindOptionValue("NewGameConfig", "Files");
RefPtr<XmlDocument> settingsDoc = XmlUtility::XmlDocFromFile(filepath.c_str());
XmlNode* rootNode = settingsDoc->first_node("NewGameSettings");
// Read values
XmlNode* gameTypesListNode = rootNode->first_node("GameTypes");
XmlNode* gameTypeNode = gameTypesListNode->first_node();
while(gameTypeNode != 0)
{
GameTypeNames.push_back(XmlUtility::XmlGetString(gameTypeNode, "name"));
gameTypeNode = gameTypeNode->next_sibling();
}
XmlNode* colorsListNode = rootNode->first_node("AvailableColors");
XmlNode* colorNode = colorsListNode->first_node();
while(colorNode != 0)
{
PlayersColorsList.push_back(XmlUtility::XmlGetRGB(colorNode));
colorNode = colorNode->next_sibling();
}
NoColorIndex = PlayersColorsList.size() - 1;
XmlNode* resourceModesListNode = rootNode->first_node("ResourceModes");
XmlNode* resourceModeNode = resourceModesListNode->first_node();
while(resourceModeNode != 0)
{
ResourceModeNames.push_back(XmlUtility::XmlGetString(resourceModeNode, "name"));
resourceModeNode = resourceModeNode->next_sibling();
}
XmlNode* visibilityModesListNode = rootNode->first_node("VisibilityModes");
XmlNode* visibilityModeNode = visibilityModesListNode->first_node();
while(visibilityModeNode != 0)
{
VisibilityModeNames.push_back(XmlUtility::XmlGetString(visibilityModeNode, "name"));
visibilityModeNode = visibilityModeNode->next_sibling();
}
XmlNode* startModesListNode = rootNode->first_node("StartLocModes");
XmlNode* startModeNode = startModesListNode->first_node();
while(startModeNode != 0)
{
StartLocModeNames.push_back(XmlUtility::XmlGetString(startModeNode, "name"));
startModeNode = startModeNode->next_sibling();
}
}
}
示例2: AddGameModes
void CreateGameScreen::AddGameModes(XmlNode* mapNode)
{
string defMode = XmlUtility::XmlGetString(mapNode->first_node("DefaultMode"), "name");
_currentMode = 0;
_availableModes.clear();
_comboGameMode->removeAllItems();
XmlNode* modesListNode = mapNode->first_node("Modes");
int modeNum = 0;
XmlNode* modeNode = modesListNode->first_node();
while(modeNode != 0)
{
Mode mode;
mode.Name = modeNode->name();
mode.Display = XmlUtility::XmlGetStringIfExists(modeNode, "display", mode.Name.c_str());
mode.IsCustomisable = XmlUtility::XmlGetBoolIfExists(modeNode, "customisable", true);
_availableModes.push_back(mode);
_comboGameMode->addItem(mode.Display, modeNum);
// Additionaly find default mode index
if(mode.Name.compare(defMode) == 0)
{
_currentMode = modeNum;
_comboGameMode->setIndexSelected(modeNum);
}
++modeNum;
modeNode = modeNode->next_sibling();
}
}
示例3:
IAction* ForIntegerAction::Factory::Create(XmlNode* actionNode)
{
ForIntegerAction* newAction = xNew0(ForIntegerAction);
XmlNode* fromNode = actionNode->first_node("From");
XmlNode* toNode = actionNode->first_node("To");
XmlNode* incNode = actionNode->first_node("IncrementBy");
XmlNode* varNode = actionNode->first_node("Variable");
XmlNode* childActionNode = actionNode->first_node("Actions")->first_node();
MultiAction* actions = xNew0(MultiAction);
while(childActionNode != 0)
{
actions->AddAction(MainEventPool::GlobalPool->
CreateAction(childActionNode));
childActionNode = childActionNode->next_sibling();
}
newAction->SetParameters(
IntRetrieverFactory::Create(fromNode),
IntRetrieverFactory::Create(toNode),
IntRetrieverFactory::Create(incNode),
XmlUtility::XmlGetString(varNode, "name"),
actions);
return newAction;
}
示例4: ParseWeapons
void UnitDefinition::ParseWeapons(XmlNode* wNode)
{
// Load all weapon definitions
XmlNode* weaponNode = wNode->first_node("Weapon",6);
while(weaponNode != 0)
{
bool isActive = XmlUtility::XmlGetBool(weaponNode, "active", 6);
string weaponName = XmlUtility::XmlGetString(weaponNode, "definition", 10);
// Becouse in this point they might be not loaded yet,
// postpone it until all defs are loaded
auto addWeaponDef = [this, weaponName, isActive]()
{
_weapons.push_back(std::make_pair(
MainGameObjectPool::GlobalPool->GetObjectDefinitionByNameCast
<WeaponDefinition>(weaponName, "Weapon"), isActive));
};
MainGameObjectPool::GlobalPool->OnAllDefinitionsLoaded() +=
xNew1(DelegateEventHandler<decltype(addWeaponDef)>, addWeaponDef);
weaponNode = weaponNode->next_sibling();
}
}
示例5: ParseTrainableUnits
void UnitDefinition::ParseTrainableUnits(XmlNode* trainableNode)
{
XmlNode* unitNode = trainableNode->first_node("Unit");
while(unitNode != 0)
{
const char* defName = CopyChar(XmlUtility::XmlGetString(unitNode, "definition"));
int num = XmlUtility::XmlGetInt(unitNode, "num");
TrainableUnit* unit(xNew0(TrainableUnit));
unit->DefinitionName = defName;
unit->Number = num;
XmlNode* allReqsNode = unitNode->first_node("Requirements");
if( allReqsNode != 0 )
{
XmlNode* reqNode = allReqsNode->first_node("Requirement");
while( reqNode != 0 )
{
unit->RequirementNames.push_back(CopyChar(
XmlUtility::XmlGetString(reqNode, "name")));
}
}
_trainableUnitsDefs.push_back(unit);
unitNode = unitNode->next_sibling();
}
}
示例6: readModel
void XmlParser::readModel(Transform * transform, XmlNode * modelNode) {
// Create model
glm::mat4 model;
if (modelNode) {
// Get each transformation
XmlNode * transformNode = modelNode->first_node();
while (transformNode) {
std::string type(transformNode->name());
// Translate
if (type == "translate") {
XmlAttr * x, * y, * z;
xmlAttribute(x, transformNode);
xmlAttribute(y, transformNode);
xmlAttribute(z, transformNode);
// Apply transformation
transform->translate(atof(x->value()), atof(y->value()), atof(z->value()));
}
// Rotate
else if (type == "rotate") {
// Read angle
XmlAttr * angle;
xmlAttribute(angle, transformNode);
// Check normal
glm::vec3 normal(0, 1, 0);
XmlNode * normalNode = transformNode->first_node("normal");
if (normalNode) {
XmlAttr * x, * y, * z;
xmlAttribute(x, normalNode);
xmlAttribute(y, normalNode);
xmlAttribute(z, normalNode);
// Set new normal
normal = glm::vec3(atof(x->value()), atof(y->value()), atof(z->value()));
}
// Apply transformation
transform->rotate(atof(angle->value()), normal);
}
// Scale
else if (type == "scale") {
XmlAttr * x, * y, * z;
xmlAttribute(x, transformNode);
xmlAttribute(y, transformNode);
xmlAttribute(z, transformNode);
// Apply transformation
transform->scale(atof(x->value()), atof(y->value()), atof(z->value()));
}
// Get next transformation
transformNode = transformNode->next_sibling();
}
}
}
示例7: readScripts
void XmlParser::readScripts(Scene * scene, Transform * transform, XmlNode * scripts) {
if (scripts) {
// Get each script
XmlNode * script = scripts->first_node("script");
while (script) {
XmlAttr * name;
xmlAttribute(name, script);
// Crate script and bind it to transform
scene->addScript(Script::GetScriptByName(transform, name->value()));
// Get next script
script = script->next_sibling("script");
}
}
}
示例8: ParseCommands
void UnitDefinition::ParseCommands(XmlNode* commandsNode)
{
// Get command list
XmlNode* commandNode = commandsNode->first_node("Command",7);
while(commandNode != 0)
{
Command* customCommand = 0;
// Read command type and if its default one
int key = OrderTypes::ParseOrderType(commandNode->first_attribute("type",4,false)->value());
if( XmlUtility::XmlGetBool(commandNode, "custom", 6) )
{
// Custom command ( ability or non-default non-ability )
}
// Get command button its name, position, hotkey
XmlNode* buttonNode = commandNode->first_node("Button",6);
string buttonName = XmlUtility::XmlGetString(buttonNode,"definition", 10);
int hotkey = SystemSettings::GetKeyBindings().KeyCodeNamesMap[
XmlUtility::XmlGetString(buttonNode, "key", 3)];
int posx = XmlUtility::XmlGetInt(buttonNode, "x", 1);
int posy = XmlUtility::XmlGetInt(buttonNode, "y", 1);
// Lambda funtion for creating button -> button needs definition which can
// be not loaded at this point ( as CommandSet is created in UnitDefinition ),
// so we'll create it later, when all Definitions are loaded
auto createButton = [this, key, buttonName, hotkey, posx, posy, customCommand]()
{
CommandButton* button = xNew1(CommandButton,
MainGameObjectPool::GlobalPool->GetObjectDefinitionByNameCast
<CommandButtonDefinition>(buttonName, "CommandButton"));
button->SetHotkey(hotkey);
button->SetPosX(posx);
button->SetPosY(posy);
if( customCommand == 0 )
_defaultCommandButtons.push_back(std::make_pair(key, button));
else
_customCommands.push_back(std::make_pair(customCommand, button));
};
MainGameObjectPool::GlobalPool->OnAllDefinitionsLoaded() +=
xNew1(DelegateEventHandler<decltype(createButton)>,createButton);
commandNode = commandNode->next_sibling();
}
}
示例9: MapSelected
void CreateGameScreen::MapSelected(RefPtr<XmlDocument>& mapDoc)
{
_currentMapDoc = mapDoc;
_currentMapDir = _mapList->GetCurrentDir();
_buttonStart->setEnabled(false);
try
{
// Read and set preview image and start locations
XmlNode* mapNode = mapDoc->first_node("Map");
Vector2 mapSize = XmlUtility::XmlGetXY(mapNode->first_node("Size"));
string previewImage = XmlUtility::XmlGetString(mapNode->first_node("PreviewImage"), "value");
XmlNode* startLocListNode = mapNode->first_node("AvailableStartLocations");
XmlNode* startLocNode = startLocListNode->first_node();
while( startLocNode != 0 )
{
_startLocPositions.push_back(XmlUtility::XmlGetXY(startLocNode));
startLocNode = startLocNode->next_sibling();
}
_mapPreview->SetNewMap(mapSize, _mapList->GetCurrentDir() + previewImage,
previewImage, _startLocPositions.size());
for(unsigned int i = 0; i < _startLocPositions.size(); ++i)
{
_mapPreview->MoveStartingPosition(i, _startLocPositions[i]);
_mapPreview->SetStartingPositionColor(i, PlayersColorsList[NoColorIndex]);
}
AddGameModes(mapNode);
int defMode = _currentMode;
_currentMode = -1;
SetGameMode(defMode);
_comboGameMode->setEnabled(true);
_comboResourcesMode->setEnabled(true);
_comboStartLocMode->setEnabled(true);
_comboVisibilityMode->setEnabled(true);
}
catch(...)
{
_ASSERT(false);
// Map file is corrupted, maybe show some info on it
}
}
示例10: ParseUnitSounds
void UnitDefinition::ParseUnitSounds(XmlNode* soundsNode)
{
_unitSoundSet.resize( UnitSounds::DefSoundActionsCount, 0 );
if( soundsNode != 0 )
{
// Parse all sounds
XmlNode* sndNode = soundsNode->first_node("Sound");
while(sndNode != 0)
{
const char* actionName = XmlUtility::XmlGetString(sndNode, "action");
const char* soundName = XmlUtility::XmlGetString(sndNode, "name");
const char* soundPack = XmlUtility::XmlGetString(sndNode, "pack");
float gain = XmlUtility::XmlGetFloatIfExists(sndNode, "gain", 1.f);
int actionNum = UnitSounds::ParseSoundAction(actionName);
_ASSERT( actionNum >= 0 );
if( actionNum < 0 )
continue;
Media::SoundSource* ssource = Media::AudioManager::Instance()->CreateSoundSource(
soundName, soundPack);
_unitSoundSet[actionNum] = ssource;
ssource->SetGain(gain);
Media::AudioManager::Instance()->LoadSoundPack( soundPack );
sndNode = sndNode->next_sibling();
}
}
// For all non-set sounds set default ones
for(unsigned int i = 0; i < _unitSoundSet.size(); ++i)
{
if( _unitSoundSet[i] == 0 )
{
Media::SoundSource* ssource = Media::AudioManager::Instance()->CreateSoundSource(
UnitSounds::GetDefaultSound((UnitSounds::SoundAction)i));
_unitSoundSet[i] = ssource;
}
}
}
示例11: ParseAllTriggers
void MainEventPool::ParseAllTriggers(XmlNode* rootNode)
{
// trigsNode is root node in map's triggers file
// First save all variables - find node Variables
XmlNode* varsNode = rootNode->first_node("Variables", 9);
// Save all variables
// Create triggers - find Triggers node
XmlNode* trigsNode = rootNode->first_node("Triggers", 8);
XmlNode* trigNode = trigsNode->first_node("Trigger");
while(trigNode != 0)
{
Trigger* trigger = CreateTrigger(trigNode);
_triggers.insert(std::make_pair(trigger->GetName(), trigger));
bool enabled = XmlUtility::XmlGetBoolIfExists(trigNode, "is_enabled", true);
if(enabled)
trigger->Enable();
trigNode = trigNode->next_sibling();
}
}
示例12: CreateTrigger
Trigger* MainEventPool::CreateTrigger(XmlNode* trigNode)
{
const char* trigName = XmlUtility::XmlGetString(trigNode, "name");
Trigger* trigger = xNew1(Trigger, trigName);
XmlNode* evtNode = trigNode->first_node("Event");
if(evtNode != 0) // Trigger may not have and event
{
trigger->SetEvent(FindEvent(evtNode));
}
XmlNode* actsNode = trigNode->first_node("Actions", 7);
MultiAction* actions = xNew0(MultiAction);
XmlNode* actNode = actsNode->first_node("Action", 6);
while (actNode != 0)
{
actions->AddAction(CreateAction(actNode));
actNode = actNode->next_sibling();
}
trigger->SetActions(actions);
return trigger;
}
示例13: readLights
void XmlParser::readLights(Scene * scene, XmlNode * lights) {
if (lights) {
// Read all lights from scene
XmlNode * light = lights->first_node("light");
while (light) {
// Create light
Light * l = new Light();
// Get position from xml
XmlNode * position;
xmlElement(position, light);
// Get coordinates
XmlAttr * x, * y, * z;
xmlAttribute(x, position);
xmlAttribute(y, position);
xmlAttribute(z, position);
// Set position
l->setPosition(atof(x->value()), atof(y->value()), atof(z->value()));
// Get direction from xml
XmlNode * direction;
xmlElement(direction, light);
// Get coordinates
xmlAttribute(x, direction);
xmlAttribute(y, direction);
xmlAttribute(z, direction);
// Set position
l->setDirection(atof(x->value()), atof(y->value()), atof(z->value()));
// Check angle
XmlNode * angle = light->first_node("angle");
if (angle) {
XmlAttr * value;
xmlAttribute(value, angle);
l->setLightAngle(atof(value->value()));
}
// Try to get diffuse
XmlNode * diffuse = light->first_node("diffuse");
if (diffuse) {
// Get coordinates
XmlAttr * r, * g, * b;
xmlAttribute(r, diffuse);
xmlAttribute(g, diffuse);
xmlAttribute(b, diffuse);
// Set diffuse
l->setDiffuse(atof(r->value()), atof(g->value()), atof(b->value()));
}
// Try to get specular
XmlNode * specular = light->first_node("specular");
if (specular) {
// Get coordinates
XmlAttr * r, * g, * b;
xmlAttribute(r, specular);
xmlAttribute(g, specular);
xmlAttribute(b, specular);
// Set specular
l->setSpecular(atof(r->value()), atof(g->value()), atof(b->value()));
}
// Read scripts
XmlNode * scripts = light->first_node("scripts");
readScripts(scene, l, scripts);
// Add to scene
scene->addLight(l);
// Get next light
light = light->next_sibling("light");
}
} else {
printf("No lights\n");
}
}