com.bladecoder.engine.actions.Action - java examples

Here are the examples of the java api com.bladecoder.engine.actions.Action taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

44 Examples 7

19 View Complete Implementation : ActionList.java
Copyright Apache License 2.0
Author : bladecoder
private boolean isControlAction(Action e) {
    return e instanceof AbstractControlAction;
}

19 View Complete Implementation : ActionList.java
Copyright Apache License 2.0
Author : bladecoder
private int deleteFirstActionNamed(int pos, String actionId) {
    while (!(list.gereplacedems().get(pos) instanceof AbstractControlAction && getOrCreateControlActionId((AbstractControlAction) list.gereplacedems().get(pos)).equals(actionId))) pos++;
    Action e2 = list.gereplacedems().removeIndex(pos);
    parent.getActions().remove(e2);
    return pos;
}

19 View Complete Implementation : UndoDeleteAction.java
Copyright Apache License 2.0
Author : bladecoder
public clreplaced UndoDeleteAction implements UndoOp {

    private Verb v;

    private Action a;

    private int idx;

    public UndoDeleteAction(Verb v, Action a, int idx) {
        this.v = v;
        this.a = a;
        this.idx = idx;
    }

    @Override
    public void undo() {
        v.getActions().add(idx, a);
        Ctx.project.setModified(this, Project.NOTIFY_ELEMENT_CREATED, null, a);
    }
}

18 View Complete Implementation : ActionList.java
Copyright Apache License 2.0
Author : bladecoder
@Override
protected EditModelDialog<Verb, Action> getEditElementDialogInstance(Action e) {
    EditActionDialog editActionDialog = new EditActionDialog(skin, parent, e, scope, list.getSelectedIndex());
    return editActionDialog;
}

18 View Complete Implementation : Verb.java
Copyright Apache License 2.0
Author : bladecoder
public void add(Action a) {
    actions.add(a);
}

17 View Complete Implementation : ActionList.java
Copyright Apache License 2.0
Author : bladecoder
private void insertEndAction(int pos, String id) {
    final Action e = new EndAction();
    try {
        ActionUtils.setParam(e, CONTROL_ACTION_ID_ATTR, id);
    } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e1) {
        EditorLogger.error(e1.getMessage());
    }
    list.gereplacedems().insert(pos, e);
    parent.getActions().add(pos, e);
}

16 View Complete Implementation : I18NHandler.java
Copyright Apache License 2.0
Author : bladecoder
public void putTranslationsInElement(Action a, boolean worldScope) {
    String[] names = ActionUtils.getFieldNames(a);
    for (String name : names) {
        if (name.toLowerCase().endsWith("text")) {
            try {
                String value = null;
                if (worldScope)
                    value = getWorldTranslation(ActionUtils.getStringValue(a, name));
                else
                    value = getTranslation(ActionUtils.getStringValue(a, name));
                ActionUtils.setParam(a, name, value);
            } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
                EditorLogger.error(e.getMessage());
            }
        }
    }
}

16 View Complete Implementation : I18NHandler.java
Copyright Apache License 2.0
Author : bladecoder
public void putTranslationsInElement(Verb v, boolean worldScope) {
    ArrayList<Action> actions = v.getActions();
    for (Action a : actions) {
        putTranslationsInElement(a, worldScope);
    }
}

