use of com.bladecoder.engine.model.Scene in project bladecoder-adventure-engine by bladecoder.
the class SetSceneStateAction method run.
@Override
public boolean run(VerbRunner cb) {
Scene s = (scene != null && !scene.isEmpty()) ? World.getInstance().getScene(scene) : World.getInstance().getCurrentScene();
s.setState(state);
return false;
}
use of com.bladecoder.engine.model.Scene in project bladecoder-adventure-engine by bladecoder.
the class ModelTools method addCutMode.
public static final void addCutMode() {
Map<String, Scene> scenes = World.getInstance().getScenes();
for (Scene scn : scenes.values()) {
Map<String, BaseActor> actors = scn.getActors();
for (BaseActor a : actors.values()) {
if (a instanceof InteractiveActor) {
InteractiveActor ia = (InteractiveActor) a;
HashMap<String, Verb> verbs = ia.getVerbManager().getVerbs();
for (Verb v : verbs.values()) {
ArrayList<Action> actions = v.getActions();
// Don't process verbs for inventory
if (v.getState() != null && v.getState().equalsIgnoreCase("INVENTORY"))
continue;
if (actions.size() == 1) {
Action act = actions.get(0);
if (act instanceof LookAtAction || act instanceof SayAction) {
actions.clear();
SetCutmodeAction cma1 = new SetCutmodeAction();
SetCutmodeAction cma2 = new SetCutmodeAction();
try {
ActionUtils.setParam(cma1, "value", "true");
ActionUtils.setParam(cma2, "value", "false");
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
EditorLogger.printStackTrace(e);
}
actions.add(cma1);
actions.add(act);
actions.add(cma2);
}
}
}
}
}
}
Ctx.project.setModified();
}
use of com.bladecoder.engine.model.Scene in project bladecoder-adventure-engine by bladecoder.
the class ModelTools method checkI18NMissingKeys.
public static final void checkI18NMissingKeys() throws NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
Map<String, Scene> scenes = World.getInstance().getScenes();
for (Scene scn : scenes.values()) {
Map<String, BaseActor> actors = scn.getActors();
// SCENE VERBS
HashMap<String, Verb> verbs = scn.getVerbManager().getVerbs();
for (Verb v : verbs.values()) {
ArrayList<Action> actions = v.getActions();
for (Action act : actions) {
String[] params = ActionUtils.getFieldNames(act);
for (String p : params) {
String val = ActionUtils.getStringValue(act, p);
if (val != null && !val.isEmpty() && val.charAt(0) == I18N.PREFIX) {
String trans = Ctx.project.translate(val);
if (trans == val) {
EditorLogger.error("Key not found: " + val);
}
}
}
}
}
for (BaseActor a : actors.values()) {
if (a instanceof InteractiveActor) {
InteractiveActor ia = (InteractiveActor) a;
// DESC
if (ia.getDesc() != null && !ia.getDesc().isEmpty() && ia.getDesc().charAt(0) == I18N.PREFIX) {
String trans = Ctx.project.translate(ia.getDesc());
if (trans == ia.getDesc()) {
EditorLogger.error("Key not found: " + ia.getDesc());
}
}
// ACTOR VERBS
verbs = ia.getVerbManager().getVerbs();
for (Verb v : verbs.values()) {
ArrayList<Action> actions = v.getActions();
for (Action act : actions) {
String[] params = ActionUtils.getFieldNames(act);
for (String p : params) {
String val = ActionUtils.getStringValue(act, p);
if (val != null && !val.isEmpty() && val.charAt(0) == I18N.PREFIX) {
String trans = Ctx.project.translate(val);
if (trans == val) {
EditorLogger.error("Key not found: " + val);
}
}
}
}
}
}
// DIALOGS
if (a instanceof CharacterActor) {
HashMap<String, Dialog> dialogs = ((CharacterActor) a).getDialogs();
if (dialogs != null) {
for (Dialog d : dialogs.values()) {
ArrayList<DialogOption> options = d.getOptions();
for (DialogOption o : options) {
if (o.getText() != null && !o.getText().isEmpty() && o.getText().charAt(0) == I18N.PREFIX) {
String trans = Ctx.project.translate(o.getText());
if (trans == o.getText()) {
EditorLogger.error("Key not found: " + o.getText());
}
}
if (o.getResponseText() != null && !o.getResponseText().isEmpty() && o.getResponseText().charAt(0) == I18N.PREFIX) {
String trans = Ctx.project.translate(o.getResponseText());
if (trans == o.getResponseText()) {
EditorLogger.error("Key not found: " + o.getResponseText());
}
}
}
}
}
}
}
}
}
use of com.bladecoder.engine.model.Scene 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.Scene in project bladecoder-adventure-engine by bladecoder.
the class ActorList method edit.
@Override
protected void edit() {
BaseActor e = list.getSelected();
if (e == null)
return;
EditModelDialog<Scene, BaseActor> dialog = getEditElementDialogInstance(e);
dialog.show(getStage());
dialog.setListener(new ChangeListener() {
@SuppressWarnings("unchecked")
@Override
public void changed(ChangeEvent event, Actor actor) {
BaseActor e = ((EditModelDialog<Scene, BaseActor>) actor).getElement();
// When the type is changed, a new element is created and it is needed to replace the previous element.
if (e != list.getSelected()) {
int i = list.getSelectedIndex();
getItems().set(i, e);
list.setSelectedIndex(i);
list.invalidateHierarchy();
}
}
});
}
Aggregations