本文整理汇总了C++中XmlNodeRef::findChild方法的典型用法代码示例。如果您正苦于以下问题:C++ XmlNodeRef::findChild方法的具体用法?C++ XmlNodeRef::findChild怎么用?C++ XmlNodeRef::findChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlNodeRef
的用法示例。
在下文中一共展示了XmlNodeRef::findChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadProfile
//------------------------------------------------------------------------
bool CPlayerProfileImplConsole::LoadProfile(SUserEntry* pEntry, CPlayerProfile* pProfile, const char* name)
{
// load the profile from a specific location
// XML for now
string path;
InternalMakeFSPath(pEntry, name, path);
XmlNodeRef rootNode = GetISystem()->CreateXmlNode(PROFILE_ROOT_TAG);
CSerializerXML serializer(rootNode, true);
XmlNodeRef profile = LoadXMLFile(path+"profile.xml");
bool ok = false;
if(profile)
{
XmlNodeRef attrNode = profile->findChild("Attributes");
XmlNodeRef actionNode = profile->findChild("ActionMaps");
if(!(attrNode && actionNode)) //default (PC) profile?
{
attrNode = LoadXMLFile(path+"attributes.xml");
actionNode = LoadXMLFile(path+"actionmaps.xml");
}
if(attrNode && actionNode)
{
serializer.SetSection(CPlayerProfileManager::ePPS_Attribute, attrNode);
serializer.SetSection(CPlayerProfileManager::ePPS_Actionmap, actionNode);
ok = pProfile->SerializeXML(&serializer);
}
}
return ok;
}
示例2: SaveProfile
//------------------------------------------------------------------------
bool CPlayerProfileImplConsole::SaveProfile(SUserEntry* pEntry, CPlayerProfile* pProfile, const char* name, bool initialSave, int /*reason = ePR_All*/)
{
IPlatformOS *os = gEnv->pSystem->GetPlatformOS();
// save the profile into a specific location
// check if it's a valid filename
if (IsValidFilename(name) == false)
return false;
string path;
InternalMakeFSPath(pEntry, name, path);
XmlNodeRef rootNode = GetISystem()->CreateXmlNode(PROFILE_ROOT_TAG);
rootNode->setAttr(PROFILE_NAME_TAG, name);
CSerializerXML serializer(rootNode, false);
pProfile->SerializeXML(&serializer);
XmlNodeRef attributes = serializer.GetSection(CPlayerProfileManager::ePPS_Attribute);
XmlNodeRef actionMap = serializer.GetSection(CPlayerProfileManager::ePPS_Actionmap);
if(!rootNode->findChild("Attributes"))
rootNode->addChild(attributes);
if(!rootNode->findChild("ActionMaps"))
rootNode->addChild(actionMap);
return SaveXMLFile(path+"profile.xml", rootNode);
}
示例3: Init
void CMercyTimeFilter::Init( const XmlNodeRef& xml )
{
CRY_ASSERT(xml != NULL);
const XmlNodeRef difficultyFilterNode = xml->findChild("DifficultyFilters");
if(difficultyFilterNode != NULL)
{
const int childCount = difficultyFilterNode->getChildCount();
for(int i = 0; i < childCount; ++i)
{
const XmlNodeRef& childNode = difficultyFilterNode->getChild(i);
int difficultyLevel = 0;
if(childNode->getAttr("level", difficultyLevel) &&
((difficultyLevel > 0) && (difficultyLevel <= MaxDifficultyLevels)))
{
uint32 allowedHits = 0;
childNode->getAttr("killAfterHits", allowedHits);
m_difficultyTolerance[difficultyLevel-1] = allowedHits;
}
}
}
const XmlNodeRef projectileFilterNode = xml->findChild("ProjectileFilters");
if(projectileFilterNode != NULL)
{
const int childCount = projectileFilterNode->getChildCount();
m_filteredProjectiles.reserve( childCount );
for (int i = 0; i < childCount; ++i)
{
const XmlNodeRef& childNode = projectileFilterNode->getChild( i );
ClassFilter classFilter;
classFilter.classId = ~uint16(0);
classFilter.type = ClassFilter::eType_None;
if(g_pGame->GetIGameFramework()->GetNetworkSafeClassId( classFilter.classId, childNode->getAttr("class") ))
{
const char* filterType = childNode->haveAttr("filter") ? childNode->getAttr("filter") : "none";
if(strcmp(filterType, "self") == 0)
{
classFilter.type = ClassFilter::eType_Self;
}
m_filteredProjectiles.push_back( classFilter );
}
}
std::sort( m_filteredProjectiles.begin(), m_filteredProjectiles.end(), CompareClassFilter() );
}
}
示例4: PopulateDLCContents
void CDLCManager::PopulateDLCContents(const XmlNodeRef &rootNode, int dlcId, const char* name )
{
mbstowcs( m_dlcContents[dlcId].name, name, MAX_DLC_NAME );
XmlNodeRef levelsNode = rootNode->findChild("levels");
if (levelsNode)
{
XmlString levelName;
int numLevels = levelsNode->getChildCount();
CryLog( "Found %d levels in the DLC", numLevels );
m_dlcContents[dlcId].levels.reserve(numLevels);
for (int i=0; i<numLevels; ++i)
{
XmlNodeRef levelNode = levelsNode->getChild(i);
if (levelNode->getAttr("name", levelName))
{
CryLog( "Found level %s and added to the DLC manager", levelName.c_str() );
m_dlcContents[dlcId].levels.push_back(levelName);
}
}
}
XmlNodeRef bonusNode = rootNode->findChild("bonus");
if( bonusNode )
{
CryLog( "DLC pak includes a pre-sale bonus" );
uint32 bonusID = 0;
bonusNode->getAttr("id", bonusID );
m_dlcContents[dlcId].bonusID = bonusID;
}
XmlNodeRef uniqueIdNode = rootNode->findChild("uniqueId");
if( uniqueIdNode )
{
uint32 uniqueID = 0;
uniqueIdNode->getAttr("id", uniqueID );
m_dlcContents[dlcId].uniqueID = uniqueID;
}
XmlNodeRef uniqueTagNode = rootNode->findChild("uniqueTag");
if( uniqueTagNode )
{
const char* str = uniqueTagNode->getAttr( "tag" );
m_dlcContents[dlcId].uniqueTag.Format( str );
}
}
示例5: LoadEntityXMLProperties
void CEntityPropertyHandler::LoadEntityXMLProperties(IEntity *pEntity, const XmlNodeRef& xml)
{
if(auto properties = xml->findChild("Properties"))
{
for(int i = 0; i < properties->getNumAttributes(); i++)
{
const char *name;
const char *value;
properties->getAttributeByIndex(i, &name, &value);
int index = 0;
bool exists = false;
for(; index < GetPropertyCount(); index++)
{
SPropertyInfo info;
GetPropertyInfo(index, info);
if(!strcmp(info.name, name))
{
exists = true;
break;
}
}
if(exists)
SetProperty(pEntity, index, value);
else
MonoWarning("Could not set property %s because it did not exist", name);
}
}
}
示例6: LoadParamsFromXml
void CMFXParticleEffect::LoadParamsFromXml(const XmlNodeRef& paramsNode)
{
// Xml data format
/*
<Particle>
<Name userdata="..." scale="..." maxdist="..." minscale="..." maxscale="..." maxscaledist="..." attach="...">particle.name</Name>
<Direction>DirectionType</Direction>
</Particle>
*/
for (int i=0; i<paramsNode->getChildCount(); ++i)
{
XmlNodeRef child = paramsNode->getChild(i);
if (!strcmp(child->getTag(), "Name"))
{
SMFXParticleEntry entry;
entry.name = child->getContent();
if (child->haveAttr("userdata"))
entry.userdata = child->getAttr("userdata");
if (child->haveAttr("scale"))
child->getAttr("scale", entry.scale);
if (child->haveAttr("maxdist"))
child->getAttr("maxdist", entry.maxdist);
if (child->haveAttr("minscale"))
child->getAttr("minscale", entry.minscale);
if (child->haveAttr("maxscale"))
child->getAttr("maxscale", entry.maxscale);
if (child->haveAttr("maxscaledist"))
child->getAttr("maxscaledist", entry.maxscaledist);
if (child->haveAttr("attach"))
child->getAttr("attach", entry.attachToTarget);
m_particleParams.m_entries.push_back(entry);
}
}
SMFXParticleParams::EDirectionType directionType = SMFXParticleParams::eDT_Normal;
XmlNodeRef dirType = paramsNode->findChild("Direction");
if (dirType)
{
const char *val = dirType->getContent();
if (!strcmp(val, "Normal"))
{
directionType = SMFXParticleParams::eDT_Normal;
}
else if (!strcmp(val, "Ricochet"))
{
directionType = SMFXParticleParams::eDT_Ricochet;
}
}
m_particleParams.directionType = directionType;
}
开发者ID:NightOwlsEntertainment,项目名称:PetBox_A_Journey_to_Conquer_Elementary_Algebra,代码行数:60,代码来源:MFXParticleEffect.cpp
示例7: 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
示例8: SerializeXML
void CClipVolumeProxy::SerializeXML(XmlNodeRef &entityNodeXML, bool loading)
{
if(loading)
{
LOADING_TIME_PROFILE_SECTION;
if(XmlNodeRef pVolumeNode = entityNodeXML->findChild( "ClipVolume" ))
{
const char* szFileName = NULL;
if(pVolumeNode->getAttr("GeometryFileName",&szFileName))
{
// replace %level% by level path
char szFilePath[_MAX_PATH];
const int nAliasNameLen = sizeof("%level%")-1;
cry_strcpy(szFilePath, gEnv->p3DEngine->GetLevelFilePath(szFileName+nAliasNameLen));
if(m_pEntity && LoadFromFile(szFilePath))
gEnv->p3DEngine->UpdateClipVolume(m_pClipVolume, m_pRenderMesh, m_pBspTree, m_pEntity->GetWorldTM(), !m_pEntity->IsHidden(), m_pEntity->GetName());
}
}
}
else
{
XmlNodeRef volumeNode = entityNodeXML->newChild( "ClipVolume" );
volumeNode->setAttr( "GeometryFileName", m_GeometryFileName );
}
}
示例9: RegisterTemplates
//------------------------------------------------------------------------
bool CVehicleDamagesTemplateRegistry::RegisterTemplates(const string& filename, const string& defFilename)
{
XmlNodeRef table = gEnv->pSystem->LoadXmlFromFile(filename);
if (!table)
return false;
m_templateFiles.resize(m_templateFiles.size() + 1);
STemplateFile& templateFile = m_templateFiles.back();
templateFile.defFilename = defFilename;
templateFile.filename = filename;
templateFile.templateTable = table;
if (XmlNodeRef damagesGroupsTable = table->findChild("DamagesGroups"))
{
int i = 0;
int c = damagesGroupsTable->getChildCount();
for (; i < c; i++)
{
if (XmlNodeRef damagesGroupTable = damagesGroupsTable->getChild(i))
{
string name = damagesGroupTable->getAttr("name");
if (!name.empty())
m_templates.insert(TTemplateMap::value_type(name, damagesGroupTable));
}
}
}
return true;
}
示例10: GetSharedParameters
void CItemComponent::GetSharedParameters(XmlNodeRef rootParams)
{
// Parameters get stored under a combination of the class name and the section name for the parameters.
CryFixedStringT<256> sharedName;
sharedName.Format("item::%s::%s", GetEntity()->GetClass()->GetName(), "itemBase");
ISharedParamsManager* pSharedParamsManager = gEnv->pGameFramework->GetISharedParamsManager();
CRY_ASSERT(pSharedParamsManager);
m_itemBaseParameter = CastSharedParamsPtr<SItemBaseParameter>(pSharedParamsManager->Get(sharedName));
// If no parameter set exists we should attempt to create and register one.
if (!m_itemBaseParameter)
{
SItemBaseParameter sharedParams;
// Load in the base item shared parameters.
XmlNodeRef itemBaseParams = rootParams->findChild("itemBase");
if (itemBaseParams)
sharedParams.Read(itemBaseParams);
// Register a new set of parameters and retrieve a shared pointer to them.
m_itemBaseParameter = CastSharedParamsPtr<SItemBaseParameter>(pSharedParamsManager->Register(sharedName, sharedParams));
}
// Double check the shared parameter.
CRY_ASSERT(m_itemBaseParameter.get());
}
示例11: LoadExternalEntities
void CCheckpointSystem::LoadExternalEntities(XmlNodeRef parentNode)
{
XmlNodeRef data = parentNode->findChild(EXTERNAL_ENTITIES_SECTION);
if(!data)
return;
int numEntities = data->getChildCount();
for(int i = 0; i < numEntities; ++i)
{
XmlNodeRef nextEntity = data->getChild(i);
if(nextEntity)
{
EntityId id = 0;
nextEntity->getAttr("id", id);
const char *name = nextEntity->getAttr("name");
//fix entityId if broken
if(RepairEntityId(id, name))
{
IEntity *pEntity = gEnv->pEntitySystem->GetEntity(id);
//setup entity
bool bActive = false;
bool bHidden = false;
nextEntity->getAttr("active", bActive);
nextEntity->getAttr("hidden", bHidden);
pEntity->Activate(bActive);
pEntity->Hide(bHidden);
//load matrix
SerializeWorldTM(pEntity, nextEntity, false);
}
}
}
}
开发者ID:NightOwlsEntertainment,项目名称:PetBox_A_Journey_to_Conquer_Elementary_Algebra,代码行数:33,代码来源:CheckPointSystem.cpp
示例12: GetAdditionalMinimapData
//////////////////////////////////////////////////////////////////////////
//
// Allows the game code to write game-specific data into the minimap xml
// file on level export. Currently used to export data to StatsTool
//
//////////////////////////////////////////////////////////////////////////
bool CEditorGame::GetAdditionalMinimapData(XmlNodeRef output)
{
string classes = g_pGameCVars->g_telemetryEntityClassesToExport;
if(!classes.empty())
{
// additional data relating to StatsTool
XmlNodeRef statsNode = output->findChild("StatsTool");
if(!statsNode)
{
statsNode = GetISystem()->CreateXmlNode("StatsTool");
output->addChild(statsNode);
}
else
{
statsNode->removeAllChilds();
}
// first build a list of entity classes from the cvar
std::vector<IEntityClass*> interestingClasses;
int curPos = 0;
string currentClass = classes.Tokenize(",",curPos);
IEntitySystem* pES = GetISystem()->GetIEntitySystem();
if(IEntityClassRegistry* pClassReg = pES->GetClassRegistry())
{
while (!currentClass.empty())
{
if(IEntityClass* pClass = pClassReg->FindClass(currentClass.c_str()))
{
interestingClasses.push_back(pClass);
}
currentClass = classes.Tokenize(",",curPos);
}
}
// now iterate through all entities and save the ones which match the classes
if(interestingClasses.size() > 0)
{
IEntityItPtr it = pES->GetEntityIterator();
while(IEntity* pEntity = it->Next())
{
if(stl::find(interestingClasses, pEntity->GetClass()))
{
XmlNodeRef entityNode = GetISystem()->CreateXmlNode("Entity");
statsNode->addChild(entityNode);
entityNode->setAttr("class", pEntity->GetClass()->GetName());
Vec3 pos = pEntity->GetWorldPos();
entityNode->setAttr("x", pos.x);
entityNode->setAttr("y", pos.y);
entityNode->setAttr("z", pos.z);
}
}
}
}
return true;
}
示例13: 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;
}
示例14: ReadMetaData
bool CCheckpointSystem::ReadMetaData(XmlNodeRef parentNode, SCheckpointData &metaData, bool bRepairId /*=true*/)
{
XmlNodeRef data = parentNode->findChild(META_DATA_SECTION);
if(!data)
return false;
metaData.m_versionNumber = 0;
metaData.m_levelName.clear();
metaData.m_saveTime.clear();
metaData.m_checkPointId = 0;
//read meta data
int numAttribs = data->getNumAttributes();
const char *key, *value;
const char *checkpointName = NULL;
for(int i = 0; i < numAttribs; ++i)
{
data->getAttributeByIndex(i, &key, &value);
if(!stricmp("Version", key))
{
metaData.m_versionNumber = atoi(value);
}
else if(!stricmp("CheckpointId", key))
{
metaData.m_checkPointId = EntityId(atoi(value));
}
else if(!stricmp("CheckpointName", key))
{
checkpointName = value;
}
else if(!stricmp("LevelName", key))
{
metaData.m_levelName = value;
}
else if(!stricmp("Timestamp", key))
{
metaData.m_saveTime = value;
}
}
//EntityId's may change on level export -> fix id
if(checkpointName && bRepairId)
{
if(!RepairEntityId(metaData.m_checkPointId, checkpointName))
CryWarning(VALIDATOR_MODULE_GAME, VALIDATOR_ERROR, "Failed finding checkpoint entity during loading, flowgraph might be broken.");
}
//check all values have been read
CRY_ASSERT(metaData.m_levelName.size() > 0);
CRY_ASSERT(metaData.m_saveTime.size() > 0);
//CRY_ASSERT(metaData.m_checkPointId);
return true;
}
开发者ID:NightOwlsEntertainment,项目名称:PetBox_A_Journey_to_Conquer_Elementary_Algebra,代码行数:55,代码来源:CheckPointSystem.cpp
示例15: GetArchetypesFromLevelLib
void GetArchetypesFromLevelLib(XmlNodeRef root, std::vector<string>* archetypeNames)
{
if (!root)
return;
string sRootName;
sRootName = root->getTag();
XmlNodeRef pLevelNode = root->findChild("EntityPrototypesLibs");
if (!pLevelNode)
return;
XmlNodeRef pLevelLibrary = pLevelNode->findChild("LevelLibrary");
if (!pLevelLibrary)
return;
GetArchetypesFromLib(pLevelLibrary, sRootName, archetypeNames);
}