16 View Complete Implementation : ActionList.java
Copyright Apache License 2.0
Author : bladecoder
public clreplaced ActionList extends ModelList<Verb, Action> {

    private static final String CONTROL_ACTION_ID_ATTR = "caID";

    Skin skin;

    private ImageButton upBtn;

    private ImageButton downBtn;

    private ImageButton disableBtn;

    private String scope;

    private final List<Action> multiClipboard = new ArrayList<Action>();

    public ActionList(Skin skin) {
        super(skin, false);
        this.skin = skin;
        setCellRenderer(listCellRenderer);
        disableBtn = new ImageButton(skin);
        toolbar.addToolBarButton(disableBtn, "ic_eye", "Enable/Disable", "Enable/Disable");
        disableBtn.setDisabled(false);
        disableBtn.addListener(new ChangeListener() {

            @Override
            public void changed(ChangeEvent event, Actor actor) {
                toggleEnabled();
            }
        });
        upBtn = new ImageButton(skin);
        downBtn = new ImageButton(skin);
        toolbar.addToolBarButton(upBtn, "ic_up", "Move up", "Move up");
        toolbar.addToolBarButton(downBtn, "ic_down", "Move down", "Move down");
        toolbar.pack();
        list.addListener(new ChangeListener() {

            @Override
            public void changed(ChangeEvent event, Actor actor) {
                int pos = list.getSelectedIndex();
                toolbar.disableEdit(pos == -1);
                disableBtn.setDisabled(pos == -1);
                upBtn.setDisabled(pos == -1 || pos == 0);
                downBtn.setDisabled(pos == -1 || pos == list.gereplacedems().size - 1);
            }
        });
        list.getSelection().setMultiple(true);
        upBtn.addListener(new ChangeListener() {

            @Override
            public void changed(ChangeEvent event, Actor actor) {
                up();
            }
        });
        downBtn.addListener(new ChangeListener() {

            @Override
            public void changed(ChangeEvent event, Actor actor) {
                down();
            }
        });
        Ctx.project.addPropertyChangeListener(Project.NOTIFY_ELEMENT_CREATED, new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                if (evt.getNewValue() instanceof Action && !(evt.getSource() instanceof EditActionDialog)) {
                    addElements(parent, parent.getActions());
                }
            }
        });
    }

    private void toggleEnabled() {
        if (list.getSelection().size() <= 0)
            return;
        Array<Action> sel = new Array<Action>();
        for (Action a : list.getSelection().toArray()) {
            // CONTROL ACTIONS CAN'T BE DISABLED
            if (a == null || isControlAction(a))
                continue;
            Array<Action> items = list.gereplacedems();
            int pos = items.indexOf(a, true);
            if (a instanceof DisableActionAction) {
                Action a2 = ((DisableActionAction) a).getAction();
                parent.getActions().set(pos, a2);
                items.set(pos, a2);
                sel.add(a2);
            } else {
                DisableActionAction a2 = new DisableActionAction();
                a2.setAction(a);
                parent.getActions().set(pos, a2);
                items.set(pos, a2);
                sel.add(a2);
            }
        }
        Ctx.project.setModified();
        list.getSelection().clear();
        list.getSelection().addAll(sel);
    }

    @Override
    protected EditModelDialog<Verb, Action> getEditElementDialogInstance(Action e) {
        EditActionDialog editActionDialog = new EditActionDialog(skin, parent, e, scope, list.getSelectedIndex());
        return editActionDialog;
    }

    public void setScope(String scope) {
        this.scope = scope;
    }

    @Override
    protected void create() {
        EditModelDialog<Verb, Action> dialog = getEditElementDialogInstance(null);
        dialog.show(getStage());
        dialog.setListener(new ChangeListener() {

            @SuppressWarnings("unchecked")
            @Override
            public void changed(ChangeEvent event, Actor actor) {
                int pos = list.getSelectedIndex() + 1;
                Action e = ((EditModelDialog<Verb, Action>) actor).getElement();
                list.gereplacedems().insert(pos, e);
                parent.getActions().add(pos, e);
                list.getSelection().choose(list.gereplacedems().get(pos));
                if (isControlAction(e)) {
                    insertEndAction(pos + 1, getOrCreateControlActionId((AbstractControlAction) e));
                    if (e instanceof AbstractIfAction)
                        insertEndAction(pos + 2, getOrCreateControlActionId((AbstractControlAction) e));
                }
                list.invalidateHierarchy();
            }
        });
    }

    private Action editedElement;

    @Override
    protected void edit() {
        Action e = list.getSelected();
        if (e == null || e instanceof EndAction || e instanceof DisableActionAction)
            return;
        editedElement = (Action) ElementUtils.cloneElement(e);
        EditModelDialog<Verb, Action> dialog = getEditElementDialogInstance(e);
        dialog.show(getStage());
        dialog.setListener(new ChangeListener() {

            @SuppressWarnings("unchecked")
            @Override
            public void changed(ChangeEvent event, Actor actor) {
                Action e = ((EditModelDialog<Verb, Action>) actor).getElement();
                int pos = list.getSelectedIndex();
                list.gereplacedems().set(pos, e);
                parent.getActions().set(pos, e);
                Ctx.project.setModified();
                if (isControlAction(editedElement)) {
                    if (!editedElement.getClreplaced().getName().equals(e.getClreplaced().getName())) {
                        deleteControlAction(pos, (AbstractControlAction) editedElement);
                        if (isControlAction(e)) {
                            insertEndAction(pos + 1, getOrCreateControlActionId((AbstractControlAction) e));
                            if (e instanceof AbstractIfAction)
                                insertEndAction(pos + 2, getOrCreateControlActionId((AbstractControlAction) e));
                        }
                    } else {
                        // insert previous caId
                        try {
                            ActionUtils.setParam(e, CONTROL_ACTION_ID_ATTR, getOrCreateControlActionId((AbstractControlAction) editedElement));
                        } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e1) {
                            EditorLogger.error(e1.getMessage());
                        }
                    }
                }
            }
        });
    }

    private String getOrCreateControlActionId(AbstractControlAction a) {
        String id = a.getControlActionID();
        if (id == null || id.isEmpty()) {
            id = Integer.toString(MathUtils.random(1, Integer.MAX_VALUE));
            try {
                ActionUtils.setParam(a, CONTROL_ACTION_ID_ATTR, id);
            } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
                EditorLogger.error(e.getMessage());
            }
        }
        return id;
    }

    private void insertEndAction(int pos, String id) {
        final Action e = new EndAction();
        try {
            ActionUtils.setParam(e, CONTROL_ACTION_ID_ATTR, id);
        } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e1) {
            EditorLogger.error(e1.getMessage());
        }
        list.gereplacedems().insert(pos, e);
        parent.getActions().add(pos, e);
    }

    @Override
    protected void copy() {
        if (parent == null || list.getSelection().size() == 0)
            return;
        multiClipboard.clear();
        for (Action e : getSortedSelection()) {
            if (e == null || e instanceof EndAction)
                return;
            Action cloned = (Action) ElementUtils.cloneElement(e);
            multiClipboard.add(cloned);
            toolbar.disablePaste(false);
            // TRANSLATIONS
            if (scope.equals(ScopePanel.WORLD_SCOPE))
                Ctx.project.getI18N().putTranslationsInElement(cloned, true);
            else
                Ctx.project.getI18N().putTranslationsInElement(cloned, false);
        }
    }

    @Override
    protected void paste() {
        if (parent == null || multiClipboard.size() == 0)
            return;
        Array<Action> sel = new Array<Action>();
        for (int i = multiClipboard.size() - 1; i >= 0; i--) {
            Action newElement = (Action) ElementUtils.cloneElement(multiClipboard.get(i));
            int pos = list.getSelectedIndex() + 1;
            list.gereplacedems().insert(pos, newElement);
            parent.getActions().add(pos, newElement);
            if (scope.equals(ScopePanel.WORLD_SCOPE))
                Ctx.project.getI18N().extractStrings(null, null, parent.getHashKey(), pos, newElement);
            else if (scope.equals(ScopePanel.SCENE_SCOPE))
                Ctx.project.getI18N().extractStrings(Ctx.project.getSelectedScene().getId(), null, parent.getHashKey(), pos, newElement);
            else
                Ctx.project.getI18N().extractStrings(Ctx.project.getSelectedScene().getId(), Ctx.project.getSelectedActor().getId(), parent.getHashKey(), pos, newElement);
            list.invalidateHierarchy();
            if (isControlAction(newElement)) {
                try {
                    ActionUtils.setParam(newElement, CONTROL_ACTION_ID_ATTR, null);
                } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
                    EditorLogger.error(e.getMessage());
                }
                insertEndAction(pos + 1, getOrCreateControlActionId((AbstractControlAction) newElement));
                if (newElement instanceof AbstractIfAction)
                    insertEndAction(pos + 2, getOrCreateControlActionId((AbstractControlAction) newElement));
            }
            sel.add(newElement);
        }
        list.getSelection().clear();
        list.getSelection().addAll(sel);
        Ctx.project.setModified();
    }

    @Override
    protected void delete() {
        if (list.getSelection().size() == 0)
            return;
        multiClipboard.clear();
        int pos = list.getSelectedIndex();
        for (Action e : getSortedSelection()) {
            if (e instanceof EndAction)
                continue;
            int pos2 = list.gereplacedems().indexOf(e, true);
            list.gereplacedems().removeValue(e, true);
            int idx = parent.getActions().indexOf(e);
            parent.getActions().remove(e);
            multiClipboard.add(e);
            // TRANSLATIONS
            if (scope.equals(ScopePanel.WORLD_SCOPE))
                Ctx.project.getI18N().putTranslationsInElement(e, true);
            else
                Ctx.project.getI18N().putTranslationsInElement(e, false);
            // UNDO
            Ctx.project.getUndoStack().add(new UndoDeleteAction(parent, e, idx));
            if (isControlAction(e))
                deleteControlAction(pos2, (AbstractControlAction) e);
        }
        if (list.gereplacedems().size == 0) {
            list.getSelection().clear();
        } else if (pos >= list.gereplacedems().size) {
            list.getSelection().choose(list.gereplacedems().get(list.gereplacedems().size - 1));
        } else {
            list.getSelection().choose(list.gereplacedems().get(pos));
        }
        toolbar.disablePaste(false);
        Ctx.project.setModified();
    }

    private Array<Action> getSortedSelection() {
        Array<Action> array = list.getSelection().toArray();
        array.sort(new Comparator<Action>() {

            @Override
            public int compare(Action arg0, Action arg1) {
                Integer i0 = list.gereplacedems().indexOf(arg0, true);
                Integer i1 = list.gereplacedems().indexOf(arg1, true);
                return i0.compareTo(i1);
            }
        });
        return array;
    }

    private boolean isControlAction(Action e) {
        return e instanceof AbstractControlAction;
    }

    private void deleteControlAction(int pos, final AbstractControlAction e) {
        final String id = getOrCreateControlActionId(e);
        if (e instanceof AbstractIfAction) {
            pos = deleteFirstActionNamed(pos, id);
        }
        deleteFirstActionNamed(pos, id);
    }

    private int deleteFirstActionNamed(int pos, String actionId) {
        while (!(list.gereplacedems().get(pos) instanceof AbstractControlAction && getOrCreateControlActionId((AbstractControlAction) list.gereplacedems().get(pos)).equals(actionId))) pos++;
        Action e2 = list.gereplacedems().removeIndex(pos);
        parent.getActions().remove(e2);
        return pos;
    }

    private void up() {
        if (parent == null || list.getSelection().size() == 0)
            return;
        Array<Action> sel = new Array<Action>();
        for (Action a : getSortedSelection()) {
            int pos = list.gereplacedems().indexOf(a, true);
            if (pos == -1 || pos == 0)
                return;
            Array<Action> items = list.gereplacedems();
            Action e = items.get(pos);
            Action e2 = items.get(pos - 1);
            sel.add(e);
            if (isControlAction(e) && isControlAction(e2)) {
                continue;
            }
            parent.getActions().set(pos - 1, e);
            parent.getActions().set(pos, e2);
            items.set(pos - 1, e);
            items.set(pos, e2);
        }
        list.getSelection().clear();
        list.getSelection().addAll(sel);
        upBtn.setDisabled(list.getSelectedIndex() == 0);
        downBtn.setDisabled(list.getSelectedIndex() == list.gereplacedems().size - 1);
        Ctx.project.setModified();
    }

    private void down() {
        if (parent == null || list.getSelection().size() == 0)
            return;
        Array<Action> sel = new Array<Action>();
        Array<Action> sortedSelection = getSortedSelection();
        for (int i = sortedSelection.size - 1; i >= 0; i--) {
            int pos = list.gereplacedems().indexOf(sortedSelection.get(i), true);
            Array<Action> items = list.gereplacedems();
            if (pos == -1 || pos == items.size - 1)
                return;
            Action e = items.get(pos);
            Action e2 = items.get(pos + 1);
            sel.add(e);
            if (isControlAction(e) && isControlAction(e2)) {
                continue;
            }
            parent.getActions().set(pos + 1, e);
            parent.getActions().set(pos, e2);
            items.set(pos + 1, e);
            items.set(pos, e2);
        }
        list.getSelection().clear();
        list.getSelection().addAll(sel);
        upBtn.setDisabled(list.getSelectedIndex() == 0);
        downBtn.setDisabled(list.getSelectedIndex() == list.gereplacedems().size - 1);
        Ctx.project.setModified();
    }

    // -------------------------------------------------------------------------
    // ListCellRenderer
    // -------------------------------------------------------------------------
    private final CellRenderer<Action> listCellRenderer = new CellRenderer<Action>() {

        @Override
        protected String getCellreplacedle(Action a) {
            boolean enabled = true;
            if (a instanceof CommentAction) {
                String comment = null;
                try {
                    comment = ActionUtils.getStringValue(a, "comment");
                } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
                    EditorLogger.error(e.getMessage());
                }
                if (comment == null)
                    comment = "COMMENT";
                else if (comment.indexOf('\n') != -1) {
                    comment = comment.substring(0, comment.indexOf('\n'));
                }
                return "[YELLOW]" + comment + "[]";
            }
            if (a instanceof DisableActionAction) {
                a = ((DisableActionAction) a).getAction();
                enabled = false;
            }
            String id = ActionUtils.getName(a.getClreplaced());
            if (id == null)
                id = a.getClreplaced().getCanonicalName();
            Field field = ActionUtils.getField(a.getClreplaced(), "actor");
            String actor = null;
            if (field != null) {
                try {
                    field.setAccessible(true);
                    Object v = field.get(a);
                    if (v != null)
                        actor = v.toString();
                } catch (IllegalArgumentException | IllegalAccessException e) {
                    EditorLogger.error(e.getMessage());
                }
            }
            boolean animationAction = id.equals("Animation");
            boolean controlAction = isControlAction(a);
            if (!enabled && !controlAction) {
                if (actor != null && !animationAction) {
                    SceneActorRef sa = new SceneActorRef(actor);
                    if (sa.getSceneId() != null)
                        id = MessageFormat.format("[GRAY]{0} {1}.{2}[]", sa.getSceneId(), sa.getActorId(), id);
                    else
                        id = MessageFormat.format("[GRAY]{0}.{1}[]", sa.getActorId(), id);
                } else if (animationAction) {
                    field = ActionUtils.getField(a.getClreplaced(), "animation");
                    String animation = null;
                    if (field != null) {
                        try {
                            field.setAccessible(true);
                            animation = field.get(a).toString();
                        } catch (IllegalArgumentException | IllegalAccessException e) {
                            EditorLogger.error(e.getMessage());
                        }
                    }
                    ActorAnimationRef aa = new ActorAnimationRef(animation);
                    if (aa.getActorId() != null)
                        id = MessageFormat.format("[GRAY]{0}.{1} {2}[]", aa.getActorId(), id, aa.getAnimationId());
                    else
                        id = MessageFormat.format("[GRAY]{0} {1}[]", id, aa.getAnimationId());
                } else {
                    id = MessageFormat.format("[GRAY]{0}[]", id);
                }
            } else if (actor != null && !animationAction && !controlAction) {
                SceneActorRef sa = new SceneActorRef(actor);
                if (sa.getSceneId() != null)
                    id = MessageFormat.format("[GREEN]{0}[] {1}.{2}", sa.getSceneId(), sa.getActorId(), id);
                else
                    id = MessageFormat.format("{0}.{1}", sa.getActorId(), id);
            } else if (animationAction) {
                field = ActionUtils.getField(a.getClreplaced(), "animation");
                String animation = null;
                if (field != null) {
                    try {
                        field.setAccessible(true);
                        animation = field.get(a).toString();
                    } catch (IllegalArgumentException | IllegalAccessException e) {
                        EditorLogger.error(e.getMessage());
                    }
                }
                ActorAnimationRef aa = new ActorAnimationRef(animation);
                if (aa.getActorId() != null)
                    id = MessageFormat.format("[GREEN]{0}.{1} {2}[]", aa.getActorId(), id, aa.getAnimationId());
                else
                    id = MessageFormat.format("[GREEN]{0} {1}[]", id, aa.getAnimationId());
            } else if (controlAction) {
                if (a instanceof EndAction) {
                    Action parentAction = findParentAction((EndAction) a);
                    if (parentAction instanceof AbstractIfAction && isElse((AbstractIfAction) parentAction, (EndAction) a)) {
                        id = "Else";
                    } else {
                        id = "End" + ActionUtils.getName(parentAction.getClreplaced());
                    }
                }
                if (actor != null) {
                    SceneActorRef sa = new SceneActorRef(actor);
                    if (sa.getSceneId() != null)
                        id = MessageFormat.format("[GREEN]{0}[] [BLUE]{1}.{2}[]", sa.getSceneId(), sa.getActorId(), id);
                    else
                        id = MessageFormat.format("[BLUE]{0}.{1}[BLUE]", sa.getActorId(), id);
                } else
                    id = MessageFormat.format("[BLUE]{0}[]", id);
            }
            if (ActionUtils.isDeprecated(a.getClreplaced()))
                id = "[RED]D[] " + id;
            return id;
        }

        private boolean isElse(AbstractIfAction parentAction, EndAction ea) {
            final String caID = ea.getControlActionID();
            ArrayList<Action> actions = parent.getActions();
            int idx = actions.indexOf(parentAction);
            for (int i = idx + 1; i < actions.size(); i++) {
                Action aa = actions.get(i);
                if (isControlAction(aa) && ((AbstractControlAction) aa).getControlActionID().equals(caID)) {
                    if (aa == ea)
                        return true;
                    return false;
                }
            }
            return false;
        }

        private Action findParentAction(EndAction a) {
            final String caID = a.getControlActionID();
            ArrayList<Action> actions = parent.getActions();
            for (Action a2 : actions) {
                if (isControlAction(a2) && ((AbstractControlAction) a2).getControlActionID().equals(caID)) {
                    return a2;
                }
            }
            return null;
        }

        @Override
        protected String getCellSubreplacedle(Action a) {
            if (a instanceof CommentAction)
                return "";
            if (a instanceof DisableActionAction)
                a = ((DisableActionAction) a).getAction();
            StringBuilder sb = new StringBuilder();
            String[] params = ActionUtils.getFieldNames(a);
            String actionName = ActionUtils.getName(a.getClreplaced());
            for (String p : params) {
                if (p.equals("actor") || (actionName != null && actionName.equals("Animation") && p.equals("animation")))
                    continue;
                if (p.equals("caID"))
                    continue;
                Field f = ActionUtils.getField(a.getClreplaced(), p);
                try {
                    final boolean accessible = f.isAccessible();
                    f.setAccessible(true);
                    Object o = f.get(a);
                    if (o == null)
                        continue;
                    String v = o.toString();
                    // Check world Scope for translations
                    if (scope.equals(ScopePanel.WORLD_SCOPE))
                        sb.append(p).append(": ").append(Ctx.project.getI18N().getWorldTranslation(v).replace("\n", "|")).append(' ');
                    else
                        sb.append(p).append(": ").append(Ctx.project.translate(v).replace("\n", "|")).append(' ');
                    f.setAccessible(accessible);
                } catch (IllegalArgumentException | IllegalAccessException e) {
                    EditorLogger.error(e.getMessage());
                }
            }
            return sb.toString();
        }

        @Override
        protected boolean hreplacedubreplacedle() {
            return true;
        }
    };
}

