Search in sources :

Example 1 with ActorRenderer

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

the class EditActorDialog method modelToInputs.

@Override
protected void modelToInputs() {
    id.setText(e.getId());
    visible.setText(Boolean.toString(e.isVisible()));
    pos.setText(Param.toStringParam(new Vector2(e.getX(), e.getY())));
    if (e instanceof InteractiveActor) {
        InteractiveActor ia = (InteractiveActor) e;
        layer.setText(ia.getLayer());
        interaction.setText(Boolean.toString(ia.getInteraction()));
        refPoint.setText(Param.toStringParam(ia.getRefPoint()));
        desc.setText(Ctx.project.translate(ia.getDesc()));
        state.setText(ia.getState());
        zIndex.setText(Float.toString(ia.getZIndex()));
        if (e instanceof SpriteActor) {
            SpriteActor sa = (SpriteActor) e;
            ActorRenderer r = sa.getRenderer();
            if (r instanceof AtlasRenderer) {
                renderer.setText(Project.ATLAS_RENDERER_STRING);
            } else if (r instanceof ImageRenderer) {
                renderer.setText(Project.IMAGE_RENDERER_STRING);
            } else if (r instanceof Sprite3DRenderer) {
                renderer.setText(Project.S3D_RENDERER_STRING);
                Sprite3DRenderer s3d = (Sprite3DRenderer) r;
                fov.setText(Float.toString(s3d.getCameraFOV()));
                cameraName.setText(s3d.getCameraName());
                spriteSize.setText(Param.toStringParam(s3d.getSpriteSize()));
            } else if (r instanceof ParticleRenderer) {
                renderer.setText(Project.PARTICLE_RENDERER_STRING);
                ParticleRenderer pr = (ParticleRenderer) r;
                particleName.setText(pr.getParticleName());
                particleAtlas.setText(pr.getAtlasName());
            } else if (r instanceof TextRenderer) {
                renderer.setText(Project.TEXT_RENDERER_STRING);
                TextRenderer tr = (TextRenderer) r;
                text.setText(Ctx.project.translate(tr.getText()));
                size.setText(Integer.toString(tr.getFontSize()));
                font.setText(tr.getFontName());
                borderWidth.setText(Integer.toString(tr.getBorderWidth()));
                textAlign.setText(AlignUtils.getAlign(tr.getAlign()));
                borderColor.setText(tr.getBorderColor().toString());
                borderStraight.setText(Boolean.toString(tr.isBorderStraight()));
                shadowOffsetX.setText(Integer.toString(tr.getShadowOffsetX()));
                shadowOffsetY.setText(Integer.toString(tr.getShadowOffsetY()));
                shadowColor.setText(tr.getShadowColor().toString());
            } else if (r instanceof SpineRenderer) {
                renderer.setText(Project.SPINE_RENDERER_STRING);
                spineSkin.setText(((SpineRenderer) r).getSkin());
            }
            fakeDepth.setText(Boolean.toString(sa.getFakeDepth()));
            scale.setText(Float.toString(sa.getScale()));
            rot.setText(Float.toString(sa.getRot()));
            tint.setText(sa.getTint() == null ? null : sa.getTint().toString());
            bboxFromRenderer.setText(Boolean.toString(sa.isBboxFromRenderer()));
            orgAlign.setText(AlignUtils.getAlign(sa.getRenderer().getOrgAlign()));
            if (e instanceof CharacterActor) {
                CharacterActor ca = (CharacterActor) e;
                walkingSpeed.setText(Float.toString(ca.getWalkingSpeed()));
                textColor.setText(ca.getTextColor() == null ? null : ca.getTextColor().toString());
                textStyle.setText(ca.getTextStyle());
                typePanel.setText(CHARACTER_TYPE_STR);
            } else {
                typePanel.setText(SPRITE_TYPE_STR);
            }
        } else {
            typePanel.setText(BACKGROUND_TYPE_STR);
        }
    } else if (e instanceof AnchorActor) {
        typePanel.setText(ANCHOR_TYPE_STR);
    } else if (e instanceof ObstacleActor) {
        typePanel.setText(OBSTACLE_TYPE_STR);
    }
}
Also used : AtlasRenderer(com.bladecoder.engine.model.AtlasRenderer) InteractiveActor(com.bladecoder.engine.model.InteractiveActor) ParticleRenderer(com.bladecoder.engine.model.ParticleRenderer) SpineRenderer(com.bladecoder.engine.spine.SpineRenderer) CharacterActor(com.bladecoder.engine.model.CharacterActor) AnchorActor(com.bladecoder.engine.model.AnchorActor) ImageRenderer(com.bladecoder.engine.model.ImageRenderer) Vector2(com.badlogic.gdx.math.Vector2) ObstacleActor(com.bladecoder.engine.model.ObstacleActor) Sprite3DRenderer(com.bladecoder.engine.model.Sprite3DRenderer) SpriteActor(com.bladecoder.engine.model.SpriteActor) ActorRenderer(com.bladecoder.engine.model.ActorRenderer) TextRenderer(com.bladecoder.engine.model.TextRenderer)

