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()); }
/** * \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); } }
void ResourceFolder::UnserializeFrom(const SerializerElement & element, gd::ResourcesManager & parentManager) { name = element.GetStringAttribute("name"); SerializerElement & resourcesElement = element.GetChild("resources", 0, "Resources"); resourcesElement.ConsiderAsArrayOf("resource", "Resource"); for(std::size_t i = 0;i<resourcesElement.GetChildrenCount();++i) AddResource(resourcesElement.GetChild(i).GetStringAttribute("name"), parentManager); }
void EventsFunctionsExtension::UnserializeFrom( gd::Project& project, const SerializerElement& element) { version = element.GetStringAttribute("version"); extensionNamespace = element.GetStringAttribute("extensionNamespace"); description = element.GetStringAttribute("description"); name = element.GetStringAttribute("name"); fullName = element.GetStringAttribute("fullName"); const gd::SerializerElement& eventsFunctionsElement = element.GetChild("eventsFunctions"); eventsFunctions.clear(); eventsFunctionsElement.ConsiderAsArrayOf("eventsFunction"); for (std::size_t i = 0; i < eventsFunctionsElement.GetChildrenCount(); ++i) { gd::EventsFunction& newEventsFunction = InsertNewEventsFunction("", GetEventsFunctionsCount()); newEventsFunction.UnserializeFrom(project, eventsFunctionsElement.GetChild(i)); } }
void LayoutEditorCanvasOptions::UnserializeFrom(const SerializerElement & element) { grid = element.GetBoolAttribute("grid"); snap = element.GetBoolAttribute("snap"); windowMask = element.GetBoolAttribute("windowMask"); gridWidth = element.GetIntAttribute("gridWidth", 32); gridHeight = element.GetIntAttribute("gridHeight", 32); gridOffsetX = element.GetIntAttribute("gridOffsetX", 0); gridOffsetY = element.GetIntAttribute("gridOffsetY", 0); gridR = element.GetIntAttribute("gridR", 158); gridG = element.GetIntAttribute("gridG", 180); gridB = element.GetIntAttribute("gridB", 255); zoomFactor = element.GetDoubleAttribute("zoomFactor", 1.0); associatedLayout = element.GetStringAttribute("associatedLayout"); }
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")); }
void AudioResource::UnserializeFrom(const SerializerElement & element) { SetUserAdded( element.GetBoolAttribute("userAdded") ); SetFile(element.GetStringAttribute("file")); }
void SourceFile::UnserializeFrom(const SerializerElement & element) { filename = element.GetStringAttribute("filename"); language = element.GetStringAttribute("language", "C++"); gdManaged = element.GetBoolAttribute("gdManaged"); }
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; } } }