16 View Complete Implementation : ActionCallbackSerializer.java
Copyright Apache License 2.0
Author : bladecoder
private static String find(ActionCallback cb, Verb v) {
    String id = v.getHashKey();
    if (cb == v)
        return id;
    int pos = 0;
    for (Action a : v.getActions()) {
        if (cb == a) {
            StringBuilder stringBuilder = new StringBuilder(id);
            stringBuilder.append(SEPARATION_SYMBOL).append(pos);
            return stringBuilder.toString();
        }
        pos++;
    }
    return null;
}

16 View Complete Implementation : ActionCallbackSerializer.java
Copyright Apache License 2.0
Author : bladecoder
private static String find(ActionCallback cb, InkVerbRunner im) {
    if (im == null)
        return null;
    if (cb instanceof InkVerbRunner) {
        if (cb == im) {
            return INK_MANAGER_TAG;
        } else {
            EngineLogger.debug("CB pointing to an old InkVerbRunner. IGNORING.");
            return null;
        }
    }
    int pos = 0;
    for (Action a : im.getActions()) {
        if (cb == a) {
            StringBuilder stringBuilder = new StringBuilder(INK_MANAGER_TAG);
            stringBuilder.append(SEPARATION_SYMBOL).append(pos);
            return stringBuilder.toString();
        }
        pos++;
    }
    return null;
}

15 View Complete Implementation : I18NHandler.java
Copyright Apache License 2.0
Author : bladecoder
public void extractStrings(String sceneid, String actorid, String parent, int pos, Action a) {
    String[] names = ActionUtils.getFieldNames(a);
    for (String name : names) {
        if (name.toLowerCase().endsWith("text")) {
            try {
                String value = ActionUtils.getStringValue(a, name);
                if (value != null && !value.isEmpty() && value.charAt(0) != I18N.PREFIX) {
                    String key = genKey(sceneid, actorid, parent, pos, name);
                    ActionUtils.setParam(a, name, key);
                    if (sceneid == null)
                        setWorldTranslation(key, value);
                    else
                        setTranslation(key, value);
                }
            } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
                EditorLogger.error(e.getMessage());
            }
        }
    }
}

15 View Complete Implementation : I18NHandler.java
Copyright Apache License 2.0
Author : bladecoder
private void getUsedKeys(Verb v, ArrayList<String> usedKeys) {
    for (Action a : v.getActions()) {
        if (a instanceof DisableActionAction)
            a = ((DisableActionAction) a).getAction();
        String[] fieldNames = ActionUtils.getFieldNames(a);
        for (String name : fieldNames) {
            if (name.toLowerCase().endsWith("text")) {
                String value = null;
                try {
                    value = ActionUtils.getStringValue(a, name);
                } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
                    EditorLogger.error(e.getMessage());
                }
                if (value != null && !value.isEmpty() && value.charAt(0) == I18N.PREFIX) {
                    usedKeys.add(value.substring(1));
                }
            }
        }
    }
}

