diff --git a/h2d-libgdx-spine-extension b/h2d-libgdx-spine-extension index 4088491a..95066c86 160000 --- a/h2d-libgdx-spine-extension +++ b/h2d-libgdx-spine-extension @@ -1 +1 @@ -Subproject commit 4088491af2d9f45e5164df26838f54d14ea5eb53 +Subproject commit 95066c86cd8da8e08620578e3a39d2ede483f1c7 diff --git a/src/main/java/games/rednblack/editor/controller/commands/component/UpdateSpineDataCommand.java b/src/main/java/games/rednblack/editor/controller/commands/component/UpdateSpineDataCommand.java index 4df51feb..f0b8020e 100644 --- a/src/main/java/games/rednblack/editor/controller/commands/component/UpdateSpineDataCommand.java +++ b/src/main/java/games/rednblack/editor/controller/commands/component/UpdateSpineDataCommand.java @@ -26,7 +26,9 @@ public class UpdateSpineDataCommand extends EntityModifyRevertibleCommand { SpineComponent spineComponent = SandboxComponentRetriever.get(entity, SpineComponent.class); spineComponent.currentAnimationName = vo.currentAnimationName; + spineComponent.currentSkinName = vo.currentSkinName; spineComponent.setAnimation(vo.currentAnimationName); + spineComponent.setSkin(vo.currentSkinName); HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ITEM_DATA_UPDATED, entity); } @@ -37,7 +39,9 @@ public class UpdateSpineDataCommand extends EntityModifyRevertibleCommand { SpineComponent spineComponent = SandboxComponentRetriever.get(entity, SpineComponent.class); spineComponent.currentAnimationName = backup.currentAnimationName; + spineComponent.currentSkinName = backup.currentSkinName; spineComponent.setAnimation(backup.currentAnimationName); + spineComponent.setSkin(backup.currentSkinName); HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ITEM_DATA_UPDATED, entity); } diff --git a/src/main/java/games/rednblack/editor/view/ui/properties/panels/UISpineAnimationItemProperties.java b/src/main/java/games/rednblack/editor/view/ui/properties/panels/UISpineAnimationItemProperties.java index 5fbf2652..be09d0ba 100644 --- a/src/main/java/games/rednblack/editor/view/ui/properties/panels/UISpineAnimationItemProperties.java +++ b/src/main/java/games/rednblack/editor/view/ui/properties/panels/UISpineAnimationItemProperties.java @@ -30,13 +30,20 @@ import games.rednblack.h2d.common.view.ui.StandardWidgetsFactory; */ public class UISpineAnimationItemProperties extends UIItemCollapsibleProperties { - private VisSelectBox animationsSelectBox; + private VisSelectBox animationsSelectBox, skinSelectBox; public UISpineAnimationItemProperties() { super("Spine Animations"); animationsSelectBox = StandardWidgetsFactory.createSelectBox(String.class); - mainTable.add(StandardWidgetsFactory.createLabel("Animations:", Align.right)).padRight(5).colspan(2).fillX(); - mainTable.add(animationsSelectBox).width(120).colspan(2); + skinSelectBox = StandardWidgetsFactory.createSelectBox(String.class); + + mainTable.add(StandardWidgetsFactory.createLabel("Animation:", Align.right)).padRight(5).colspan(2).fillX(); + mainTable.add(animationsSelectBox).width(120).colspan(2).row(); + + mainTable.add().padTop(7).colspan(4).row(); + + mainTable.add(StandardWidgetsFactory.createLabel("Skin:", Align.right)).padRight(5).colspan(2).fillX(); + mainTable.add(skinSelectBox).width(120).colspan(2).row(); setListeners(); } @@ -44,18 +51,34 @@ public class UISpineAnimationItemProperties extends UIItemCollapsibleProperties return animationsSelectBox.getItems(); } + public Array getSkins() { + return skinSelectBox.getItems(); + } + public void setAnimations(Array animations) { animationsSelectBox.setItems(animations); } - public String getSelected() { + public void setSkins(Array animations) { + skinSelectBox.setItems(animations); + } + + public String getSelectedAnimation() { return animationsSelectBox.getSelected(); } + public String getSelectedSkin() { + return skinSelectBox.getSelected(); + } + public void setSelectedAnimation(String currentAnimationName) { animationsSelectBox.setSelected(currentAnimationName); } + public void setSelectedSkin(String currentSkinName) { + skinSelectBox.setSelected(currentSkinName); + } + @Override public String getPrefix() { return this.getClass().getCanonicalName(); @@ -63,5 +86,6 @@ public class UISpineAnimationItemProperties extends UIItemCollapsibleProperties private void setListeners() { animationsSelectBox.addListener(new SelectBoxChangeListener(getUpdateEventName())); + skinSelectBox.addListener(new SelectBoxChangeListener(getUpdateEventName())); } } diff --git a/src/main/java/games/rednblack/editor/view/ui/properties/panels/UISpineAnimationItemPropertiesMediator.java b/src/main/java/games/rednblack/editor/view/ui/properties/panels/UISpineAnimationItemPropertiesMediator.java index d4a4847c..1e96462b 100644 --- a/src/main/java/games/rednblack/editor/view/ui/properties/panels/UISpineAnimationItemPropertiesMediator.java +++ b/src/main/java/games/rednblack/editor/view/ui/properties/panels/UISpineAnimationItemPropertiesMediator.java @@ -20,6 +20,7 @@ package games.rednblack.editor.view.ui.properties.panels; import com.badlogic.gdx.utils.Array; import com.esotericsoftware.spine.Animation; +import com.esotericsoftware.spine.Skin; import games.rednblack.editor.controller.commands.component.UpdateSpineDataCommand; import games.rednblack.h2d.extension.spine.SpineVO; import games.rednblack.editor.utils.runtime.SandboxComponentRetriever; @@ -33,6 +34,9 @@ public class UISpineAnimationItemPropertiesMediator extends UIItemPropertiesMedi private SpineComponent spineComponent; + Array animations = new Array<>(); + Array skins = new Array<>(); + public UISpineAnimationItemPropertiesMediator() { super(NAME, new UISpineAnimationItemProperties()); } @@ -40,20 +44,28 @@ public class UISpineAnimationItemPropertiesMediator extends UIItemPropertiesMedi @Override protected void translateObservableDataToView(int entity) { spineComponent = SandboxComponentRetriever.get(entity, SpineComponent.class); - - Array animations = new Array<>(); + + animations.clear(); for (Animation animation : spineComponent.getAnimations()) { animations.add(animation.getName()); } viewComponent.setAnimations(animations); viewComponent.setSelectedAnimation(spineComponent.currentAnimationName); + + skins.clear(); + for (Skin skin : spineComponent.getSkins()) { + skins.add(skin.getName()); + } + viewComponent.setSkins(skins); + viewComponent.setSelectedSkin(spineComponent.currentSkinName); } @Override protected void translateViewToItemData() { SpineVO payloadVO = new SpineVO(); - payloadVO.currentAnimationName = viewComponent.getSelected(); + payloadVO.currentAnimationName = viewComponent.getSelectedAnimation(); + payloadVO.currentSkinName = viewComponent.getSelectedSkin(); Object payload = UpdateSpineDataCommand.payload(observableReference, payloadVO); facade.sendNotification(MsgAPI.ACTION_UPDATE_SPINE_ANIMATION_DATA, payload);