Search in sources :

Example 11 with BaseActor

use of com.bladecoder.engine.model.BaseActor 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 12 with BaseActor

use of com.bladecoder.engine.model.BaseActor in project bladecoder-adventure-engine by bladecoder.

the class ActorList method copy.

@Override
protected void copy() {
    BaseActor e = list.getSelected();
    if (e == null)
        return;
    clipboard = (BaseActor) ElementUtils.cloneElement(e);
    toolbar.disablePaste(false);
    // TRANSLATIONS
    Ctx.project.getI18N().putTranslationsInElement(clipboard);
}
Also used : BaseActor(com.bladecoder.engine.model.BaseActor)

Example 13 with BaseActor

use of com.bladecoder.engine.model.BaseActor in project bladecoder-adventure-engine by bladecoder.

the class ActorList method setPlayer.

private void setPlayer() {
    int pos = list.getSelectedIndex();
    if (pos == -1)
        return;
    BaseActor a = list.getItems().get(pos);
    if (a instanceof CharacterActor) {
        Ctx.project.getSelectedScene().setPlayer((CharacterActor) a);
        Ctx.project.setModified();
    }
}
Also used : BaseActor(com.bladecoder.engine.model.BaseActor) CharacterActor(com.bladecoder.engine.model.CharacterActor)

Example 14 with BaseActor

use of com.bladecoder.engine.model.BaseActor in project bladecoder-adventure-engine by bladecoder.

the class ActorList method paste.

@Override
protected void paste() {
    BaseActor newElement = (BaseActor) ElementUtils.cloneElement(clipboard);
    newElement.setId(ElementUtils.getCheckedId(newElement.getId(), parent.getActors().keySet().toArray(new String[0])));
    int pos = list.getSelectedIndex() + 1;
    list.getItems().insert(pos, newElement);
    parent.addActor(newElement);
    Ctx.project.getI18N().extractStrings(parent.getId(), newElement);
    if (newElement instanceof SpriteActor) {
        SpriteActor ia = (SpriteActor) newElement;
        ia.loadAssets();
        EngineAssetManager.getInstance().finishLoading();
        ia.retrieveAssets();
    }
    list.setSelectedIndex(pos);
    list.invalidateHierarchy();
    Ctx.project.setModified();
}
Also used : BaseActor(com.bladecoder.engine.model.BaseActor) SpriteActor(com.bladecoder.engine.model.SpriteActor)

Example 15 with BaseActor

use of com.bladecoder.engine.model.BaseActor 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

BaseActor (com.bladecoder.engine.model.BaseActor)40 InteractiveActor (com.bladecoder.engine.model.InteractiveActor)26 Scene (com.bladecoder.engine.model.Scene)16 SpriteActor (com.bladecoder.engine.model.SpriteActor)13 CharacterActor (com.bladecoder.engine.model.CharacterActor)12 Vector2 (com.badlogic.gdx.math.Vector2)8 Verb (com.bladecoder.engine.model.Verb)8 Polygon (com.badlogic.gdx.math.Polygon)7 World (com.bladecoder.engine.model.World)7 Rectangle (com.badlogic.gdx.math.Rectangle)5 Action (com.bladecoder.engine.actions.Action)5 AnchorActor (com.bladecoder.engine.model.AnchorActor)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 ObstacleActor (com.bladecoder.engine.model.ObstacleActor)4 SceneLayer (com.bladecoder.engine.model.SceneLayer)4 Color (com.badlogic.gdx.graphics.Color)3