New MainItemComponent#uniqueId management, change from integer to a non persistent random string
This commit is contained in:
@@ -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
|
||||
|
||||
Submodule hyperlap2d-runtime-libgdx updated: c8b4af722d...61c97ca4fb
@@ -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<Integer> entityIds;
|
||||
private Array<String> entityIds;
|
||||
|
||||
@Override
|
||||
public void doAction() {
|
||||
|
||||
@@ -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
|
||||
|
||||
+2
-2
@@ -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;
|
||||
|
||||
|
||||
+4
-4
@@ -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<Integer, String> layersBackup;
|
||||
protected HashMap<String, String> 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
@@ -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<Integer> entityIdsToDelete;
|
||||
private Array<String> entityIdsToDelete;
|
||||
|
||||
private void backup() {
|
||||
Set<Integer> 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<Integer> newEntitiesList = PasteItemsCommand.createEntitiesFromVO(compositeVO);
|
||||
|
||||
sandbox.getEngine().process();
|
||||
|
||||
+1
-2
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -17,8 +17,8 @@ import java.util.Map;
|
||||
*/
|
||||
public class ItemChildrenTransformCommand extends EntityModifyRevertibleCommand {
|
||||
|
||||
private HashMap<Integer, Vector2> prevPosMap = new HashMap<>();
|
||||
private HashMap<Integer, PositionSize> parentPositionAndSizeMap = new HashMap<>();
|
||||
private final HashMap<String, Vector2> prevPosMap = new HashMap<>();
|
||||
private final HashMap<String, PositionSize> parentPositionAndSizeMap = new HashMap<>();
|
||||
private int entity;
|
||||
|
||||
private Vector2 prevLo;
|
||||
@@ -49,8 +49,8 @@ public class ItemChildrenTransformCommand extends EntityModifyRevertibleCommand
|
||||
}
|
||||
|
||||
private void undoActionOnParent() {
|
||||
Map.Entry<Integer, PositionSize> entry = parentPositionAndSizeMap.entrySet().iterator().next();
|
||||
Integer entityUniqueId = entry.getKey();
|
||||
Map.Entry<String, PositionSize> 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<Integer, Vector2> entry : prevPosMap.entrySet()) {
|
||||
Integer entityUniqueId = entry.getKey();
|
||||
for (Map.Entry<String, Vector2> entry : prevPosMap.entrySet()) {
|
||||
String entityUniqueId = entry.getKey();
|
||||
Vector2 oldPosition = entry.getValue();
|
||||
int entity = EntityUtils.getByUniqueId(entityUniqueId);
|
||||
TransformComponent transformComponent = SandboxComponentRetriever.get(entity, TransformComponent.class);
|
||||
|
||||
@@ -16,7 +16,7 @@ public class ItemTransformCommand extends EntityModifyRevertibleCommand {
|
||||
|
||||
private Array<Object> payload;
|
||||
|
||||
private Integer entityId;
|
||||
private String entityId;
|
||||
|
||||
@Override
|
||||
public void doAction() {
|
||||
|
||||
@@ -36,7 +36,7 @@ public class ItemsMoveCommand extends EntityModifyRevertibleCommand {
|
||||
|
||||
public static final String TAG = ItemsMoveCommand.class.getCanonicalName();
|
||||
|
||||
private HashMap<Integer, Vector2> prevLocations = new HashMap<>();
|
||||
private final HashMap<String, Vector2> 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<Integer, Vector2> entry : prevLocations.entrySet()) {
|
||||
Integer entityUniqueId = entry.getKey();
|
||||
for (Map.Entry<String, Vector2> entry : prevLocations.entrySet()) {
|
||||
String entityUniqueId = entry.getKey();
|
||||
Vector2 prevLocation = entry.getValue();
|
||||
|
||||
int entity = EntityUtils.getByUniqueId(entityUniqueId);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -44,7 +44,7 @@ import java.util.Set;
|
||||
*/
|
||||
public class PasteItemsCommand extends EntityModifyRevertibleCommand {
|
||||
|
||||
private Array<Integer> pastedEntityIds = new Array<>();
|
||||
private final Array<String> 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<Integer> 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);
|
||||
|
||||
+1
-1
@@ -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<Integer> entityIds;
|
||||
private Array<String> entityIds;
|
||||
|
||||
@Override
|
||||
public void doAction() {
|
||||
|
||||
@@ -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<Integer> previousSelectionIds;
|
||||
private Array<String> previousSelectionIds;
|
||||
|
||||
@Override
|
||||
public void doAction() {
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ import games.rednblack.puremvc.Facade;
|
||||
public class UpdateEntityComponentsCommand extends EntityModifyRevertibleCommand {
|
||||
|
||||
private Array<Component> backupComponents = new Array<>();
|
||||
private Integer entityId;
|
||||
private String entityId;
|
||||
|
||||
@Override
|
||||
public void doAction() {
|
||||
|
||||
+1
-1
@@ -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() {
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+1
-1
@@ -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<TextureAtlas.AtlasRegion> backupAnimRegions;
|
||||
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ import games.rednblack.puremvc.Facade;
|
||||
|
||||
public class UpdateImageItemDataCommand extends EntityModifyRevertibleCommand {
|
||||
|
||||
private Integer entityId;
|
||||
private String entityId;
|
||||
private SimpleImageVO backup;
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ import games.rednblack.h2d.common.MsgAPI;
|
||||
*/
|
||||
public class UpdateLabelDataCommand extends EntityModifyRevertibleCommand {
|
||||
|
||||
Integer entityId;
|
||||
String entityId;
|
||||
|
||||
String prevFontName;
|
||||
int prevFontSize;
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ import games.rednblack.puremvc.Facade;
|
||||
|
||||
public class UpdateLightBodyDataCommand extends EntityModifyRevertibleCommand {
|
||||
|
||||
private Integer entityId;
|
||||
private String entityId;
|
||||
private LightBodyDataVO backup;
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ import games.rednblack.puremvc.Facade;
|
||||
|
||||
public class UpdateLightDataCommand extends EntityModifyRevertibleCommand {
|
||||
|
||||
private Integer entityId;
|
||||
private String entityId;
|
||||
private LightVO backup;
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ import games.rednblack.puremvc.Facade;
|
||||
|
||||
public class UpdateParticleDataCommand extends EntityModifyRevertibleCommand {
|
||||
|
||||
private Integer entityId;
|
||||
private String entityId;
|
||||
private ParticleEffectVO backup;
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ import games.rednblack.puremvc.Facade;
|
||||
|
||||
public class UpdatePhysicsDataCommand extends EntityModifyRevertibleCommand {
|
||||
|
||||
private Integer entityId;
|
||||
private String entityId;
|
||||
private PhysicsBodyDataVO backup;
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -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<Vector2> dataFrom;
|
||||
|
||||
+1
-1
@@ -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() {
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ import games.rednblack.puremvc.Facade;
|
||||
|
||||
public class UpdateSpineDataCommand extends EntityModifyRevertibleCommand {
|
||||
|
||||
private Integer entityId;
|
||||
private String entityId;
|
||||
private SpineVO backup;
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ import games.rednblack.puremvc.Facade;
|
||||
|
||||
public class UpdateTalosDataCommand extends EntityModifyRevertibleCommand {
|
||||
|
||||
private Integer entityId;
|
||||
private String entityId;
|
||||
private TalosVO backup;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -173,7 +173,6 @@ public class ItemFactory implements IFactory {
|
||||
HashMap<String, CompositeItemVO> libraryItems = projectManager.currentProjectInfoVO.libraryItems;
|
||||
|
||||
CompositeItemVO itemVO = libraryItems.get(libraryName);
|
||||
itemVO.cleanIds();
|
||||
createdEntity = createCompositeItem(itemVO, position);
|
||||
|
||||
if (createdEntity == -1) return false;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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<Integer> getEntityId(Iterable<Integer> entities) {
|
||||
Array<Integer> entityIds = new Array<>();
|
||||
public static Array<String> getEntityId(Iterable<Integer> entities) {
|
||||
Array<String> 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<Integer> getByUniqueId(Array<Integer> ids) {
|
||||
public static HashSet<Integer> getByUniqueId(Array<String> ids) {
|
||||
HashSet<Integer> entities = new HashSet<>();
|
||||
for (Integer id : ids) {
|
||||
for (String id : ids) {
|
||||
Integer entity = Sandbox.getInstance().getSceneControl().sceneLoader.getEntityFactory().getEntityByUniqueId(id);
|
||||
entities.add(entity);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
+7
-7
@@ -25,8 +25,8 @@ import java.util.Map;
|
||||
*/
|
||||
public class CompositeStrategy extends AbstractTransformStrategy {
|
||||
|
||||
private HashMap<Integer, Vector2> childrenInitialPositions = new HashMap<>();
|
||||
private HashMap<Integer, Vector2> childrenFinalPositions = new HashMap<>();
|
||||
private final HashMap<String, Vector2> childrenInitialPositions = new HashMap<>();
|
||||
private final HashMap<String, Vector2> childrenFinalPositions = new HashMap<>();
|
||||
private final Array<Object[]> 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<Integer, Vector2> entrySet : childrenFinalPositions.entrySet()) {
|
||||
for (Map.Entry<String, Vector2> 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<Integer, Vector2> entityPos) {
|
||||
private void getChildrenPositions(int parentEntity, HashMap<String, Vector2> 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<Integer, Vector2> posMap) {
|
||||
for (Map.Entry<Integer, Vector2> entrySet : posMap.entrySet()) {
|
||||
Integer id = entrySet.getKey();
|
||||
private void setEntityChildrenAtPositions(HashMap<String, Vector2> posMap) {
|
||||
for (Map.Entry<String, Vector2> entrySet : posMap.entrySet()) {
|
||||
String id = entrySet.getKey();
|
||||
Vector2 position = entrySet.getValue();
|
||||
int entity = EntityUtils.getByUniqueId(id);
|
||||
EntityUtils.setPosition(entity, position);
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ public class UICompositeHierarchyMediator extends Mediator<UICompositeHierarchy>
|
||||
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<UICompositeHierarchy>
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -227,9 +227,9 @@ public class UIItemsTreeBox extends UICollapsibleBox {
|
||||
if (tree == null || selection == null) return;
|
||||
Array<UIItemsTreeNode> 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<UIItemsTreeNode> 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;
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public class UIItemsTreeBoxMediator extends PanelMediator<UIItemsTreeBox> {
|
||||
Set<Integer> 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);
|
||||
|
||||
@@ -21,7 +21,7 @@ public class UIItemsTreeNode extends Tree.Node<UIItemsTreeNode, UIItemsTreeValue
|
||||
setValue(new UIItemsTreeValue());
|
||||
}
|
||||
|
||||
public void setNodeValue(int entityId, int zIndex) {
|
||||
public void setNodeValue(String entityId, int zIndex) {
|
||||
getValue().setEntityId(entityId);
|
||||
getValue().setzIndex(zIndex);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package games.rednblack.editor.view.ui.box;
|
||||
|
||||
public class UIItemsTreeValue {
|
||||
public int entityId = -1;
|
||||
public String entityId = null;
|
||||
public int zIndex = -1;
|
||||
|
||||
public void setEntityId(int entityId) {
|
||||
public void setEntityId(String entityId) {
|
||||
this.entityId = entityId;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ public class UIItemsTreeValue {
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
entityId = -1;
|
||||
entityId = null;
|
||||
zIndex = -1;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -203,7 +203,7 @@ public class UIBasicItemProperties extends UIItemProperties {
|
||||
return positionTable;
|
||||
}
|
||||
|
||||
public void setItemType(int type, int itemUniqueId) {
|
||||
public void setItemType(int type, String itemUniqueId) {
|
||||
itemType.setText(EntityUtils.itemTypeNameMap.get(type) + " ("+itemUniqueId+")");
|
||||
itemTypeIcon.setDrawable(VisUI.getSkin().getDrawable(EntityUtils.itemTypeIconMap.get(type)));
|
||||
itemTypeIcon.setScaling(Scaling.fit);
|
||||
|
||||
Reference in New Issue
Block a user