Search in sources :

Example 1 with FrameRange

use of games.rednblack.editor.renderer.data.FrameRange in project HyperLap2D by rednblackgames.

the class EditSpriteAnimationPanel method updateView.

public void updateView(Map<String, FrameRange> frameRangeMap) {
    createNewAnimationTable(frameRangeMap.get("Default").endFrame);
    animationsList.clear();
    for (Map.Entry<String, FrameRange> entry : frameRangeMap.entrySet()) {
        String animationName = entry.getKey();
        FrameRange range = entry.getValue();
        VisTable row = new VisTable();
        VisImageButton trashBtn = new VisImageButton("trash-button");
        row.add(StandardWidgetsFactory.createLabel(animationName)).width(120).left();
        row.add(StandardWidgetsFactory.createLabel(range.startFrame + "")).width(50).left();
        row.add(StandardWidgetsFactory.createLabel(range.endFrame + "")).width(50).left();
        if (!animationName.equals("Default"))
            row.add(trashBtn).padLeft(10);
        row.row();
        animationsList.add(row).left();
        animationsList.row();
        trashBtn.addListener(new ClickListener() {

            @Override
            public void clicked(InputEvent event, float x, float y) {
                facade.sendNotification(DELETE_BUTTON_PRESSED, animationName);
            }
        });
    }
    invalidateHeight();
}
Also used : VisImageButton(com.kotcrab.vis.ui.widget.VisImageButton) FrameRange(games.rednblack.editor.renderer.data.FrameRange) VisTable(com.kotcrab.vis.ui.widget.VisTable) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) Map(java.util.Map) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 2 with FrameRange

use of games.rednblack.editor.renderer.data.FrameRange in project HyperLap2D by rednblackgames.

the class ReplaceSpriteAnimationCommand method doAction.

@Override
public void doAction() {
    Object[] payload = getNotification().getBody();
    int entity = (int) payload[0];
    String animName = (String) payload[1];
    Array<TextureAtlas.AtlasRegion> regions = (Array<TextureAtlas.AtlasRegion>) payload[2];
    entityId = EntityUtils.getEntityId(entity);
    SpriteAnimationComponent spriteAnimationComponent = SandboxComponentRetriever.get(entity, SpriteAnimationComponent.class);
    SpriteAnimationStateComponent spriteAnimationStateComponent = SandboxComponentRetriever.get(entity, SpriteAnimationStateComponent.class);
    TextureRegionComponent textureRegionComponent = SandboxComponentRetriever.get(entity, TextureRegionComponent.class);
    DimensionsComponent size = SandboxComponentRetriever.get(entity, DimensionsComponent.class);
    TransformComponent transformComponent = SandboxComponentRetriever.get(entity, TransformComponent.class);
    backupAnimName = spriteAnimationComponent.animationName;
    backupAnimRegions = spriteAnimationStateComponent.allRegions;
    spriteAnimationComponent.animationName = animName;
    spriteAnimationComponent.frameRangeMap.clear();
    spriteAnimationComponent.frameRangeMap.put("Default", new FrameRange("Default", 0, regions.size - 1));
    spriteAnimationComponent.currentAnimation = "Default";
    spriteAnimationComponent.playMode = Animation.PlayMode.LOOP;
    spriteAnimationStateComponent.setAllRegions(regions);
    spriteAnimationStateComponent.set(spriteAnimationComponent);
    textureRegionComponent.region = regions.get(0);
    ProjectInfoVO projectInfoVO = Sandbox.getInstance().getSceneControl().sceneLoader.getRm().getProjectVO();
    float ppwu = projectInfoVO.pixelToWorld;
    size.width = textureRegionComponent.region.getRegionWidth() / ppwu;
    size.height = textureRegionComponent.region.getRegionHeight() / ppwu;
    transformComponent.originX = size.width / 2;
    transformComponent.originY = size.height / 2;
    HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ITEM_DATA_UPDATED, entity);
}
Also used : FrameRange(games.rednblack.editor.renderer.data.FrameRange) SpriteAnimationComponent(games.rednblack.editor.renderer.components.sprite.SpriteAnimationComponent) Array(com.badlogic.gdx.utils.Array) TextureRegionComponent(games.rednblack.editor.renderer.components.TextureRegionComponent) SpriteAnimationStateComponent(games.rednblack.editor.renderer.components.sprite.SpriteAnimationStateComponent) ProjectInfoVO(games.rednblack.editor.renderer.data.ProjectInfoVO) TextureAtlas(com.badlogic.gdx.graphics.g2d.TextureAtlas) DimensionsComponent(games.rednblack.editor.renderer.components.DimensionsComponent) TransformComponent(games.rednblack.editor.renderer.components.TransformComponent)

