Search in sources :

Example 11 with Scene

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;
}
Also used : Scene(com.bladecoder.engine.model.Scene)

Example 12 with Scene

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();
}
Also used : LookAtAction(com.bladecoder.engine.actions.LookAtAction) SayAction(com.bladecoder.engine.actions.SayAction) SetCutmodeAction(com.bladecoder.engine.actions.SetCutmodeAction) Action(com.bladecoder.engine.actions.Action) LookAtAction(com.bladecoder.engine.actions.LookAtAction) InteractiveActor(com.bladecoder.engine.model.InteractiveActor) SayAction(com.bladecoder.engine.actions.SayAction) Scene(com.bladecoder.engine.model.Scene) SetCutmodeAction(com.bladecoder.engine.actions.SetCutmodeAction) Verb(com.bladecoder.engine.model.Verb) BaseActor(com.bladecoder.engine.model.BaseActor)

Example 13 with Scene

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());
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : LookAtAction(com.bladecoder.engine.actions.LookAtAction) SayAction(com.bladecoder.engine.actions.SayAction) SetCutmodeAction(com.bladecoder.engine.actions.SetCutmodeAction) Action(com.bladecoder.engine.actions.Action) InteractiveActor(com.bladecoder.engine.model.InteractiveActor) Scene(com.bladecoder.engine.model.Scene) CharacterActor(com.bladecoder.engine.model.CharacterActor) Dialog(com.bladecoder.engine.model.Dialog) Verb(com.bladecoder.engine.model.Verb) BaseActor(com.bladecoder.engine.model.BaseActor) DialogOption(com.bladecoder.engine.model.DialogOption)

Example 14 with Scene

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);
}
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)

Example 15 with Scene

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();
            }
        }
    });
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) BaseActor(com.bladecoder.engine.model.BaseActor) ObstacleActor(com.bladecoder.engine.model.ObstacleActor) UndoDeleteActor(com.bladecoder.engineeditor.undo.UndoDeleteActor) CharacterActor(com.bladecoder.engine.model.CharacterActor) AnchorActor(com.bladecoder.engine.model.AnchorActor) Actor(com.badlogic.gdx.scenes.scene2d.Actor) InteractiveActor(com.bladecoder.engine.model.InteractiveActor) SpriteActor(com.bladecoder.engine.model.SpriteActor) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) PropertyChangeListener(java.beans.PropertyChangeListener) BaseActor(com.bladecoder.engine.model.BaseActor) Scene(com.bladecoder.engine.model.Scene)

Aggregations

Scene (com.bladecoder.engine.model.Scene)35 InteractiveActor (com.bladecoder.engine.model.InteractiveActor)18 BaseActor (com.bladecoder.engine.model.BaseActor)16 Verb (com.bladecoder.engine.model.Verb)9 Vector2 (com.badlogic.gdx.math.Vector2)8 CharacterActor (com.bladecoder.engine.model.CharacterActor)8 SpriteActor (com.bladecoder.engine.model.SpriteActor)8 Action (com.bladecoder.engine.actions.Action)6 World (com.bladecoder.engine.model.World)5 LookAtAction (com.bladecoder.engine.actions.LookAtAction)4 SayAction (com.bladecoder.engine.actions.SayAction)4 SetCutmodeAction (com.bladecoder.engine.actions.SetCutmodeAction)4 Dialog (com.bladecoder.engine.model.Dialog)4 DialogOption (com.bladecoder.engine.model.DialogOption)4 Polygon (com.badlogic.gdx.math.Polygon)3 AnchorActor (com.bladecoder.engine.model.AnchorActor)3 UndoDeleteScene (com.bladecoder.engineeditor.undo.UndoDeleteScene)3 AnimationRenderer (com.bladecoder.engine.model.AnimationRenderer)2 SceneLayer (com.bladecoder.engine.model.SceneLayer)2 VerbRunner (com.bladecoder.engine.model.VerbRunner)2