本文整理汇总了C++中XmlNodeRef::getChild方法的典型用法代码示例。如果您正苦于以下问题:C++ XmlNodeRef::getChild方法的具体用法?C++ XmlNodeRef::getChild怎么用?C++ XmlNodeRef::getChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlNodeRef
的用法示例。
在下文中一共展示了XmlNodeRef::getChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InitModification
void CVehicleModificationParams::InitModification( XmlNodeRef xmlModificationData )
{
assert( xmlModificationData );
bool hasParentModification = xmlModificationData->haveAttr( "parent" );
if ( hasParentModification )
{
XmlNodeRef xmlModificationsGroup = xmlModificationData->getParent();
const char* parentModificationName = xmlModificationData->getAttr( "parent" );
XmlNodeRef xmlParentModificationData = FindModificationNodeByName( parentModificationName, xmlModificationsGroup );
if ( xmlParentModificationData && ( xmlParentModificationData != xmlModificationData ) )
{
InitModification( xmlParentModificationData );
}
}
XmlNodeRef xmlElemsGroup = xmlModificationData->findChild( "Elems" );
if ( ! xmlElemsGroup )
{
return;
}
for ( int i = 0; i < xmlElemsGroup->getChildCount(); ++i )
{
XmlNodeRef xmlElem = xmlElemsGroup->getChild( i );
InitModificationElem( xmlElem );
}
}
开发者ID:NightOwlsEntertainment,项目名称:PetBox_A_Journey_to_Conquer_Elementary_Algebra,代码行数:30,代码来源:VehicleModificationParams.cpp
示例2: SetString
void CWorldState::SetString(const char * entityName, char * valueName , string value)
{
// CryLog("CWorldState::SetString()");
if(worldStateXml)
{
XmlNodeRef entityNode = worldStateXml->findChild(entityName);
if(!entityNode)
{
CreateChild(entityName);
entityNode = worldStateXml->findChild(entityName);
}
const uint32 Count = entityNode->getChildCount();
for (uint32 Index = 0; Index < Count; ++Index)
{
XmlNodeRef child = entityNode->getChild(Index);
if(strcmp(child->getTag(),valueName)==0)
{
child->setAttr("value",value);
worldStateXml->saveToFile(szSaveFile);
return;
}
}
//CryLog("CWorldState::CreateString()");
XmlNodeRef child = entityNode->newChild(valueName);
child->setAttr("value",value);
worldStateXml->saveToFile(szSaveFile);
}
else
return;
}
示例3: Init
//------------------------------------------------------------------------
void CGameRulesHoldObjectiveBase::Init( XmlNodeRef xml )
{
const int numChildren = xml->getChildCount();
for (int childIdx = 0; childIdx < numChildren; ++ childIdx)
{
XmlNodeRef xmlChild = xml->getChild(childIdx);
if (!stricmp(xmlChild->getTag(), "SpawnParams"))
{
const char *pType = 0;
if (xmlChild->getAttr("type", &pType))
{
if (!stricmp(pType, "avoid"))
{
m_spawnPOIType = eSPT_Avoid;
}
else
{
CryLog("CGameRulesHoldObjectiveBase::Init: ERROR: Unknown spawn point of interest type ('%s')", pType);
}
xmlChild->getAttr("distance", m_spawnPOIDistance);
}
}
else if (!stricmp(xmlChild->getTag(), "EffectData"))
{
InitEffectData(xmlChild);
}
}
for (int i = 0; i < HOLD_OBJECTIVE_MAX_ENTITIES; ++ i)
{
m_entities[i].Reset();
}
}
示例4: LoadAntiCheatVars
void CAntiCheatManager::LoadAntiCheatVars(XmlNodeRef child)
{
int numVars = child->getChildCount();
for (int i=0; i<numVars; ++i)
{
XmlNodeRef varsChild = child->getChild(i);
if (varsChild->isTag("Var"))
{
const char* sVarName = varsChild->getAttr("name");
TAntiCheatVarIdx antiCheatVarIdx = FindAntiCheatVarIdx_Float(sVarName);
if (antiCheatVarIdx != eAV_Invalid_Float)
{
varsChild->getAttr("value", m_cheatVarsFloat[antiCheatVarIdx]);
}
else
{
antiCheatVarIdx = FindAntiCheatVarIdx_Int(sVarName);
if (antiCheatVarIdx != eAV_Invalid_Int)
{
varsChild->getAttr("value", m_cheatVarsInt[antiCheatVarIdx]);
}
else
{
CryLog("Unrecognised anti cheat var '%s'", sVarName);
}
}
}
else
{
CryLog("Unrecognised child node '%s'", varsChild->getTag());
}
}
}
示例5: Init
//-------------------------------------------------------------------------
void CGameRulesStandardState::Init( XmlNodeRef xml )
{
m_pGameRules = g_pGame->GetGameRules();
m_state = EGRS_Intro;
m_lastReceivedServerState = m_state;
m_timeInPostGame = 0.f;
m_introMessageShown = false;
m_isStarting = false;
m_isWaitingForOverrideTimer = false;
m_startTimerOverrideWait = 0.0f;
m_timeInCurrentPostGameState = 0.f;
m_postGameState = ePGS_Unknown;
m_bHaveNotifiedIntroListeners = false;
m_bHasShownHighlightReel = false;
ChangeState(EGRS_Intro);
int numChildren = xml->getChildCount();
for (int i = 0; i < numChildren; ++ i)
{
XmlNodeRef xmlChild = xml->getChild(i);
if (!stricmp(xmlChild->getTag(), "StartStrings"))
{
const char *pString = 0;
if (xmlChild->getAttr("startMatch", &pString))
{
m_startMatchString.Format("@%s", pString);
}
}
}
}
示例6: GetBool
bool CWorldState::GetBool(const char * entityName, char * valueName)
{
// CryLog("CWorldState::GetBool()");
bool result = false;
if(worldStateXml)
{
XmlNodeRef entityNode = worldStateXml->findChild(entityName);
if(entityNode)
{
const uint32 Count = entityNode->getChildCount();
for (uint32 Index = 0; Index < Count; ++Index)
{
const XmlNodeRef currentNode = entityNode->getChild(Index);
if(strcmp(currentNode->getTag(),valueName)==0)
{
if(strcmp(currentNode->getAttr("value"),"true")==0)
result = true;
break;
}
}
}
else
CryWarning( VALIDATOR_MODULE_GAME, VALIDATOR_ERROR, "CWorldState::Failed to get world state value!");
}
else
CryWarning( VALIDATOR_MODULE_GAME, VALIDATOR_ERROR, "CWorldState::Failed to get world state value!");
return result;
}
示例7: InitGlobalFileEnums
void CEditorGame::InitGlobalFileEnums(IGameToEditorInterface* pGTE)
{
// Read in enums stored offline XML. Format is
// <GlobalEnums>
// <EnumName>
// <entry enum="someName=someValue" /> <!-- displayed name != value -->
// <entry enum="someNameValue" /> <!-- displayed name == value -->
// </EnumName>
// </GlobalEnums>
//
XmlNodeRef rootNode = GetISystem()->LoadXmlFromFile("Libs/GlobalEnums.xml");
if (!rootNode || !rootNode->getTag() || stricmp(rootNode->getTag(), "GlobalEnums") != 0)
{
// GameWarning("CEditorGame::InitUIEnums: File 'Libs/GlobalEnums.xml' is not a GlobalEnums file");
return;
}
for (int i = 0; i < rootNode->getChildCount(); ++i)
{
XmlNodeRef enumNameNode = rootNode->getChild(i);
const char* enumId = enumNameNode->getTag();
if (enumId == 0 || *enumId=='\0')
continue;
int maxChilds = enumNameNode->getChildCount();
if (maxChilds > 0)
{
// allocate enough space to hold all strings
const char** nameValueStrings = new const char*[maxChilds];
int curEntryIndex = 0;
for (int j = 0; j < maxChilds; ++j)
{
XmlNodeRef enumNode = enumNameNode->getChild(j);
const char* nameValue = enumNode->getAttr("enum");
if (nameValue != 0 && *nameValue!='\0')
{
// put in the nameValue pair
nameValueStrings[curEntryIndex++] = nameValue;
}
}
// if we found some entries inform CUIDataBase about it
if (curEntryIndex > 0)
pGTE->SetUIEnums(enumId, nameValueStrings, curEntryIndex);
// be nice and free our array
delete[] nameValueStrings;
}
}
}
示例8: Assign
void CScriptProperties::Assign( XmlNodeRef &propsNode,IScriptTable* pPropsTable )
{
const char* key = "";
const char* value = "";
int nAttrs = propsNode->getNumAttributes();
for (int attr = 0; attr < nAttrs; attr++)
{
if (!propsNode->getAttributeByIndex( attr,&key,&value ))
continue;
ScriptVarType varType = pPropsTable->GetValueType(key);
switch (varType)
{
case svtNull:
break;
case svtString:
pPropsTable->SetValue( key,value );
break;
case svtNumber:
{
float fValue = (float)atof(value);
pPropsTable->SetValue( key,fValue );
}
break;
case svtBool:
{
bool const bValue = (stricmp(value, "true") == 0) || (stricmp(value, "1") == 0);
pPropsTable->SetValue(key, bValue);
}
break;
case svtObject:
{
Vec3 vec;
propsNode->getAttr(key,vec);
CScriptVector vecTable;
pPropsTable->GetValue( key,vecTable );
vecTable.Set( vec );
//pPropsTable->SetValue( key,vec );
}
break;
case svtPointer:
case svtUserData:
case svtFunction:
// Ignore invalid property types.
break;
}
}
for (int i = 0; i < propsNode->getChildCount(); i++)
{
XmlNodeRef childNode = propsNode->getChild(i);
SmartScriptTable pChildPropTable;
if (pPropsTable->GetValue(childNode->getTag(),pChildPropTable))
{
// Recurse.
Assign( childNode,pChildPropTable );
}
}
}
示例9: LoadAttributes
//------------------------------------------------------------------------
bool CPlayerProfile::LoadAttributes(const XmlNodeRef& root, int requiredVersion)
{
int version = 0;
const bool bHaveVersion = root->getAttr(VERSION_TAG, version);
if (requiredVersion > 0)
{
if (bHaveVersion && version < requiredVersion)
{
GameWarning("CPlayerProfile::LoadAttributes: Attributes of profile '%s' have different version (%d != %d). Updated.", GetName(), version, requiredVersion);
return false;
}
else if (!bHaveVersion)
{
GameWarning("CPlayerProfile::LoadAttributes: Attributes of legacy profile '%s' has no version (req=%d). Loading anyway.", GetName(), requiredVersion);
}
m_attributesVersion = requiredVersion;
}
else
// for default profile we set the version we found in the rootNode
m_attributesVersion = version;
int nChilds = root->getChildCount();
for (int i=0; i<nChilds; ++i)
{
XmlNodeRef child = root->getChild(i);
if (child && strcmp(child->getTag(), "Attr") == 0)
{
const char* name = child->getAttr("name");
const char* value = child->getAttr("value");
const char* platform = child->getAttr("platform");
bool platformValid = true;
if(platform != NULL && platform[0])
{
#if defined(DURANGO)
platformValid = (strstr(platform, "xbox")!=0);
#elif defined(ORBIS)
platformValid = (strstr(platform, "ps4")!=0);
#else
platformValid = (strstr(platform, "pc")!=0);
#endif
}
if (name && value && platformValid)
{
m_attributeMap[name] = TFlowInputData(string(value));
}
}
}
if(m_pManager->HasEnabledOnlineAttributes() && m_pManager->CanProcessOnlineAttributes() && !IsDefault())
{
m_pManager->LoadOnlineAttributes(this);
}
return true;
}
示例10: PreLoadModule
bool CFlowGraphModule::PreLoadModule(const char* fileName)
{
m_fileName = fileName;
XmlNodeRef moduleRef = gEnv->pSystem->LoadXmlFromFile(fileName);
if (!moduleRef)
{
CryWarning(VALIDATOR_MODULE_FLOWGRAPH, VALIDATOR_WARNING, "Unable to preload Flowgraph Module: %s", PathUtil::GetFileName(fileName).c_str());
return false;
}
assert(!stricmp(moduleRef->getTag(), "Graph"));
bool module = false;
moduleRef->getAttr("isModule", module);
assert(module);
XmlString tempName;
if (moduleRef->getAttr("moduleName", tempName))
m_name = tempName;
bool bResult = (m_pRootGraph != NULL);
assert(m_pRootGraph == NULL);
// first handle module ports
XmlNodeRef modulePorts = moduleRef->findChild("ModuleInputsOutputs");
RemoveModulePorts();
if (modulePorts)
{
int nPorts = modulePorts->getChildCount();
for (int i = 0; i < nPorts; ++i)
{
XmlString portName;
int portType;
bool isInput;
XmlNodeRef port = modulePorts->getChild(i);
port->getAttr("Name", portName);
port->getAttr("Type", portType);
port->getAttr("Input", isInput);
IFlowGraphModule::SModulePortConfig portConfig;
portConfig.name = portName.c_str();
portConfig.type = (EFlowDataTypes)portType;
portConfig.input = isInput;
AddModulePort(portConfig);
}
}
// and create nodes for this module (needs to be done before actual graph load, so that the
// nodes can be created there)
RegisterNodes();
return bResult;
}
示例11: Init
//------------------------------------------------------------------------
void CGameRulesCommonDamageHandling::Init( XmlNodeRef xml )
{
m_pGameRules = g_pGame->GetGameRules();
// Reserved hit types - in sync with RESERVED_HIT_TYPES
/*00*/ //m_pGameRules->RegisterHitType("invalid", CGameRules::EHitTypeFlag::None);
/*01*/ m_pGameRules->RegisterHitType("melee", CGameRules::EHitTypeFlag::IsMeleeAttack | CGameRules::EHitTypeFlag::IgnoreHeadshots);
/*02*/ m_pGameRules->RegisterHitType("collision", CGameRules::EHitTypeFlag::Server);
/*03*/ m_pGameRules->RegisterHitType("frag", CGameRules::EHitTypeFlag::Server | CGameRules::EHitTypeFlag::AllowPostDeathDamage);
/*04*/ m_pGameRules->RegisterHitType("explosion", CGameRules::EHitTypeFlag::Server | CGameRules::EHitTypeFlag::AllowPostDeathDamage);
/*05*/ m_pGameRules->RegisterHitType("stealthKill", CGameRules::EHitTypeFlag::Server | CGameRules::EHitTypeFlag::AllowPostDeathDamage);
/*06*/ m_pGameRules->RegisterHitType("silentMelee", CGameRules::EHitTypeFlag::IsMeleeAttack | CGameRules::EHitTypeFlag::SinglePlayerOnly | CGameRules::EHitTypeFlag::IgnoreHeadshots);
/*07*/ m_pGameRules->RegisterHitType("punish", CGameRules::EHitTypeFlag::ClientSelfHarm);
/*08*/ m_pGameRules->RegisterHitType("punishFall", CGameRules::EHitTypeFlag::ClientSelfHarm);
/*10*/ m_pGameRules->RegisterHitType("fall", CGameRules::EHitTypeFlag::ClientSelfHarm);
/*11*/ m_pGameRules->RegisterHitType("normal", CGameRules::EHitTypeFlag::Server); //Used for killing players so they can switch teams
/*12*/ m_pGameRules->RegisterHitType("fire", CGameRules::EHitTypeFlag::Server); // used by PressurizedObject.lua
/*14*/ m_pGameRules->RegisterHitType("heavyBullet", CGameRules::EHitTypeFlag::ValidationRequired);
/*18*/ m_pGameRules->RegisterHitType("environmentalThrow", CGameRules::EHitTypeFlag::CustomValidationRequired | CGameRules::EHitTypeFlag::AllowPostDeathDamage | CGameRules::EHitTypeFlag::IgnoreHeadshots);
/*19*/ m_pGameRules->RegisterHitType("meleeLeft", CGameRules::EHitTypeFlag::IsMeleeAttack | CGameRules::EHitTypeFlag::SinglePlayerOnly | CGameRules::EHitTypeFlag::IgnoreHeadshots);
/*20*/ m_pGameRules->RegisterHitType("meleeRight", CGameRules::EHitTypeFlag::IsMeleeAttack | CGameRules::EHitTypeFlag::SinglePlayerOnly | CGameRules::EHitTypeFlag::IgnoreHeadshots);
/*21*/ m_pGameRules->RegisterHitType("meleeKick", CGameRules::EHitTypeFlag::IsMeleeAttack | CGameRules::EHitTypeFlag::SinglePlayerOnly | CGameRules::EHitTypeFlag::IgnoreHeadshots);
/*22*/ m_pGameRules->RegisterHitType("meleeUppercut", CGameRules::EHitTypeFlag::IsMeleeAttack | CGameRules::EHitTypeFlag::SinglePlayerOnly | CGameRules::EHitTypeFlag::IgnoreHeadshots);
/*23*/ m_pGameRules->RegisterHitType("vehicleDestruction", CGameRules::EHitTypeFlag::Server | CGameRules::EHitTypeFlag::AllowPostDeathDamage);
/*27*/ m_pGameRules->RegisterHitType("eventDamage", CGameRules::EHitTypeFlag::ClientSelfHarm);
/*29*/ m_pGameRules->RegisterHitType("environmentalMelee", CGameRules::EHitTypeFlag::IsMeleeAttack | CGameRules::EHitTypeFlag::CustomValidationRequired | CGameRules::EHitTypeFlag::AllowPostDeathDamage | CGameRules::EHitTypeFlag::IgnoreHeadshots);
CRY_ASSERT(m_pGameRules->GetHitTypesCount() == CGameRules::EHitType::Unreserved);
// Read any non-native hit_types from the HitTypes.xml file!
XmlNodeRef xmlNode = gEnv->pSystem->LoadXmlFromFile( "Scripts/Entities/Items/HitTypes.xml" );
if( xmlNode )
{
const int numEntries = xmlNode->getChildCount();
for (int i = 0; i < numEntries; ++i)
{
XmlNodeRef hitTypeXML = xmlNode->getChild(i);
if (strcmp(hitTypeXML->getTag(), "hit_type") != 0)
continue;
if( const char* pHitType = hitTypeXML->getAttr("name") )
{
TBitfield flags = CGameRules::EHitTypeFlag::None;
if( const char * pHitTypeFlags = hitTypeXML->getAttr("flags"))
{
flags = AutoEnum_GetBitfieldFromString(pHitTypeFlags, CGameRules::s_hitTypeFlags, CGameRules::EHitTypeFlag::HIT_TYPES_FLAGS_numBits);
}
m_pGameRules->RegisterHitType( pHitType, flags );
}
}
}
m_scriptHitInfo.Create(gEnv->pScriptSystem);
}
示例12:
void CD6ArmorManager::LoadFromXML(XmlNodeRef& rootNode)
{
int childCount = rootNode->getChildCount();
for (int i = 0; i < childCount; ++i)
{
XmlNodeRef node = rootNode->getChild(i);
if (NULL == node)
continue;
if (0 == strcmp(node->getTag(), "Armor"))
{
XmlString armorName;
SArmorDef armorDef;
// Read the Armor tag's name attribute
if (!node->getAttr("name", armorName))
continue;
armorDef.szArmorName = armorName;
// Read warheads
int childCount = node->getChildCount();
for (int i = 0; i < childCount; ++i)
{
XmlNodeRef warhead = node->getChild(i);
if (0 == strcmp(warhead->getTag(), "Warhead"))
{
SArmorWarheadDef warheadDef;
XmlString name;
if (!warhead->getAttr("name", name))
break;
warheadDef.szWarheadName = name;
if (!warhead->getAttr("multiplier", warheadDef.fMultiplier))
warheadDef.fMultiplier = 1.0f;
armorDef.warheads.push_back(warheadDef);
}
}
m_ArmorDefs.insert(std::make_pair(m_NextArmorId++, armorDef));
}
}
}
示例13: LoadWeaponsAccessories
void CHUD::LoadWeaponsAccessories()
{
XmlNodeRef weaponAccessoriesXmlNode = GetISystem()->LoadXmlFile("Libs/UI/WeaponAccessories.xml");
if(weaponAccessoriesXmlNode)
{
int iNumChildren = weaponAccessoriesXmlNode->getChildCount();
for(int iChild=0; iChild<iNumChildren; iChild++)
{
LoadWeaponAccessories(weaponAccessoriesXmlNode->getChild(iChild));
}
}
}
示例14: LoadEquipmentPacks
// Loads equipment packs from rootNode
void CEquipmentManager::LoadEquipmentPacks(const XmlNodeRef& rootNode)
{
MEMSTAT_CONTEXT(EMemStatContextTypes::MSC_Other, 0, "Equipment Packs");
if (rootNode->isTag("EquipPacks") == false)
return;
for (int i=0; i<rootNode->getChildCount(); ++i)
{
XmlNodeRef packNode = rootNode->getChild(i);
LoadEquipmentPack(packNode, true);
}
}
示例15: CompareNodes
bool CEntityPoolSignature::CompareNodes(const XmlNodeRef &a, const XmlNodeRef &b, bool bRecursive)
{
FUNCTION_PROFILER(GetISystem(), PROFILE_ENTITY);
assert(bool(a));
assert(bool(b));
bool bResult = (a && b && a->isTag(b->getTag()));
// Check value
bResult &= (bResult && 0 == strcmp(a->getContent(), b->getContent()));
// Check attributes
bResult &= (bResult && CompareNodeAttributes(a, b));
// Check children if recursive
if (bResult && bRecursive)
{
const int childCount_a = a->getChildCount();
const int childCount_b = b->getChildCount();
bResult &= (childCount_a == childCount_b);
if (bResult)
{
for (int child = 0; bResult && child < childCount_a; ++child)
{
XmlNodeRef child_a = a->getChild(child);
XmlNodeRef child_b = b->getChild(child);
if (child_a && child_b)
{
bResult &= CompareNodes(child_a, child_b, true);
}
}
}
}
return bResult;
}