예제 #1
0
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"));
}
예제 #2
0
파일: TileSet.cpp 프로젝트: HaoDrang/GD
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);
        }
    }
}
예제 #3
0
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;
    }
}
예제 #4
0
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"));
}
예제 #5
0
파일: TileSet.cpp 프로젝트: sakelestemur/GD
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;
}
예제 #6
0
void LightObject::DoUnserializeFrom(gd::Project & project, const gd::SerializerElement & element)
{
    SetIntensity(element.GetIntAttribute("intensity", 255));
    SetRadius(element.GetIntAttribute("radius", 180));
    SetQuality(element.GetIntAttribute("quality", 16));

    {
        int r = element.GetIntAttribute("colorR", 255);
        int g = element.GetIntAttribute("colorG", 255);
        int b = element.GetIntAttribute("colorB", 255);
        SetColor(sf::Color(r,g,b));
    }

    globalLight = element.GetBoolAttribute("globalLight", false);

    {
        int r = element.GetIntAttribute("globalColorR", 255);
        int g = element.GetIntAttribute("globalColorG", 255);
        int b = element.GetIntAttribute("globalColorB", 255);
        int a = element.GetIntAttribute("globalColorA", 255);
        globalLightColor = sf::Color(r,g,b,a);
    }

}
예제 #7
0
void ParticleEmitterBase::UnserializeParticleEmitterBaseFrom(
    const gd::SerializerElement& element) {
  tank = element.GetDoubleAttribute("tank");
  flow = element.GetDoubleAttribute("flow");
  emitterForceMin = element.GetDoubleAttribute("emitterForceMin");
  emitterForceMax = element.GetDoubleAttribute("emitterForceMax");
  emitterXDirection = element.GetDoubleAttribute("emitterXDirection");
  emitterYDirection = element.GetDoubleAttribute("emitterYDirection");
  emitterZDirection = element.GetDoubleAttribute("emitterZDirection");
  emitterAngleA = element.GetDoubleAttribute("emitterAngleA");
  emitterAngleB = element.GetDoubleAttribute("emitterAngleB");
  zoneRadius = element.GetDoubleAttribute("zoneRadius");
  particleGravityX = element.GetDoubleAttribute("particleGravityX");
  particleGravityY = element.GetDoubleAttribute("particleGravityY");
  particleGravityZ = element.GetDoubleAttribute("particleGravityZ");
  friction = element.GetDoubleAttribute("friction");
  particleLifeTimeMin = element.GetDoubleAttribute("particleLifeTimeMin");
  particleLifeTimeMax = element.GetDoubleAttribute("particleLifeTimeMax");
  particleRed1 = element.GetDoubleAttribute("particleRed1");
  particleRed2 = element.GetDoubleAttribute("particleRed2");
  particleGreen1 = element.GetDoubleAttribute("particleGreen1");
  particleGreen2 = element.GetDoubleAttribute("particleGreen2");
  particleBlue1 = element.GetDoubleAttribute("particleBlue1");
  particleBlue2 = element.GetDoubleAttribute("particleBlue2");
  particleAlpha1 = element.GetDoubleAttribute("particleAlpha1");
  particleAlpha2 = element.GetDoubleAttribute("particleAlpha2");
  rendererParam1 = element.GetDoubleAttribute("rendererParam1");
  rendererParam2 = element.GetDoubleAttribute("rendererParam2");
  particleSize1 = element.GetDoubleAttribute("particleSize1");
  particleSize2 = element.GetDoubleAttribute("particleSize2");
  particleAngle1 = element.GetDoubleAttribute("particleAngle1");
  particleAngle2 = element.GetDoubleAttribute("particleAngle2");
  particleAlphaRandomness1 =
      element.GetDoubleAttribute("particleAlphaRandomness1");
  particleAlphaRandomness2 =
      element.GetDoubleAttribute("particleAlphaRandomness2");
  particleSizeRandomness1 =
      element.GetDoubleAttribute("particleSizeRandomness1");
  particleSizeRandomness2 =
      element.GetDoubleAttribute("particleSizeRandomness2");
  particleAngleRandomness1 =
      element.GetDoubleAttribute("particleAngleRandomness1");
  particleAngleRandomness2 =
      element.GetDoubleAttribute("particleAngleRandomness2");
  additive = element.GetBoolAttribute("additive");
  destroyWhenNoParticles =
      element.GetBoolAttribute("destroyWhenNoParticles", false);
  textureParticleName = element.GetStringAttribute("textureParticleName");
  maxParticleNb = element.GetIntAttribute("maxParticleNb", 5000);

  {
    gd::String result = element.GetStringAttribute("rendererType");
    if (result == "Line")
      rendererType = Line;
    else if (result == "Quad")
      rendererType = Quad;
    else
      rendererType = Point;
  }
  {
    gd::String result = element.GetStringAttribute("redParam");
    if (result == "Mutable")
      redParam = Mutable;
    else if (result == "Random")
      redParam = Random;
    else
      redParam = Enabled;
  }
  {
    gd::String result = element.GetStringAttribute("greenParam");
    if (result == "Mutable")
      greenParam = Mutable;
    else if (result == "Random")
      greenParam = Random;
    else
      greenParam = Enabled;
  }
  {
    gd::String result = element.GetStringAttribute("blueParam");
    if (result == "Mutable")
      blueParam = Mutable;
    else if (result == "Random")
      blueParam = Random;
    else
      blueParam = Enabled;
  }
  {
    gd::String result = element.GetStringAttribute("alphaParam");
    if (result == "Mutable")
      alphaParam = Mutable;
    else if (result == "Random")
      alphaParam = Random;
    else
      alphaParam = Enabled;
  }
  {
    gd::String result = element.GetStringAttribute("sizeParam");
    if (result == "Mutable")
      sizeParam = Mutable;
    else if (result == "Random")
      sizeParam = Random;
    else
      sizeParam = Nothing;
  }
  {
    gd::String result = element.GetStringAttribute("angleParam");
    if (result == "Mutable")
      angleParam = Mutable;
    else if (result == "Random")
      angleParam = Random;
    else
      angleParam = Nothing;
  }
}