use of com.bladecoder.engineeditor.undo.UndoEditScene 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);
}
Aggregations