Search in sources :

Example 6 with AnimationRenderer

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();
}
Also used : AnimationDesc(com.bladecoder.engine.anim.AnimationDesc) UndoDeleteAnimation(com.bladecoder.engineeditor.undo.UndoDeleteAnimation) AnimationRenderer(com.bladecoder.engine.model.AnimationRenderer)

Example 7 with AnimationRenderer

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("");
}
Also used : ArrayList(java.util.ArrayList) SpriteActor(com.bladecoder.engine.model.SpriteActor) AnimationDesc(com.bladecoder.engine.anim.AnimationDesc) AnimationRenderer(com.bladecoder.engine.model.AnimationRenderer)

Example 8 with AnimationRenderer

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);
    }
}
Also used : SpriteActor(com.bladecoder.engine.model.SpriteActor) AnimationRenderer(com.bladecoder.engine.model.AnimationRenderer)

Example 9 with AnimationRenderer

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);
}
Also used : AnimationRenderer(com.bladecoder.engine.model.AnimationRenderer)

Example 10 with AnimationRenderer

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();
}
Also used : AnimationDesc(com.bladecoder.engine.anim.AnimationDesc) AnimationRenderer(com.bladecoder.engine.model.AnimationRenderer)

Aggregations

AnimationRenderer (com.bladecoder.engine.model.AnimationRenderer)12 SpriteActor (com.bladecoder.engine.model.SpriteActor)6 AnimationDesc (com.bladecoder.engine.anim.AnimationDesc)4 AtlasRenderer (com.bladecoder.engine.model.AtlasRenderer)2 ImageRenderer (com.bladecoder.engine.model.ImageRenderer)2 InteractiveActor (com.bladecoder.engine.model.InteractiveActor)2 Scene (com.bladecoder.engine.model.Scene)2 SpineRenderer (com.bladecoder.engine.spine.SpineRenderer)2 Color (com.badlogic.gdx.graphics.Color)1 Vector2 (com.badlogic.gdx.math.Vector2)1 AtlasAnimationDesc (com.bladecoder.engine.anim.AtlasAnimationDesc)1 SpineAnimationDesc (com.bladecoder.engine.anim.SpineAnimationDesc)1 ActorRenderer (com.bladecoder.engine.model.ActorRenderer)1 BaseActor (com.bladecoder.engine.model.BaseActor)1 Sprite3DRenderer (com.bladecoder.engine.model.Sprite3DRenderer)1 VerbRunner (com.bladecoder.engine.model.VerbRunner)1 UndoDeleteAnimation (com.bladecoder.engineeditor.undo.UndoDeleteAnimation)1 ArrayList (java.util.ArrayList)1