15 View Complete Implementation : ActionList.java
Copyright Apache License 2.0
Author : bladecoder
@Override
protected void delete() {
    if (list.getSelection().size() == 0)
        return;
    multiClipboard.clear();
    int pos = list.getSelectedIndex();
    for (Action e : getSortedSelection()) {
        if (e instanceof EndAction)
            continue;
        int pos2 = list.gereplacedems().indexOf(e, true);
        list.gereplacedems().removeValue(e, true);
        int idx = parent.getActions().indexOf(e);
        parent.getActions().remove(e);
        multiClipboard.add(e);
        // TRANSLATIONS
        if (scope.equals(ScopePanel.WORLD_SCOPE))
            Ctx.project.getI18N().putTranslationsInElement(e, true);
        else
            Ctx.project.getI18N().putTranslationsInElement(e, false);
        // UNDO
        Ctx.project.getUndoStack().add(new UndoDeleteAction(parent, e, idx));
        if (isControlAction(e))
            deleteControlAction(pos2, (AbstractControlAction) e);
    }
    if (list.gereplacedems().size == 0) {
        list.getSelection().clear();
    } else if (pos >= list.gereplacedems().size) {
        list.getSelection().choose(list.gereplacedems().get(list.gereplacedems().size - 1));
    } else {
        list.getSelection().choose(list.gereplacedems().get(pos));
    }
    toolbar.disablePaste(false);
    Ctx.project.setModified();
}

15 View Complete Implementation : ActionList.java
Copyright Apache License 2.0
Author : bladecoder
@Override
protected void edit() {
    Action e = list.getSelected();
    if (e == null || e instanceof EndAction || e instanceof DisableActionAction)
        return;
    editedElement = (Action) ElementUtils.cloneElement(e);
    EditModelDialog<Verb, Action> dialog = getEditElementDialogInstance(e);
    dialog.show(getStage());
    dialog.setListener(new ChangeListener() {

        @SuppressWarnings("unchecked")
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            Action e = ((EditModelDialog<Verb, Action>) actor).getElement();
            int pos = list.getSelectedIndex();
            list.gereplacedems().set(pos, e);
            parent.getActions().set(pos, e);
            Ctx.project.setModified();
            if (isControlAction(editedElement)) {
                if (!editedElement.getClreplaced().getName().equals(e.getClreplaced().getName())) {
                    deleteControlAction(pos, (AbstractControlAction) editedElement);
                    if (isControlAction(e)) {
                        insertEndAction(pos + 1, getOrCreateControlActionId((AbstractControlAction) e));
                        if (e instanceof AbstractIfAction)
                            insertEndAction(pos + 2, getOrCreateControlActionId((AbstractControlAction) e));
                    }
                } else {
                    // insert previous caId
                    try {
                        ActionUtils.setParam(e, CONTROL_ACTION_ID_ATTR, getOrCreateControlActionId((AbstractControlAction) editedElement));
                    } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e1) {
                        EditorLogger.error(e1.getMessage());
                    }
                }
            }
        }
    });
}

15 View Complete Implementation : ActionList.java
Copyright Apache License 2.0
Author : bladecoder
private void toggleEnabled() {
    if (list.getSelection().size() <= 0)
        return;
    Array<Action> sel = new Array<Action>();
    for (Action a : list.getSelection().toArray()) {
        // CONTROL ACTIONS CAN'T BE DISABLED
        if (a == null || isControlAction(a))
            continue;
        Array<Action> items = list.gereplacedems();
        int pos = items.indexOf(a, true);
        if (a instanceof DisableActionAction) {
            Action a2 = ((DisableActionAction) a).getAction();
            parent.getActions().set(pos, a2);
            items.set(pos, a2);
            sel.add(a2);
        } else {
            DisableActionAction a2 = new DisableActionAction();
            a2.setAction(a);
            parent.getActions().set(pos, a2);
            items.set(pos, a2);
            sel.add(a2);
        }
    }
    Ctx.project.setModified();
    list.getSelection().clear();
    list.getSelection().addAll(sel);
}

15 View Complete Implementation : ActionList.java
Copyright Apache License 2.0
Author : bladecoder
@Override
protected void copy() {
    if (parent == null || list.getSelection().size() == 0)
        return;
    multiClipboard.clear();
    for (Action e : getSortedSelection()) {
        if (e == null || e instanceof EndAction)
            return;
        Action cloned = (Action) ElementUtils.cloneElement(e);
        multiClipboard.add(cloned);
        toolbar.disablePaste(false);
        // TRANSLATIONS
        if (scope.equals(ScopePanel.WORLD_SCOPE))
            Ctx.project.getI18N().putTranslationsInElement(cloned, true);
        else
            Ctx.project.getI18N().putTranslationsInElement(cloned, false);
    }
}

15 View Complete Implementation : EditActionDialog.java
Copyright Apache License 2.0
Author : bladecoder
private void setAction() {
    String id = actionPanel.getText();
    getCenterPanel().clear();
    addInputPanel(actionPanel);
    Action tmp = null;
    tmp = ActionDetector.create(id, null);
    String info = ActionUtils.getInfo(tmp.getClreplaced());
    if (ActionUtils.isDeprecated(tmp.getClreplaced()))
        info = "[RED]DEPRECATED[]\n" + info;
    setInfo(info);
    if (e == null || tmp == null || !(e.getClreplaced().getName().equals(tmp.getClreplaced().getName())))
        e = tmp;
    if (e != null) {
        Param[] params = ActionUtils.getParams(e);
        i = new InputPanel[params.length];
        for (int j = 0; j < params.length; j++) {
            if (params[j].options instanceof Enum[]) {
                i[j] = InputPanelFactory.createInputPanel(getSkin(), params[j].name, params[j].desc, params[j].type, params[j].mandatory, params[j].defaultValue, (Enum[]) params[j].options);
            } else {
                i[j] = InputPanelFactory.createInputPanel(getSkin(), params[j].name, params[j].desc, params[j].type, params[j].mandatory, params[j].defaultValue, (String[]) params[j].options);
            }
            addInputPanel(i[j]);
            if ((i[j].getField() instanceof TextField && params[j].name.toLowerCase().endsWith("text")) || i[j].getField() instanceof ScrollPane) {
                i[j].getCell(i[j].getField()).fillX();
            }
        }
    } else {
        i = new InputPanel[0];
    }
}

15 View Complete Implementation : InkManager.java
Copyright Apache License 2.0
Author : bladecoder
private void processTextLine(HashMap<String, String> params, String line) {
    // Get actor name from Line. Actor is separated by ':'.
    // ej. "Johnny: Hello punks!"
    if (!params.containsKey("actor")) {
        int idx = line.indexOf(COMMAND_MARK);
        if (idx != -1) {
            params.put("actor", line.substring(0, idx).trim());
            line = line.substring(idx + 1).trim();
        }
    }
    if (!params.containsKey("actor") && w.getCurrentScene().getPlayer() != null) {
        // params.put("actor", Scene.VAR_PLAYER);
        if (!params.containsKey("type")) {
            params.put("type", Type.SUBreplacedLE.toString());
        }
    } else if (params.containsKey("actor") && !params.containsKey("type")) {
        params.put("type", Type.TALK.toString());
    } else if (!params.containsKey("type")) {
        params.put("type", Type.SUBreplacedLE.toString());
    }
    params.put("text", translateLine(line));
    try {
        Action action = null;
        if (!params.containsKey("actor")) {
            action = ActionFactory.create("Text", params);
        } else {
            action = ActionFactory.create("Say", params);
        }
        action.init(w);
        inkVerbRunner.getActions().add(action);
    } catch (ClreplacedNotFoundException | ReflectionException e) {
        EngineLogger.error(e.getMessage(), e);
    }
}

15 View Complete Implementation : Verb.java
Copyright Apache License 2.0
Author : bladecoder
@Override
public void cancel() {
    ip = actions.size() + 1;
    for (Action c : actions) {
        if (c instanceof VerbRunner)
            ((VerbRunner) c).cancel();
    }
    if (cb != null) {
        ActionCallback cb2 = cb;
        cb = null;
        cb2.resume();
    }
    EngineLogger.debug(">>> Verb CANCELLED: " + id);
}

15 View Complete Implementation : ActionUtils.java
Copyright Apache License 2.0
Author : bladecoder
public static String getStringValue(Action a, String param) throws NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
    String result = null;
    Clreplaced<?> clazz = a.getClreplaced();
    Field field = getField(clazz, param);
    if (field == null)
        throw new NoSuchFieldException(param);
    final boolean accessible = field.isAccessible();
    field.setAccessible(true);
    if (field.getType().isreplacedignableFrom(String.clreplaced)) {
        result = (String) field.get(a);
    } else if (field.getType().isreplacedignableFrom(boolean.clreplaced)) {
        result = Boolean.toString(field.getBoolean(a));
    } else if (field.getType().isreplacedignableFrom(Boolean.clreplaced)) {
        Object o = field.get(a);
        if (o != null)
            result = o.toString();
    } else if (field.getType().isreplacedignableFrom(float.clreplaced)) {
        result = Float.toString(field.getFloat(a));
    } else if (field.getType().isreplacedignableFrom(Float.clreplaced)) {
        Object o = field.get(a);
        if (o != null)
            result = o.toString();
    } else if (field.getType().isreplacedignableFrom(int.clreplaced)) {
        result = Integer.toString(field.getInt(a));
    } else if (field.getType().isreplacedignableFrom(Vector2.clreplaced)) {
        result = Param.toStringParam((Vector2) field.get(a));
    } else if (field.getType().isreplacedignableFrom(SceneActorRef.clreplaced)) {
        Object o = field.get(a);
        if (o != null)
            result = o.toString();
    } else if (field.getType().isreplacedignableFrom(ActorAnimationRef.clreplaced)) {
        Object o = field.get(a);
        if (o != null)
            result = o.toString();
    } else if (field.getType().isreplacedignableFrom(Color.clreplaced)) {
        Object o = field.get(a);
        if (o != null)
            result = o.toString();
    } else if (field.getType().isEnum()) {
        Object o = field.get(a);
        if (o != null)
            result = ((Enum<?>) o).name();
    } else {
        EngineLogger.error("ACTION FIELD TYPE NOT SUPPORTED -  type: " + field.getType());
    }
    field.setAccessible(accessible);
    return result;
}

