Search in sources :

Example 1 with UndoCreateScene

use of com.bladecoder.engineeditor.undo.UndoCreateScene in project bladecoder-adventure-engine by bladecoder.

the class EditSceneDialog method inputsToModel.

@Override
protected void inputsToModel(boolean create) {
    if (create) {
        e = new Scene();
        // CREATE DEFAULT LAYERS: BG, DYNAMIC, FG
        SceneLayer l = new SceneLayer();
        l.setName("foreground");
        l.setVisible(true);
        l.setDynamic(false);
        e.addLayer(l);
        l = new SceneLayer();
        l.setName("dynamic");
        l.setVisible(true);
        l.setDynamic(true);
        e.addLayer(l);
        l = new SceneLayer();
        l.setName("background");
        l.setVisible(true);
        l.setDynamic(false);
        e.addLayer(l);
    } else {
        parent.getScenes().remove(e.getId());
    }
    e.setId(ElementUtils.getCheckedId(id.getText(), World.getInstance().getScenes().keySet().toArray(new String[0])));
    e.setBackgroundAtlas(backgroundAtlas.getText());
    e.setBackgroundRegionId(backgroundRegion.getText());
    boolean dv = Boolean.parseBoolean(depthVector.getText());
    if (dv == true && e.getDepthVector() == null) {
        // create depth vector
        e.setDepthVector(new Vector2(World.getInstance().getHeight(), 0));
    } else if (dv == false && e.getDepthVector() != null) {
        // Remove depth vector
        e.setDepthVector(null);
    }
    e.setState(state.getText());
    MusicDesc md = null;
    if (music.getText() != null) {
        md = new MusicDesc();
        md.setFilename(music.getText());
        md.setLoop(Boolean.parseBoolean(loopMusic.getText()));
        md.setVolume(Float.parseFloat(volumeMusic.getText()));
        md.setInitialDelay(Float.parseFloat(initialMusicDelay.getText()));
        md.setRepeatDelay(Float.parseFloat(repeatMusicDelay.getText()));
        md.setStopWhenLeaving(Boolean.parseBoolean(stopWhenLeaving.getText()));
    }
    e.setMusicDesc(md);
    e.setSceneSize(Param.parseVector2(sceneSize.getText()));
    parent.addScene(e);
    if (parent.getScenes().size() == 1)
        parent.setInitScene(e.getId());
    // UNDO OP
    if (create) {
        Ctx.project.getUndoStack().add(new UndoCreateScene(e));
    } else {
        Ctx.project.getUndoStack().add(new UndoEditScene(e));
    }
    Ctx.project.setModified(this, Project.NOTIFY_ELEMENT_CREATED, null, e);
}
Also used : UndoEditScene(com.bladecoder.engineeditor.undo.UndoEditScene) SceneLayer(com.bladecoder.engine.model.SceneLayer) Vector2(com.badlogic.gdx.math.Vector2) UndoCreateScene(com.bladecoder.engineeditor.undo.UndoCreateScene) UndoCreateScene(com.bladecoder.engineeditor.undo.UndoCreateScene) Scene(com.bladecoder.engine.model.Scene) UndoEditScene(com.bladecoder.engineeditor.undo.UndoEditScene) MusicDesc(com.bladecoder.engine.model.MusicDesc)

Aggregations

Vector2 (com.badlogic.gdx.math.Vector2)1 MusicDesc (com.bladecoder.engine.model.MusicDesc)1 Scene (com.bladecoder.engine.model.Scene)1 SceneLayer (com.bladecoder.engine.model.SceneLayer)1 UndoCreateScene (com.bladecoder.engineeditor.undo.UndoCreateScene)1 UndoEditScene (com.bladecoder.engineeditor.undo.UndoEditScene)1