use of com.bladecoder.engine.actions.AbstractIfAction in project bladecoder-adventure-engine by bladecoder.
the class ActionList method edit.
@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.getItems().set(pos, e);
parent.getActions().set(pos, e);
Ctx.project.setModified();
if (isControlAction(editedElement)) {
if (!editedElement.getClass().getName().equals(e.getClass().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());
}
}
}
}
});
}
use of com.bladecoder.engine.actions.AbstractIfAction in project bladecoder-adventure-engine by bladecoder.
the class ActionList method paste.
@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.getItems().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();
}
use of com.bladecoder.engine.actions.AbstractIfAction in project bladecoder-adventure-engine by bladecoder.
the class ActionList method create.
@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.getItems().insert(pos, e);
parent.getActions().add(pos, e);
list.getSelection().choose(list.getItems().get(pos));
if (isControlAction(e)) {
insertEndAction(pos + 1, getOrCreateControlActionId((AbstractControlAction) e));
if (e instanceof AbstractIfAction)
insertEndAction(pos + 2, getOrCreateControlActionId((AbstractControlAction) e));
}
list.invalidateHierarchy();
}
});
}
Aggregations