diff --git a/hyperlap2d-common-api b/hyperlap2d-common-api index ccf1bf61..04d28291 160000 --- a/hyperlap2d-common-api +++ b/hyperlap2d-common-api @@ -1 +1 @@ -Subproject commit ccf1bf619510ee005450f72d44c47e1ac8daecb6 +Subproject commit 04d282910e70e4b1722f8f07fd32cb0456075896 diff --git a/src/main/java/games/rednblack/editor/controller/commands/ConvertToCompositeCommand.java b/src/main/java/games/rednblack/editor/controller/commands/ConvertToCompositeCommand.java index eb9eeaf1..ff8e2f96 100644 --- a/src/main/java/games/rednblack/editor/controller/commands/ConvertToCompositeCommand.java +++ b/src/main/java/games/rednblack/editor/controller/commands/ConvertToCompositeCommand.java @@ -101,8 +101,8 @@ public class ConvertToCompositeCommand extends EntityModifyRevertibleCommand { //let everyone know Facade.getInstance().sendNotification(DONE); Facade.getInstance().sendNotification(MsgAPI.NEW_ITEM_ADDED, entity); - sandbox.getSelector().setSelection(entity, true); + facade.sendNotification(MsgAPI.ACTION_SET_SELECTION, entity); } @Override diff --git a/src/main/java/games/rednblack/editor/controller/commands/CutItemsCommand.java b/src/main/java/games/rednblack/editor/controller/commands/CutItemsCommand.java index b2cdb688..b02d58ba 100644 --- a/src/main/java/games/rednblack/editor/controller/commands/CutItemsCommand.java +++ b/src/main/java/games/rednblack/editor/controller/commands/CutItemsCommand.java @@ -57,6 +57,6 @@ public class CutItemsCommand extends EntityModifyRevertibleCommand { Facade.getInstance().sendNotification(MsgAPI.NEW_ITEM_ADDED, entity); } - sandbox.getSelector().setSelections(newEntitiesList, true); + facade.sendNotification(MsgAPI.ACTION_SET_SELECTION, newEntitiesList); } } diff --git a/src/main/java/games/rednblack/editor/controller/commands/DeleteItemsCommand.java b/src/main/java/games/rednblack/editor/controller/commands/DeleteItemsCommand.java index 57d8ae62..73d019e1 100644 --- a/src/main/java/games/rednblack/editor/controller/commands/DeleteItemsCommand.java +++ b/src/main/java/games/rednblack/editor/controller/commands/DeleteItemsCommand.java @@ -84,7 +84,7 @@ public class DeleteItemsCommand extends EntityModifyRevertibleCommand { Facade.getInstance().sendNotification(MsgAPI.NEW_ITEM_ADDED, entity); } - sandbox.getSelector().setSelections(newEntitiesList, true); + facade.sendNotification(MsgAPI.ACTION_SET_SELECTION, newEntitiesList); } public void setItemsToDelete(Set entities) { diff --git a/src/main/java/games/rednblack/editor/controller/commands/LayerJumpCommand.java b/src/main/java/games/rednblack/editor/controller/commands/LayerJumpCommand.java index 78b13ec4..3bde4ee3 100644 --- a/src/main/java/games/rednblack/editor/controller/commands/LayerJumpCommand.java +++ b/src/main/java/games/rednblack/editor/controller/commands/LayerJumpCommand.java @@ -1,13 +1,14 @@ package games.rednblack.editor.controller.commands; import games.rednblack.editor.renderer.components.LayerMapComponent; +import games.rednblack.editor.renderer.systems.LayerSystem; 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"; + public static final String DONE = CLASS_NAME + ".DONE"; private Integer entityId; @@ -31,8 +32,8 @@ public class LayerJumpCommand extends EntityModifyRevertibleCommand { LayerMapComponent layerMapComponent = SandboxComponentRetriever.get(viewingEntity, LayerMapComponent.class); targetName = layerMapComponent.jump(sourceName, targetName); + Sandbox.getInstance().getEngine().getSystem(LayerSystem.class).process(); facade.sendNotification(DONE); - } @Override @@ -41,6 +42,7 @@ public class LayerJumpCommand extends EntityModifyRevertibleCommand { LayerMapComponent layerMapComponent = SandboxComponentRetriever.get(viewingEntity, LayerMapComponent.class); layerMapComponent.jump(sourceName, targetName); + Sandbox.getInstance().getEngine().getSystem(LayerSystem.class).process(); facade.sendNotification(DONE); } } diff --git a/src/main/java/games/rednblack/editor/controller/commands/LayerSwapCommand.java b/src/main/java/games/rednblack/editor/controller/commands/LayerSwapCommand.java index 3f4111b3..f1baab90 100644 --- a/src/main/java/games/rednblack/editor/controller/commands/LayerSwapCommand.java +++ b/src/main/java/games/rednblack/editor/controller/commands/LayerSwapCommand.java @@ -19,6 +19,7 @@ package games.rednblack.editor.controller.commands; import games.rednblack.editor.renderer.components.LayerMapComponent; +import games.rednblack.editor.renderer.systems.LayerSystem; import games.rednblack.editor.utils.runtime.EntityUtils; import games.rednblack.editor.utils.runtime.SandboxComponentRetriever; import games.rednblack.editor.view.stage.Sandbox; @@ -52,8 +53,8 @@ public class LayerSwapCommand extends EntityModifyRevertibleCommand { LayerMapComponent layerMapComponent = SandboxComponentRetriever.get(viewingEntity, LayerMapComponent.class); layerMapComponent.swap(sourceName, targetName); + Sandbox.getInstance().getEngine().getSystem(LayerSystem.class).process(); facade.sendNotification(DONE); - } @Override @@ -62,6 +63,7 @@ public class LayerSwapCommand extends EntityModifyRevertibleCommand { LayerMapComponent layerMapComponent = SandboxComponentRetriever.get(viewingEntity, LayerMapComponent.class); layerMapComponent.swap(targetName, sourceName); + Sandbox.getInstance().getEngine().getSystem(LayerSystem.class).process(); facade.sendNotification(DONE); } } diff --git a/src/main/java/games/rednblack/editor/controller/commands/PasteItemsCommand.java b/src/main/java/games/rednblack/editor/controller/commands/PasteItemsCommand.java index f5875200..cd0d1e83 100644 --- a/src/main/java/games/rednblack/editor/controller/commands/PasteItemsCommand.java +++ b/src/main/java/games/rednblack/editor/controller/commands/PasteItemsCommand.java @@ -26,6 +26,7 @@ import games.rednblack.editor.renderer.components.ZIndexComponent; import games.rednblack.editor.renderer.data.CompositeItemVO; import games.rednblack.editor.renderer.data.MainItemVO; import games.rednblack.editor.renderer.factory.EntityFactory; +import games.rednblack.editor.renderer.systems.LayerSystem; import games.rednblack.editor.renderer.utils.HyperJson; import games.rednblack.editor.utils.runtime.EntityUtils; import games.rednblack.editor.utils.runtime.SandboxComponentRetriever; @@ -71,12 +72,13 @@ public class PasteItemsCommand extends EntityModifyRevertibleCommand { transformComponent.x += diff.x; transformComponent.y += diff.y; ZIndexComponent zIndexComponent = SandboxComponentRetriever.get(entity, ZIndexComponent.class); -// UILayerBoxMediator layerBoxMediator = facade.retrieveMediator(UILayerBoxMediator.NAME); zIndexComponent.layerName = layerBoxMediator.getCurrentSelectedLayerName(); + Sandbox.getInstance().getEngine().getSystem(LayerSystem.class).process(); Facade.getInstance().sendNotification(MsgAPI.NEW_ITEM_ADDED, entity); pastedEntityIds.add(EntityUtils.getEntityId(entity)); } - sandbox.getSelector().setSelections(newEntitiesList, true); + + facade.sendNotification(MsgAPI.ACTION_SET_SELECTION, newEntitiesList); } @Override diff --git a/src/main/java/games/rednblack/editor/controller/commands/SetSelectionCommand.java b/src/main/java/games/rednblack/editor/controller/commands/SetSelectionCommand.java index 51975cff..def8a85e 100644 --- a/src/main/java/games/rednblack/editor/controller/commands/SetSelectionCommand.java +++ b/src/main/java/games/rednblack/editor/controller/commands/SetSelectionCommand.java @@ -34,7 +34,7 @@ import java.util.Set; public class SetSelectionCommand extends RevertibleCommand { private static final String CLASS_NAME = "games.rednblack.editor.controller.commands.SetSelectionCommand"; - public static final String DONE = CLASS_NAME + "DONE"; + public static final String DONE = CLASS_NAME + ".DONE"; private Array previousSelectionIds; @@ -44,29 +44,35 @@ public class SetSelectionCommand extends RevertibleCommand { HashSet previousSelection = new HashSet<>(Sandbox.getInstance().getSelector().getSelectedItems()); previousSelectionIds = EntityUtils.getEntityId(previousSelection); - Set items = getNotification().getBody(); + if (getNotification().getBody() instanceof Integer) { + int entity = getNotification().getBody(); + sandbox.getSelector().setSelection(entity, true); + } else { + Set items = getNotification().getBody(); - if(items == null) { - // deselect all - sandbox.getSelector().setSelections(items, true); - facade.sendNotification(DONE); - return; - } + if(items == null) { + // deselect all + sandbox.getSelector().setSelections(items, true); + facade.sendNotification(DONE); + return; + } - // check if items are in viewable element, if no - cancel - NodeComponent nodeComponent = SandboxComponentRetriever.get(sandbox.getCurrentViewingEntity(), NodeComponent.class); - for (Iterator iterator = items.iterator(); iterator.hasNext();) { - int item = iterator.next(); - if(!nodeComponent.children.contains(item, false)) { - iterator.remove(); + // check if items are in viewable element, if no - cancel + NodeComponent nodeComponent = SandboxComponentRetriever.get(sandbox.getCurrentViewingEntity(), NodeComponent.class); + for (Iterator iterator = items.iterator(); iterator.hasNext();) { + int item = iterator.next(); + if(!nodeComponent.children.contains(item, false)) { + iterator.remove(); + } + } + + if(items.size() == 0) { + cancel(); + } else { + sandbox.getSelector().setSelections(items, true); } } - if(items.size() == 0) { - cancel(); - } else { - sandbox.getSelector().setSelections(items, true); - } facade.sendNotification(DONE); } diff --git a/src/main/java/games/rednblack/editor/view/ui/box/UIItemsTreeBox.java b/src/main/java/games/rednblack/editor/view/ui/box/UIItemsTreeBox.java index 5208b223..62f06eaa 100644 --- a/src/main/java/games/rednblack/editor/view/ui/box/UIItemsTreeBox.java +++ b/src/main/java/games/rednblack/editor/view/ui/box/UIItemsTreeBox.java @@ -69,10 +69,11 @@ public class UIItemsTreeBox extends UICollapsibleBox { private final Vector2 tmp = new Vector2(); public UIItemsTreeBox() { - super("Items Tree", 180); + super("Items Tree", 190); setMovable(false); facade = Facade.getInstance(); treeTable = new VisTable(); + treeTable.setFillParent(true); treeTable.left(); zUp = StandardWidgetsFactory.createImageButton("arrow-button"); StandardWidgetsFactory.addTooltip(zUp, "Move Z-Index Up"); @@ -109,7 +110,7 @@ public class UIItemsTreeBox extends UICollapsibleBox { tree = new VisTree<>(); scroller = StandardWidgetsFactory.createScrollPane(tree); scroller.setFlickScroll(false); - treeTable.add(scroller).width(170).padTop(5).maxHeight(550).colspan(2); + treeTable.add(scroller).growX().padTop(5).maxHeight(550).colspan(2); // rootTreeNode = addTreeRoot(rootScene, null); rootTreeNode.setExpanded(true); diff --git a/src/main/java/games/rednblack/editor/view/ui/box/UIItemsTreeBoxMediator.java b/src/main/java/games/rednblack/editor/view/ui/box/UIItemsTreeBoxMediator.java index 42a9695f..5fe3362b 100644 --- a/src/main/java/games/rednblack/editor/view/ui/box/UIItemsTreeBoxMediator.java +++ b/src/main/java/games/rednblack/editor/view/ui/box/UIItemsTreeBoxMediator.java @@ -2,10 +2,7 @@ package games.rednblack.editor.view.ui.box; import com.badlogic.gdx.scenes.scene2d.utils.Selection; import com.badlogic.gdx.utils.Array; -import games.rednblack.editor.controller.commands.AddSelectionCommand; -import games.rednblack.editor.controller.commands.ItemsMoveCommand; -import games.rednblack.editor.controller.commands.ReleaseSelectionCommand; -import games.rednblack.editor.controller.commands.SetSelectionCommand; +import games.rednblack.editor.controller.commands.*; import games.rednblack.editor.controller.commands.resource.DeleteResourceCommand; import games.rednblack.editor.renderer.data.LayerItemVO; import games.rednblack.editor.utils.runtime.EntityUtils; @@ -43,7 +40,9 @@ public class UIItemsTreeBoxMediator extends PanelMediator { MsgAPI.DELETE_ITEMS_COMMAND_DONE); interests.add(MsgAPI.ACTION_Z_INDEX_CHANGED, MsgAPI.ACTION_CAMERA_CHANGE_COMPOSITE, - MsgAPI.ITEM_DATA_UPDATED); + MsgAPI.ITEM_DATA_UPDATED, + LayerJumpCommand.DONE); + interests.add(LayerSwapCommand.DONE); } @Override @@ -64,6 +63,8 @@ public class UIItemsTreeBoxMediator extends PanelMediator { case MsgAPI.NEW_ITEM_ADDED: case MsgAPI.DELETE_ITEMS_COMMAND_DONE: case DeleteResourceCommand.DONE: + case LayerJumpCommand.DONE: + case LayerSwapCommand.DONE: rootEntity = sandbox.getCurrentViewingEntity(); if (notification.getType() == null || !notification.getType().equals(ItemsMoveCommand.TAG)) viewComponent.update(rootEntity);