Example 2 with ActorRenderer

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

the class EditAnimationDialog method modelToInputs.

@Override
protected void modelToInputs() {
    source.setText(e.source);
    if (atlas.isVisible() && e instanceof SpineAnimationDesc)
        atlas.setText(((SpineAnimationDesc) e).atlas);
    id.setText(e.id);
    repeat.setText(e.animationType.toString());
    speed.setText(Float.toString(e.duration));
    count.setText(Integer.toString(e.count));
    in.setText(Param.toStringParam(e.inD));
    out.setText(Param.toStringParam(e.outD));
    sound.setText(e.sound);
    preload.setText(Boolean.toString(e.preload));
    dispose.setText(Boolean.toString(e.disposeWhenPlayed));
    showHideFieldsDelayCountFields();
    ActorRenderer renderer = parent.getRenderer();
    if (renderer instanceof ImageRenderer && e.source != null && e.source.length() > 1 && e.source.charAt(0) == I18N.PREFIX) {
        localizable.setText("true");
        source.setText(e.source.substring(1));
    }
}
Also used : SpineAnimationDesc(com.bladecoder.engine.anim.SpineAnimationDesc) ImageRenderer(com.bladecoder.engine.model.ImageRenderer) ActorRenderer(com.bladecoder.engine.model.ActorRenderer)

Example 3 with ActorRenderer

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

the class AnimationDrawer method setActor.

public void setActor(BaseActor a) {
    if (renderer != null) {
        renderer.dispose();
        renderer = null;
    }
    if (a instanceof SpriteActor && ((SpriteActor) a).getRenderer() instanceof AnimationRenderer) {
        ActorRenderer r = ((SpriteActor) a).getRenderer();
        if (r instanceof Sprite3DRenderer) {
            renderer = new Sprite3DRenderer();
            ((Sprite3DRenderer) renderer).setSpriteSize(new Vector2(r.getWidth(), r.getHeight()));
        } else if (r instanceof SpineRenderer) {
            renderer = new SpineRenderer();
            ((SpineRenderer) renderer).enableEvents(false);
            ((SpineRenderer) renderer).setSkin(((SpineRenderer) r).getSkin());
        } else if (r instanceof ImageRenderer) {
            renderer = new ImageRenderer();
        } else if (r instanceof AtlasRenderer) {
            renderer = new AtlasRenderer();
        }
        renderer.setOrgAlign(Align.bottom);
    }
}
Also used : ImageRenderer(com.bladecoder.engine.model.ImageRenderer) AtlasRenderer(com.bladecoder.engine.model.AtlasRenderer) Vector2(com.badlogic.gdx.math.Vector2) Sprite3DRenderer(com.bladecoder.engine.model.Sprite3DRenderer) SpriteActor(com.bladecoder.engine.model.SpriteActor) SpineRenderer(com.bladecoder.engine.spine.SpineRenderer) ActorRenderer(com.bladecoder.engine.model.ActorRenderer) AnimationRenderer(com.bladecoder.engine.model.AnimationRenderer)

Example 4 with ActorRenderer

use of com.bladecoder.engine.model.ActorRenderer 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 5 with ActorRenderer

use of com.bladecoder.engine.model.ActorRenderer 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)

Aggregations

ActorRenderer (com.bladecoder.engine.model.ActorRenderer)7 ImageRenderer (com.bladecoder.engine.model.ImageRenderer)5 AtlasRenderer (com.bladecoder.engine.model.AtlasRenderer)4 Sprite3DRenderer (com.bladecoder.engine.model.Sprite3DRenderer)4 SpineRenderer (com.bladecoder.engine.spine.SpineRenderer)4 SpriteActor (com.bladecoder.engine.model.SpriteActor)3 Vector2 (com.badlogic.gdx.math.Vector2)2 SpineAnimationDesc (com.bladecoder.engine.anim.SpineAnimationDesc)2 AnimationDesc (com.bladecoder.engine.anim.AnimationDesc)1 AtlasAnimationDesc (com.bladecoder.engine.anim.AtlasAnimationDesc)1 AnchorActor (com.bladecoder.engine.model.AnchorActor)1 AnimationRenderer (com.bladecoder.engine.model.AnimationRenderer)1 CharacterActor (com.bladecoder.engine.model.CharacterActor)1 InteractiveActor (com.bladecoder.engine.model.InteractiveActor)1 Inventory (com.bladecoder.engine.model.Inventory)1 ObstacleActor (com.bladecoder.engine.model.ObstacleActor)1 ParticleRenderer (com.bladecoder.engine.model.ParticleRenderer)1 TextRenderer (com.bladecoder.engine.model.TextRenderer)1 File (java.io.File)1 FilenameFilter (java.io.FilenameFilter)1