use of com.bladecoder.engine.model.SpriteActor in project bladecoder-adventure-engine by bladecoder.
the class I18NHandler method putTranslationsInElement.
public void putTranslationsInElement(BaseActor a) {
if (a instanceof InteractiveActor) {
InteractiveActor ia = (InteractiveActor) a;
// 1. DESC attribute
ia.setDesc(getTranslation(ia.getDesc()));
// 2. ACTIONS
HashMap<String, Verb> verbs = ia.getVerbManager().getVerbs();
for (Verb v : verbs.values()) putTranslationsInElement(v, false);
// 3. DIALOGS
if (a instanceof CharacterActor) {
HashMap<String, Dialog> dialogs = ((CharacterActor) a).getDialogs();
if (dialogs != null) {
for (Dialog d : dialogs.values()) putTranslationsInElement(d);
}
}
// 4. Text for TextRenderer
if (a instanceof SpriteActor && ((SpriteActor) a).getRenderer() instanceof TextRenderer) {
TextRenderer r = (TextRenderer) ((SpriteActor) a).getRenderer();
r.setText(getTranslation(r.getText()));
}
}
}
use of com.bladecoder.engine.model.SpriteActor in project bladecoder-adventure-engine by bladecoder.
the class ActorAnimationInputPanel method actorSelected.
private void actorSelected() {
String s = actor.getSelected();
SpriteActor a = null;
if (Ctx.project.getSelectedActor() instanceof SpriteActor)
a = (SpriteActor) Ctx.project.getSelectedActor();
ArrayList<String> values = new ArrayList<String>();
if (s != null && !s.isEmpty()) {
a = (SpriteActor) Ctx.project.getSelectedScene().getActor(s, false);
}
if (a != null && a.getRenderer() instanceof AnimationRenderer) {
HashMap<String, AnimationDesc> animations = ((AnimationRenderer) a.getRenderer()).getAnimations();
if (!isMandatory()) {
values.add("");
}
for (AnimationDesc anim : animations.values()) {
values.add(anim.id);
String flipped = AnimationRenderer.getFlipId(anim.id);
if (!flipped.isEmpty()) {
values.add(flipped);
}
}
}
String[] array = values.toArray(new String[values.size()]);
Arrays.sort(array);
animation.setItems(array);
if (values.size() > 0)
animation.setSelected("");
}
use of com.bladecoder.engine.model.SpriteActor in project bladecoder-adventure-engine by bladecoder.
the class ActorInputPanel method getValues.
private static String[] getValues(boolean mandatory, Param.Type type) {
Map<String, BaseActor> actors = Ctx.project.getSelectedScene().getActors();
ArrayList<BaseActor> filteredActors = new ArrayList<BaseActor>();
for (BaseActor a : actors.values()) {
if (type == Param.Type.CHARACTER_ACTOR) {
if (a instanceof CharacterActor)
filteredActors.add(a);
} else if (type == Param.Type.INTERACTIVE_ACTOR) {
if (a instanceof InteractiveActor)
filteredActors.add(a);
} else if (type == Param.Type.SPRITE_ACTOR) {
if (a instanceof SpriteActor)
filteredActors.add(a);
} else {
filteredActors.add(a);
}
}
String[] result = new String[filteredActors.size() + 1];
// Add player variable to the list
result[0] = Scene.VAR_PLAYER;
for (int i = 0; i < filteredActors.size(); i++) {
result[i + 1] = filteredActors.get(i).getId();
}
Arrays.sort(result);
return result;
}
use of com.bladecoder.engine.model.SpriteActor in project bladecoder-adventure-engine by bladecoder.
the class CanvasDrawer method drawSelectedActor.
public void drawSelectedActor(BaseActor selectedActor) {
// Gdx.gl20.glLineWidth(3);
Gdx.gl20.glEnable(GL20.GL_BLEND);
// Gdx.gl20.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
drawer.setProjectionMatrix(camera.combined);
if (selectedActor instanceof AnchorActor) {
drawer.begin(ShapeRenderer.ShapeType.Line);
drawer.setColor(MOUSESELECTION_STROKE_COLOR);
drawer.rect(selectedActor.getX() - Scene.ANCHOR_RADIUS, selectedActor.getY() - Scene.ANCHOR_RADIUS, Scene.ANCHOR_RADIUS * 2, Scene.ANCHOR_RADIUS * 2);
drawer.end();
} else {
Polygon p = selectedActor.getBBox();
Rectangle rect = p.getBoundingRectangle();
drawer.begin(ShapeRenderer.ShapeType.Filled);
drawer.setColor(MOUSESELECTION_FILL_COLOR);
drawer.rect(rect.x, rect.y, rect.width, rect.height);
drawer.end();
drawer.begin(ShapeRenderer.ShapeType.Line);
drawer.setColor(MOUSESELECTION_STROKE_COLOR);
drawer.rect(rect.x, rect.y, rect.width, rect.height);
// DRAW SELECTION BOUNDS
if ((!(selectedActor instanceof SpriteActor) || !((SpriteActor) selectedActor).isBboxFromRenderer()) && !(selectedActor instanceof AnchorActor)) {
float[] verts = selectedActor.getBBox().getTransformedVertices();
for (int i = 0; i < verts.length; i += 2) drawer.rect(verts[i] - CORNER_DIST / 2, verts[i + 1] - CORNER_DIST / 2, CORNER_DIST, CORNER_DIST);
}
// DRAW REFPOINT
if (selectedActor instanceof InteractiveActor) {
Vector2 refPoint = ((InteractiveActor) selectedActor).getRefPoint();
float orgX = selectedActor.getX() + refPoint.x;
float orgY = selectedActor.getY() + refPoint.y;
drawer.line(orgX - Scene.ANCHOR_RADIUS, orgY, orgX + Scene.ANCHOR_RADIUS, orgY);
drawer.line(orgX, orgY - Scene.ANCHOR_RADIUS, orgX, orgY + Scene.ANCHOR_RADIUS);
}
drawer.end();
}
}
use of com.bladecoder.engine.model.SpriteActor in project bladecoder-adventure-engine by bladecoder.
the class ScnWidget method setSelectedFA.
public void setSelectedFA(String selFA) {
if (selectedActor instanceof SpriteActor && ((SpriteActor) selectedActor).getRenderer() instanceof AnimationRenderer) {
AnimationRenderer s = (AnimationRenderer) ((SpriteActor) selectedActor).getRenderer();
if (selFA == null || (s.getAnimations().get(selFA) == null && s.getAnimations().get(AnimationRenderer.getFlipId(selFA)) == null)) {
selFA = s.getInitAnimation();
}
if (selFA != null && (s.getAnimations().get(selFA) != null || s.getAnimations().get(AnimationRenderer.getFlipId(selFA)) != null)) {
setAnimationRenderer(selectedActor, s.getAnimations().get(selFA));
String animInScene = selFA;
if (!inScene && s.getInitAnimation() != null)
animInScene = s.getInitAnimation();
try {
((SpriteActor) selectedActor).startAnimation(animInScene, Tween.Type.REPEAT, Tween.INFINITY, null);
} catch (Exception e) {
setAnimationRenderer(selectedActor, null);
s.getAnimations().remove(selFA);
}
} else {
setAnimationRenderer(selectedActor, null);
}
} else {
setAnimationRenderer(selectedActor, null);
}
}
Aggregations