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();
}
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);
}
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);
}
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);
}
Aggregations