Example 3 with FrameRange

use of games.rednblack.editor.renderer.data.FrameRange in project HyperLap2D by rednblackgames.

the class ReplaceSpriteAnimationCommand method undoAction.

@Override
public void undoAction() {
    int entity = EntityUtils.getByUniqueId(entityId);
    SpriteAnimationComponent spriteAnimationComponent = SandboxComponentRetriever.get(entity, SpriteAnimationComponent.class);
    SpriteAnimationStateComponent spriteAnimationStateComponent = SandboxComponentRetriever.get(entity, SpriteAnimationStateComponent.class);
    TextureRegionComponent textureRegionComponent = SandboxComponentRetriever.get(entity, TextureRegionComponent.class);
    DimensionsComponent size = SandboxComponentRetriever.get(entity, DimensionsComponent.class);
    TransformComponent transformComponent = SandboxComponentRetriever.get(entity, TransformComponent.class);
    spriteAnimationComponent.animationName = backupAnimName;
    spriteAnimationComponent.frameRangeMap.clear();
    spriteAnimationComponent.frameRangeMap.put("Default", new FrameRange("Default", 0, backupAnimRegions.size - 1));
    spriteAnimationComponent.currentAnimation = "Default";
    spriteAnimationComponent.playMode = Animation.PlayMode.LOOP;
    spriteAnimationStateComponent.setAllRegions(backupAnimRegions);
    spriteAnimationStateComponent.set(spriteAnimationComponent);
    textureRegionComponent.region = backupAnimRegions.get(0);
    ProjectInfoVO projectInfoVO = Sandbox.getInstance().getSceneControl().sceneLoader.getRm().getProjectVO();
    float ppwu = projectInfoVO.pixelToWorld;
    size.width = textureRegionComponent.region.getRegionWidth() / ppwu;
    size.height = textureRegionComponent.region.getRegionHeight() / ppwu;
    transformComponent.originX = size.width / 2;
    transformComponent.originY = size.height / 2;
    HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ITEM_DATA_UPDATED, entity);
}
Also used : TextureRegionComponent(games.rednblack.editor.renderer.components.TextureRegionComponent) SpriteAnimationStateComponent(games.rednblack.editor.renderer.components.sprite.SpriteAnimationStateComponent) FrameRange(games.rednblack.editor.renderer.data.FrameRange) ProjectInfoVO(games.rednblack.editor.renderer.data.ProjectInfoVO) DimensionsComponent(games.rednblack.editor.renderer.components.DimensionsComponent) TransformComponent(games.rednblack.editor.renderer.components.TransformComponent) SpriteAnimationComponent(games.rednblack.editor.renderer.components.sprite.SpriteAnimationComponent)

Example 4 with FrameRange

use of games.rednblack.editor.renderer.data.FrameRange in project HyperLap2D by rednblackgames.

the class EditSpriteAnimationPanelMediator method addAnimation.

private void addAnimation() {
    String name = viewComponent.getName();
    int frameFrom = viewComponent.getFrameFrom();
    int frameTo = viewComponent.getFrameTo();
    SpriteAnimationComponent spriteAnimationComponent = SandboxComponentRetriever.get(observable, SpriteAnimationComponent.class);
    spriteAnimationComponent.frameRangeMap.put(name, new FrameRange(name, frameFrom, frameTo));
    facade.sendNotification(MsgAPI.ITEM_DATA_UPDATED, observable);
}
Also used : FrameRange(games.rednblack.editor.renderer.data.FrameRange) SpriteAnimationComponent(games.rednblack.editor.renderer.components.sprite.SpriteAnimationComponent)

Aggregations

FrameRange (games.rednblack.editor.renderer.data.FrameRange)4 SpriteAnimationComponent (games.rednblack.editor.renderer.components.sprite.SpriteAnimationComponent)3 DimensionsComponent (games.rednblack.editor.renderer.components.DimensionsComponent)2 TextureRegionComponent (games.rednblack.editor.renderer.components.TextureRegionComponent)2 TransformComponent (games.rednblack.editor.renderer.components.TransformComponent)2 SpriteAnimationStateComponent (games.rednblack.editor.renderer.components.sprite.SpriteAnimationStateComponent)2 ProjectInfoVO (games.rednblack.editor.renderer.data.ProjectInfoVO)2 TextureAtlas (com.badlogic.gdx.graphics.g2d.TextureAtlas)1 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)1 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)1 Array (com.badlogic.gdx.utils.Array)1 VisImageButton (com.kotcrab.vis.ui.widget.VisImageButton)1 VisTable (com.kotcrab.vis.ui.widget.VisTable)1 Map (java.util.Map)1