Search in sources :

Example 6 with AtlasRenderer

use of com.bladecoder.engine.model.AtlasRenderer in project bladecoder-adventure-engine by bladecoder.

the class EditAnimationDialog method getSources.

private String[] getSources() {
    String path = null;
    ActorRenderer renderer = parent.getRenderer();
    if (renderer instanceof AtlasRenderer) {
        path = Ctx.project.getAssetPath() + Project.ATLASES_PATH + "/" + Ctx.project.getResDir();
        ext = EngineAssetManager.ATLAS_EXT;
    } else if (renderer instanceof Sprite3DRenderer) {
        path = Ctx.project.getAssetPath() + Project.SPRITE3D_PATH;
        ext = EngineAssetManager.MODEL3D_EXT;
    } else if (renderer instanceof SpineRenderer) {
        path = Ctx.project.getAssetPath() + Project.SPINE_PATH;
        ext = EngineAssetManager.SPINE_EXT;
    } else if (renderer instanceof ImageRenderer) {
        path = Ctx.project.getAssetPath() + Project.IMAGE_PATH + "/" + Ctx.project.getResDir();
        ext = "";
    }
    File f = new File(path);
    String[] sources = f.list(new FilenameFilter() {

        @Override
        public boolean accept(File arg0, String arg1) {
            if (arg1.endsWith(ext))
                return true;
            return false;
        }
    });
    if (sources != null) {
        Arrays.sort(sources);
        for (int i = 0; i < sources.length; i++) sources[i] = sources[i].substring(0, sources[i].length() - ext.length());
    } else {
        sources = new String[0];
    }
    return sources;
}
Also used : ImageRenderer(com.bladecoder.engine.model.ImageRenderer) FilenameFilter(java.io.FilenameFilter) AtlasRenderer(com.bladecoder.engine.model.AtlasRenderer) Sprite3DRenderer(com.bladecoder.engine.model.Sprite3DRenderer) SpineRenderer(com.bladecoder.engine.spine.SpineRenderer) ActorRenderer(com.bladecoder.engine.model.ActorRenderer) File(java.io.File)

Example 7 with AtlasRenderer

use of com.bladecoder.engine.model.AtlasRenderer 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);
    }
}
Also used : AtlasAnimationDesc(com.bladecoder.engine.anim.AtlasAnimationDesc) SpineAnimationDesc(com.bladecoder.engine.anim.SpineAnimationDesc) ImageRenderer(com.bladecoder.engine.model.ImageRenderer) AtlasRenderer(com.bladecoder.engine.model.AtlasRenderer) Sprite3DRenderer(com.bladecoder.engine.model.Sprite3DRenderer) AnimationDesc(com.bladecoder.engine.anim.AnimationDesc) AtlasAnimationDesc(com.bladecoder.engine.anim.AtlasAnimationDesc) SpineAnimationDesc(com.bladecoder.engine.anim.SpineAnimationDesc) SpineRenderer(com.bladecoder.engine.spine.SpineRenderer) ActorRenderer(com.bladecoder.engine.model.ActorRenderer)

Example 8 with AtlasRenderer

use of com.bladecoder.engine.model.AtlasRenderer 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);
            }
        }
    }
}
Also used : AtlasRenderer(com.bladecoder.engine.model.AtlasRenderer) InteractiveActor(com.bladecoder.engine.model.InteractiveActor) Verb(com.bladecoder.engine.model.Verb) SpriteActor(com.bladecoder.engine.model.SpriteActor) AnimationDesc(com.bladecoder.engine.anim.AnimationDesc)

Aggregations

AtlasRenderer (com.bladecoder.engine.model.AtlasRenderer)8 ImageRenderer (com.bladecoder.engine.model.ImageRenderer)7 SpineRenderer (com.bladecoder.engine.spine.SpineRenderer)7 Sprite3DRenderer (com.bladecoder.engine.model.Sprite3DRenderer)6 Vector2 (com.badlogic.gdx.math.Vector2)4 ActorRenderer (com.bladecoder.engine.model.ActorRenderer)4 SpriteActor (com.bladecoder.engine.model.SpriteActor)4 AnimationDesc (com.bladecoder.engine.anim.AnimationDesc)3 InteractiveActor (com.bladecoder.engine.model.InteractiveActor)3 AtlasAnimationDesc (com.bladecoder.engine.anim.AtlasAnimationDesc)2 SpineAnimationDesc (com.bladecoder.engine.anim.SpineAnimationDesc)2 AnchorActor (com.bladecoder.engine.model.AnchorActor)2 AnimationRenderer (com.bladecoder.engine.model.AnimationRenderer)2 CharacterActor (com.bladecoder.engine.model.CharacterActor)2 ObstacleActor (com.bladecoder.engine.model.ObstacleActor)2 ParticleRenderer (com.bladecoder.engine.model.ParticleRenderer)2 TextRenderer (com.bladecoder.engine.model.TextRenderer)2 Verb (com.bladecoder.engine.model.Verb)2 Polygon (com.badlogic.gdx.math.Polygon)1 BaseActor (com.bladecoder.engine.model.BaseActor)1