本文整理汇总了C++中SerializerElement::GetChildrenCount方法的典型用法代码示例。如果您正苦于以下问题:C++ SerializerElement::GetChildrenCount方法的具体用法?C++ SerializerElement::GetChildrenCount怎么用?C++ SerializerElement::GetChildrenCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SerializerElement
的用法示例。
在下文中一共展示了SerializerElement::GetChildrenCount方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 );
}
}
示例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 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);
}
示例4: 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);
}
示例5: 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);
}
示例6: UnserializeObjectsFrom
void ClassWithObjects::UnserializeObjectsFrom(gd::Project & project, const SerializerElement & element)
{
initialObjects.clear();
element.ConsiderAsArrayOf("object", "Objet");
for (std::size_t i = 0; i < element.GetChildrenCount(); ++i)
{
const SerializerElement & objectElement = element.GetChild(i);
gd::String type = objectElement.GetStringAttribute("type");
std::shared_ptr<gd::Object> newObject =
project.CreateObject(type, objectElement.GetStringAttribute("name", "", "nom"));
if ( newObject != std::shared_ptr<gd::Object>() )
{
newObject->UnserializeFrom(project, objectElement);
initialObjects.push_back( newObject );
}
else
std::cout << "WARNING: Unknown object type \"" << type << "\"" << std::endl;
}
}
示例7: UnserializeEventsFrom
void EventsListSerialization::UnserializeEventsFrom(gd::Project & project, EventsList & list, const SerializerElement & events)
{
events.ConsiderAsArrayOf("event", "Event");
for(unsigned int i = 0; i<events.GetChildrenCount(); ++i)
{
SerializerElement & eventElem = events.GetChild(i);
std::string type = eventElem.GetChild("type", 0, "Type").GetValue().GetString();
gd::BaseEventSPtr event = project.CreateEvent(type);
if ( event != std::shared_ptr<gd::BaseEvent>())
event->UnserializeFrom(project, eventElem);
else
{
std::cout << "WARNING: Unknown event of type " << type << std::endl;
event = std::shared_ptr<gd::BaseEvent>(new EmptyEvent);
}
event->SetDisabled(eventElem.GetBoolAttribute("disabled"));
event->folded = eventElem.GetBoolAttribute("folded");
list.InsertEvent(event, list.GetEventsCount());
}
}