use of com.bladecoder.engine.model.MusicDesc 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);
}
use of com.bladecoder.engine.model.MusicDesc in project bladecoder-adventure-engine by bladecoder.
the class EditSceneDialog method modelToInputs.
@Override
protected void modelToInputs() {
id.setText(e.getId());
backgroundAtlas.setText(e.getBackgroundAtlas());
backgroundRegion.setText(e.getBackgroundRegionId());
if (e.getDepthVector() != null)
depthVector.setText("true");
else
depthVector.setText("false");
state.setText(e.getState());
MusicDesc md = e.getMusicDesc();
if (md != null) {
music.setText(md.getFilename());
loopMusic.setText(Boolean.toString(md.isLoop()));
volumeMusic.setText(Float.toString(md.getVolume()));
initialMusicDelay.setText(Float.toString(md.getInitialDelay()));
repeatMusicDelay.setText(Float.toString(md.getRepeatDelay()));
stopWhenLeaving.setText(Boolean.toString(md.isStopWhenLeaving()));
}
if (e.getSceneSize() != null)
sceneSize.setText(Param.toStringParam(e.getSceneSize()));
}
use of com.bladecoder.engine.model.MusicDesc in project bladecoder-adventure-engine by bladecoder.
the class MusicAction method run.
@Override
public boolean run(VerbRunner cb) {
MusicManager musicEngine = World.getInstance().getMusicManager();
if (filename == null) {
musicEngine.setMusic(null);
} else {
MusicDesc md = new MusicDesc();
md.setFilename(filename);
md.setLoop(loop);
md.setInitialDelay(initialDelay);
md.setRepeatDelay(repeatDelay);
md.setStopWhenLeaving(stopWhenLeaving);
md.setVolume(volume);
musicEngine.setMusic(md);
}
return false;
}
Aggregations