use of com.bladecoder.engine.anim.AnimationDesc 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.anim.AnimationDesc in project bladecoder-adventure-engine by bladecoder.
the class EditAnimationDialog method setSource.
private void setSource() {
AnimationDesc anim = null;
ActorRenderer renderer = parent.getRenderer();
String sourceStr = source.getText();
if (renderer instanceof SpineRenderer) {
anim = new SpineAnimationDesc();
if (spineAtlasExists(sourceStr)) {
((SpineAnimationDesc) anim).atlas = null;
setVisible(atlas, false);
} else {
if (!atlas.isVisible()) {
setVisible(atlas, true);
}
((SpineAnimationDesc) anim).atlas = atlas.getText();
}
} else if (renderer instanceof AtlasRenderer) {
anim = new AtlasAnimationDesc();
} else {
anim = new AnimationDesc();
}
anim.source = sourceStr;
anim.count = Tween.INFINITY;
anim.preload = true;
anim.disposeWhenPlayed = false;
if (renderer instanceof SpineRenderer) {
spriteWidget.setSource(Project.SPINE_RENDERER_STRING, anim);
} else if (renderer instanceof AtlasRenderer) {
spriteWidget.setSource(Project.ATLAS_RENDERER_STRING, anim);
} else if (renderer instanceof ImageRenderer) {
spriteWidget.setSource(Project.IMAGE_RENDERER_STRING, anim);
} else if (renderer instanceof Sprite3DRenderer) {
spriteWidget.setSource(Project.S3D_RENDERER_STRING, anim);
}
}
use of com.bladecoder.engine.anim.AnimationDesc 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();
}
use of com.bladecoder.engine.anim.AnimationDesc in project bladecoder-adventure-engine by bladecoder.
the class CheckInteractionVerbs method visit.
@Override
public void visit(BaseActor a) {
if (a instanceof InteractiveActor) {
ia = (InteractiveActor) a;
hasLookat = false;
hasPickup = false;
hasTalkto = false;
hasLeave = false;
hasEnterExit = false;
hasUse = false;
if (ia.getInteraction()) {
HashMap<String, Verb> verbs = ia.getVerbManager().getVerbs();
for (Verb v : verbs.values()) checkVerb(v);
if (hasLeave || hasEnterExit)
return;
// discard inventory actors
if (hasLookat) {
if (ia instanceof SpriteActor) {
SpriteActor sa = (SpriteActor) ia;
if (sa.getRenderer() instanceof AtlasRenderer) {
AtlasRenderer r = (AtlasRenderer) sa.getRenderer();
HashMap<String, AnimationDesc> animations = r.getAnimations();
if (animations.size() == 0) {
EditorLogger.error("CheckInteractionVerbs: Actor with no animations! - " + sa.getScene().getId() + "." + sa.getId());
}
if (animations.get(r.getInitAnimation()).source.contains("inventory")) {
if (!hasUse)
EditorLogger.msg("CheckInteractionVerbs: Inventory item should has default 'use' - " + sa.getScene().getId() + "." + sa.getId());
return;
}
}
}
}
// check for lookat and pickup/talk verbs
if (!hasLookat || (!hasPickup && !hasTalkto)) {
String msg = "CheckInteractionVerbs: " + a.getScene().getId() + "." + a.getId();
if (!hasLookat)
EditorLogger.error(msg);
else
EditorLogger.msg(msg);
}
}
}
}
use of com.bladecoder.engine.anim.AnimationDesc in project bladecoder-adventure-engine by bladecoder.
the class Sprite3DRenderer method startAnimation.
// public Array<Animation> getAnimations() {
// return modelInstance.animations;
// }
@Override
public void startAnimation(String id, Tween.Type repeatType, int count, ActionCallback cb) {
AnimationDesc fa = fanims.get(id);
if (fa == null) {
EngineLogger.error("AnimationDesc not found: " + id);
return;
}
if (currentAnimation != null && currentAnimation.disposeWhenPlayed)
disposeSource(currentAnimation.source);
currentAnimation = fa;
currentSource = sourceCache.get(fa.source);
animationCb = cb;
if (currentSource == null || currentSource.refCounter < 1) {
// If the source is not loaded. Load it.
loadSource(fa.source);
EngineAssetManager.getInstance().finishLoading();
retrieveSource(fa.source);
currentSource = sourceCache.get(fa.source);
if (currentSource == null) {
EngineLogger.error("Could not load AnimationDesc: " + id);
currentAnimation = null;
return;
}
}
if (repeatType == Tween.Type.SPRITE_DEFINED) {
currentAnimationType = currentAnimation.animationType;
currentCount = currentAnimation.count;
} else {
currentCount = count;
currentAnimationType = repeatType;
}
lastAnimationTime = 0;
float speed = currentAnimation.duration;
if (currentAnimationType == Tween.Type.REVERSE || currentAnimationType == Tween.Type.REVERSE_REPEAT)
speed *= -1;
ModelCacheEntry cs = (ModelCacheEntry) currentSource;
if (cs.modelInstance.getAnimation(id) != null) {
animationCb = cb;
cs.controller.setAnimation(id, currentCount, speed, animationListener);
computeBbox();
return;
}
int idx = id.indexOf('.');
if (idx != -1) {
String s = id.substring(0, idx);
String dir = id.substring(idx + 1);
lookat(dir);
if (cs.modelInstance.getAnimation(s) != null) {
cs.controller.setAnimation(s, count, speed, animationListener);
computeBbox();
return;
}
}
// ERROR CASE
EngineLogger.error("Animation NOT FOUND: " + id);
for (Animation a : cs.modelInstance.animations) {
EngineLogger.debug(a.id);
}
if (cb != null) {
ActionCallbackQueue.add(cb);
}
computeBbox();
}
Aggregations