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::UnserializeInstructionsFrom( project, conditions, element.GetChild("conditions", 0, "Conditions")); gd::EventsListSerialization::UnserializeInstructionsFrom( project, actions, element.GetChild("actions", 0, "Actions")); gd::EventsListSerialization::UnserializeEventsFrom( project, events, element.GetChild("events", 0, "Events")); }
void ParticleEmitterObject::DoUnserializeFrom( gd::Project& project, const gd::SerializerElement& element) { ParticleEmitterBase::UnserializeParticleEmitterBaseFrom(element); #if defined(GD_IDE_ONLY) particleEditionSimpleMode = element.GetBoolAttribute("particleEditionSimpleMode"); emissionEditionSimpleMode = element.GetBoolAttribute("emissionEditionSimpleMode"); gravityEditionSimpleMode = element.GetBoolAttribute("gravityEditionSimpleMode"); #endif }
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 PlatformerObjectBehavior::UnserializeFrom(const gd::SerializerElement & element) { gravity = element.GetDoubleAttribute("gravity"); maxFallingSpeed = element.GetDoubleAttribute("maxFallingSpeed"); acceleration = element.GetDoubleAttribute("acceleration"); deceleration = element.GetDoubleAttribute("deceleration"); maxSpeed = element.GetDoubleAttribute("maxSpeed"); jumpSpeed = element.GetDoubleAttribute("jumpSpeed"); ignoreDefaultControls = element.GetBoolAttribute("ignoreDefaultControls"); SetSlopeMaxAngle(element.GetDoubleAttribute("slopeMaxAngle")); canGrabPlatforms = element.GetBoolAttribute("canGrabPlatforms", false); yGrabOffset = element.GetDoubleAttribute("yGrabOffset"); xGrabTolerance = element.GetDoubleAttribute("xGrabTolerance", 10); }
void PlatformerObjectBehavior::SerializeTo(gd::SerializerElement & element) const { element.SetAttribute("gravity", gravity); element.SetAttribute("maxFallingSpeed", maxFallingSpeed); element.SetAttribute("acceleration", acceleration); element.SetAttribute("deceleration", deceleration); element.SetAttribute("maxSpeed", maxSpeed); element.SetAttribute("jumpSpeed", jumpSpeed); element.SetAttribute("ignoreDefaultControls", ignoreDefaultControls); element.SetAttribute("slopeMaxAngle", slopeMaxAngle); element.SetAttribute("canGrabPlatforms", canGrabPlatforms); element.SetAttribute("yGrabOffset", yGrabOffset); element.SetAttribute("xGrabTolerance", xGrabTolerance); }
void ShapePainterObjectBase::SerializeTo(gd::SerializerElement & element) const { element.AddChild("fillOpacity").SetValue(fillOpacity); element.AddChild("outlineSize").SetValue(outlineSize); element.AddChild("outlineOpacity").SetValue(outlineOpacity); element.AddChild("fillColor") .SetAttribute("r", (int)fillColorR) .SetAttribute("g", (int)fillColorG) .SetAttribute("b", (int)fillColorB); element.AddChild("outlineColor") .SetAttribute("r", (int)outlineColorR) .SetAttribute("g", (int)outlineColorG) .SetAttribute("b", (int)outlineColorB); element.AddChild("absoluteCoordinates").SetValue(absoluteCoordinates); }
void TileHitbox::SerializeTo(gd::SerializerElement &element) const { element.SetAttribute("collidable", collidable); //Serialize the polygon gd::String polygonStr; for(std::vector<sf::Vector2f>::const_iterator vertexIt = hitbox.vertices.begin(); vertexIt != hitbox.vertices.end(); vertexIt++) { if(vertexIt != hitbox.vertices.begin()) polygonStr += "|"; polygonStr += gd::String::From(vertexIt->x) + ";" + gd::String::From(vertexIt->y); } element.SetAttribute("polygon", polygonStr); }
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 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 PathfindingBehavior::SerializeTo(gd::SerializerElement & element) const { element.SetAttribute("allowDiagonals", allowDiagonals); element.SetAttribute("acceleration", acceleration); element.SetAttribute("maxSpeed", maxSpeed); element.SetAttribute("angularMaxSpeed", angularMaxSpeed); element.SetAttribute("rotateObject", rotateObject); element.SetAttribute("angleOffset", angleOffset); element.SetAttribute("cellWidth", (int)cellWidth); element.SetAttribute("cellHeight", (int)cellHeight); element.SetAttribute("extraBorder", extraBorder); }
void Box3DObject::DoSerializeTo(gd::SerializerElement & element) const { element.AddChild("frontTexture").SetValue(frontTextureName); element.AddChild("topTexture").SetValue(topTextureName); element.AddChild("bottomTexture").SetValue(bottomTextureName); element.AddChild("leftTexture").SetValue(leftTextureName); element.AddChild("rightTexture").SetValue(rightTextureName); element.AddChild("backTexture").SetValue(backTextureName); element.AddChild("width").SetValue(width); element.AddChild("height").SetValue(height); element.AddChild("depth").SetValue(depth); }
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 TileSet::SerializeTo(gd::SerializerElement &element) const { element.SetAttribute("textureName", textureName); element.SetAttribute("tileSizeX", tileSize.x); element.SetAttribute("tileSizeY", tileSize.y); element.SetAttribute("tileSpacingX", tileSpacing.x); element.SetAttribute("tileSpacingY", tileSpacing.y); gd::SerializerElement &tilesElem = element.AddChild("hitboxes"); //Save polygons for(std::vector<TileHitbox>::const_iterator it = m_hitboxes.begin(); it != m_hitboxes.end(); it++) { gd::SerializerElement &hitboxElem = tilesElem.AddChild("tileHitbox"); it->SerializeTo(hitboxElem); } }
TopDownMovementRuntimeBehavior::TopDownMovementRuntimeBehavior( const gd::SerializerElement& behaviorContent) : RuntimeBehavior(behaviorContent), allowDiagonals(true), acceleration(400), deceleration(800), maxSpeed(200), angularMaxSpeed(180), rotateObject(true), angleOffset(0), xVelocity(0), yVelocity(0), angularSpeed(0), angle(0), ignoreDefaultControls(false), leftKey(false), rightKey(false), upKey(false), downKey(false) { allowDiagonals = behaviorContent.GetBoolAttribute("allowDiagonals"); acceleration = behaviorContent.GetDoubleAttribute("acceleration"); deceleration = behaviorContent.GetDoubleAttribute("deceleration"); maxSpeed = behaviorContent.GetDoubleAttribute("maxSpeed"); angularMaxSpeed = behaviorContent.GetDoubleAttribute("angularMaxSpeed"); rotateObject = behaviorContent.GetBoolAttribute("rotateObject"); angleOffset = behaviorContent.GetDoubleAttribute("angleOffset"); ignoreDefaultControls = behaviorContent.GetBoolAttribute("ignoreDefaultControls"); }
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 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 PathBehavior::SerializeTo(gd::SerializerElement & element) const { SerializePathsTo(element.AddChild("paths")); element.SetAttribute("currentPath", GetCurrentPathName()); element.SetAttribute("speed", GetSpeed()); element.SetAttribute("offsetX", GetOffsetX()); element.SetAttribute("offsetY", GetOffsetY()); element.SetAttribute("angleOffset", angleOffset); element.SetAttribute("reverseAtEnd", ReverseAtEnd()); element.SetAttribute("stopAtEnd", StopAtEnd()); element.SetAttribute("followAngle", FollowAngle()); }
void TileHitbox::UnserializeFrom(const gd::SerializerElement &element, sf::Vector2f defaultTileSize) { collidable = element.GetBoolAttribute("collidable", true); hitbox.vertices.clear(); gd::String defaultPolygonStr = "0;0|" + gd::String::From(defaultTileSize.x) + ";0|" + gd::String::From(defaultTileSize.x) + ";" + gd::String::From(defaultTileSize.y) + "|" + "0;" + gd::String::From(defaultTileSize.y); gd::String polygonStr = element.GetStringAttribute("polygon", defaultPolygonStr); std::vector<gd::String> vertices = polygonStr.Split(U'|'); for(std::vector<gd::String>::iterator vertexIt = vertices.begin(); vertexIt != vertices.end(); vertexIt++) { hitbox.vertices.push_back(sf::Vector2f(vertexIt->Split(U';')[0].To<float>(), vertexIt->Split(U';')[1].To<float>() )); } }
void ScenePathDatas::SerializeTo(gd::SerializerElement & element) const { gd::SerializerElement & pathsElement = element.AddChild("paths"); pathsElement.ConsiderAsArrayOf("path"); for(std::map<gd::String, std::vector<sf::Vector2f> >::const_iterator it = globalPaths.begin(); it != globalPaths.end(); it++) { gd::SerializerElement & pathElement = pathsElement.AddChild("path"); pathElement.SetAttribute("name", it->first); pathElement.SetAttribute("coords", PathBehavior::GetStringFromCoordsVector(it->second, '/', ';')); } }
void TextObject::DoSerializeTo(gd::SerializerElement & element) const { element.AddChild("string").SetValue(GetString()); element.AddChild("font").SetValue(GetFontFilename()); element.AddChild("characterSize").SetValue(GetCharacterSize()); element.AddChild("color").SetAttribute("r", (int)GetColorR()) .SetAttribute("g", (int)GetColorG()) .SetAttribute("b", (int)GetColorB()); element.SetAttribute("smoothed", smoothed); element.SetAttribute("bold", bold); element.SetAttribute("italic", italic); element.SetAttribute("underlined", underlined); }
void TileSet::SerializeTo(gd::SerializerElement &element) const { element.SetAttribute("version", 2); element.SetAttribute("textureName", textureName); element.SetAttribute("tileSizeX", tileSize.x); element.SetAttribute("tileSizeY", tileSize.y); element.SetAttribute("tileSpacingX", tileSpacing.x); element.SetAttribute("tileSpacingY", tileSpacing.y); //Save if it is collidable or not gd::SerializerElement &collidableElem = element.AddChild("collidable"); for(auto it = m_collidable.begin(); it != m_collidable.end(); ++it) { gd::SerializerElement &tileElem = collidableElem.AddChild("tile"); tileElem.SetAttribute("collidable", *it); } //Save polygons hitboxes gd::SerializerElement &tilesElem = element.AddChild("hitboxes"); for(auto it = m_hitboxes.begin(); it != m_hitboxes.end(); ++it) { gd::SerializerElement &hitboxElem = tilesElem.AddChild("tileHitbox"); hitboxElem.SetAttribute("tileId", it->first); it->second.SerializeTo(hitboxElem); } }
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 PlatformerObjectAutomatism::UnserializeFrom(const gd::SerializerElement & element) { gravity = element.GetDoubleAttribute("gravity"); maxFallingSpeed = element.GetDoubleAttribute("maxFallingSpeed"); acceleration = element.GetDoubleAttribute("acceleration"); deceleration = element.GetDoubleAttribute("deceleration"); maxSpeed = element.GetDoubleAttribute("maxSpeed"); jumpSpeed = element.GetDoubleAttribute("jumpSpeed"); ignoreDefaultControls = element.GetBoolAttribute("ignoreDefaultControls"); SetSlopeMaxAngle(element.GetDoubleAttribute("slopeMaxAngle")); }
void SoundObject::DoSerializeTo(gd::SerializerElement & element) const { element.AddChild("type").SetValue(type); element.AddChild("filename").SetValue(fileName); element.AddChild("loop").SetValue(IsLooping()); element.AddChild("volume").SetValue(GetVolume()); element.AddChild("pitch").SetValue(GetPitch()); element.AddChild("attenuation").SetValue(GetAttenuation()); element.AddChild("minDistance").SetValue(GetMinDistance()); element.AddChild("zPos").SetValue(GetZPos()); }
void PlatformerObjectAutomatism::SerializeTo(gd::SerializerElement & element) const { element.SetAttribute("gravity", gravity); element.SetAttribute("maxFallingSpeed", maxFallingSpeed); element.SetAttribute("acceleration", acceleration); element.SetAttribute("deceleration", deceleration); element.SetAttribute("maxSpeed", maxSpeed); element.SetAttribute("jumpSpeed", jumpSpeed); element.SetAttribute("ignoreDefaultControls", ignoreDefaultControls); element.SetAttribute("slopeMaxAngle", slopeMaxAngle); }
void LightObject::DoSerializeTo(gd::SerializerElement & element) const { element.SetAttribute("intensity", GetIntensity()); element.SetAttribute("radius", GetRadius()); element.SetAttribute("quality", GetQuality()); element.SetAttribute("colorR", GetColor().r); element.SetAttribute("colorG", GetColor().g); element.SetAttribute("colorB", GetColor().b); element.SetAttribute("globalLight", globalLight); element.SetAttribute("globalColorR", globalLightColor.r); element.SetAttribute("globalColorG", globalLightColor.g); element.SetAttribute("globalColorB", globalLightColor.b); element.SetAttribute("globalColorA", globalLightColor.a); }
AnchorRuntimeBehavior::AnchorRuntimeBehavior( const gd::SerializerElement& behaviorContent) : RuntimeBehavior(behaviorContent), m_relativeToOriginalWindowSize(true), m_leftEdgeAnchor(ANCHOR_HORIZONTAL_NONE), m_rightEdgeAnchor(ANCHOR_HORIZONTAL_NONE), m_topEdgeAnchor(ANCHOR_VERTICAL_NONE), m_bottomEdgeAnchor(ANCHOR_VERTICAL_NONE), m_invalidDistances(true), m_leftEdgeDistance(0.f), m_rightEdgeDistance(0.f), m_topEdgeDistance(0.f), m_bottomEdgeDistance(0.f) { m_relativeToOriginalWindowSize = behaviorContent.GetBoolAttribute("relativeToOriginalWindowSize"); m_leftEdgeAnchor = static_cast<HorizontalAnchor>( behaviorContent.GetIntAttribute("leftEdgeAnchor")); m_rightEdgeAnchor = static_cast<HorizontalAnchor>( behaviorContent.GetIntAttribute("rightEdgeAnchor")); m_topEdgeAnchor = static_cast<VerticalAnchor>( behaviorContent.GetIntAttribute("topEdgeAnchor")); m_bottomEdgeAnchor = static_cast<VerticalAnchor>( behaviorContent.GetIntAttribute("bottomEdgeAnchor")); }
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; }
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 PathfindingBehavior::UnserializeFrom(const gd::SerializerElement & element) { allowDiagonals = element.GetBoolAttribute("allowDiagonals"); acceleration = element.GetDoubleAttribute("acceleration"); maxSpeed = element.GetDoubleAttribute("maxSpeed"); angularMaxSpeed = element.GetDoubleAttribute("angularMaxSpeed"); rotateObject = element.GetBoolAttribute("rotateObject"); angleOffset = element.GetDoubleAttribute("angleOffset"); extraBorder = element.GetDoubleAttribute("extraBorder"); { int value = element.GetIntAttribute("cellWidth", 0); if (value > 0) cellWidth = value; } { int value = element.GetIntAttribute("cellHeight", 0); if (value > 0) cellHeight = value; } }