use of com.bladecoder.engine.model.SceneLayer in project bladecoder-adventure-engine by bladecoder.
the class SetActorAttrAction method run.
@Override
public boolean run(VerbRunner cb) {
Scene s = actor.getScene();
BaseActor a = s.getActor(actor.getActorId(), true);
if (a == null) {
EngineLogger.error("SetActorAttr - Actor not found:" + this.actor.getActorId());
return false;
}
if (visible != null)
a.setVisible(visible);
if (interaction != null) {
if (a instanceof InteractiveActor)
((InteractiveActor) a).setInteraction(interaction);
else
EngineLogger.error("'Interaction' property not supported for actor:" + a.getId());
}
if (layer != null) {
if (a instanceof InteractiveActor) {
InteractiveActor iActor = (InteractiveActor) a;
String oldLayer = iActor.getLayer();
s.getLayer(oldLayer).remove(iActor);
iActor.setLayer(layer);
SceneLayer l = s.getLayer(layer);
l.add(iActor);
if (!l.isDynamic())
l.orderByZIndex();
} else
EngineLogger.error("'layer' property not supported for actor:" + a.getId());
}
if (zIndex != null) {
if (a instanceof InteractiveActor) {
InteractiveActor iActor = (InteractiveActor) a;
iActor.setZIndex(zIndex);
SceneLayer l = s.getLayer(iActor.getLayer());
if (!l.isDynamic())
l.orderByZIndex();
} else
EngineLogger.error("'zIndex' property not supported for actor:" + a.getId());
}
if (scale != null) {
if (a instanceof SpriteActor)
((SpriteActor) a).setScale(scale);
else
EngineLogger.error("'scale' property not supported for actor:" + a.getId());
}
if (rotation != null) {
if (a instanceof SpriteActor)
((SpriteActor) a).setRot(rotation);
else
EngineLogger.error("'rotation' property not supported for actor:" + a.getId());
}
if (tint != null) {
if (a instanceof SpriteActor)
((SpriteActor) a).setTint(tint);
else
EngineLogger.error("'tint' property not supported for actor:" + a.getId());
}
if (fakeDepth != null) {
if (a instanceof SpriteActor) {
((SpriteActor) a).setFakeDepth(fakeDepth);
} else
EngineLogger.error("'fakeDepth' property not supported for actor:" + a.getId());
}
if (standAnimation != null) {
if (a instanceof CharacterActor)
((CharacterActor) a).setStandAnim(standAnimation);
else
EngineLogger.error("'standAnimation' property not supported for actor:" + a.getId());
}
if (walkAnimation != null) {
if (a instanceof CharacterActor)
((CharacterActor) a).setWalkAnim(walkAnimation);
else
EngineLogger.error("'walkAnimation' property not supported for actor:" + a.getId());
}
if (talkAnimation != null) {
if (a instanceof CharacterActor)
((CharacterActor) a).setTalkAnim(talkAnimation);
else
EngineLogger.error("'talkAnimation' property not supported for actor:" + a.getId());
}
if (walkingSpeed != null) {
if (a instanceof CharacterActor)
((CharacterActor) a).setWalkingSpeed(walkingSpeed);
else
EngineLogger.error("'walkingSpeed' property not supported for actor:" + a.getId());
}
if (uiActor != null) {
if (a instanceof InteractiveActor) {
if (uiActor)
setUIActor(s, (InteractiveActor) a);
else
removeUIActor(s, (InteractiveActor) a);
} else
EngineLogger.error("'uiActor' property not supported for actor:" + a.getId());
}
return false;
}
use of com.bladecoder.engine.model.SceneLayer in project bladecoder-adventure-engine by bladecoder.
the class EditLayerDialog method inputsToModel.
@Override
protected void inputsToModel(boolean create) {
if (create) {
e = new SceneLayer();
}
// TODO if the name is changed. Change all actor layer name.
e.setName(name.getText());
e.setVisible(Boolean.parseBoolean(visible.getText()));
e.setDynamic(Boolean.parseBoolean(dynamic.getText()));
e.setParallaxMultiplier(Float.parseFloat(parallax.getText()));
if (create) {
parent.getLayers().add(e);
}
// TODO UNDO OP
// UndoOp undoOp = new UndoAddElement(doc, e);
// Ctx.project.getUndoStack().add(undoOp);
Ctx.project.setModified();
}
use of com.bladecoder.engine.model.SceneLayer 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.SceneLayer in project bladecoder-adventure-engine by bladecoder.
the class LayerList method toggleVisibility.
private void toggleVisibility() {
SceneLayer e = list.getSelected();
if (e == null)
return;
e.setVisible(!e.isVisible());
Ctx.project.setModified();
}
use of com.bladecoder.engine.model.SceneLayer in project bladecoder-adventure-engine by bladecoder.
the class LayerList method up.
private void up() {
int pos = list.getSelectedIndex();
if (pos == -1 || pos == 0)
return;
Array<SceneLayer> items = list.getItems();
SceneLayer e = items.get(pos);
SceneLayer e2 = items.get(pos - 1);
parent.getLayers().set(pos, e2);
parent.getLayers().set(pos - 1, e);
items.removeIndex(pos);
items.insert(pos - 1, e);
list.setSelectedIndex(pos - 1);
upBtn.setDisabled(list.getSelectedIndex() == 0);
downBtn.setDisabled(list.getSelectedIndex() == list.getItems().size - 1);
Ctx.project.setModified();
}
Aggregations