14 View Complete Implementation : I18NHandler.java
Copyright Apache License 2.0
Author : bladecoder
public void extractStrings(String sceneid, String actorid, Verb v) {
    ArrayList<Action> actions = v.getActions();
    for (int i = 0; i < actions.size(); i++) {
        Action a = actions.get(i);
        extractStrings(sceneid, actorid, v.getHashKey(), i, a);
    }
}

14 View Complete Implementation : ActionList.java
Copyright Apache License 2.0
Author : bladecoder
private void down() {
    if (parent == null || list.getSelection().size() == 0)
        return;
    Array<Action> sel = new Array<Action>();
    Array<Action> sortedSelection = getSortedSelection();
    for (int i = sortedSelection.size - 1; i >= 0; i--) {
        int pos = list.gereplacedems().indexOf(sortedSelection.get(i), true);
        Array<Action> items = list.gereplacedems();
        if (pos == -1 || pos == items.size - 1)
            return;
        Action e = items.get(pos);
        Action e2 = items.get(pos + 1);
        sel.add(e);
        if (isControlAction(e) && isControlAction(e2)) {
            continue;
        }
        parent.getActions().set(pos + 1, e);
        parent.getActions().set(pos, e2);
        items.set(pos + 1, e);
        items.set(pos, e2);
    }
    list.getSelection().clear();
    list.getSelection().addAll(sel);
    upBtn.setDisabled(list.getSelectedIndex() == 0);
    downBtn.setDisabled(list.getSelectedIndex() == list.gereplacedems().size - 1);
    Ctx.project.setModified();
}

14 View Complete Implementation : ActionList.java
Copyright Apache License 2.0
Author : bladecoder
private void up() {
    if (parent == null || list.getSelection().size() == 0)
        return;
    Array<Action> sel = new Array<Action>();
    for (Action a : getSortedSelection()) {
        int pos = list.gereplacedems().indexOf(a, true);
        if (pos == -1 || pos == 0)
            return;
        Array<Action> items = list.gereplacedems();
        Action e = items.get(pos);
        Action e2 = items.get(pos - 1);
        sel.add(e);
        if (isControlAction(e) && isControlAction(e2)) {
            continue;
        }
        parent.getActions().set(pos - 1, e);
        parent.getActions().set(pos, e2);
        items.set(pos - 1, e);
        items.set(pos, e2);
    }
    list.getSelection().clear();
    list.getSelection().addAll(sel);
    upBtn.setDisabled(list.getSelectedIndex() == 0);
    downBtn.setDisabled(list.getSelectedIndex() == list.gereplacedems().size - 1);
    Ctx.project.setModified();
}

14 View Complete Implementation : InkManager.java
Copyright Apache License 2.0
Author : bladecoder
private void processCommand(HashMap<String, String> params, String line) {
    String commandName = null;
    String[] commandParams = null;
    int i = line.indexOf(NAME_VALUE_TAG_SEPARATOR);
    if (i == -1) {
        commandName = line.substring(1).trim();
    } else {
        commandName = line.substring(1, i).trim();
        commandParams = line.substring(i + 1).split(PARAM_SEPARATOR);
        processParams(Arrays.asList(commandParams), params);
    }
    if ("LeaveNow".equals(commandName)) {
        boolean init = true;
        String initVerb = null;
        if (params.get("init") != null)
            init = Boolean.parseBoolean(params.get("init"));
        if (params.get("initVerb") != null)
            initVerb = params.get("initVerb");
        w.setCurrentScene(params.get("scene"), init, initVerb);
    } else {
        // Some preliminar validation to see if it's an action
        if (commandName.length() > 0) {
            // Try to create action by default
            Action action;
            try {
                Clreplaced<?> c = ActionFactory.getClreplacedTags().get(commandName);
                if (c == null && commandName.indexOf('.') == -1) {
                    commandName = "com.bladecoder.engine.actions." + commandName + "Action";
                }
                action = ActionFactory.create(commandName, params);
                action.init(w);
                inkVerbRunner.getActions().add(action);
            } catch (ClreplacedNotFoundException | ReflectionException e) {
                EngineLogger.error(e.getMessage(), e);
            }
        } else {
            EngineLogger.error("Ink command not found: " + commandName);
        }
    }
}

13 View Complete Implementation : ActionCallbackSerializer.java
Copyright Apache License 2.0
Author : bladecoder
/**
 * Searches for the ActionCallback represented by the id string.
 *
 * @param id
 */
public static ActionCallback find(World w, Scene s, String id) {
    if (id == null)
        return null;
    String[] split = id.split(SEPARATION_SYMBOL);
    if (id.startsWith(INK_MANAGER_TAG)) {
        if (split.length == 1)
            return w.getInkManager().getVerbRunner();
        int actionPos = Integer.parseInt(split[1]);
        Action action = w.getInkManager().getVerbRunner().getActions().get(actionPos);
        if (action instanceof ActionCallback)
            return (ActionCallback) action;
    }
    if (split.length < 2)
        return null;
    String actorId;
    String verbId;
    int actionPos = -1;
    if (id.startsWith(UIACTORS_TAG) || id.startsWith(INVENTORY_TAG)) {
        actorId = split[1];
        verbId = split[2];
        if (split.length > 3)
            actionPos = Integer.parseInt(split[3]);
    } else {
        actorId = split[0];
        verbId = split[1];
        if (split.length > 2)
            actionPos = Integer.parseInt(split[2]);
    }
    Verb v = null;
    if (actorId.equals(DEFAULT_VERB_TAG)) {
        v = w.getVerbManager().getVerb(verbId, null, null);
    } else {
        InteractiveActor a;
        if (actorId.equals(s.getId())) {
            v = s.getVerbManager().getVerbs().get(verbId);
        } else {
            a = (InteractiveActor) s.getActor(actorId, true);
            if (a == null) {
                EngineLogger.error("ActionCallbackSerialization - Actor not found: " + actorId + " cb: " + id);
                return null;
            }
            v = a.getVerbManager().getVerbs().get(verbId);
        }
    }
    if (v == null) {
        EngineLogger.error("ActionCallbackSerialization - Verb not found: " + verbId + " cb: " + id);
        return null;
    }
    if (actionPos == -1)
        return v;
    Action action = v.getActions().get(actionPos);
    if (action instanceof ActionCallback)
        return (ActionCallback) action;
    EngineLogger.error("ActionCallbackSerialization - CB not found: " + id);
    return null;
}

12 View Complete Implementation : Verb.java
Copyright Apache License 2.0
Author : bladecoder
public void nextStep() {
    boolean stop = false;
    while (!isFinished() && !stop) {
        Action a = actions.get(ip);
        if (EngineLogger.debugMode())
            EngineLogger.debug(ip + ". " + a.getClreplaced().getSimpleName());
        try {
            if (a.run(this))
                stop = true;
            else
                ip++;
        } catch (Exception e) {
            EngineLogger.error("EXCEPTION EXECUTING ACTION: " + a.getClreplaced().getSimpleName() + " - " + e.getMessage(), e);
            ip++;
        }
    }
    if (ip == actions.size()) {
        EngineLogger.debug(">>> Verb FINISHED: " + id);
        if (cb != null) {
            ActionCallback cb2 = cb;
            cb = null;
            cb2.resume();
        }
    }
}

11 View Complete Implementation : ActionList.java
Copyright Apache License 2.0
Author : bladecoder
@Override
protected void paste() {
    if (parent == null || multiClipboard.size() == 0)
        return;
    Array<Action> sel = new Array<Action>();
    for (int i = multiClipboard.size() - 1; i >= 0; i--) {
        Action newElement = (Action) ElementUtils.cloneElement(multiClipboard.get(i));
        int pos = list.getSelectedIndex() + 1;
        list.gereplacedems().insert(pos, newElement);
        parent.getActions().add(pos, newElement);
        if (scope.equals(ScopePanel.WORLD_SCOPE))
            Ctx.project.getI18N().extractStrings(null, null, parent.getHashKey(), pos, newElement);
        else if (scope.equals(ScopePanel.SCENE_SCOPE))
            Ctx.project.getI18N().extractStrings(Ctx.project.getSelectedScene().getId(), null, parent.getHashKey(), pos, newElement);
        else
            Ctx.project.getI18N().extractStrings(Ctx.project.getSelectedScene().getId(), Ctx.project.getSelectedActor().getId(), parent.getHashKey(), pos, newElement);
        list.invalidateHierarchy();
        if (isControlAction(newElement)) {
            try {
                ActionUtils.setParam(newElement, CONTROL_ACTION_ID_ATTR, null);
            } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
                EditorLogger.error(e.getMessage());
            }
            insertEndAction(pos + 1, getOrCreateControlActionId((AbstractControlAction) newElement));
            if (newElement instanceof AbstractIfAction)
                insertEndAction(pos + 2, getOrCreateControlActionId((AbstractControlAction) newElement));
        }
        sel.add(newElement);
    }
    list.getSelection().clear();
    list.getSelection().addAll(sel);
    Ctx.project.setModified();
}

