Search in sources :

Example 1 with DialogOption

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

the class SetDialogOptionAttrAction method run.

@Override
public boolean run(VerbRunner cb) {
    final Scene s = actor.getScene();
    CharacterActor a = (CharacterActor) s.getActor(actor.getActorId(), true);
    Dialog d = a.getDialog(dialog);
    if (d == null) {
        EngineLogger.error("SetDialogOptionAttrAction: Dialog '" + dialog + "' not found");
        return false;
    }
    DialogOption o = d.getOptions().get(option);
    if (o == null) {
        EngineLogger.error("SetDialogOptionAttrAction: Option '" + option + "' not found");
        return false;
    }
    if (visible != null)
        o.setVisible(visible);
    return false;
}
Also used : Dialog(com.bladecoder.engine.model.Dialog) Scene(com.bladecoder.engine.model.Scene) CharacterActor(com.bladecoder.engine.model.CharacterActor) DialogOption(com.bladecoder.engine.model.DialogOption)

Example 2 with DialogOption

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

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

the class OptionList method copy.

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

Example 4 with DialogOption

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

the class EditOptionDialog method inputsToModel.

@Override
protected void inputsToModel(boolean create) {
    if (create) {
        e = new DialogOption();
        // parent.addOption(e);
        parent.getOptions().add(pos, e);
    }
    String key = e.getText();
    if (key == null || key.isEmpty() || key.charAt(0) != I18N.PREFIX)
        key = Ctx.project.getI18N().genKey(Ctx.project.getSelectedScene().getId(), Ctx.project.getSelectedActor().getId(), parent.getId(), pos, "text");
    Ctx.project.getI18N().setTranslation(key, text.getText());
    if (text.getText() != null && !text.getText().isEmpty())
        e.setText(key);
    else
        e.setText(null);
    String responseKey = e.getResponseText();
    if (responseKey == null || responseKey.isEmpty() || responseKey.charAt(0) != I18N.PREFIX)
        responseKey = Ctx.project.getI18N().genKey(Ctx.project.getSelectedScene().getId(), Ctx.project.getSelectedActor().getId(), parent.getId(), pos, "responseText");
    Ctx.project.getI18N().setTranslation(responseKey, responseText.getText());
    if (responseText.getText() != null && !responseText.getText().isEmpty())
        e.setResponseText(responseKey);
    else
        e.setResponseText(null);
    e.setVerbId(verb.getText());
    e.setNext(next.getText());
    e.setVisible(Boolean.parseBoolean(visible.getText()));
    e.setOnce(Boolean.parseBoolean(once.getText()));
    e.setVoiceId(voice.getText());
    e.setResponseVoiceId(responseVoice.getText());
    // TODO UNDO OP
    // UndoOp undoOp = new UndoAddElement(doc, e);
    // Ctx.project.getUndoStack().add(undoOp);
    Ctx.project.setModified();
}
Also used : DialogOption(com.bladecoder.engine.model.DialogOption)

Example 5 with DialogOption

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

the class OptionList method delete.

@Override
protected void delete() {
    DialogOption option = removeSelected();
    int idx = parent.getOptions().indexOf(option);
    parent.getOptions().remove(option);
    // TRANSLATIONS
    Ctx.project.getI18N().putTranslationsInElement(option);
    // UNDO
    Ctx.project.getUndoStack().add(new UndoDeleteOption(parent, option, idx));
    Ctx.project.setModified();
}
Also used : UndoDeleteOption(com.bladecoder.engineeditor.undo.UndoDeleteOption) DialogOption(com.bladecoder.engine.model.DialogOption)

Aggregations

DialogOption (com.bladecoder.engine.model.DialogOption)14 CharacterActor (com.bladecoder.engine.model.CharacterActor)6 Dialog (com.bladecoder.engine.model.Dialog)5 BaseActor (com.bladecoder.engine.model.BaseActor)4 InteractiveActor (com.bladecoder.engine.model.InteractiveActor)4 Scene (com.bladecoder.engine.model.Scene)4 Verb (com.bladecoder.engine.model.Verb)4 Action (com.bladecoder.engine.actions.Action)3 LookAtAction (com.bladecoder.engine.actions.LookAtAction)2 SayAction (com.bladecoder.engine.actions.SayAction)2 SetCutmodeAction (com.bladecoder.engine.actions.SetCutmodeAction)2 SpriteActor (com.bladecoder.engine.model.SpriteActor)2 Rectangle (com.badlogic.gdx.math.Rectangle)1 Actor (com.badlogic.gdx.scenes.scene2d.Actor)1 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)1 TextRenderer (com.bladecoder.engine.model.TextRenderer)1 World (com.bladecoder.engine.model.World)1 UndoDeleteOption (com.bladecoder.engineeditor.undo.UndoDeleteOption)1 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1