Exemplo n.º 1
0
void ImageResource::UnserializeFrom(const SerializerElement & element)
{
    alwaysLoaded = element.GetBoolAttribute("alwaysLoaded");
    smooth = element.GetBoolAttribute("smoothed");
    SetUserAdded( element.GetBoolAttribute("userAdded") );
    SetFile(element.GetStringAttribute("file"));
}
Exemplo n.º 2
0
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");
}
Exemplo n.º 3
0
/**
 * \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);
    }
}
Exemplo n.º 4
0
void WhileEvent::UnserializeFrom(gd::Project & project, const SerializerElement & element)
{
    justCreatedByTheUser = false;
    infiniteLoopWarning = element.GetBoolAttribute("infiniteLoopWarning");
    gd::EventsListSerialization::OpenConditions(project, whileConditions, element.GetChild("whileConditions", 0, "WhileConditions"));
    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"));
}
Exemplo n.º 5
0
void AudioResource::UnserializeFrom(const SerializerElement & element)
{
    SetUserAdded( element.GetBoolAttribute("userAdded") );
    SetFile(element.GetStringAttribute("file"));
}
Exemplo n.º 6
0
void SourceFile::UnserializeFrom(const SerializerElement & element)
{
    filename = element.GetStringAttribute("filename");
    language = element.GetStringAttribute("language", "C++");
    gdManaged = element.GetBoolAttribute("gdManaged");
}
Exemplo n.º 7
0
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;
        }

    }
}