11 View Complete Implementation : ActionUtils.java
Copyright Apache License 2.0
Author : bladecoder
public static String[] getFieldNames(Action a) {
    List<String> result = new ArrayList<>();
    Clreplaced<?> clazz = a.getClreplaced();
    while (clazz != null && clazz != Object.clreplaced) {
        for (Field field : clazz.getDeclaredFields()) {
            final ActionProperty property = field.getAnnotation(ActionProperty.clreplaced);
            if (property == null) {
                continue;
            }
            final String name = field.getName();
            result.add(name);
        }
        clazz = clazz.getSuperclreplaced();
    }
    return result.toArray(new String[result.size()]);
}

9 View Complete Implementation : InkManager.java
Copyright Apache License 2.0
Author : bladecoder
@Override
public void read(Json json, JsonValue jsonData) {
    BladeJson bjson = (BladeJson) json;
    World w = bjson.getWorld();
    final String name = json.readValue("storyName", String.clreplaced, jsonData);
    if (bjson.getMode() == Mode.MODEL) {
        story = null;
        storyName = name;
        // Only load in new game.
        // If the SAVED_GAME_VERSION property exists we are loading a saved
        // game and we will load the story in the STATE mode.
        if (bjson.getInit()) {
            loadThreaded(name, null);
        }
    } else {
        wasInCutmode = json.readValue("wasInCutmode", Boolean.clreplaced, jsonData);
        sCb = json.readValue("cb", String.clreplaced, jsonData);
        // READ ACTIONS
        JsonValue actionsValue = jsonData.get("actions");
        inkVerbRunner = new InkVerbRunner();
        for (int i = 0; i < actionsValue.size; i++) {
            JsonValue aValue = actionsValue.get(i);
            Action a = ActionUtils.readJson(w, json, aValue);
            inkVerbRunner.getActions().add(a);
        }
        inkVerbRunner.setIP(json.readValue("ip", Integer.clreplaced, jsonData));
        actionsValue = jsonData.get("actionsSer");
        int i = 0;
        for (Action a : inkVerbRunner.getActions()) {
            if (a instanceof Serializable && i < actionsValue.size) {
                if (actionsValue.get(i) == null)
                    break;
                ((Serializable) a).read(json, actionsValue.get(i));
                i++;
            }
        }
        // READ STORY
        final String storyString = json.readValue("story", String.clreplaced, jsonData);
        if (storyString != null) {
            loadThreaded(name, storyString);
        }
    }
}

9 View Complete Implementation : Verb.java
Copyright Apache License 2.0
Author : bladecoder
@Override
public void write(Json json) {
    BladeJson bjson = (BladeJson) json;
    if (bjson.getMode() == Mode.MODEL) {
        json.writeValue("id", id);
        if (target != null)
            json.writeValue("target", target);
        if (state != null)
            json.writeValue("state", state);
        if (icon != null)
            json.writeValue("icon", icon);
        json.writeArrayStart("actions");
        for (Action a : actions) {
            ActionUtils.writeJson(a, json);
        }
        json.writeArrayEnd();
    } else {
        json.writeValue("ip", ip);
        if (cb != null)
            json.writeValue("cb", ActionCallbackSerializer.find(bjson.getWorld(), bjson.getScene(), cb));
        if (currentTarget != null)
            json.writeValue("currentTarget", currentTarget);
        json.writeArrayStart("actions");
        for (Action a : actions) {
            if (a instanceof Serializable) {
                json.writeObjectStart();
                ((Serializable) a).write(json);
                json.writeObjectEnd();
            }
        }
        json.writeArrayEnd();
    }
}

9 View Complete Implementation : ActionUtils.java
Copyright Apache License 2.0
Author : bladecoder
public static Param[] getParams(Action action) {
    List<Param> params = new ArrayList<>();
    Clreplaced<?> clazz = action.getClreplaced();
    while (clazz != null && clazz != Object.clreplaced) {
        for (Field field : clazz.getDeclaredFields()) {
            final ActionProperty property = field.getAnnotation(ActionProperty.clreplaced);
            if (property == null) {
                continue;
            }
            final ActionPropertyDescription propertyDescription = field.getAnnotation(ActionPropertyDescription.clreplaced);
            // properties without description are not editables but will be
            // saved in the model.
            if (propertyDescription == null)
                continue;
            final String name = field.getName();
            Param.Type type = property.type();
            Enum<?>[] options = null;
            if (field.getType().isEnum()) {
                final boolean accessible = field.isAccessible();
                field.setAccessible(true);
                options = (Enum[]) field.getType().getEnumConstants();
                field.setAccessible(accessible);
                type = Param.Type.OPTION;
            } else if (property.type() == Param.Type.NOT_SET) {
                type = getType(field);
            }
            params.add(new Param(name, propertyDescription != null ? propertyDescription.value() : "", type, property.required(), property.defaultValue(), options));
        }
        clazz = clazz.getSuperclreplaced();
    }
    return params.toArray(new Param[params.size()]);
}

9 View Complete Implementation : ActionUtils.java
Copyright Apache License 2.0
Author : bladecoder
public static Action readJson(World w, Json json, JsonValue jsonData) {
    String clreplacedName = jsonData.getString("clreplaced", null);
    Action action = null;
    if (clreplacedName != null) {
        jsonData.remove("clreplaced");
        try {
            action = ActionFactory.create(clreplacedName, null);
        } catch (ClreplacedNotFoundException | ReflectionException e1) {
            throw new SerializationException(e1);
        }
        for (int j = 0; j < jsonData.size; j++) {
            JsonValue v = jsonData.get(j);
            try {
                if (v.isNull())
                    ActionUtils.setParam(action, v.name, null);
                else
                    ActionUtils.setParam(action, v.name, v.replacedtring());
            } catch (NoSuchFieldException e) {
                EngineLogger.error("Action field not found - clreplaced: " + clreplacedName + " field: " + v.name);
            } catch (IllegalArgumentException | IllegalAccessException e) {
                EngineLogger.error("Action field error - clreplaced: " + clreplacedName + " field: " + v.name + " value: " + (v == null ? "null" : v.replacedtring()));
            }
        }
        action.init(w);
    }
    return action;
}

8 View Complete Implementation : CheckCutmodeEnd.java
Copyright Apache License 2.0
Author : bladecoder
@Override
public void visit(Scene s, InteractiveActor a, Verb v) {
    ArrayList<Action> actions = v.getActions();
    if (actions.size() > 0) {
        Action action = actions.get(actions.size() - 1);
        if (action instanceof SetCutmodeAction) {
            try {
                String val = ActionUtils.getStringValue(action, "value");
                if ("true".equals(val)) {
                    StringBuilder sb = new StringBuilder("CheckCutmodeEnd: Cutmode ends with value=true! - ");
                    if (s != null) {
                        sb.append(s.getId());
                        sb.append(".");
                    }
                    if (a != null) {
                        sb.append(a.getId());
                        sb.append(".");
                    }
                    sb.append(v.getId());
                    EditorLogger.error(sb.toString());
                }
            } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
            }
        }
    }
}

8 View Complete Implementation : Verb.java
Copyright Apache License 2.0
Author : bladecoder
@Override
public void read(Json json, JsonValue jsonData) {
    BladeJson bjson = (BladeJson) json;
    if (bjson.getMode() == Mode.MODEL) {
        id = json.readValue("id", String.clreplaced, jsonData);
        target = json.readValue("target", String.clreplaced, (String) null, jsonData);
        state = json.readValue("state", String.clreplaced, (String) null, jsonData);
        icon = json.readValue("icon", String.clreplaced, (String) null, jsonData);
        actions.clear();
        JsonValue actionsValue = jsonData.get("actions");
        for (int i = 0; i < actionsValue.size; i++) {
            JsonValue aValue = actionsValue.get(i);
            String clazz = aValue.getString("clreplaced");
            try {
                Action a = ActionUtils.readJson(bjson.getWorld(), json, aValue);
                actions.add(a);
            } catch (SerializationException e) {
                EngineLogger.error("Error loading action: " + clazz + " " + aValue.toString());
                throw e;
            }
        }
    } else {
        // MUTABLE
        currentTarget = json.readValue("currentTarget", String.clreplaced, (String) null, jsonData);
        ip = json.readValue("ip", Integer.clreplaced, jsonData);
        cb = ActionCallbackSerializer.find(bjson.getWorld(), bjson.getScene(), json.readValue("cb", String.clreplaced, jsonData));
        JsonValue actionsValue = jsonData.get("actions");
        int i = 0;
        for (Action a : actions) {
            if (a instanceof Serializable && i < actionsValue.size) {
                if (actionsValue.get(i) == null)
                    break;
                ((Serializable) a).read(json, actionsValue.get(i));
                i++;
            }
        }
    }
}

