From c05aede8b020a6ecdf94c461dc153892cd556c51 Mon Sep 17 00:00:00 2001 From: fgnm Date: Sat, 16 Sep 2023 19:35:10 +0200 Subject: [PATCH] New `MainItemComponent#uniqueId` management, change from integer to a non persistent random string --- CHANGES | 1 + hyperlap2d-runtime-libgdx | 2 +- .../commands/AddSelectionCommand.java | 2 +- .../commands/AddToLibraryCommand.java | 6 ++--- .../CompositeCameraChangeCommand.java | 4 +-- .../commands/ConvertToCompositeCommand.java | 8 +++--- .../commands/CreateItemCommand.java | 2 +- .../commands/CustomVariableModifyCommand.java | 2 +- .../commands/DeleteItemsCommand.java | 25 +++---------------- .../EntityModifyRevertibleCommand.java | 3 +-- .../ItemChildrenTransformCommand.java | 12 ++++----- .../commands/ItemTransformCommand.java | 2 +- .../controller/commands/ItemsMoveCommand.java | 10 +++++--- .../controller/commands/LayerJumpCommand.java | 2 +- .../controller/commands/LayerSwapCommand.java | 2 +- .../commands/PasteItemsCommand.java | 5 ++-- .../commands/ReleaseSelectionCommand.java | 2 +- .../commands/SetSelectionCommand.java | 2 +- .../UpdateEntityComponentsCommand.java | 2 +- .../commands/UpdatePolygonDataCommand.java | 2 +- .../component/ReplaceRegionCommand.java | 2 +- .../component/ReplaceSpineCommand.java | 2 +- .../ReplaceSpriteAnimationCommand.java | 2 +- .../component/UpdateCircleShapeCommand.java | 2 +- .../component/UpdateCompositeDataCommand.java | 2 +- .../component/UpdateImageItemDataCommand.java | 2 +- .../component/UpdateLabelDataCommand.java | 2 +- .../component/UpdateLightBodyDataCommand.java | 2 +- .../component/UpdateLightDataCommand.java | 2 +- .../component/UpdateParticleDataCommand.java | 2 +- .../component/UpdatePhysicsDataCommand.java | 2 +- .../UpdatePolygonVerticesCommand.java | 2 +- .../component/UpdateSensorDataCommand.java | 2 +- .../component/UpdateShaderDataCommand.java | 2 +- .../component/UpdateSpineDataCommand.java | 2 +- .../UpdateSpriteAnimationDataCommand.java | 2 +- .../component/UpdateTalosDataCommand.java | 2 +- .../migrations/migrators/VersionMigTo100.java | 1 - .../rednblack/editor/factory/ItemFactory.java | 1 - .../editor/utils/MoveCommandBuilder.java | 3 ++- .../editor/utils/runtime/EntityUtils.java | 12 ++++----- .../view/stage/tools/SelectionTool.java | 4 +-- .../transformStrategy/CompositeStrategy.java | 14 +++++------ .../view/ui/box/UICompositeHierarchy.java | 2 +- .../ui/box/UICompositeHierarchyMediator.java | 8 +++--- .../editor/view/ui/box/UIItemsTreeBox.java | 8 +++--- .../view/ui/box/UIItemsTreeBoxMediator.java | 2 +- .../editor/view/ui/box/UIItemsTreeNode.java | 2 +- .../editor/view/ui/box/UIItemsTreeValue.java | 6 ++--- .../panels/UIBasicItemProperties.java | 2 +- 50 files changed, 88 insertions(+), 107 deletions(-) diff --git a/CHANGES b/CHANGES index e25ca0af..503008b3 100644 --- a/CHANGES +++ b/CHANGES @@ -9,6 +9,7 @@ - Bug fixing and stability improvements **Runtime** +- [BREAK CHANGE] New `MainItemComponent#uniqueId` management, change from integer to a non persistent random string - Chained Entities and Spine' SkeletonRenderSeparator - Improved PhysicsActions. Add `PhysicsActions#transformTo` and `PhysicsActions#transformBy` - Fixed physic's step diff --git a/hyperlap2d-runtime-libgdx b/hyperlap2d-runtime-libgdx index c8b4af72..61c97ca4 160000 --- a/hyperlap2d-runtime-libgdx +++ b/hyperlap2d-runtime-libgdx @@ -1 +1 @@ -Subproject commit c8b4af722d0cfb7cac277e84bea42a8266b7955c +Subproject commit 61c97ca4fb09dabcbdff32deb8f28456f19fd3b3 diff --git a/src/main/java/games/rednblack/editor/controller/commands/AddSelectionCommand.java b/src/main/java/games/rednblack/editor/controller/commands/AddSelectionCommand.java index 3845cf35..0aa5f716 100644 --- a/src/main/java/games/rednblack/editor/controller/commands/AddSelectionCommand.java +++ b/src/main/java/games/rednblack/editor/controller/commands/AddSelectionCommand.java @@ -32,7 +32,7 @@ public class AddSelectionCommand extends RevertibleCommand { private static final String CLASS_NAME = "games.rednblack.editor.controller.commands.AddSelectionCommand"; public static final String DONE = CLASS_NAME + "DONE"; - private Array entityIds; + private Array entityIds; @Override public void doAction() { diff --git a/src/main/java/games/rednblack/editor/controller/commands/AddToLibraryCommand.java b/src/main/java/games/rednblack/editor/controller/commands/AddToLibraryCommand.java index d3eff10e..6e2594b9 100644 --- a/src/main/java/games/rednblack/editor/controller/commands/AddToLibraryCommand.java +++ b/src/main/java/games/rednblack/editor/controller/commands/AddToLibraryCommand.java @@ -36,14 +36,15 @@ public class AddToLibraryCommand extends HistoricRevertibleCommand { private String createdLibraryItemName; private CompositeItemVO overwritten; private String prevName; - private Integer entityId; + private String entityId; @Override public void doAction() { Object[] payload = getNotification().getBody(); int item = ((int) payload[0]); - entityId = EntityUtils.getEntityId(item); + if (entityId == null) + entityId = EntityUtils.getEntityId(item); createdLibraryItemName = (String) payload[1]; MainItemComponent mainItemComponent = SandboxComponentRetriever.get(item, MainItemComponent.class); @@ -58,7 +59,6 @@ public class AddToLibraryCommand extends HistoricRevertibleCommand { CompositeItemVO newVO = new CompositeItemVO(); newVO.loadFromEntity(item, sandbox.getEngine(), sandbox.sceneControl.sceneLoader.getEntityFactory()); - newVO.cleanIds(); libraryItems.put(createdLibraryItemName, newVO); //mark this entity as belonging to library diff --git a/src/main/java/games/rednblack/editor/controller/commands/CompositeCameraChangeCommand.java b/src/main/java/games/rednblack/editor/controller/commands/CompositeCameraChangeCommand.java index 1075250d..5aeeea09 100644 --- a/src/main/java/games/rednblack/editor/controller/commands/CompositeCameraChangeCommand.java +++ b/src/main/java/games/rednblack/editor/controller/commands/CompositeCameraChangeCommand.java @@ -34,8 +34,8 @@ public class CompositeCameraChangeCommand extends RevertibleCommand { private static final String CLASS_NAME = "games.rednblack.editor.controller.commands.CompositeCameraChangeCommand"; public static final String DONE = CLASS_NAME + "DONE"; - private Integer previousViewEntityId; - private Integer enteringInto; + private String previousViewEntityId; + private String enteringInto; private boolean wasPrevSelected = false; 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 ff8e2f96..76ff0e4b 100644 --- a/src/main/java/games/rednblack/editor/controller/commands/ConvertToCompositeCommand.java +++ b/src/main/java/games/rednblack/editor/controller/commands/ConvertToCompositeCommand.java @@ -41,10 +41,10 @@ public class ConvertToCompositeCommand extends EntityModifyRevertibleCommand { private static final String CLASS_NAME = "games.rednblack.editor.controller.commands.ConvertToCompositeCommand"; public static final String DONE = CLASS_NAME + "DONE"; - protected Integer entityId; - protected Integer parentEntityId; + protected String entityId; + protected String parentEntityId; - protected HashMap layersBackup; + protected HashMap layersBackup; @Override public void doAction() { @@ -57,7 +57,7 @@ public class ConvertToCompositeCommand extends EntityModifyRevertibleCommand { layersBackup = new HashMap<>(); for(int entity: entities) { ZIndexComponent zIndexComponent = SandboxComponentRetriever.get(entity, ZIndexComponent.class); - int tmpId = EntityUtils.getEntityId(entity); + String tmpId = EntityUtils.getEntityId(entity); layersBackup.put(tmpId, zIndexComponent.layerName); } } diff --git a/src/main/java/games/rednblack/editor/controller/commands/CreateItemCommand.java b/src/main/java/games/rednblack/editor/controller/commands/CreateItemCommand.java index f00df22a..7d5465e9 100644 --- a/src/main/java/games/rednblack/editor/controller/commands/CreateItemCommand.java +++ b/src/main/java/games/rednblack/editor/controller/commands/CreateItemCommand.java @@ -36,7 +36,7 @@ import java.util.Set; */ public class CreateItemCommand extends EntityModifyRevertibleCommand { - private Integer entityId; + private String entityId; private int entityType; private String serializedEntity; diff --git a/src/main/java/games/rednblack/editor/controller/commands/CustomVariableModifyCommand.java b/src/main/java/games/rednblack/editor/controller/commands/CustomVariableModifyCommand.java index 93cfa4d3..0f76cff4 100644 --- a/src/main/java/games/rednblack/editor/controller/commands/CustomVariableModifyCommand.java +++ b/src/main/java/games/rednblack/editor/controller/commands/CustomVariableModifyCommand.java @@ -12,7 +12,7 @@ public class CustomVariableModifyCommand extends EntityModifyRevertibleCommand { private static final String CLASS_NAME = "games.rednblack.editor.controller.commands.CustomVariableModifyCommand"; public static final String DONE = CLASS_NAME + "DONE"; - private Integer entityId; + private String entityId; private boolean isAdding; private String key; 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 73d019e1..0d04f579 100644 --- a/src/main/java/games/rednblack/editor/controller/commands/DeleteItemsCommand.java +++ b/src/main/java/games/rednblack/editor/controller/commands/DeleteItemsCommand.java @@ -1,21 +1,3 @@ -/* - * ****************************************************************************** - * * Copyright 2015 See AUTHORS file. - * * - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * ***************************************************************************** - */ - package games.rednblack.editor.controller.commands; import com.badlogic.gdx.utils.Array; @@ -36,7 +18,7 @@ import java.util.Set; public class DeleteItemsCommand extends EntityModifyRevertibleCommand { private String backup; - private Array entityIdsToDelete; + private Array entityIdsToDelete; private void backup() { Set entitySet = new HashSet<>(); @@ -47,7 +29,7 @@ public class DeleteItemsCommand extends EntityModifyRevertibleCommand { entityIdsToDelete.add(EntityUtils.getEntityId(entity)); } } else { - for(Integer entityId: entityIdsToDelete) { + for(String entityId: entityIdsToDelete) { entitySet.add(EntityUtils.getByUniqueId(entityId)); } } @@ -60,7 +42,7 @@ public class DeleteItemsCommand extends EntityModifyRevertibleCommand { backup(); FollowersUIMediator followersUIMediator = Facade.getInstance().retrieveMediator(FollowersUIMediator.NAME); - for (Integer entityId : entityIdsToDelete) { + for (String entityId : entityIdsToDelete) { int item = EntityUtils.getByUniqueId(entityId); followersUIMediator.removeFollower(item); sandbox.getEngine().delete(item); @@ -76,7 +58,6 @@ public class DeleteItemsCommand extends EntityModifyRevertibleCommand { public void undoAction() { Json json = HyperJson.getJson(); CompositeItemVO compositeVO = json.fromJson(CompositeItemVO.class, backup); - compositeVO.cleanIds(); Set newEntitiesList = PasteItemsCommand.createEntitiesFromVO(compositeVO); sandbox.getEngine().process(); diff --git a/src/main/java/games/rednblack/editor/controller/commands/EntityModifyRevertibleCommand.java b/src/main/java/games/rednblack/editor/controller/commands/EntityModifyRevertibleCommand.java index 934b885f..c9d4761b 100644 --- a/src/main/java/games/rednblack/editor/controller/commands/EntityModifyRevertibleCommand.java +++ b/src/main/java/games/rednblack/editor/controller/commands/EntityModifyRevertibleCommand.java @@ -47,7 +47,7 @@ public abstract class EntityModifyRevertibleCommand extends HistoricRevertibleCo } protected void postChange() { - Integer parentId = EntityUtils.getEntityId(sandbox.getCurrentViewingEntity()); + String parentId = EntityUtils.getEntityId(sandbox.getCurrentViewingEntity()); int entity = EntityUtils.getByUniqueId(parentId); // Update item library data if it was in library @@ -60,7 +60,6 @@ public abstract class EntityModifyRevertibleCommand extends HistoricRevertibleCo if (libraryItems.containsKey(mainItemComponent.libraryLink)) { CompositeItemVO itemVO = new CompositeItemVO(); itemVO.loadFromEntity(entity, sandbox.getEngine(), sandbox.sceneControl.sceneLoader.getEntityFactory()); - itemVO.cleanIds(); libraryItems.put(mainItemComponent.libraryLink, itemVO); } diff --git a/src/main/java/games/rednblack/editor/controller/commands/ItemChildrenTransformCommand.java b/src/main/java/games/rednblack/editor/controller/commands/ItemChildrenTransformCommand.java index 0b010b98..f0109285 100644 --- a/src/main/java/games/rednblack/editor/controller/commands/ItemChildrenTransformCommand.java +++ b/src/main/java/games/rednblack/editor/controller/commands/ItemChildrenTransformCommand.java @@ -17,8 +17,8 @@ import java.util.Map; */ public class ItemChildrenTransformCommand extends EntityModifyRevertibleCommand { - private HashMap prevPosMap = new HashMap<>(); - private HashMap parentPositionAndSizeMap = new HashMap<>(); + private final HashMap prevPosMap = new HashMap<>(); + private final HashMap parentPositionAndSizeMap = new HashMap<>(); private int entity; private Vector2 prevLo; @@ -49,8 +49,8 @@ public class ItemChildrenTransformCommand extends EntityModifyRevertibleCommand } private void undoActionOnParent() { - Map.Entry entry = parentPositionAndSizeMap.entrySet().iterator().next(); - Integer entityUniqueId = entry.getKey(); + Map.Entry entry = parentPositionAndSizeMap.entrySet().iterator().next(); + String entityUniqueId = entry.getKey(); PositionSize positionSize = entry.getValue(); Vector2 prevLocation = positionSize.position; Vector2 prevSize = positionSize.size; @@ -91,8 +91,8 @@ public class ItemChildrenTransformCommand extends EntityModifyRevertibleCommand @Override public void undoAction() { undoActionOnParent(); - for (Map.Entry entry : prevPosMap.entrySet()) { - Integer entityUniqueId = entry.getKey(); + for (Map.Entry entry : prevPosMap.entrySet()) { + String entityUniqueId = entry.getKey(); Vector2 oldPosition = entry.getValue(); int entity = EntityUtils.getByUniqueId(entityUniqueId); TransformComponent transformComponent = SandboxComponentRetriever.get(entity, TransformComponent.class); diff --git a/src/main/java/games/rednblack/editor/controller/commands/ItemTransformCommand.java b/src/main/java/games/rednblack/editor/controller/commands/ItemTransformCommand.java index 3b5db89d..aa773967 100644 --- a/src/main/java/games/rednblack/editor/controller/commands/ItemTransformCommand.java +++ b/src/main/java/games/rednblack/editor/controller/commands/ItemTransformCommand.java @@ -16,7 +16,7 @@ public class ItemTransformCommand extends EntityModifyRevertibleCommand { private Array payload; - private Integer entityId; + private String entityId; @Override public void doAction() { diff --git a/src/main/java/games/rednblack/editor/controller/commands/ItemsMoveCommand.java b/src/main/java/games/rednblack/editor/controller/commands/ItemsMoveCommand.java index 874adcb7..b2fd1d5c 100644 --- a/src/main/java/games/rednblack/editor/controller/commands/ItemsMoveCommand.java +++ b/src/main/java/games/rednblack/editor/controller/commands/ItemsMoveCommand.java @@ -36,7 +36,7 @@ public class ItemsMoveCommand extends EntityModifyRevertibleCommand { public static final String TAG = ItemsMoveCommand.class.getCanonicalName(); - private HashMap prevLocations = new HashMap<>(); + private final HashMap prevLocations = new HashMap<>(); @Override public void doAction() { @@ -45,7 +45,9 @@ public class ItemsMoveCommand extends EntityModifyRevertibleCommand { for(int i = 0; i < payload.size; i++) { Object[] itemData = payload.get(i); - int entity = (int) itemData[0]; + String entityUniqueId = (String) itemData[0]; + + int entity = EntityUtils.getByUniqueId(entityUniqueId); Vector2 newLocation = (Vector2) itemData[1]; TransformComponent transformComponent = SandboxComponentRetriever.get(entity, TransformComponent.class); @@ -66,8 +68,8 @@ public class ItemsMoveCommand extends EntityModifyRevertibleCommand { @Override public void undoAction() { - for (Map.Entry entry : prevLocations.entrySet()) { - Integer entityUniqueId = entry.getKey(); + for (Map.Entry entry : prevLocations.entrySet()) { + String entityUniqueId = entry.getKey(); Vector2 prevLocation = entry.getValue(); int entity = EntityUtils.getByUniqueId(entityUniqueId); 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 3bde4ee3..484e5fc8 100644 --- a/src/main/java/games/rednblack/editor/controller/commands/LayerJumpCommand.java +++ b/src/main/java/games/rednblack/editor/controller/commands/LayerJumpCommand.java @@ -10,7 +10,7 @@ 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 entityId; private String sourceName; private String targetName; 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 f1baab90..82776b4c 100644 --- a/src/main/java/games/rednblack/editor/controller/commands/LayerSwapCommand.java +++ b/src/main/java/games/rednblack/editor/controller/commands/LayerSwapCommand.java @@ -31,7 +31,7 @@ public class LayerSwapCommand extends EntityModifyRevertibleCommand { private static final String CLASS_NAME = "games.rednblack.editor.controller.commands.LayerSwapCommand"; public static final String DONE = CLASS_NAME + "DONE"; - private Integer entityId; + private String entityId; private String sourceName; private String targetName; 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 cd0d1e83..2f61a31d 100644 --- a/src/main/java/games/rednblack/editor/controller/commands/PasteItemsCommand.java +++ b/src/main/java/games/rednblack/editor/controller/commands/PasteItemsCommand.java @@ -44,7 +44,7 @@ import java.util.Set; */ public class PasteItemsCommand extends EntityModifyRevertibleCommand { - private Array pastedEntityIds = new Array<>(); + private final Array pastedEntityIds = new Array<>(); @Override public void doAction() { @@ -63,7 +63,6 @@ public class PasteItemsCommand extends EntityModifyRevertibleCommand { Json json = HyperJson.getJson(); CompositeItemVO compositeVO = json.fromJson(CompositeItemVO.class, (String) payload[1]); - compositeVO.cleanIds(); Set newEntitiesList = createEntitiesFromVO(compositeVO); sandbox.getEngine().process(); @@ -84,7 +83,7 @@ public class PasteItemsCommand extends EntityModifyRevertibleCommand { @Override public void undoAction() { FollowersUIMediator followersUIMediator = Facade.getInstance().retrieveMediator(FollowersUIMediator.NAME); - for (Integer entityId : pastedEntityIds) { + for (String entityId : pastedEntityIds) { int entity = EntityUtils.getByUniqueId(entityId); followersUIMediator.removeFollower(entity); sandbox.getEngine().delete(entity); diff --git a/src/main/java/games/rednblack/editor/controller/commands/ReleaseSelectionCommand.java b/src/main/java/games/rednblack/editor/controller/commands/ReleaseSelectionCommand.java index 8ec73377..f6408577 100644 --- a/src/main/java/games/rednblack/editor/controller/commands/ReleaseSelectionCommand.java +++ b/src/main/java/games/rednblack/editor/controller/commands/ReleaseSelectionCommand.java @@ -34,7 +34,7 @@ public class ReleaseSelectionCommand extends RevertibleCommand { private static final String CLASS_NAME = "games.rednblack.editor.controller.commands.ReleaseSelectionCommand"; public static final String DONE = CLASS_NAME + "DONE"; - private Array entityIds; + private Array entityIds; @Override public void doAction() { 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 def8a85e..94914c30 100644 --- a/src/main/java/games/rednblack/editor/controller/commands/SetSelectionCommand.java +++ b/src/main/java/games/rednblack/editor/controller/commands/SetSelectionCommand.java @@ -36,7 +36,7 @@ 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"; - private Array previousSelectionIds; + private Array previousSelectionIds; @Override public void doAction() { diff --git a/src/main/java/games/rednblack/editor/controller/commands/UpdateEntityComponentsCommand.java b/src/main/java/games/rednblack/editor/controller/commands/UpdateEntityComponentsCommand.java index 6b77d7b4..bdf8ed9a 100644 --- a/src/main/java/games/rednblack/editor/controller/commands/UpdateEntityComponentsCommand.java +++ b/src/main/java/games/rednblack/editor/controller/commands/UpdateEntityComponentsCommand.java @@ -32,7 +32,7 @@ import games.rednblack.puremvc.Facade; public class UpdateEntityComponentsCommand extends EntityModifyRevertibleCommand { private Array backupComponents = new Array<>(); - private Integer entityId; + private String entityId; @Override public void doAction() { diff --git a/src/main/java/games/rednblack/editor/controller/commands/UpdatePolygonDataCommand.java b/src/main/java/games/rednblack/editor/controller/commands/UpdatePolygonDataCommand.java index e9b9b114..9ea377f9 100644 --- a/src/main/java/games/rednblack/editor/controller/commands/UpdatePolygonDataCommand.java +++ b/src/main/java/games/rednblack/editor/controller/commands/UpdatePolygonDataCommand.java @@ -12,7 +12,7 @@ import games.rednblack.puremvc.Facade; public class UpdatePolygonDataCommand extends EntityModifyRevertibleCommand { private boolean openPathBackup; - private int entityId; + private String entityId; @Override public void doAction() { diff --git a/src/main/java/games/rednblack/editor/controller/commands/component/ReplaceRegionCommand.java b/src/main/java/games/rednblack/editor/controller/commands/component/ReplaceRegionCommand.java index 18086a96..601baa4e 100644 --- a/src/main/java/games/rednblack/editor/controller/commands/component/ReplaceRegionCommand.java +++ b/src/main/java/games/rednblack/editor/controller/commands/component/ReplaceRegionCommand.java @@ -14,7 +14,7 @@ import games.rednblack.puremvc.Facade; public class ReplaceRegionCommand extends EntityModifyRevertibleCommand { - private Integer entityId; + private String entityId; private String backupRegionName; private TextureRegion backupRegion; diff --git a/src/main/java/games/rednblack/editor/controller/commands/component/ReplaceSpineCommand.java b/src/main/java/games/rednblack/editor/controller/commands/component/ReplaceSpineCommand.java index e3475454..5b297916 100644 --- a/src/main/java/games/rednblack/editor/controller/commands/component/ReplaceSpineCommand.java +++ b/src/main/java/games/rednblack/editor/controller/commands/component/ReplaceSpineCommand.java @@ -12,7 +12,7 @@ import games.rednblack.puremvc.Facade; public class ReplaceSpineCommand extends EntityModifyRevertibleCommand { - private Integer entityId; + private String entityId; private String backupAnimName; private SkeletonJson backupSkeletonJson; private Skeleton backupSkeleton; diff --git a/src/main/java/games/rednblack/editor/controller/commands/component/ReplaceSpriteAnimationCommand.java b/src/main/java/games/rednblack/editor/controller/commands/component/ReplaceSpriteAnimationCommand.java index 714d65a8..e49cce2e 100644 --- a/src/main/java/games/rednblack/editor/controller/commands/component/ReplaceSpriteAnimationCommand.java +++ b/src/main/java/games/rednblack/editor/controller/commands/component/ReplaceSpriteAnimationCommand.java @@ -19,7 +19,7 @@ import games.rednblack.puremvc.Facade; public class ReplaceSpriteAnimationCommand extends EntityModifyRevertibleCommand { - private Integer entityId; + private String entityId; private String backupAnimName; private Array backupAnimRegions; diff --git a/src/main/java/games/rednblack/editor/controller/commands/component/UpdateCircleShapeCommand.java b/src/main/java/games/rednblack/editor/controller/commands/component/UpdateCircleShapeCommand.java index 659484cd..679cd752 100644 --- a/src/main/java/games/rednblack/editor/controller/commands/component/UpdateCircleShapeCommand.java +++ b/src/main/java/games/rednblack/editor/controller/commands/component/UpdateCircleShapeCommand.java @@ -9,7 +9,7 @@ import games.rednblack.h2d.common.MsgAPI; import games.rednblack.puremvc.Facade; public class UpdateCircleShapeCommand extends EntityModifyRevertibleCommand { - private int entityId; + private String entityId; private float radiusBackup; @Override diff --git a/src/main/java/games/rednblack/editor/controller/commands/component/UpdateCompositeDataCommand.java b/src/main/java/games/rednblack/editor/controller/commands/component/UpdateCompositeDataCommand.java index 701f1f5a..e5929fd9 100644 --- a/src/main/java/games/rednblack/editor/controller/commands/component/UpdateCompositeDataCommand.java +++ b/src/main/java/games/rednblack/editor/controller/commands/component/UpdateCompositeDataCommand.java @@ -10,7 +10,7 @@ import games.rednblack.h2d.common.MsgAPI; import games.rednblack.puremvc.Facade; public class UpdateCompositeDataCommand extends EntityModifyRevertibleCommand { - private Integer entityId; + private String entityId; private CompositeItemVO backup; @Override diff --git a/src/main/java/games/rednblack/editor/controller/commands/component/UpdateImageItemDataCommand.java b/src/main/java/games/rednblack/editor/controller/commands/component/UpdateImageItemDataCommand.java index 46c82d59..bed0d7ad 100644 --- a/src/main/java/games/rednblack/editor/controller/commands/component/UpdateImageItemDataCommand.java +++ b/src/main/java/games/rednblack/editor/controller/commands/component/UpdateImageItemDataCommand.java @@ -11,7 +11,7 @@ import games.rednblack.puremvc.Facade; public class UpdateImageItemDataCommand extends EntityModifyRevertibleCommand { - private Integer entityId; + private String entityId; private SimpleImageVO backup; @Override diff --git a/src/main/java/games/rednblack/editor/controller/commands/component/UpdateLabelDataCommand.java b/src/main/java/games/rednblack/editor/controller/commands/component/UpdateLabelDataCommand.java index 32c358b4..1e6edab0 100644 --- a/src/main/java/games/rednblack/editor/controller/commands/component/UpdateLabelDataCommand.java +++ b/src/main/java/games/rednblack/editor/controller/commands/component/UpdateLabelDataCommand.java @@ -34,7 +34,7 @@ import games.rednblack.h2d.common.MsgAPI; */ public class UpdateLabelDataCommand extends EntityModifyRevertibleCommand { - Integer entityId; + String entityId; String prevFontName; int prevFontSize; diff --git a/src/main/java/games/rednblack/editor/controller/commands/component/UpdateLightBodyDataCommand.java b/src/main/java/games/rednblack/editor/controller/commands/component/UpdateLightBodyDataCommand.java index a74b92ac..c8606bc5 100644 --- a/src/main/java/games/rednblack/editor/controller/commands/component/UpdateLightBodyDataCommand.java +++ b/src/main/java/games/rednblack/editor/controller/commands/component/UpdateLightBodyDataCommand.java @@ -10,7 +10,7 @@ import games.rednblack.puremvc.Facade; public class UpdateLightBodyDataCommand extends EntityModifyRevertibleCommand { - private Integer entityId; + private String entityId; private LightBodyDataVO backup; @Override diff --git a/src/main/java/games/rednblack/editor/controller/commands/component/UpdateLightDataCommand.java b/src/main/java/games/rednblack/editor/controller/commands/component/UpdateLightDataCommand.java index c71c6bfd..8ef2bc67 100644 --- a/src/main/java/games/rednblack/editor/controller/commands/component/UpdateLightDataCommand.java +++ b/src/main/java/games/rednblack/editor/controller/commands/component/UpdateLightDataCommand.java @@ -28,7 +28,7 @@ import games.rednblack.puremvc.Facade; public class UpdateLightDataCommand extends EntityModifyRevertibleCommand { - private Integer entityId; + private String entityId; private LightVO backup; @Override diff --git a/src/main/java/games/rednblack/editor/controller/commands/component/UpdateParticleDataCommand.java b/src/main/java/games/rednblack/editor/controller/commands/component/UpdateParticleDataCommand.java index ce9966d5..e5f4162d 100644 --- a/src/main/java/games/rednblack/editor/controller/commands/component/UpdateParticleDataCommand.java +++ b/src/main/java/games/rednblack/editor/controller/commands/component/UpdateParticleDataCommand.java @@ -10,7 +10,7 @@ import games.rednblack.puremvc.Facade; public class UpdateParticleDataCommand extends EntityModifyRevertibleCommand { - private Integer entityId; + private String entityId; private ParticleEffectVO backup; @Override diff --git a/src/main/java/games/rednblack/editor/controller/commands/component/UpdatePhysicsDataCommand.java b/src/main/java/games/rednblack/editor/controller/commands/component/UpdatePhysicsDataCommand.java index 212a95da..9e81b086 100644 --- a/src/main/java/games/rednblack/editor/controller/commands/component/UpdatePhysicsDataCommand.java +++ b/src/main/java/games/rednblack/editor/controller/commands/component/UpdatePhysicsDataCommand.java @@ -10,7 +10,7 @@ import games.rednblack.puremvc.Facade; public class UpdatePhysicsDataCommand extends EntityModifyRevertibleCommand { - private Integer entityId; + private String entityId; private PhysicsBodyDataVO backup; @Override diff --git a/src/main/java/games/rednblack/editor/controller/commands/component/UpdatePolygonVerticesCommand.java b/src/main/java/games/rednblack/editor/controller/commands/component/UpdatePolygonVerticesCommand.java index 08d5e075..c240312a 100644 --- a/src/main/java/games/rednblack/editor/controller/commands/component/UpdatePolygonVerticesCommand.java +++ b/src/main/java/games/rednblack/editor/controller/commands/component/UpdatePolygonVerticesCommand.java @@ -12,7 +12,7 @@ import games.rednblack.puremvc.Facade; public class UpdatePolygonVerticesCommand extends EntityModifyRevertibleCommand { - private Integer entityId; + private String entityId; private Vector2[][] polygonizedDataFrom; private Vector2[][] polygonizedDataTo; private Array dataFrom; diff --git a/src/main/java/games/rednblack/editor/controller/commands/component/UpdateSensorDataCommand.java b/src/main/java/games/rednblack/editor/controller/commands/component/UpdateSensorDataCommand.java index 8940c8dc..84a0a106 100644 --- a/src/main/java/games/rednblack/editor/controller/commands/component/UpdateSensorDataCommand.java +++ b/src/main/java/games/rednblack/editor/controller/commands/component/UpdateSensorDataCommand.java @@ -15,7 +15,7 @@ import games.rednblack.puremvc.Facade; */ public class UpdateSensorDataCommand extends EntityModifyRevertibleCommand { - private Integer entityId; + private String entityId; private SensorDataVO backup; public UpdateSensorDataCommand() { diff --git a/src/main/java/games/rednblack/editor/controller/commands/component/UpdateShaderDataCommand.java b/src/main/java/games/rednblack/editor/controller/commands/component/UpdateShaderDataCommand.java index 34ad1a86..fe89fe5e 100644 --- a/src/main/java/games/rednblack/editor/controller/commands/component/UpdateShaderDataCommand.java +++ b/src/main/java/games/rednblack/editor/controller/commands/component/UpdateShaderDataCommand.java @@ -10,7 +10,7 @@ import games.rednblack.h2d.common.MsgAPI; public class UpdateShaderDataCommand extends EntityModifyRevertibleCommand { - private Integer entityId; + private String entityId; private String backupName; private MainItemVO.RenderingLayer backupLayer; 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 4cbde4e3..f2fce21c 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 @@ -10,7 +10,7 @@ import games.rednblack.puremvc.Facade; public class UpdateSpineDataCommand extends EntityModifyRevertibleCommand { - private Integer entityId; + private String entityId; private SpineVO backup; @Override diff --git a/src/main/java/games/rednblack/editor/controller/commands/component/UpdateSpriteAnimationDataCommand.java b/src/main/java/games/rednblack/editor/controller/commands/component/UpdateSpriteAnimationDataCommand.java index acd73b0b..228654f8 100644 --- a/src/main/java/games/rednblack/editor/controller/commands/component/UpdateSpriteAnimationDataCommand.java +++ b/src/main/java/games/rednblack/editor/controller/commands/component/UpdateSpriteAnimationDataCommand.java @@ -14,7 +14,7 @@ import games.rednblack.puremvc.Facade; */ public class UpdateSpriteAnimationDataCommand extends EntityModifyRevertibleCommand { - private Integer entityId; + private String entityId; private int previousFps; private String previousAnimationName; diff --git a/src/main/java/games/rednblack/editor/controller/commands/component/UpdateTalosDataCommand.java b/src/main/java/games/rednblack/editor/controller/commands/component/UpdateTalosDataCommand.java index e1c3e7a1..6675160a 100644 --- a/src/main/java/games/rednblack/editor/controller/commands/component/UpdateTalosDataCommand.java +++ b/src/main/java/games/rednblack/editor/controller/commands/component/UpdateTalosDataCommand.java @@ -10,7 +10,7 @@ import games.rednblack.puremvc.Facade; public class UpdateTalosDataCommand extends EntityModifyRevertibleCommand { - private Integer entityId; + private String entityId; private TalosVO backup; @Override diff --git a/src/main/java/games/rednblack/editor/data/migrations/migrators/VersionMigTo100.java b/src/main/java/games/rednblack/editor/data/migrations/migrators/VersionMigTo100.java index 9f01e298..fff610d1 100644 --- a/src/main/java/games/rednblack/editor/data/migrations/migrators/VersionMigTo100.java +++ b/src/main/java/games/rednblack/editor/data/migrations/migrators/VersionMigTo100.java @@ -212,7 +212,6 @@ public class VersionMigTo100 implements IVersionMigrator { } private void copyMainItemField(MainItemVO vo, MainItemVO target) { - target.uniqueId = vo.uniqueId; target.itemIdentifier = vo.itemIdentifier; target.itemName = vo.itemName; if(vo.tags != null) target.tags = Arrays.copyOf(vo.tags, vo.tags.length); diff --git a/src/main/java/games/rednblack/editor/factory/ItemFactory.java b/src/main/java/games/rednblack/editor/factory/ItemFactory.java index bf3060d8..e3adc4c1 100644 --- a/src/main/java/games/rednblack/editor/factory/ItemFactory.java +++ b/src/main/java/games/rednblack/editor/factory/ItemFactory.java @@ -173,7 +173,6 @@ public class ItemFactory implements IFactory { HashMap libraryItems = projectManager.currentProjectInfoVO.libraryItems; CompositeItemVO itemVO = libraryItems.get(libraryName); - itemVO.cleanIds(); createdEntity = createCompositeItem(itemVO, position); if (createdEntity == -1) return false; diff --git a/src/main/java/games/rednblack/editor/utils/MoveCommandBuilder.java b/src/main/java/games/rednblack/editor/utils/MoveCommandBuilder.java index 58336ce7..08410a89 100644 --- a/src/main/java/games/rednblack/editor/utils/MoveCommandBuilder.java +++ b/src/main/java/games/rednblack/editor/utils/MoveCommandBuilder.java @@ -22,6 +22,7 @@ import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.utils.Array; import games.rednblack.editor.renderer.components.TransformComponent; import games.rednblack.editor.renderer.utils.ComponentRetriever; +import games.rednblack.editor.utils.runtime.EntityUtils; import games.rednblack.editor.view.stage.Sandbox; import games.rednblack.h2d.common.MsgAPI; import games.rednblack.puremvc.Facade; @@ -49,7 +50,7 @@ public class MoveCommandBuilder { public void setXY(int entity, float x, float y) { Object[] data = new Object[2]; - data[0] = entity; + data[0] = EntityUtils.getEntityId(entity); data[1] = new Vector2(x, y); payload.add(data); } diff --git a/src/main/java/games/rednblack/editor/utils/runtime/EntityUtils.java b/src/main/java/games/rednblack/editor/utils/runtime/EntityUtils.java index c5afdca8..6213030a 100644 --- a/src/main/java/games/rednblack/editor/utils/runtime/EntityUtils.java +++ b/src/main/java/games/rednblack/editor/utils/runtime/EntityUtils.java @@ -102,13 +102,13 @@ public class EntityUtils { return VisUI.getSkin().getDrawable(icon); } - public static Integer getEntityId(int entity) { + public static String getEntityId(int entity) { MainItemComponent mainItemComponent = SandboxComponentRetriever.get(entity, MainItemComponent.class); return mainItemComponent.uniqueId; } - public static Array getEntityId(Iterable entities) { - Array entityIds = new Array<>(); + public static Array getEntityId(Iterable entities) { + Array entityIds = new Array<>(); for (int entity : entities) { MainItemComponent mainItemComponent = SandboxComponentRetriever.get(entity, MainItemComponent.class); if (mainItemComponent != null) @@ -118,13 +118,13 @@ public class EntityUtils { return entityIds; } - public static int getByUniqueId(Integer id) { + public static int getByUniqueId(String id) { return Sandbox.getInstance().getSceneControl().sceneLoader.getEntityFactory().getEntityByUniqueId(id); } - public static HashSet getByUniqueId(Array ids) { + public static HashSet getByUniqueId(Array ids) { HashSet entities = new HashSet<>(); - for (Integer id : ids) { + for (String id : ids) { Integer entity = Sandbox.getInstance().getSceneControl().sceneLoader.getEntityFactory().getEntityByUniqueId(id); entities.add(entity); } diff --git a/src/main/java/games/rednblack/editor/view/stage/tools/SelectionTool.java b/src/main/java/games/rednblack/editor/view/stage/tools/SelectionTool.java index ac13f7bf..eadf9269 100644 --- a/src/main/java/games/rednblack/editor/view/stage/tools/SelectionTool.java +++ b/src/main/java/games/rednblack/editor/view/stage/tools/SelectionTool.java @@ -322,7 +322,7 @@ public class SelectionTool extends SimpleTool { Vector2 oldPosition = dragStartPositions.get(itemInstance); Object[] payload = new Object[3]; - payload[0] = itemInstance; + payload[0] = EntityUtils.getEntityId(itemInstance); payload[1] = newPosition; payload[2] = oldPosition; payloads.add(payload); @@ -464,7 +464,7 @@ public class SelectionTool extends SimpleTool { continue; Object[] payload = new Object[3]; - payload[0] = itemInstance; + payload[0] = EntityUtils.getEntityId(itemInstance); payload[1] = newPosition; payload[2] = oldPosition; payloads.add(payload); diff --git a/src/main/java/games/rednblack/editor/view/stage/tools/transformStrategy/CompositeStrategy.java b/src/main/java/games/rednblack/editor/view/stage/tools/transformStrategy/CompositeStrategy.java index 01c7d7f5..dcd112c6 100644 --- a/src/main/java/games/rednblack/editor/view/stage/tools/transformStrategy/CompositeStrategy.java +++ b/src/main/java/games/rednblack/editor/view/stage/tools/transformStrategy/CompositeStrategy.java @@ -25,8 +25,8 @@ import java.util.Map; */ public class CompositeStrategy extends AbstractTransformStrategy { - private HashMap childrenInitialPositions = new HashMap<>(); - private HashMap childrenFinalPositions = new HashMap<>(); + private final HashMap childrenInitialPositions = new HashMap<>(); + private final HashMap childrenFinalPositions = new HashMap<>(); private final Array payloads = new Array<>(); private final Vector2 parentInitialPosition = new Vector2(); @@ -60,7 +60,7 @@ public class CompositeStrategy extends AbstractTransformStrategy { private void sendResizePositionNotification(int entity) { payloads.clear(); payloads.add(parentEntity(entity)); - for (Map.Entry entrySet : childrenFinalPositions.entrySet()) { + for (Map.Entry entrySet : childrenFinalPositions.entrySet()) { Object[] payload = new Object[2]; payload[0] = EntityUtils.getByUniqueId(entrySet.getKey()); payload[1] = entrySet.getValue(); @@ -88,7 +88,7 @@ public class CompositeStrategy extends AbstractTransformStrategy { return obj; } - private void getChildrenPositions(int parentEntity, HashMap entityPos) { + private void getChildrenPositions(int parentEntity, HashMap entityPos) { NodeComponent nodeComponent = SandboxComponentRetriever.get(parentEntity, NodeComponent.class); if (nodeComponent != null) { for (int entity : nodeComponent.children) { @@ -99,9 +99,9 @@ public class CompositeStrategy extends AbstractTransformStrategy { } } - private void setEntityChildrenAtPositions(HashMap posMap) { - for (Map.Entry entrySet : posMap.entrySet()) { - Integer id = entrySet.getKey(); + private void setEntityChildrenAtPositions(HashMap posMap) { + for (Map.Entry entrySet : posMap.entrySet()) { + String id = entrySet.getKey(); Vector2 position = entrySet.getValue(); int entity = EntityUtils.getByUniqueId(id); EntityUtils.setPosition(entity, position); diff --git a/src/main/java/games/rednblack/editor/view/ui/box/UICompositeHierarchy.java b/src/main/java/games/rednblack/editor/view/ui/box/UICompositeHierarchy.java index 2d988aeb..eb1a3fb4 100644 --- a/src/main/java/games/rednblack/editor/view/ui/box/UICompositeHierarchy.java +++ b/src/main/java/games/rednblack/editor/view/ui/box/UICompositeHierarchy.java @@ -32,7 +32,7 @@ public class UICompositeHierarchy extends UIBaseBox { row(); } - public void addItem(String name, Integer id, boolean isRoot) { + public void addItem(String name, String id, boolean isRoot) { String classType = "hierarchy-item"; if(isRoot) classType+="-root"; diff --git a/src/main/java/games/rednblack/editor/view/ui/box/UICompositeHierarchyMediator.java b/src/main/java/games/rednblack/editor/view/ui/box/UICompositeHierarchyMediator.java index 8cb85679..8b81e022 100644 --- a/src/main/java/games/rednblack/editor/view/ui/box/UICompositeHierarchyMediator.java +++ b/src/main/java/games/rednblack/editor/view/ui/box/UICompositeHierarchyMediator.java @@ -43,7 +43,7 @@ public class UICompositeHierarchyMediator extends Mediator buildCompositeTree(sandbox.getRootEntity()); break; case CompositeCameraChangeCommand.DONE: - Integer entityId = notification.getBody(); + String entityId = notification.getBody(); changeComposite(entityId); break; case UICompositeHierarchy.SWITCH_VIEW_COMPOSITE_CLICKED: @@ -84,16 +84,16 @@ public class UICompositeHierarchyMediator extends Mediator } } - private void changeComposite(Integer entityId) { + private void changeComposite(String entityId) { buildCompositeTree(EntityUtils.getByUniqueId(entityId)); } private static class CompositeHierarchyItem { String name; - int entityId; + String entityId; boolean isRoot = false; - public CompositeHierarchyItem(String name, int entityId) { + public CompositeHierarchyItem(String name, String entityId) { this.entityId = entityId; this.name = name; } 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 62f06eaa..f027e13b 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 @@ -227,9 +227,9 @@ public class UIItemsTreeBox extends UICollapsibleBox { if (tree == null || selection == null) return; Array allSceneRootNodes = tree.getRootNodes().get(0).getChildren(); - for (int entityId : EntityUtils.getEntityId(selection)) { + for (String entityId : EntityUtils.getEntityId(selection)) { for (UIItemsTreeNode n : allSceneRootNodes) { - if(n.getValue().entityId == entityId) { + if(n.getValue().entityId.equals(entityId)) { tree.getSelection().add(n); break; } @@ -252,9 +252,9 @@ public class UIItemsTreeBox extends UICollapsibleBox { if (tree == null || selection == null) return; Array allSceneRootNodes = tree.getRootNodes().get(0).getChildren(); - for (int entityId : EntityUtils.getEntityId(selection)) { + for (String entityId : EntityUtils.getEntityId(selection)) { for (UIItemsTreeNode n : allSceneRootNodes) { - if(n.getValue().entityId == entityId) { + if(n.getValue().entityId.equals(entityId)) { tree.getSelection().remove(n); break; } 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 5fe3362b..94ff9a6b 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 @@ -75,7 +75,7 @@ public class UIItemsTreeBoxMediator extends PanelMediator { Set items = new HashSet<>(); for (UIItemsTreeNode node : nodes) { - Integer entityId = node.getValue().entityId; + String entityId = node.getValue().entityId; int item = EntityUtils.getByUniqueId(entityId); //layer lock thing LayerItemVO layerItemVO = EntityUtils.getEntityLayer(item); diff --git a/src/main/java/games/rednblack/editor/view/ui/box/UIItemsTreeNode.java b/src/main/java/games/rednblack/editor/view/ui/box/UIItemsTreeNode.java index c66f85c9..42ed055d 100644 --- a/src/main/java/games/rednblack/editor/view/ui/box/UIItemsTreeNode.java +++ b/src/main/java/games/rednblack/editor/view/ui/box/UIItemsTreeNode.java @@ -21,7 +21,7 @@ public class UIItemsTreeNode extends Tree.Node