本文整理汇总了C++中SerializerElement::GetChild方法的典型用法代码示例。如果您正苦于以下问题:C++ SerializerElement::GetChild方法的具体用法?C++ SerializerElement::GetChild怎么用?C++ SerializerElement::GetChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SerializerElement
的用法示例。
在下文中一共展示了SerializerElement::GetChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UnserializeFrom
void ResourcesManager::UnserializeFrom(const SerializerElement & element)
{
const SerializerElement & resourcesElement = element.GetChild("resources", 0, "Resources");
resourcesElement.ConsiderAsArrayOf("resource", "Resource");
for(std::size_t i = 0;i<resourcesElement.GetChildrenCount();++i)
{
const SerializerElement & resourceElement = resourcesElement.GetChild(i);
gd::String kind = resourceElement.GetStringAttribute("kind");
gd::String name = resourceElement.GetStringAttribute("name");
std::shared_ptr<Resource> resource = CreateResource(kind);
resource->SetName(name);
resource->UnserializeFrom(resourceElement);
resources.push_back(resource);
}
#if defined(GD_IDE_ONLY)
const SerializerElement & resourcesFoldersElement = element.GetChild("resourceFolders", 0, "ResourceFolders");
resourcesFoldersElement.ConsiderAsArrayOf("folder", "Folder");
for(std::size_t i = 0;i<resourcesFoldersElement.GetChildrenCount();++i)
{
ResourceFolder folder;
folder.UnserializeFrom(resourcesFoldersElement.GetChild(i), *this);
folders.push_back(folder);
}
#endif
}
示例2: UnserializeFrom
/**
* \brief Unserialize the layer.
*/
void Layer::UnserializeFrom(const SerializerElement & element)
{
SetName(element.GetStringAttribute("name", "", "Name"));
SetVisibility(element.GetBoolAttribute("visibility", true, "Visibility"));
//Compatibility with GD <= 3.3
if (element.HasChild("Camera"))
{
for (std::size_t i = 0; i < element.GetChildrenCount("Camera"); ++i)
{
const SerializerElement & cameraElement = element.GetChild("Camera", i);
SetCameraCount(GetCameraCount()+1);
Camera & camera = GetCamera(GetCameraCount()-1);
camera.SetUseDefaultSize(cameraElement.GetBoolAttribute("DefaultSize", true));
camera.SetSize(cameraElement.GetDoubleAttribute("Width"), cameraElement.GetDoubleAttribute("Height"));
camera.SetUseDefaultViewport(cameraElement.GetBoolAttribute("DefaultViewport", true));
camera.SetViewport(cameraElement.GetDoubleAttribute("ViewportLeft"),
cameraElement.GetDoubleAttribute("ViewportTop"),
cameraElement.GetDoubleAttribute("ViewportRight"),
cameraElement.GetDoubleAttribute("ViewportBottom")
); // (sf::Rect used Right and Bottom instead of Width and Height before)
}
}
//End of compatibility code
else
{
SerializerElement & camerasElement = element.GetChild("cameras");
camerasElement.ConsiderAsArrayOf("camera");
for (std::size_t i = 0; i < camerasElement.GetChildrenCount(); ++i)
{
const SerializerElement & cameraElement = camerasElement.GetChild(i);
SetCameraCount(GetCameraCount()+1);
Camera & camera = GetCamera(GetCameraCount()-1);
camera.SetUseDefaultSize(cameraElement.GetBoolAttribute("defaultSize", true));
camera.SetSize(cameraElement.GetDoubleAttribute("width"), cameraElement.GetDoubleAttribute("height"));
camera.SetUseDefaultViewport(cameraElement.GetBoolAttribute("defaultViewport", true));
camera.SetViewport(cameraElement.GetDoubleAttribute("viewportLeft"),
cameraElement.GetDoubleAttribute("viewportTop"),
cameraElement.GetDoubleAttribute("viewportRight"),
cameraElement.GetDoubleAttribute("viewportBottom")); // (sf::Rect used Right and Bottom instead of Width and Height before)
}
}
effects.clear();
SerializerElement & effectsElement = element.GetChild("effects");
effectsElement.ConsiderAsArrayOf("effect");
for (std::size_t i = 0; i < effectsElement.GetChildrenCount(); ++i)
{
const SerializerElement & effectElement = effectsElement.GetChild(i);
auto effect = std::shared_ptr<gd::Effect>(new Effect);
effect->UnserializeFrom(effectElement);
effects.push_back(effect);
}
}
示例3: UnserializeFrom
void LinkEvent::UnserializeFrom(gd::Project & project, const SerializerElement & element)
{
SerializerElement & includeElement = element.GetChild("include", 0, "Limites");
SetTarget(element.GetChild("target", 0, "Scene").GetValue().GetString());
if(includeElement.HasAttribute("includeAll"))
{
//Compatibility with GDevelop <= 4.0.92
if(includeElement.GetBoolAttribute("includeAll", true))
{
SetIncludeAllEvents();
}
else
{
SetIncludeStartAndEnd(includeElement.GetIntAttribute("start"),
includeElement.GetIntAttribute("end"));
}
}
else
{
//GDevelop > 4.0.92
IncludeConfig config = static_cast<IncludeConfig>(includeElement.GetIntAttribute("includeConfig", 0));
if(config == INCLUDE_ALL)
SetIncludeAllEvents();
else if(config == INCLUDE_EVENTS_GROUP)
SetIncludeEventsGroup(includeElement.GetStringAttribute("eventsGroup"));
else if(config == INCLUDE_BY_INDEX)
SetIncludeStartAndEnd(includeElement.GetIntAttribute("start"), includeElement.GetIntAttribute("end"));
}
}
示例4: UnserializeFrom
void ForEachEvent::UnserializeFrom(gd::Project & project, const SerializerElement & element)
{
objectsToPick = gd::Expression(element.GetChild("object", 0, "Object").GetValue().GetString());
gd::EventsListSerialization::OpenConditions(project, conditions, element.GetChild("conditions", 0, "Conditions"));
gd::EventsListSerialization::OpenActions(project, actions, element.GetChild("actions", 0, "Actions"));
gd::EventsListSerialization::UnserializeEventsFrom(project, events, element.GetChild("events", 0, "Events"));
}
示例5: UnserializeFrom
void RepeatEvent::UnserializeFrom(gd::Project & project, const SerializerElement & element)
{
repeatNumberExpression = gd::Expression(element.GetChild("repeatExpression", 0, "RepeatExpression").GetValue().GetString());
gd::EventsListSerialization::OpenConditions(project, conditions, element.GetChild("conditions", 0, "Conditions"));
gd::EventsListSerialization::OpenActions(project, actions, element.GetChild("actions", 0, "Actions"));
gd::EventsListSerialization::UnserializeEventsFrom(project, events, element.GetChild("events", 0, "Events"));
}
示例6: UnserializeFrom
void LinkEvent::UnserializeFrom(gd::Project & project, const SerializerElement & element)
{
SerializerElement & includeElement = element.GetChild("include", 0, "Limites");
SetIncludeStartAndEnd(includeElement.GetIntAttribute("start"),
includeElement.GetIntAttribute("end"));
SetIncludeAllEvents(includeElement.GetBoolAttribute("includeAll", true));
SetTarget(element.GetChild("target", 0, "Scene").GetValue().GetString());
}
示例7: UnserializeFrom
void ExternalLayout::UnserializeFrom(const SerializerElement & element)
{
name = element.GetStringAttribute("name", "", "Name");
instances.UnserializeFrom(element.GetChild("instances", 0, "Instances"));
#if defined(GD_IDE_ONLY) && !defined(GD_NO_WX_GUI)
editionSettings.UnserializeFrom(element.GetChild("editionSettings"));
associatedLayout = element.GetStringAttribute("associatedLayout");
#endif
}
示例8: UnserializeFrom
void WhileEvent::UnserializeFrom(gd::Project & project, const SerializerElement & element)
{
justCreatedByTheUser = false;
infiniteLoopWarning = element.GetBoolAttribute("infiniteLoopWarning");
gd::EventsListSerialization::OpenConditions(project, whileConditions, element.GetChild("whileConditions", 0, "WhileConditions"));
gd::EventsListSerialization::OpenConditions(project, conditions, element.GetChild("conditions", 0, "Conditions"));
gd::EventsListSerialization::OpenActions(project, actions, element.GetChild("actions", 0, "Actions"));
gd::EventsListSerialization::UnserializeEventsFrom(project, events, element.GetChild("events", 0, "Events"));
}
示例9: UnserializeFrom
void Object::UnserializeFrom(gd::Project & project, const SerializerElement & element)
{
//Name and type are already loaded.
objectVariables.UnserializeFrom(element.GetChild("variables", 0, "Variables"));
//Compatibility with GD <= 3.3
if (element.HasChild("Automatism"))
{
for (std::size_t i = 0; i < element.GetChildrenCount("Automatism"); ++i)
{
SerializerElement & behaviorElement = element.GetChild("Automatism", i);
gd::String autoType = behaviorElement.GetStringAttribute("type", "", "Type")
.FindAndReplace("Automatism", "Behavior");
gd::String autoName = behaviorElement.GetStringAttribute("name", "", "Name");
Behavior* behavior = project.CreateBehavior(autoType);
if ( behavior != NULL )
{
behavior->SetName(autoName);
behavior->UnserializeFrom(behaviorElement);
behaviors[behavior->GetName()] = behavior;
}
else
std::cout << "WARNING: Unknown behavior " << autoType << std::endl;
}
}
//End of compatibility code
else
{
SerializerElement & behaviorsElement = element.GetChild("behaviors", 0, "automatisms");
behaviorsElement.ConsiderAsArrayOf("behavior", "automatism");
for (std::size_t i = 0; i < behaviorsElement.GetChildrenCount(); ++i)
{
SerializerElement & behaviorElement = behaviorsElement.GetChild(i);
gd::String autoType = behaviorElement.GetStringAttribute("type")
.FindAndReplace("Automatism", "Behavior"); //Compatibility with GD <= 4
gd::String autoName = behaviorElement.GetStringAttribute("name");
Behavior* behavior = project.CreateBehavior(autoType);
if ( behavior != NULL )
{
behavior->SetName(autoName);
behavior->UnserializeFrom(behaviorElement);
behaviors[behavior->GetName()] = behavior;
}
else
std::cout << "WARNING: Unknown behavior " << autoType << std::endl;
}
}
DoUnserializeFrom(project, element);
}
示例10: UnserializeFrom
void CommentEvent::UnserializeFrom(gd::Project & project, const SerializerElement & element)
{
const SerializerElement & colorElement = element.GetChild("color", 0, "Couleur");
r = colorElement.GetIntAttribute("r");
v = colorElement.GetIntAttribute("g", 0, "v");
b = colorElement.GetIntAttribute("b");
textR = colorElement.GetIntAttribute("textR");
textG = colorElement.GetIntAttribute("textG");
textB = colorElement.GetIntAttribute("textB");
com1 = element.GetChild("comment", 0, "Com1").GetValue().GetString();
com2 = element.GetChild("comment2", 0, "Com2").GetValue().GetString();
}
示例11: UnserializeFrom
void ExternalEvents::UnserializeFrom(gd::Project & project, const SerializerElement & element)
{
name = element.GetStringAttribute("name", "", "Name");
associatedScene = element.GetStringAttribute("associatedLayout", "", "AssociatedScene");
lastChangeTimeStamp = element.GetIntAttribute("lastChangeTimeStamp", 0, "LastChangeTimeStamp");
gd::EventsListSerialization::UnserializeEventsFrom(project, events, element.GetChild("events", 0, "Events"));
}
示例12: UnserializeFrom
void GroupEvent::UnserializeFrom(gd::Project & project, const SerializerElement & element)
{
name = element.GetStringAttribute("name");
source = element.GetStringAttribute("source");
creationTime = element.GetIntAttribute("creationTime");
colorR = element.GetIntAttribute("colorR");
colorG = element.GetIntAttribute("colorG");
colorB = element.GetIntAttribute("colorB");
gd::EventsListSerialization::UnserializeEventsFrom(project, events, element.GetChild("events"));
parameters.clear();
gd::SerializerElement & parametersElement = element.GetChild("parameters");
parametersElement.ConsiderAsArrayOf("parameters");
for ( std::size_t i = 0;i < parametersElement.GetChildrenCount();++i)
parameters.push_back(parametersElement.GetChild(i).GetValue().GetString());
}
示例13: UnserializeFrom
void ObjectGroup::UnserializeFrom(std::vector < gd::ObjectGroup > & list, const SerializerElement & element)
{
element.ConsiderAsArrayOf("group", "Groupe");
for (unsigned int i = 0; i < element.GetChildrenCount(); ++i)
{
SerializerElement & groupElement = element.GetChild(i);
gd::ObjectGroup objectGroup;
objectGroup.SetName(groupElement.GetStringAttribute("name", "", "nom"));
//Compatibility with GD <= 3.3
if ( groupElement.HasChild("Objet") )
{
for (unsigned int j = 0; j < groupElement.GetChildrenCount("Objet"); ++j)
objectGroup.AddObject(groupElement.GetChild("Objet", j).GetStringAttribute("nom"));
}
//End of compatibility code
else
{
SerializerElement & objectsElement = groupElement.GetChild("objects");
objectsElement.ConsiderAsArrayOf("object");
for (unsigned int j = 0; j < objectsElement.GetChildrenCount(); ++j)
objectGroup.AddObject(objectsElement.GetChild(j).GetStringAttribute("name"));
}
list.push_back( objectGroup );
}
}
示例14: OpenConditions
void gd::EventsListSerialization::OpenConditions(gd::Project & project, gd::InstructionsList & conditions, const SerializerElement & elem)
{
elem.ConsiderAsArrayOf("condition", "Condition");
for(std::size_t i = 0; i<elem.GetChildrenCount(); ++i)
{
gd::Instruction instruction;
const SerializerElement & conditionElem = elem.GetChild(i);
instruction.SetType(conditionElem.GetChild("type", 0, "Type").GetStringAttribute("value")
.FindAndReplace("Automatism", "Behavior")); //Compatibility with GD <= 4
instruction.SetInverted(conditionElem.GetChild("type", 0, "Type").GetBoolAttribute("inverted", false, "Contraire"));
//Read parameters
vector < gd::Expression > parameters;
//Compatibility with GD <= 3.3
if (conditionElem.HasChild("Parametre")) {
for (std::size_t j = 0;j<conditionElem.GetChildrenCount("Parametre");++j)
parameters.push_back(gd::Expression(conditionElem.GetChild("Parametre", j).GetValue().GetString()));
}
//end of compatibility code
else
{
const SerializerElement & parametersElem = conditionElem.GetChild("parameters");
parametersElem.ConsiderAsArrayOf("parameter");
for (std::size_t j = 0;j<parametersElem.GetChildrenCount();++j)
parameters.push_back(gd::Expression(parametersElem.GetChild(j).GetValue().GetString()));
}
instruction.SetParameters( parameters );
//Read sub conditions
if ( conditionElem.HasChild("subConditions", "SubConditions") )
OpenConditions(project, instruction.GetSubInstructions(), conditionElem.GetChild("subConditions", 0, "SubConditions" ));
conditions.Insert( instruction );
}
if ( project.GetLastSaveGDMajorVersion() < 3 ||
(project.GetLastSaveGDMajorVersion() == 3 && project.GetLastSaveGDMinorVersion() <= 1 ) )
UpdateInstructionsFromGD31x(project, conditions, false);
if ( project.GetLastSaveGDMajorVersion() < 3 )
UpdateInstructionsFromGD2x(project, conditions, false);
}
示例15: OpenActions
void gd::EventsListSerialization::OpenActions(gd::Project & project, vector < gd::Instruction > & actions, const SerializerElement & elem)
{
elem.ConsiderAsArrayOf("action", "Action");
for(unsigned int i = 0; i<elem.GetChildrenCount(); ++i)
{
gd::Instruction instruction;
const SerializerElement & actionElem = elem.GetChild(i);
instruction.SetType( actionElem.GetChild("type", 0, "Type").GetStringAttribute("value") );
//Read parameters
vector < gd::Expression > parameters;
//Compatibility with GD <= 3.3
if (actionElem.HasChild("Parametre")) {
for (unsigned int j = 0;j<actionElem.GetChildrenCount("Parametre");++j)
parameters.push_back(gd::Expression(actionElem.GetChild("Parametre", j).GetValue().GetString()));
}
//end of compatibility code
else
{
const SerializerElement & parametersElem = actionElem.GetChild("parameters");
parametersElem.ConsiderAsArrayOf("parameter");
for (unsigned int j = 0;j<parametersElem.GetChildrenCount();++j)
parameters.push_back(gd::Expression(parametersElem.GetChild(j).GetValue().GetString()));
}
instruction.SetParameters( parameters );
//Read sub actions
if ( actionElem.HasChild("subActions", "SubActions") )
OpenActions(project, instruction.GetSubInstructions(), actionElem.GetChild("subActions", 0, "SubActions" ));
actions.push_back( instruction );
}
if ( project.GetLastSaveGDMajorVersion() < 3 ||
(project.GetLastSaveGDMajorVersion() == 3 && project.GetLastSaveGDMinorVersion() <= 1 ) )
UpdateInstructionsFromGD31x(project, actions, true);
if ( project.GetLastSaveGDMajorVersion() < 3 )
UpdateInstructionsFromGD2x(project, actions, true);
}