8 View Complete Implementation : ActionUtils.java
Copyright Apache License 2.0
Author : bladecoder
@SuppressWarnings("unchecked")
public static void setParam(Action action, String param, String value) throws NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
    Clreplaced<?> clazz = action.getClreplaced();
    Field field = getField(clazz, param);
    if (field == null)
        throw new NoSuchFieldException(param);
    final boolean accessible = field.isAccessible();
    field.setAccessible(true);
    if (field.getType().isreplacedignableFrom(String.clreplaced)) {
        field.set(action, value);
    } else if (field.getType().isreplacedignableFrom(boolean.clreplaced)) {
        field.setBoolean(action, Boolean.parseBoolean(value));
    } else if (field.getType().isreplacedignableFrom(Boolean.clreplaced)) {
        Boolean b = null;
        if (value != null)
            b = Boolean.valueOf(value);
        field.set(action, b);
    } else if (field.getType().isreplacedignableFrom(float.clreplaced)) {
        try {
            field.setFloat(action, Float.parseFloat(value));
        } catch (NumberFormatException ignored) {
        }
    } else if (field.getType().isreplacedignableFrom(Float.clreplaced)) {
        try {
            Float f = null;
            if (value != null)
                f = Float.valueOf(value);
            field.set(action, f);
        } catch (NumberFormatException ignored) {
        }
    } else if (field.getType().isreplacedignableFrom(int.clreplaced)) {
        try {
            Integer i = null;
            if (value != null) {
                i = Integer.parseInt(value);
                field.setInt(action, i);
            }
        } catch (NumberFormatException ignored) {
        }
    } else if (field.getType().isreplacedignableFrom(Integer.clreplaced)) {
        try {
            Float f = null;
            if (value != null)
                f = Float.valueOf(value);
            field.set(action, f);
        } catch (NumberFormatException ignored) {
        }
    } else if (field.getType().isreplacedignableFrom(Vector2.clreplaced)) {
        field.set(action, Param.parseVector2(value));
    } else if (field.getType().isreplacedignableFrom(SceneActorRef.clreplaced)) {
        if (value == null)
            field.set(action, null);
        else
            field.set(action, new SceneActorRef(value));
    } else if (field.getType().isreplacedignableFrom(ActorAnimationRef.clreplaced)) {
        if (value == null)
            field.set(action, null);
        else
            field.set(action, new ActorAnimationRef(value));
    } else if (field.getType().isreplacedignableFrom(Color.clreplaced)) {
        Color a = Param.parseColor(value);
        field.set(action, a);
    } else if (field.getType().isEnum()) {
        field.set(action, Enum.valueOf(field.getType().replacedubclreplaced(Enum.clreplaced), value.toUpperCase(Locale.ENGLISH)));
    } else {
        EngineLogger.error("ACTION FIELD TYPE NOT SUPPORTED -  type: " + field.getType());
    }
    field.setAccessible(accessible);
}

5 View Complete Implementation : WorldSerialization.java
Copyright Apache License 2.0
Author : bladecoder
private void cacheSounds() {
    for (Scene s : w.getScenes().values()) {
        HashMap<String, Verb> verbs = s.getVerbManager().getVerbs();
        // Search SoundAction and PlaySoundAction
        for (Verb v : verbs.values()) {
            ArrayList<Action> actions = v.getActions();
            for (int i = 0; i < actions.size(); i++) {
                Action act = actions.get(i);
                try {
                    if (act instanceof SoundAction) {
                        String actor = ActionUtils.getStringValue(act, "actor");
                        String play = ActionUtils.getStringValue(act, "play");
                        if (play != null) {
                            SoundDesc sd = w.getSounds().get(actor + "_" + play);
                            if (sd != null)
                                s.getSoundManager().addSoundToLoad(sd);
                            HashMap<String, String> params = new HashMap<>();
                            params.put("sound", sd.getId());
                            try {
                                Action a2 = ActionFactory.create(PlaySoundAction.clreplaced.getName(), params);
                                actions.set(i, a2);
                                a2.init(w);
                            } catch (ClreplacedNotFoundException | ReflectionException e) {
                                e.printStackTrace();
                            }
                            EngineLogger.debug("Converting SoundAction:" + s.getId() + "." + v.getId());
                        } else {
                            EngineLogger.debug("WARNING: Cannot convert SoundAction:" + s.getId() + "." + v.getId());
                        }
                    } else if (act instanceof PlaySoundAction) {
                        String sound = ActionUtils.getStringValue(act, "sound");
                        SoundDesc sd = w.getSounds().get(sound);
                        if (sd != null && sd.isPreload())
                            s.getSoundManager().addSoundToLoad(sd);
                    }
                } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
                }
            }
        }
        for (BaseActor a : s.getActors().values()) {
            if (a instanceof InteractiveActor) {
                HashMap<String, Verb> actorVerbs = ((InteractiveActor) a).getVerbManager().getVerbs();
                for (Verb v : actorVerbs.values()) {
                    ArrayList<Action> actions = v.getActions();
                    for (int i = 0; i < actions.size(); i++) {
                        Action act = actions.get(i);
                        try {
                            if (act instanceof SoundAction) {
                                String actor = ActionUtils.getStringValue(act, "actor");
                                String play = ActionUtils.getStringValue(act, "play");
                                if (play != null) {
                                    SoundDesc sd = w.getSounds().get(actor + "_" + play);
                                    if (sd != null)
                                        s.getSoundManager().addSoundToLoad(sd);
                                    HashMap<String, String> params = new HashMap<>();
                                    params.put("sound", sd.getId());
                                    try {
                                        Action a2 = ActionFactory.create(PlaySoundAction.clreplaced.getName(), params);
                                        actions.set(i, a2);
                                        a2.init(w);
                                    } catch (ClreplacedNotFoundException | ReflectionException e) {
                                        e.printStackTrace();
                                    }
                                    EngineLogger.debug("Converting SoundAction in:" + s.getId() + "." + a.getId() + "." + v.getId());
                                } else {
                                    EngineLogger.debug("WARNING: Cannot convert SoundAction:" + s.getId() + "." + a.getId() + "." + v.getId());
                                }
                            } else if (act instanceof PlaySoundAction) {
                                String sound = ActionUtils.getStringValue(act, "sound");
                                SoundDesc sd = w.getSounds().get(sound);
                                if (sd != null && sd.isPreload())
                                    s.getSoundManager().addSoundToLoad(sd);
                            }
                        } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
                        }
                    }
                }
            }
            if (a instanceof SpriteActor && ((SpriteActor) a).getRenderer() instanceof AnimationRenderer) {
                HashMap<String, AnimationDesc> anims = ((AnimationRenderer) ((SpriteActor) a).getRenderer()).getAnimations();
                for (AnimationDesc ad : anims.values()) {
                    if (ad.sound != null) {
                        String sid = ad.sound;
                        SoundDesc sd = w.getSounds().get(sid);
                        if (sd == null)
                            sid = a.getId() + "_" + sid;
                        sd = w.getSounds().get(sid);
                        if (sd != null) {
                            if (sd.isPreload())
                                s.getSoundManager().addSoundToLoad(sd);
                        } else
                            EngineLogger.error(a.getId() + ": SOUND not found: " + ad.sound + " in animation: " + ad.id);
                    }
                }
            }
        }
    }
}

4 View Complete Implementation : ModelTools.java
Copyright Apache License 2.0
Author : bladecoder
public static final void fixSaySubreplacedleActor() {
    Map<String, Scene> scenes = Ctx.project.getWorld().getScenes();
    for (Scene scn : scenes.values()) {
        Map<String, BaseActor> actors = scn.getActors();
        HashMap<String, Verb> verbs = scn.getVerbManager().getVerbs();
        for (Verb v : verbs.values()) {
            ArrayList<Action> actions = v.getActions();
            for (Action act : actions) {
                if (act instanceof SayAction) {
                    try {
                        String stringValue = ActionUtils.getStringValue(act, "type");
                        if (stringValue.equals("SUBreplacedLE"))
                            ActionUtils.setParam(act, "actor", "$PLAYER");
                    } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
                        EditorLogger.printStackTrace(e);
                        return;
                    }
                }
            }
        }
        for (BaseActor a : actors.values()) {
            if (a instanceof InteractiveActor) {
                InteractiveActor ia = (InteractiveActor) a;
                verbs = ia.getVerbManager().getVerbs();
                for (Verb v : verbs.values()) {
                    ArrayList<Action> actions = v.getActions();
                    for (Action act : actions) {
                        if (act instanceof SayAction) {
                            try {
                                String stringValue = ActionUtils.getStringValue(act, "type");
                                if (stringValue.equals("SUBreplacedLE"))
                                    ActionUtils.setParam(act, "actor", "$PLAYER");
                            } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
                                EditorLogger.printStackTrace(e);
                                return;
                            }
                        }
                    }
                }
            }
        }
    }
    Ctx.project.setModified();
}

