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