本文整理汇总了C++中SerializerElement::HasChild方法的典型用法代码示例。如果您正苦于以下问题:C++ SerializerElement::HasChild方法的具体用法?C++ SerializerElement::HasChild怎么用?C++ SerializerElement::HasChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SerializerElement
的用法示例。
在下文中一共展示了SerializerElement::HasChild方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
示例2: 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);
}
示例3: UnserializeFrom
void Variable::UnserializeFrom(const SerializerElement & element)
{
isStructure = element.HasChild("children", "Children");
if (isStructure)
{
const SerializerElement & childrenElement = element.GetChild("children", 0, "Children");
childrenElement.ConsiderAsArrayOf("variable", "Variable");
for (int i = 0; i < childrenElement.GetChildrenCount(); ++i)
{
const SerializerElement & childElement = childrenElement.GetChild(i);
std::string name = childElement.GetStringAttribute("name", "", "Name");
gd::Variable childVariable;
childVariable.UnserializeFrom(childElement);
children[name] = childVariable;
}
}
else
SetString(element.GetStringAttribute("value", "", "Value"));
}
示例4: UnserializeFrom
void Layout::UnserializeFrom(gd::Project & project, const SerializerElement & element)
{
SetBackgroundColor(element.GetIntAttribute( "r" ), element.GetIntAttribute( "v" ), element.GetIntAttribute( "b" ));
SetWindowDefaultTitle( element.GetStringAttribute("title", "(No title)", "titre") );
oglFOV = element.GetDoubleAttribute("oglFOV");
oglZNear = element.GetDoubleAttribute("oglZNear");
oglZFar = element.GetDoubleAttribute("oglZFar");
standardSortMethod = element.GetBoolAttribute( "standardSortMethod" );
stopSoundsOnStartup = element.GetBoolAttribute( "stopSoundsOnStartup" );
disableInputWhenNotFocused = element.GetBoolAttribute( "disableInputWhenNotFocused" );
#if defined(GD_IDE_ONLY) && !defined(GD_NO_WX_GUI)
associatedSettings.UnserializeFrom(element.GetChild("uiSettings", 0, "UISettings"));
#endif
#if defined(GD_IDE_ONLY)
gd::ObjectGroup::UnserializeFrom(objectGroups, element.GetChild( "objectsGroups", 0, "GroupesObjets" ));
gd::EventsListSerialization::UnserializeEventsFrom(project, GetEvents(), element.GetChild("events", 0, "Events"));
#endif
UnserializeObjectsFrom(project, element.GetChild("objects", 0, "Objets"));
initialInstances.UnserializeFrom(element.GetChild("instances", 0, "Positions"));
variables.UnserializeFrom(element.GetChild("variables", 0, "Variables"));
initialLayers.clear();
SerializerElement & layersElement = element.GetChild("layers", 0, "Layers");
layersElement.ConsiderAsArrayOf("layer", "Layer");
for (std::size_t i = 0; i < layersElement.GetChildrenCount(); ++i)
{
gd::Layer layer;
layer.UnserializeFrom(layersElement.GetChild(i));
initialLayers.push_back(layer);
}
//Compatibility with GD <= 4
gd::String deprecatedTag1 = "automatismsSharedData";
gd::String deprecatedTag2 = "automatismSharedData";
if (!element.HasChild(deprecatedTag1))
{
deprecatedTag1 = "AutomatismsSharedDatas";
deprecatedTag2 = "AutomatismSharedDatas";
}
//end of compatibility code
SerializerElement & behaviorsDataElement = element.GetChild("behaviorsSharedData", 0, deprecatedTag1);
behaviorsDataElement.ConsiderAsArrayOf("behaviorSharedData", deprecatedTag2);
for (unsigned int i = 0; i < behaviorsDataElement.GetChildrenCount(); ++i)
{
SerializerElement & behaviorDataElement = behaviorsDataElement.GetChild(i);
gd::String type = behaviorDataElement.GetStringAttribute("type", "", "Type")
.FindAndReplace("Automatism", "Behavior"); //Compatibility with GD <= 4
std::shared_ptr<gd::BehaviorsSharedData> sharedData = project.CreateBehaviorSharedDatas(type);
if ( sharedData != std::shared_ptr<gd::BehaviorsSharedData>() )
{
sharedData->SetName( behaviorDataElement.GetStringAttribute("name", "", "Name") );
sharedData->UnserializeFrom(behaviorDataElement);
behaviorsInitialSharedDatas[sharedData->GetName()] = sharedData;
}
}
}