Smart layers drag n drop
This commit is contained in:
+1
-1
Submodule hyperlap2d-common-api updated: 057a2a0eba...19c2b01f94
Submodule hyperlap2d-runtime-libgdx updated: 5e780865d6...6159f1be86
@@ -53,6 +53,7 @@ public class BootstrapCommand extends SimpleCommand {
|
||||
facade.registerCommand(MsgAPI.ACTION_DELETE_LAYER, DeleteLayerCommand::new);
|
||||
facade.registerCommand(MsgAPI.ACTION_NEW_LAYER, NewLayerCommand::new);
|
||||
facade.registerCommand(MsgAPI.ACTION_SWAP_LAYERS, LayerSwapCommand::new);
|
||||
facade.registerCommand(MsgAPI.ACTION_JUMP_LAYERS, LayerJumpCommand::new);
|
||||
facade.registerCommand(MsgAPI.ACTION_RENAME_LAYER, RenameLayerCommand::new);
|
||||
|
||||
facade.registerCommand(MsgAPI.ACTION_ADD_COMPONENT, AddComponentToItemCommand::new);
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package games.rednblack.editor.controller.commands;
|
||||
|
||||
import games.rednblack.editor.renderer.components.LayerMapComponent;
|
||||
import games.rednblack.editor.utils.runtime.EntityUtils;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.editor.view.stage.Sandbox;
|
||||
|
||||
public class LayerJumpCommand extends EntityModifyRevertibleCommand {
|
||||
private static final String CLASS_NAME = "games.rednblack.editor.controller.commands.LayerJumpCommand";
|
||||
public static final String DONE = CLASS_NAME + "DONE";
|
||||
|
||||
private Integer entityId;
|
||||
|
||||
private String sourceName;
|
||||
private String targetName;
|
||||
|
||||
private void backup() {
|
||||
if(entityId == null) {
|
||||
Object[] payload = getNotification().getBody();
|
||||
sourceName = (String) payload[0];
|
||||
targetName = (String) payload[1];
|
||||
entityId = EntityUtils.getEntityId(Sandbox.getInstance().getCurrentViewingEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doAction() {
|
||||
backup();
|
||||
|
||||
int viewingEntity = EntityUtils.getByUniqueId(entityId);
|
||||
LayerMapComponent layerMapComponent = SandboxComponentRetriever.get(viewingEntity, LayerMapComponent.class);
|
||||
targetName = layerMapComponent.jump(sourceName, targetName);
|
||||
|
||||
facade.sendNotification(DONE);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undoAction() {
|
||||
int viewingEntity = EntityUtils.getByUniqueId(entityId);
|
||||
LayerMapComponent layerMapComponent = SandboxComponentRetriever.get(viewingEntity, LayerMapComponent.class);
|
||||
layerMapComponent.jump(sourceName, targetName);
|
||||
|
||||
facade.sendNotification(DONE);
|
||||
}
|
||||
}
|
||||
@@ -74,7 +74,7 @@ public class UILayerBoxMediator extends PanelMediator<UILayerBox> {
|
||||
DeleteLayerCommand.DONE,
|
||||
DeleteLayerCommand.UNDONE,
|
||||
NewLayerCommand.DONE,
|
||||
LayerSwapCommand.DONE,
|
||||
LayerJumpCommand.DONE,
|
||||
RenameLayerCommand.DONE
|
||||
|
||||
|
||||
@@ -136,9 +136,9 @@ public class UILayerBoxMediator extends PanelMediator<UILayerBox> {
|
||||
});
|
||||
break;
|
||||
case UILayerBox.LAYER_DROPPED:
|
||||
facade.sendNotification(MsgAPI.ACTION_SWAP_LAYERS, notification.getBody());
|
||||
facade.sendNotification(MsgAPI.ACTION_JUMP_LAYERS, notification.getBody());
|
||||
break;
|
||||
case LayerSwapCommand.DONE:
|
||||
case LayerJumpCommand.DONE:
|
||||
int index = viewComponent.getCurrentSelectedLayerIndex();
|
||||
initLayerData();
|
||||
viewComponent.setCurrentSelectedLayer(index);
|
||||
|
||||
Reference in New Issue
Block a user