4 View Complete Implementation : ModelWalker.java
Copyright Apache License 2.0
Author : bladecoder
public void walk(World w) {
    Map<String, Scene> scenes = Ctx.project.getWorld().getScenes();
    for (StartVisitor sv : startVisitors) sv.start(w);
    for (Scene scn : scenes.values()) {
        for (SceneVisitor sv : sceneVisitors) sv.visit(scn);
        Map<String, BaseActor> actors = scn.getActors();
        // SCENE VERBS
        HashMap<String, Verb> verbs = scn.getVerbManager().getVerbs();
        for (Verb v : verbs.values()) {
            for (VerbVisitor vv : verbVisitors) vv.visit(scn, null, v);
            ArrayList<Action> actions = v.getActions();
            for (Action act : actions) {
                for (ActionVisitor av : actionVisitors) av.visit(scn, null, v, act);
            }
        }
        for (BaseActor a : actors.values()) {
            for (ActorVisitor av : actorVisitors) av.visit(a);
            if (a instanceof InteractiveActor) {
                InteractiveActor ia = (InteractiveActor) a;
                // ACTOR VERBS
                verbs = ia.getVerbManager().getVerbs();
                for (Verb v : verbs.values()) {
                    for (VerbVisitor vv : verbVisitors) vv.visit(scn, ia, v);
                    ArrayList<Action> actions = v.getActions();
                    for (Action act : actions) {
                        for (ActionVisitor av : actionVisitors) av.visit(scn, ia, v, act);
                    }
                }
            }
            // DIALOGS
            if (a instanceof CharacterActor) {
                HashMap<String, Dialog> dialogs = ((CharacterActor) a).getDialogs();
                if (dialogs != null) {
                    for (Dialog d : dialogs.values()) {
                        for (DialogVisitor dv : dialogVisitors) dv.visit((CharacterActor) a, d);
                        ArrayList<DialogOption> options = d.getOptions();
                        for (DialogOption o : options) {
                            for (DialogOptionVisitor ov : optionVisitors) ov.visit((CharacterActor) a, d, o);
                        }
                    }
                }
            }
        }
    }
    for (EndVisitor ev : endVisitors) ev.end(w);
}

4 View Complete Implementation : InkManager.java
Copyright Apache License 2.0
Author : bladecoder
@Override
public void write(Json json) {
    BladeJson bjson = (BladeJson) json;
    World w = bjson.getWorld();
    json.writeValue("storyName", storyName);
    if (bjson.getMode() == Mode.STATE) {
        json.writeValue("wasInCutmode", wasInCutmode);
        if (cb == null && sCb != null)
            cb = ActionCallbackSerializer.find(w, w.getCurrentScene(), sCb);
        if (cb != null)
            json.writeValue("cb", ActionCallbackSerializer.find(w, w.getCurrentScene(), cb));
        // SAVE ACTIONS
        json.writeArrayStart("actions");
        for (Action a : inkVerbRunner.getActions()) {
            ActionUtils.writeJson(a, json);
        }
        json.writeArrayEnd();
        json.writeValue("ip", inkVerbRunner.getIP());
        json.writeArrayStart("actionsSer");
        for (Action a : inkVerbRunner.getActions()) {
            if (a instanceof Serializable) {
                json.writeObjectStart();
                ((Serializable) a).write(json);
                json.writeObjectEnd();
            }
        }
        json.writeArrayEnd();
        // SAVE STORY
        if (story != null) {
            try {
                json.writeValue("story", story.getState().toJson());
            } catch (Exception e) {
                EngineLogger.error(e.getMessage(), e);
            }
        }
    }
}

4 View Complete Implementation : ActionUtils.java
Copyright Apache License 2.0
Author : bladecoder
public static void writeJson(Action a, Json json) {
    Clreplaced<?> clazz = a.getClreplaced();
    json.writeObjectStart(clazz, null);
    while (clazz != null && clazz != Object.clreplaced) {
        for (Field field : clazz.getDeclaredFields()) {
            final ActionProperty property = field.getAnnotation(ActionProperty.clreplaced);
            if (property == null) {
                continue;
            }
            // json.writeField(a, field.getName());
            final boolean accessible = field.isAccessible();
            field.setAccessible(true);
            try {
                Object o = field.get(a);
                // doesn't write null fields
                if (o == null)
                    continue;
                if (o instanceof SceneActorRef) {
                    SceneActorRef sceneActor = (SceneActorRef) o;
                    json.writeValue(field.getName(), sceneActor.toString());
                } else if (o instanceof ActorAnimationRef) {
                    ActorAnimationRef aa = (ActorAnimationRef) o;
                    json.writeValue(field.getName(), aa.toString());
                } else if (o instanceof Color) {
                    json.writeValue(field.getName(), ((Color) o).toString());
                } else if (o instanceof Vector2) {
                    json.writeValue(field.getName(), Param.toStringParam((Vector2) o));
                } else {
                    json.writeValue(field.getName(), o);
                }
            } catch (IllegalArgumentException | IllegalAccessException e) {
            }
            field.setAccessible(accessible);
        }
        clazz = clazz.getSuperclreplaced();
    }
    json.writeObjectEnd();
}

1 View Complete Implementation : ModelTools.java
Copyright Apache License 2.0
Author : bladecoder
public static final void addCutMode() {
    Map<String, Scene> scenes = Ctx.project.getWorld().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();
}

0 View Complete Implementation : ModelTools.java
Copyright Apache License 2.0
Author : bladecoder
public static final void checkI18NMissingKeys() throws NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
    Map<String, Scene> scenes = Ctx.project.getWorld().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());
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

0 View Complete Implementation : ModelTools.java
Copyright Apache License 2.0
Author : bladecoder
public static final void extractDialogs() {
    Map<String, Scene> scenes = Ctx.project.getWorld().getScenes();
    BufferedWriter writer = null;
    try {
        // create a temporary file
        File dFile = new File(Ctx.project.getProjectPath() + "/" + "DIALOGS.md");
        writer = new BufferedWriter(new FileWriter(dFile));
        writer.write("# DIALOGS - " + (Ctx.project.getreplacedle() != null ? Ctx.project.getreplacedle().toUpperCase() : "") + "\n\n");
        for (Scene scn : scenes.values()) {
            Map<String, BaseActor> actors = scn.getActors();
            writer.write("\n## SCENE: " + scn.getId() + "\n\n");
            HashMap<String, Verb> verbs = scn.getVerbManager().getVerbs();
            // Process SayAction of TALK type
            for (Verb v : verbs.values()) {
                ArrayList<Action> actions = v.getActions();
                for (Action act : actions) {
                    if (act instanceof SayAction) {
                        String type = ActionUtils.getStringValue(act, "type");
                        if ("TALK".equals(type)) {
                            String actor = ActionUtils.getStringValue(act, "actor").toUpperCase();
                            String rawText = ActionUtils.getStringValue(act, "text");
                            String text = Ctx.project.translate(rawText).replace("\\n\\n", "\n").replace("\\n", "\n");
                            writer.write(actor + ": " + text + "\n");
                        }
                    }
                }
            }
            for (BaseActor a : actors.values()) {
                if (a instanceof InteractiveActor) {
                    InteractiveActor ia = (InteractiveActor) a;
                    verbs = ia.getVerbManager().getVerbs();
                    // Process SayAction of TALK type
                    for (Verb v : verbs.values()) {
                        ArrayList<Action> actions = v.getActions();
                        for (Action act : actions) {
                            if (act instanceof SayAction) {
                                String type = ActionUtils.getStringValue(act, "type");
                                if ("TALK".equals(type)) {
                                    String actor = ActionUtils.getStringValue(act, "actor").toUpperCase();
                                    String rawText = ActionUtils.getStringValue(act, "text");
                                    String text = Ctx.project.translate(rawText).replace("\\n\\n", "\n").replace("\\n", "\n");
                                    writer.write(actor + ": " + text + "\n");
                                }
                            }
                        }
                    }
                }
                if (a instanceof CharacterActor) {
                    CharacterActor ca = (CharacterActor) a;
                    HashMap<String, Dialog> dialogs = ca.getDialogs();
                    if (dialogs == null)
                        continue;
                    // Process SayAction of TALK type
                    for (Dialog d : dialogs.values()) {
                        ArrayList<DialogOption> options = d.getOptions();
                        if (options.size() > 0)
                            writer.write("\n**" + ca.getId().toUpperCase() + " - " + d.getId() + "**\n\n");
                        for (DialogOption o : options) {
                            String text = o.getText();
                            String response = o.getResponseText();
                            writer.write(scn.getPlayer().getId().toUpperCase() + ": " + Ctx.project.translate(text).replace("\\n\\n", "\n").replace("\\n", "\n") + "\n");
                            if (response != null)
                                writer.write(ca.getId().toUpperCase() + ": " + Ctx.project.translate(response).replace("\\n\\n", "\n").replace("\\n", "\n") + "\n\n");
                        }
                    }
                }
            }
        }
    } catch (Exception e) {
        EditorLogger.printStackTrace(e);
    } finally {
        try {
            // Close the writer regardless of what happens...
            writer.close();
        } catch (Exception e) {
        }
    }
}