use of com.bladecoder.engine.model.BaseActor in project bladecoder-adventure-engine by bladecoder.
the class ModelTools method checkI18NMissingKeys.
public static final void checkI18NMissingKeys() throws NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
Map<String, Scene> scenes = World.getInstance().getScenes();
for (Scene scn : scenes.values()) {
Map<String, BaseActor> actors = scn.getActors();
// SCENE VERBS
HashMap<String, Verb> verbs = scn.getVerbManager().getVerbs();
for (Verb v : verbs.values()) {
ArrayList<Action> actions = v.getActions();
for (Action act : actions) {
String[] params = ActionUtils.getFieldNames(act);
for (String p : params) {
String val = ActionUtils.getStringValue(act, p);
if (val != null && !val.isEmpty() && val.charAt(0) == I18N.PREFIX) {
String trans = Ctx.project.translate(val);
if (trans == val) {
EditorLogger.error("Key not found: " + val);
}
}
}
}
}
for (BaseActor a : actors.values()) {
if (a instanceof InteractiveActor) {
InteractiveActor ia = (InteractiveActor) a;
// DESC
if (ia.getDesc() != null && !ia.getDesc().isEmpty() && ia.getDesc().charAt(0) == I18N.PREFIX) {
String trans = Ctx.project.translate(ia.getDesc());
if (trans == ia.getDesc()) {
EditorLogger.error("Key not found: " + ia.getDesc());
}
}
// ACTOR VERBS
verbs = ia.getVerbManager().getVerbs();
for (Verb v : verbs.values()) {
ArrayList<Action> actions = v.getActions();
for (Action act : actions) {
String[] params = ActionUtils.getFieldNames(act);
for (String p : params) {
String val = ActionUtils.getStringValue(act, p);
if (val != null && !val.isEmpty() && val.charAt(0) == I18N.PREFIX) {
String trans = Ctx.project.translate(val);
if (trans == val) {
EditorLogger.error("Key not found: " + val);
}
}
}
}
}
}
// DIALOGS
if (a instanceof CharacterActor) {
HashMap<String, Dialog> dialogs = ((CharacterActor) a).getDialogs();
if (dialogs != null) {
for (Dialog d : dialogs.values()) {
ArrayList<DialogOption> options = d.getOptions();
for (DialogOption o : options) {
if (o.getText() != null && !o.getText().isEmpty() && o.getText().charAt(0) == I18N.PREFIX) {
String trans = Ctx.project.translate(o.getText());
if (trans == o.getText()) {
EditorLogger.error("Key not found: " + o.getText());
}
}
if (o.getResponseText() != null && !o.getResponseText().isEmpty() && o.getResponseText().charAt(0) == I18N.PREFIX) {
String trans = Ctx.project.translate(o.getResponseText());
if (trans == o.getResponseText()) {
EditorLogger.error("Key not found: " + o.getResponseText());
}
}
}
}
}
}
}
}
}
use of com.bladecoder.engine.model.BaseActor in project bladecoder-adventure-engine by bladecoder.
the class ActorList method copy.
@Override
protected void copy() {
BaseActor e = list.getSelected();
if (e == null)
return;
clipboard = (BaseActor) ElementUtils.cloneElement(e);
toolbar.disablePaste(false);
// TRANSLATIONS
Ctx.project.getI18N().putTranslationsInElement(clipboard);
}
use of com.bladecoder.engine.model.BaseActor in project bladecoder-adventure-engine by bladecoder.
the class ActorList method setPlayer.
private void setPlayer() {
int pos = list.getSelectedIndex();
if (pos == -1)
return;
BaseActor a = list.getItems().get(pos);
if (a instanceof CharacterActor) {
Ctx.project.getSelectedScene().setPlayer((CharacterActor) a);
Ctx.project.setModified();
}
}
use of com.bladecoder.engine.model.BaseActor in project bladecoder-adventure-engine by bladecoder.
the class ActorList method paste.
@Override
protected void paste() {
BaseActor newElement = (BaseActor) ElementUtils.cloneElement(clipboard);
newElement.setId(ElementUtils.getCheckedId(newElement.getId(), parent.getActors().keySet().toArray(new String[0])));
int pos = list.getSelectedIndex() + 1;
list.getItems().insert(pos, newElement);
parent.addActor(newElement);
Ctx.project.getI18N().extractStrings(parent.getId(), newElement);
if (newElement instanceof SpriteActor) {
SpriteActor ia = (SpriteActor) newElement;
ia.loadAssets();
EngineAssetManager.getInstance().finishLoading();
ia.retrieveAssets();
}
list.setSelectedIndex(pos);
list.invalidateHierarchy();
Ctx.project.setModified();
}
use of com.bladecoder.engine.model.BaseActor in project bladecoder-adventure-engine by bladecoder.
the class ActorList method edit.
@Override
protected void edit() {
BaseActor e = list.getSelected();
if (e == null)
return;
EditModelDialog<Scene, BaseActor> dialog = getEditElementDialogInstance(e);
dialog.show(getStage());
dialog.setListener(new ChangeListener() {
@SuppressWarnings("unchecked")
@Override
public void changed(ChangeEvent event, Actor actor) {
BaseActor e = ((EditModelDialog<Scene, BaseActor>) actor).getElement();
// When the type is changed, a new element is created and it is needed to replace the previous element.
if (e != list.getSelected()) {
int i = list.getSelectedIndex();
getItems().set(i, e);
list.setSelectedIndex(i);
list.invalidateHierarchy();
}
}
});
}
Aggregations