void CppCodeEvent::UnserializeFrom(gd::Project & project, const gd::SerializerElement & element) { functionToCall = element.GetStringAttribute("functionToCall", "", "FunctionToCall"); functionNameAutogenerated = element.GetBoolAttribute("functionNameAutogenerated", false, "FunctionNameAutogenerated"), inlineCode = element.GetStringAttribute("inlineCode", "", "InlineCode"); associatedGDManagedSourceFile = element.GetStringAttribute("associatedGDManagedSourceFile", "", "AssociatedGDManagedSourceFile"); passSceneAsParameter = element.GetBoolAttribute("passSceneAsParameter", false, "PassSceneAsParameter"); passObjectListAsParameter = element.GetBoolAttribute("passObjectListAsParameter", false, "PassObjectListAsParameter"); objectToPassAsParameter = element.GetStringAttribute("objectToPassAsParameter", "", "ObjectToPassAsParameter"); codeDisplayedInEditor = element.GetBoolAttribute("codeDisplayedInEditor", true, "CodeDisplayedInEditor"); displayedName = element.GetStringAttribute("displayedName", "", "DisplayedName"); lastChangeTimeStamp = element.GetIntAttribute("lastChangeTimeStamp"); includeFiles.clear(); gd::SerializerElement & includesElement = element.GetChild("includes", 0, "Includes"); includesElement.ConsiderAsArrayOf("include", "Include"); for ( std::size_t i = 0;i < includesElement.GetChildrenCount();++i) includeFiles.push_back(includesElement.GetChild(i).GetValue().GetString()); dependencies.clear(); gd::SerializerElement & dependenciesElement = element.GetChild("dependencies", 0, "Dependencies"); dependenciesElement.ConsiderAsArrayOf("dependency", "Dependency"); for ( std::size_t i = 0;i < dependenciesElement.GetChildrenCount();++i) dependencies.push_back(dependenciesElement.GetChild(i).GetStringAttribute("sourceFile")); }
void TimedEvent::UnserializeFrom(gd::Project & project, const gd::SerializerElement & element) { name = element.GetChild("name", 0, "Name").GetValue().GetString(); timeout = element.GetChild("timeout", 0, "Timeout").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")); }
void FunctionEvent::UnserializeFrom(gd::Project & project, const gd::SerializerElement & element) { name = element.GetChild("name", 0, "Name").GetValue().GetString(); objectsPassedAsArgument = element.GetChild("objectsPassedAsArgument").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")); }
void TileMapObject::DoUnserializeFrom(gd::Project & project, const gd::SerializerElement & element) { if(element.HasChild("tileSet")) { tileSet.Get().UnserializeFrom(element.GetChild("tileSet")); } if(element.HasChild("tileMap")) { tileMap.Get().UnserializeFrom(element.GetChild("tileMap")); } }
void TextObject::DoUnserializeFrom(gd::Project & project, const gd::SerializerElement & element) { SetString(element.GetChild("string", 0,"String").GetValue().GetString()); SetFontFilename(element.GetChild("font", 0,"Font").GetValue().GetString()); SetCharacterSize(element.GetChild("characterSize", 0, "CharacterSize").GetValue().GetInt()); SetColor(element.GetChild("color", 0,"Color").GetIntAttribute("r", 255), element.GetChild("color", 0,"Color").GetIntAttribute("g", 255), element.GetChild("color", 0,"Color").GetIntAttribute("b", 255)); smoothed = element.GetBoolAttribute("smoothed"); bold = element.GetBoolAttribute("bold"); italic = element.GetBoolAttribute("italic"); underlined = element.GetBoolAttribute("underlined"); }
void Box3DObject::DoUnserializeFrom(gd::Project & project, const gd::SerializerElement & element) { frontTextureName = element.GetChild("frontTexture").GetValue().GetString(); topTextureName = element.GetChild("topTexture").GetValue().GetString(); bottomTextureName = element.GetChild("bottomTexture").GetValue().GetString(); leftTextureName = element.GetChild("leftTexture").GetValue().GetString(); rightTextureName = element.GetChild("rightTexture").GetValue().GetString(); backTextureName = element.GetChild("backTexture").GetValue().GetString(); width = element.GetChild("width").GetValue().GetInt(); height = element.GetChild("height").GetValue().GetInt(); depth = element.GetChild("depth").GetValue().GetInt(); }
void TileSet::UnserializeFrom(const gd::SerializerElement &element) { int serializationVersion = element.GetIntAttribute("version", 1); textureName = element.GetStringAttribute("textureName", ""); tileSize.x = element.GetIntAttribute("tileSizeX", 32); tileSize.y = element.GetIntAttribute("tileSizeY", 32); tileSpacing.x = element.GetIntAttribute("tileSpacingX", 0); tileSpacing.y = element.GetIntAttribute("tileSpacingY", 0); ResetHitboxes(); m_collidable.clear(); if(serializationVersion == 1) { if(element.HasChild("hitboxes")) { gd::SerializerElement &tilesElem = element.GetChild("hitboxes"); tilesElem.ConsiderAsArrayOf("tileHitbox"); for(int i = 0; i < tilesElem.GetChildrenCount("tileHitbox"); i++) { m_collidable.push_back(tilesElem.GetChild(i).GetBoolAttribute("collidable", true)); TileHitbox newHitbox; newHitbox.UnserializeFrom(tilesElem.GetChild(i), tileSize); if(newHitbox != TileHitbox::Rectangle(tileSize)) m_hitboxes[i] = newHitbox; } } } else if(serializationVersion == 2) { gd::SerializerElement &collidableElem = element.GetChild("collidable"); collidableElem.ConsiderAsArrayOf("tile"); for(int i = 0; i < collidableElem.GetChildrenCount("tile"); i++) { m_collidable.push_back(collidableElem.GetChild(i).GetBoolAttribute("collidable", true)); } gd::SerializerElement &hitboxesElem = element.GetChild("hitboxes"); hitboxesElem.ConsiderAsArrayOf("tileHitbox"); for(int i = 0; i < hitboxesElem.GetChildrenCount("tileHitbox"); i++) { m_hitboxes[hitboxesElem.GetChild(i).GetIntAttribute("tileId", -1)].UnserializeFrom(hitboxesElem.GetChild(i), tileSize); } } }
void OpenPointsSprites(vector < Point > & points, const gd::SerializerElement & element) { element.ConsiderAsArrayOf("point", "Point"); for (unsigned int i = 0; i < element.GetChildrenCount(); ++i) { Point point(""); OpenPoint(point, element.GetChild(i)); points.push_back(point); } }
void PathBehavior::UnserializeFrom(const gd::SerializerElement & element) { UnserializePathsFrom(element.GetChild("paths", 0, "Paths")); ChangeCurrentPath(element.GetStringAttribute("currentPath")); speed = element.GetDoubleAttribute("speed"); offset.x = element.GetDoubleAttribute("offsetX"); offset.y = element.GetDoubleAttribute("offsetY"); angleOffset = element.GetDoubleAttribute("angleOffset"); reverseAtEnd = element.GetBoolAttribute("reverseAtEnd"); stopAtEnd = element.GetBoolAttribute("stopAtEnd"); followAngle = element.GetBoolAttribute("followAngle"); }
void SoundObject::DoUnserializeFrom(gd::Project & project, const gd::SerializerElement & element) { SetSoundType(element.GetChild("type", 0, "Type").GetValue().GetString()); SetSoundFileName(element.GetChild("filename", 0, "Filename").GetValue().GetString()); SetPitch(element.GetChild("volume", 0, "Volume").GetValue().GetDouble()); SetPitch(element.GetChild("pitch", 0, "Pitch").GetValue().GetDouble()); SetMinDistance(element.GetChild("minDistance", 0, "MinDistance").GetValue().GetDouble()); SetAttenuation(element.GetChild("attenuation", 0, "Attenuation").GetValue().GetDouble()); SetLooping(element.GetChild("loop", 0, "Loop").GetValue().GetBool()); SetZPos(element.GetChild("zPos", 0, "ZPos").GetValue().GetDouble()); }
void PathBehavior::UnserializePathsFrom(const gd::SerializerElement & element) { localePaths.clear(); element.ConsiderAsArrayOf("path", "Path"); for(std::size_t i = 0;i<element.GetChildrenCount();++i) { const gd::SerializerElement & pathElement = element.GetChild(i); localePaths[pathElement.GetStringAttribute("name")] = GetCoordsVectorFromString(pathElement.GetStringAttribute("coords"), '/', ';'); } if(localePaths.empty()) localePaths["Object main path"] = std::vector<sf::Vector2f>(1, sf::Vector2f(0,0)); }
void Direction::UnserializeFrom(const gd::SerializerElement & element) { SetTimeBetweenFrames(element.GetDoubleAttribute("timeBetweenFrames", 1, "tempsEntre")); SetLoop(element.GetBoolAttribute("looping", false, "boucle")); const gd::SerializerElement & spritesElement = element.GetChild("sprites", 0, "Sprites"); spritesElement.ConsiderAsArrayOf("sprite", "Sprite"); for (unsigned int i = 0; i < spritesElement.GetChildrenCount(); ++i) { const gd::SerializerElement & spriteElement = spritesElement.GetChild(i); Sprite sprite; sprite.SetImageName(spriteElement.GetStringAttribute("image")); OpenPointsSprites(sprite.GetAllNonDefaultPoints(), spriteElement.GetChild("points", 0, "Points")); OpenPoint(sprite.GetOrigin(), spriteElement.GetChild("originPoint" , 0, "PointOrigine")); OpenPoint(sprite.GetCenter(), spriteElement.GetChild("centerPoint" , 0, "PointCentre")); sprite.SetDefaultCenterPoint(spriteElement.GetChild("centerPoint" , 0, "PointCentre").GetBoolAttribute("automatic", true)); if (spriteElement.HasChild("CustomCollisionMask")) sprite.SetCollisionMaskAutomatic(!spriteElement.GetChild("CustomCollisionMask").GetBoolAttribute("custom", false)); else sprite.SetCollisionMaskAutomatic(!spriteElement.GetBoolAttribute("hasCustomCollisionMask", false)); std::vector<Polygon2d> mask; const gd::SerializerElement & collisionMaskElement = spriteElement.GetChild("customCollisionMask", 0, "CustomCollisionMask"); collisionMaskElement.ConsiderAsArrayOf("polygon", "Polygon"); for (unsigned int j = 0; j < collisionMaskElement.GetChildrenCount(); ++j) { Polygon2d polygon; const gd::SerializerElement & polygonElement = collisionMaskElement.GetChild(j); polygonElement.ConsiderAsArrayOf("vertice", "Point"); for (unsigned int k = 0; k < polygonElement.GetChildrenCount(); ++k) { const gd::SerializerElement & verticeElement = polygonElement.GetChild(k); polygon.vertices.push_back(sf::Vector2f(verticeElement.GetDoubleAttribute("x"), verticeElement.GetDoubleAttribute("y"))); } mask.push_back(polygon); } sprite.SetCustomCollisionMask(mask); sprites.push_back(sprite); } };
void ScenePathDatas::UnserializeFrom(const gd::SerializerElement & element) { globalPaths.clear(); if (!element.HasChild("paths", "Paths")) return; const gd::SerializerElement & pathsElement = element.GetChild("paths", 0, "Paths"); pathsElement.ConsiderAsArrayOf("path", "Path"); for (int i = 0; i < pathsElement.GetChildrenCount(); ++i) { const gd::SerializerElement & pathElement = pathsElement.GetChild(i); globalPaths[pathElement.GetStringAttribute("name")] = PathBehavior::GetCoordsVectorFromString(pathElement.GetStringAttribute("coords"), '/', ';'); } }
void ShapePainterObjectBase::UnserializeFrom(const gd::SerializerElement & element) { fillOpacity = element.GetChild("fillOpacity", 0, "FillOpacity").GetValue().GetInt(); outlineSize = element.GetChild("outlineSize", 0, "OutlineSize").GetValue().GetInt(); outlineOpacity = element.GetChild("outlineOpacity", 0, "OutlineOpacity").GetValue().GetInt(); fillColorR = element.GetChild("fillColor", 0, "FillColor").GetIntAttribute("r"); fillColorG = element.GetChild("fillColor", 0, "FillColor").GetIntAttribute("g"); fillColorB = element.GetChild("fillColor", 0, "FillColor").GetIntAttribute("b"); outlineColorR = element.GetChild("outlineColor", 0, "OutlineColor").GetIntAttribute("r"); outlineColorG = element.GetChild("outlineColor", 0, "OutlineColor").GetIntAttribute("g"); outlineColorB = element.GetChild("outlineColor", 0, "OutlineColor").GetIntAttribute("b"); absoluteCoordinates = element.GetChild("absoluteCoordinates", 0, "AbsoluteCoordinates").GetValue().GetBool(); }
void SpriteObject::DoUnserializeFrom(gd::Project & project, const gd::SerializerElement & element) { const gd::SerializerElement & animationsElement = element.GetChild("animations", 0, "Animations"); animationsElement.ConsiderAsArrayOf("animation", "Animation"); for (std::size_t i = 0; i < animationsElement.GetChildrenCount(); ++i) { const gd::SerializerElement & animationElement = animationsElement.GetChild(i); Animation newAnimation; newAnimation.useMultipleDirections = animationElement.GetBoolAttribute("useMultipleDirections", false, "typeNormal"); //Compatibility with GD <= 3.3 if (animationElement.HasChild("Direction")) { for (std::size_t j = 0; j < animationElement.GetChildrenCount("Direction"); ++j) { Direction direction; direction.UnserializeFrom(animationElement.GetChild("Direction", j)); newAnimation.SetDirectionsCount(newAnimation.GetDirectionsCount()+1); newAnimation.SetDirection(direction, newAnimation.GetDirectionsCount()-1); } } //End of compatibility code else { const gd::SerializerElement & directionsElement = animationElement.GetChild("directions"); directionsElement.ConsiderAsArrayOf("direction"); for (std::size_t j = 0; j < directionsElement.GetChildrenCount(); ++j) { Direction direction; direction.UnserializeFrom(directionsElement.GetChild(j)); newAnimation.SetDirectionsCount(newAnimation.GetDirectionsCount()+1); newAnimation.SetDirection(direction, newAnimation.GetDirectionsCount()-1); } } AddAnimation( newAnimation ); } }
void TileSet::UnserializeFrom(const gd::SerializerElement &element) { ResetHitboxes(); textureName = element.GetStringAttribute("textureName", ""); tileSize.x = element.GetIntAttribute("tileSizeX", 32); tileSize.y = element.GetIntAttribute("tileSizeY", 32); tileSpacing.x = element.GetIntAttribute("tileSpacingX", 0); tileSpacing.y = element.GetIntAttribute("tileSpacingY", 0); if (element.HasChild("hitboxes")) { gd::SerializerElement &tilesElem = element.GetChild("hitboxes"); tilesElem.ConsiderAsArrayOf("tileHitbox"); for(int i = 0; i < tilesElem.GetChildrenCount("tileHitbox"); i++) { TileHitbox newHitbox; newHitbox.UnserializeFrom(tilesElem.GetChild(i), tileSize); m_hitboxes.push_back(newHitbox); } } m_dirty = true; }