Support Spine Skins
This commit is contained in:
Submodule h2d-libgdx-spine-extension updated: 4088491af2...95066c86cd
+4
@@ -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);
|
||||
}
|
||||
|
||||
+28
-4
@@ -30,13 +30,20 @@ import games.rednblack.h2d.common.view.ui.StandardWidgetsFactory;
|
||||
*/
|
||||
public class UISpineAnimationItemProperties extends UIItemCollapsibleProperties {
|
||||
|
||||
private VisSelectBox<String> animationsSelectBox;
|
||||
private VisSelectBox<String> 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<String> getSkins() {
|
||||
return skinSelectBox.getItems();
|
||||
}
|
||||
|
||||
public void setAnimations(Array<String> animations) {
|
||||
animationsSelectBox.setItems(animations);
|
||||
}
|
||||
|
||||
public String getSelected() {
|
||||
public void setSkins(Array<String> 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()));
|
||||
}
|
||||
}
|
||||
|
||||
+15
-3
@@ -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<String> animations = new Array<>();
|
||||
Array<String> 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<String> 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);
|
||||
|
||||
Reference in New Issue
Block a user