use of com.bladecoder.engine.model.AnimationRenderer in project bladecoder-adventure-engine by bladecoder.
the class SpriteList method delete.
@Override
protected void delete() {
AnimationDesc d = removeSelected();
AnimationRenderer renderer = (AnimationRenderer) parent.getRenderer();
renderer.getAnimations().remove(d.id);
// UNDO
Ctx.project.getUndoStack().add(new UndoDeleteAnimation(parent, d));
// init_animation
if (renderer.getInitAnimation().equals(d.id)) {
HashMap<String, AnimationDesc> animations = renderer.getAnimations();
String newValue = null;
if (animations.size() > 0)
newValue = animations.keySet().iterator().next();
renderer.setInitAnimation(newValue);
Ctx.project.setModified(this, "init_animation", d.id, newValue);
}
Ctx.project.setModified();
}
use of com.bladecoder.engine.model.AnimationRenderer 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.AnimationRenderer 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);
}
}
use of com.bladecoder.engine.model.AnimationRenderer in project bladecoder-adventure-engine by bladecoder.
the class SpriteList method setDefault.
private void setDefault() {
int pos = list.getSelectedIndex();
if (pos == -1)
return;
AnimationRenderer renderer = (AnimationRenderer) ((SpriteActor) Ctx.project.getSelectedActor()).getRenderer();
String id = list.getItems().get(pos).id;
String oldId = renderer.getInitAnimation();
renderer.setInitAnimation(id);
Ctx.project.setModified(this, "init_animation", oldId, id);
}
use of com.bladecoder.engine.model.AnimationRenderer in project bladecoder-adventure-engine by bladecoder.
the class SpriteList method paste.
@Override
protected void paste() {
AnimationDesc newElement = (AnimationDesc) ElementUtils.cloneElement(clipboard);
int pos = list.getSelectedIndex() + 1;
list.getItems().insert(pos, newElement);
((AnimationRenderer) parent.getRenderer()).addAnimation(newElement);
list.setSelectedIndex(pos);
list.invalidateHierarchy();
Ctx.project.setModified();
}
Aggregations