* Rework CompositeItemVO class to support general entities type.
* Remove `CompositeVO` * Upgrade Project Version to `1.0.0` (support migration) * Bump HyperLap2D version to `0.1.0`
This commit is contained in:
@@ -1 +1 @@
|
||||
version=0.0.8-SNAPSHOT
|
||||
version=0.1.0-SNAPSHOT
|
||||
+1
-1
@@ -14,7 +14,7 @@ plugins {
|
||||
}
|
||||
|
||||
group 'games.rednblack'
|
||||
version '0.0.8'
|
||||
version '0.1.0'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
Submodule h2d-libgdx-spine-extension updated: 30f169459e...b6ecaca39d
Submodule h2d-libgdx-talos-extension updated: 9a1dfeb358...35f0a1ed8c
Submodule h2d-libgdx-typinglabel-extension updated: 185801e545...40d2d9637a
+1
-1
Submodule hyperlap2d-common-api updated: 25457b5d12...c1d4e0df74
Submodule hyperlap2d-runtime-libgdx updated: 711e9939ea...ffa0272325
+2
-1
@@ -3,6 +3,7 @@ package games.rednblack.editor.plugin.tiled.save;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.utils.Json;
|
||||
import games.rednblack.editor.renderer.utils.HyperJson;
|
||||
|
||||
/**
|
||||
* Created by mariam on 3/24/16.
|
||||
@@ -16,7 +17,7 @@ public class SaveDataManager {
|
||||
|
||||
|
||||
public SaveDataManager(String projectPath) {
|
||||
json = new Json();
|
||||
json = HyperJson.getJson();
|
||||
fileHandle = Gdx.files.absolute(projectPath + "/tiled_plugin.dt");
|
||||
load();
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ public class HyperLap2DApp extends ApplicationAdapter {
|
||||
hyperlap2D = new HyperLap2D(settingsManager);
|
||||
|
||||
Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
|
||||
config.setTitle("HyperLap2D - Public Alpha v" + AppConfig.getInstance().versionString);
|
||||
config.setTitle("HyperLap2D - Beta v" + AppConfig.getInstance().versionString);
|
||||
config.setResizable(true);
|
||||
config.setWindowedMode((int) (windowWidth), (int) (windowHeight));
|
||||
config.setIdleFPS(60);
|
||||
|
||||
@@ -57,7 +57,7 @@ public class AddToLibraryCommand extends RevertibleCommand {
|
||||
}
|
||||
|
||||
CompositeItemVO newVO = new CompositeItemVO();
|
||||
newVO.loadFromEntity(item, sandbox.getEngine());
|
||||
newVO.loadFromEntity(item, sandbox.getEngine(), sandbox.sceneControl.sceneLoader.getEntityFactory());
|
||||
newVO.cleanIds();
|
||||
libraryItems.put(createdLibraryItemName, newVO);
|
||||
|
||||
|
||||
@@ -20,7 +20,8 @@ package games.rednblack.editor.controller.commands;
|
||||
|
||||
import com.badlogic.gdx.utils.Json;
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.renderer.data.CompositeVO;
|
||||
import games.rednblack.editor.renderer.data.CompositeItemVO;
|
||||
import games.rednblack.editor.renderer.utils.HyperJson;
|
||||
import games.rednblack.editor.utils.runtime.EntityUtils;
|
||||
import games.rednblack.editor.view.stage.Sandbox;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
@@ -47,8 +48,8 @@ public class CutItemsCommand extends EntityModifyRevertibleCommand {
|
||||
|
||||
@Override
|
||||
public void undoAction() {
|
||||
Json json = new Json();
|
||||
CompositeVO compositeVO = json.fromJson(CompositeVO.class, backup);
|
||||
Json json = HyperJson.getJson();
|
||||
CompositeItemVO compositeVO = json.fromJson(CompositeItemVO.class, backup);
|
||||
Set<Integer> newEntitiesList = PasteItemsCommand.createEntitiesFromVO(compositeVO);
|
||||
|
||||
sandbox.getEngine().process();
|
||||
|
||||
@@ -21,7 +21,8 @@ package games.rednblack.editor.controller.commands;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Json;
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.renderer.data.CompositeVO;
|
||||
import games.rednblack.editor.renderer.data.CompositeItemVO;
|
||||
import games.rednblack.editor.renderer.utils.HyperJson;
|
||||
import games.rednblack.editor.utils.runtime.EntityUtils;
|
||||
import games.rednblack.editor.view.ui.FollowersUIMediator;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
@@ -73,8 +74,8 @@ public class DeleteItemsCommand extends EntityModifyRevertibleCommand {
|
||||
|
||||
@Override
|
||||
public void undoAction() {
|
||||
Json json = new Json();
|
||||
CompositeVO compositeVO = json.fromJson(CompositeVO.class, backup);
|
||||
Json json = HyperJson.getJson();
|
||||
CompositeItemVO compositeVO = json.fromJson(CompositeItemVO.class, backup);
|
||||
Set<Integer> newEntitiesList = PasteItemsCommand.createEntitiesFromVO(compositeVO);
|
||||
|
||||
sandbox.getEngine().process();
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ public class DeleteLayerAtomCommand extends EntityModifyRevertibleCommand {
|
||||
int viewingEntity = Sandbox.getInstance().getCurrentViewingEntity();
|
||||
LayerMapComponent layerMapComponent = SandboxComponentRetriever.get(viewingEntity, LayerMapComponent.class);
|
||||
|
||||
if(layerMapComponent.getLayers().size() > 1) {
|
||||
if(layerMapComponent.getLayers().size > 1) {
|
||||
layerMapComponent.deleteLayer(layerName);
|
||||
} else {
|
||||
cancel();
|
||||
|
||||
+2
-2
@@ -59,7 +59,7 @@ public abstract class EntityModifyRevertibleCommand extends RevertibleCommand {
|
||||
HashMap<String, CompositeItemVO> libraryItems = projectManager.currentProjectInfoVO.libraryItems;
|
||||
if (libraryItems.containsKey(mainItemComponent.libraryLink)) {
|
||||
CompositeItemVO itemVO = new CompositeItemVO();
|
||||
itemVO.loadFromEntity(entity, sandbox.getEngine());
|
||||
itemVO.loadFromEntity(entity, sandbox.getEngine(), sandbox.sceneControl.sceneLoader.getEntityFactory());
|
||||
itemVO.cleanIds();
|
||||
libraryItems.put(mainItemComponent.libraryLink, itemVO);
|
||||
}
|
||||
@@ -75,7 +75,7 @@ public abstract class EntityModifyRevertibleCommand extends RevertibleCommand {
|
||||
sandbox.getEngine().process();
|
||||
|
||||
EntityFactory factory = sandbox.getSceneControl().sceneLoader.getEntityFactory();
|
||||
factory.initAllChildren(dependable, libraryItems.get(link).composite);
|
||||
factory.initAllChildren(dependable, libraryItems.get(link));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,9 +24,10 @@ import com.badlogic.gdx.utils.Json;
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.renderer.components.TransformComponent;
|
||||
import games.rednblack.editor.renderer.components.ZIndexComponent;
|
||||
import games.rednblack.editor.renderer.data.CompositeVO;
|
||||
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.utils.HyperJson;
|
||||
import games.rednblack.editor.utils.runtime.EntityUtils;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.editor.view.stage.Sandbox;
|
||||
@@ -34,7 +35,6 @@ import games.rednblack.editor.view.ui.FollowersUIMediator;
|
||||
import games.rednblack.editor.view.ui.box.UILayerBoxMediator;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -60,9 +60,10 @@ public class PasteItemsCommand extends EntityModifyRevertibleCommand {
|
||||
|
||||
Vector2 diff = cameraCurrPosition.sub(cameraPrevPosition);
|
||||
|
||||
Json json = new Json();
|
||||
CompositeVO compositeVO = json.fromJson(CompositeVO.class, (String) payload[1]);
|
||||
forceIdChange(compositeVO);
|
||||
Json json = HyperJson.getJson();
|
||||
CompositeItemVO compositeVO = json.fromJson(CompositeItemVO.class, (String) payload[1]);
|
||||
compositeVO.cleanIds();
|
||||
|
||||
Set<Integer> newEntitiesList = createEntitiesFromVO(compositeVO);
|
||||
sandbox.getEngine().process();
|
||||
for (int entity : newEntitiesList) {
|
||||
@@ -91,60 +92,31 @@ public class PasteItemsCommand extends EntityModifyRevertibleCommand {
|
||||
pastedEntityIds.clear();
|
||||
}
|
||||
|
||||
public static void forceIdChange(CompositeVO compositeVO) {
|
||||
ArrayList<MainItemVO> items = compositeVO.getAllItems();
|
||||
for(MainItemVO item: items) {
|
||||
item.uniqueId = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static Set<Integer> createEntitiesFromVO(CompositeVO compositeVO) {
|
||||
public static Set<Integer> createEntitiesFromVO(CompositeItemVO compositeVO) {
|
||||
Set<Integer> entities = new HashSet<>();
|
||||
|
||||
EntityFactory factory = Sandbox.getInstance().sceneControl.sceneLoader.getEntityFactory();
|
||||
int parentEntity = Sandbox.getInstance().getCurrentViewingEntity();
|
||||
|
||||
for (int i = 0; i < compositeVO.sImages.size(); i++) {
|
||||
int child = factory.createEntity(parentEntity, compositeVO.sImages.get(i));
|
||||
entities.add(child);
|
||||
|
||||
for (String key : compositeVO.content.keys()) {
|
||||
if (key.equals(CompositeItemVO.class.getName())) continue;
|
||||
|
||||
Array<MainItemVO> vos = compositeVO.content.get(key);
|
||||
for (MainItemVO mainItemVO : vos) {
|
||||
int entity = factory.createEntity(parentEntity, mainItemVO);
|
||||
entities.add(entity);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < compositeVO.sImage9patchs.size(); i++) {
|
||||
int child = factory.createEntity(parentEntity, compositeVO.sImage9patchs.get(i));
|
||||
entities.add(child);
|
||||
}
|
||||
for (int i = 0; i < compositeVO.sLabels.size(); i++) {
|
||||
int child = factory.createEntity(parentEntity, compositeVO.sLabels.get(i));
|
||||
entities.add(child);
|
||||
}
|
||||
for (int i = 0; i < compositeVO.sParticleEffects.size(); i++) {
|
||||
int child = factory.createEntity(parentEntity, compositeVO.sParticleEffects.get(i));
|
||||
entities.add(child);
|
||||
}
|
||||
for (int i = 0; i < compositeVO.sTalosVFX.size(); i++) {
|
||||
int child = factory.createEntity(parentEntity, compositeVO.sTalosVFX.get(i));
|
||||
entities.add(child);
|
||||
}
|
||||
for (int i = 0; i < compositeVO.sLights.size(); i++) {
|
||||
int child = factory.createEntity(parentEntity, compositeVO.sLights.get(i));
|
||||
entities.add(child);
|
||||
}
|
||||
for (int i = 0; i < compositeVO.sSpineAnimations.size(); i++) {
|
||||
int child = factory.createEntity(parentEntity, compositeVO.sSpineAnimations.get(i));
|
||||
entities.add(child);
|
||||
}
|
||||
for (int i = 0; i < compositeVO.sSpriteAnimations.size(); i++) {
|
||||
int child = factory.createEntity(parentEntity, compositeVO.sSpriteAnimations.get(i));
|
||||
entities.add(child);
|
||||
}
|
||||
for (int i = 0; i < compositeVO.sColorPrimitives.size(); i++) {
|
||||
int child = factory.createEntity(parentEntity, compositeVO.sColorPrimitives.get(i));
|
||||
entities.add(child);
|
||||
}
|
||||
for (int i = 0; i < compositeVO.sComposites.size(); i++) {
|
||||
int child = factory.createEntity(parentEntity, compositeVO.sComposites.get(i));
|
||||
entities.add(child);
|
||||
factory.initAllChildren(child, compositeVO.sComposites.get(i).composite);
|
||||
|
||||
Array<MainItemVO> compositeVOs = compositeVO.content.get(CompositeItemVO.class.getName());
|
||||
if (compositeVOs != null) {
|
||||
for (MainItemVO mainItemVO : compositeVOs) {
|
||||
CompositeItemVO compositeItemVO = (CompositeItemVO) mainItemVO;
|
||||
int composite = factory.createEntity(parentEntity, compositeItemVO);
|
||||
entities.add(composite);
|
||||
factory.initAllChildren(composite, compositeItemVO);
|
||||
}
|
||||
}
|
||||
|
||||
return entities;
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ public class UpdateCompositeDataCommand extends EntityModifyRevertibleCommand {
|
||||
entityId = EntityUtils.getEntityId(entity);
|
||||
|
||||
backup = new CompositeItemVO();
|
||||
backup.loadFromEntity(entity, sandbox.getEngine());
|
||||
backup.loadFromEntity(entity, sandbox.getEngine(), sandbox.sceneControl.sceneLoader.getEntityFactory());
|
||||
|
||||
CompositeTransformComponent transformComponent = SandboxComponentRetriever.get(entity, CompositeTransformComponent.class);
|
||||
transformComponent.automaticResize = vo.automaticResize;
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ public class UpdateLightDataCommand extends EntityModifyRevertibleCommand {
|
||||
entityId = EntityUtils.getEntityId(entity);
|
||||
|
||||
backup = new LightVO();
|
||||
backup.loadFromEntity(entity, sandbox.getEngine());
|
||||
backup.loadFromEntity(entity, sandbox.getEngine(), sandbox.sceneControl.sceneLoader.getEntityFactory());
|
||||
|
||||
LightObjectComponent lightObjectComponent = SandboxComponentRetriever.get(entity, LightObjectComponent.class);
|
||||
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ public class UpdateParticleDataCommand extends EntityModifyRevertibleCommand {
|
||||
entityId = EntityUtils.getEntityId(entity);
|
||||
|
||||
backup = new ParticleEffectVO();
|
||||
backup.loadFromEntity(entity, sandbox.getEngine());
|
||||
backup.loadFromEntity(entity, sandbox.getEngine(), sandbox.sceneControl.sceneLoader.getEntityFactory());
|
||||
|
||||
ParticleComponent particleComponent = SandboxComponentRetriever.get(entity, ParticleComponent.class);
|
||||
particleComponent.transform = vo.transform;
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ public class UpdateSpineDataCommand extends EntityModifyRevertibleCommand {
|
||||
entityId = EntityUtils.getEntityId(entity);
|
||||
|
||||
backup = new SpineVO();
|
||||
backup.loadFromEntity(entity, sandbox.getEngine());
|
||||
backup.loadFromEntity(entity, sandbox.getEngine(), sandbox.sceneControl.sceneLoader.getEntityFactory());
|
||||
|
||||
SpineDataComponent spineDataComponent = SandboxComponentRetriever.get(entity, SpineDataComponent.class);
|
||||
SpineObjectComponent spineObjectComponent = SandboxComponentRetriever.get(entity, SpineObjectComponent.class);
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ public class UpdateTalosDataCommand extends EntityModifyRevertibleCommand {
|
||||
entityId = EntityUtils.getEntityId(entity);
|
||||
|
||||
backup = new TalosVO();
|
||||
backup.loadFromEntity(entity, sandbox.getEngine());
|
||||
backup.loadFromEntity(entity, sandbox.getEngine(), sandbox.sceneControl.sceneLoader.getEntityFactory());
|
||||
|
||||
TalosDataComponent dataComponent = SandboxComponentRetriever.get(entity, TalosDataComponent.class);
|
||||
dataComponent.transform = vo.transform;
|
||||
|
||||
+2
-1
@@ -8,6 +8,7 @@ import games.rednblack.editor.controller.commands.AddToLibraryAction;
|
||||
import games.rednblack.editor.controller.commands.NonRevertibleCommand;
|
||||
import games.rednblack.editor.proxy.ProjectManager;
|
||||
import games.rednblack.editor.renderer.data.GraphVO;
|
||||
import games.rednblack.editor.renderer.utils.HyperJson;
|
||||
import games.rednblack.editor.view.stage.Sandbox;
|
||||
import games.rednblack.editor.view.ui.validator.StringNameValidator;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
@@ -36,7 +37,7 @@ public class DuplicateLibraryAction extends NonRevertibleCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
Json json = new Json();
|
||||
Json json = HyperJson.getJson();
|
||||
GraphVO duplicated = json.fromJson(GraphVO.class, json.toJson(actionToDuplicate));
|
||||
|
||||
Object[] payload = AddToLibraryAction.getPayload(input, duplicated);
|
||||
|
||||
+13
-13
@@ -6,7 +6,6 @@ import com.badlogic.gdx.graphics.g2d.ParticleEffect;
|
||||
import com.badlogic.gdx.graphics.g2d.ParticleEmitter;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Json;
|
||||
import com.badlogic.gdx.utils.JsonWriter;
|
||||
import com.talosvfx.talos.runtime.ParticleEffectDescriptor;
|
||||
import com.talosvfx.talos.runtime.ParticleEmitterDescriptor;
|
||||
import com.talosvfx.talos.runtime.modules.*;
|
||||
@@ -14,6 +13,7 @@ import games.rednblack.editor.controller.commands.NonRevertibleCommand;
|
||||
import games.rednblack.editor.proxy.ProjectManager;
|
||||
import games.rednblack.editor.proxy.ResourceManager;
|
||||
import games.rednblack.editor.renderer.data.*;
|
||||
import games.rednblack.editor.renderer.utils.HyperJson;
|
||||
import games.rednblack.editor.utils.ImportUtils;
|
||||
import games.rednblack.editor.utils.ZipUtils;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
@@ -33,7 +33,7 @@ public class ExportLibraryItemCommand extends NonRevertibleCommand {
|
||||
|
||||
private static final String CLASS_NAME = "games.rednblack.editor.controller.commands.resource.ExportLibraryItemCommand";
|
||||
public static final String DONE = CLASS_NAME + "DONE";
|
||||
private final Json json = new Json(JsonWriter.OutputType.json);
|
||||
private final Json json = HyperJson.getJson();
|
||||
|
||||
private final String currentProjectPath;
|
||||
private final ResourceManager resourceManager;
|
||||
@@ -106,7 +106,7 @@ public class ExportLibraryItemCommand extends NonRevertibleCommand {
|
||||
|
||||
FileUtils.writeStringToFile(new File(tempDir.getPath() + File.separator + libraryItemName + ".lib"), json.toJson(compositeItemVO), "utf-8");
|
||||
|
||||
exportAllAssets(compositeItemVO.composite, tempDir);
|
||||
exportAllAssets(compositeItemVO, tempDir);
|
||||
|
||||
exportMapperVO.mapper.add(new ExportedAsset(ImportUtils.TYPE_HYPERLAP2D_INTERNAL_LIBRARY, libraryItemName + ".lib"));
|
||||
|
||||
@@ -116,36 +116,36 @@ public class ExportLibraryItemCommand extends NonRevertibleCommand {
|
||||
FileUtils.deleteDirectory(tempDir);
|
||||
}
|
||||
|
||||
private void exportAllAssets(CompositeVO compositeVO, File tmpDir) throws IOException {
|
||||
for (SimpleImageVO imageVO : compositeVO.sImages) {
|
||||
private void exportAllAssets(CompositeItemVO compositeVO, File tmpDir) throws IOException {
|
||||
for (SimpleImageVO imageVO : compositeVO.getElementsArray(SimpleImageVO.class)) {
|
||||
File fileSrc = new File(currentProjectPath + ProjectManager.IMAGE_DIR_PATH + File.separator + imageVO.imageName + ".png");
|
||||
FileUtils.copyFileToDirectory(fileSrc, tmpDir);
|
||||
exportMapperVO.mapper.add(new ExportedAsset(ImportUtils.TYPE_IMAGE, fileSrc.getName()));
|
||||
copyShader(imageVO.shaderName, tmpDir);
|
||||
}
|
||||
|
||||
for (Image9patchVO imageVO : compositeVO.sImage9patchs) {
|
||||
for (Image9patchVO imageVO : compositeVO.getElementsArray(Image9patchVO.class)) {
|
||||
File fileSrc = new File(currentProjectPath + ProjectManager.IMAGE_DIR_PATH + File.separator + imageVO.imageName + ".9.png");
|
||||
FileUtils.copyFileToDirectory(fileSrc, tmpDir);
|
||||
exportMapperVO.mapper.add(new ExportedAsset(ImportUtils.TYPE_IMAGE, fileSrc.getName()));
|
||||
copyShader(imageVO.shaderName, tmpDir);
|
||||
}
|
||||
|
||||
for (SpineVO imageVO : compositeVO.sSpineAnimations) {
|
||||
for (SpineVO imageVO : compositeVO.getElementsArray(SpineVO.class)) {
|
||||
File fileSrc = new File(currentProjectPath + ProjectManager.SPINE_DIR_PATH + File.separator + imageVO.animationName);
|
||||
FileUtils.copyDirectory(fileSrc, tmpDir);
|
||||
exportMapperVO.mapper.add(new ExportedAsset(ImportUtils.TYPE_SPINE_ANIMATION, fileSrc.getName() + ".json"));
|
||||
copyShader(imageVO.shaderName, tmpDir);
|
||||
}
|
||||
|
||||
for (SpriteAnimationVO imageVO : compositeVO.sSpriteAnimations) {
|
||||
for (SpriteAnimationVO imageVO : compositeVO.getElementsArray(SpriteAnimationVO.class)) {
|
||||
File fileSrc = new File(currentProjectPath + ProjectManager.SPRITE_DIR_PATH + File.separator + imageVO.animationName);
|
||||
FileUtils.copyDirectory(fileSrc, tmpDir);
|
||||
exportMapperVO.mapper.add(new ExportedAsset(ImportUtils.TYPE_SPRITE_ANIMATION_ATLAS, fileSrc.getName() + ".atlas"));
|
||||
copyShader(imageVO.shaderName, tmpDir);
|
||||
}
|
||||
|
||||
for (ParticleEffectVO imageVO : compositeVO.sParticleEffects) {
|
||||
for (ParticleEffectVO imageVO : compositeVO.getElementsArray(ParticleEffectVO.class)) {
|
||||
File fileSrc = new File(currentProjectPath + ProjectManager.PARTICLE_DIR_PATH + File.separator + imageVO.particleName);
|
||||
FileUtils.copyFileToDirectory(fileSrc, tmpDir);
|
||||
exportMapperVO.mapper.add(new ExportedAsset(ImportUtils.TYPE_PARTICLE_EFFECT, fileSrc.getName()));
|
||||
@@ -159,7 +159,7 @@ public class ExportLibraryItemCommand extends NonRevertibleCommand {
|
||||
copyShader(imageVO.shaderName, tmpDir);
|
||||
}
|
||||
|
||||
for (TalosVO imageVO : compositeVO.sTalosVFX) {
|
||||
for (TalosVO imageVO : compositeVO.getElementsArray(TalosVO.class)) {
|
||||
File fileSrc = new File(currentProjectPath + ProjectManager.TALOS_VFX_DIR_PATH + File.separator + imageVO.particleName);
|
||||
FileUtils.copyFileToDirectory(fileSrc, tmpDir);
|
||||
exportMapperVO.mapper.add(new ExportedAsset(ImportUtils.TYPE_TALOS_VFX, fileSrc.getName()));
|
||||
@@ -194,8 +194,8 @@ public class ExportLibraryItemCommand extends NonRevertibleCommand {
|
||||
copyShader(imageVO.shaderName, tmpDir);
|
||||
}
|
||||
|
||||
for (CompositeItemVO compositeItemVO : compositeVO.sComposites) {
|
||||
exportAllAssets(compositeItemVO.composite, tmpDir);
|
||||
for (CompositeItemVO compositeItemVO : compositeVO.getElementsArray(CompositeItemVO.class)) {
|
||||
exportAllAssets(compositeItemVO, tmpDir);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ public class ExportLibraryItemCommand extends NonRevertibleCommand {
|
||||
}
|
||||
|
||||
private void adjustPPWCoordinates(CompositeItemVO compositeItemVO) {
|
||||
for (MainItemVO item : compositeItemVO.composite.getAllItems()) {
|
||||
for (MainItemVO item : compositeItemVO.getAllItems()) {
|
||||
item.originX = item.originX * projectManager.getCurrentProjectInfoVO().pixelToWorld;
|
||||
item.originY = item.originY * projectManager.getCurrentProjectInfoVO().pixelToWorld;
|
||||
item.x = item.x * projectManager.getCurrentProjectInfoVO().pixelToWorld;
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.badlogic.gdx.utils.Json;
|
||||
import com.badlogic.gdx.utils.JsonWriter;
|
||||
import games.rednblack.editor.data.migrations.migrators.*;
|
||||
import games.rednblack.editor.renderer.data.ProjectInfoVO;
|
||||
import games.rednblack.editor.renderer.utils.HyperJson;
|
||||
import games.rednblack.h2d.common.vo.ProjectVO;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
@@ -43,9 +44,9 @@ public class ProjectVersionMigrator {
|
||||
/**
|
||||
* this is the current supported version, change when data format is changed, and add migration script
|
||||
*/
|
||||
public static String dataFormatVersion = "0.2.0";
|
||||
public static String dataFormatVersion = "1.0.0";
|
||||
|
||||
private final Json json = new Json();
|
||||
private final Json json = HyperJson.getJson();
|
||||
|
||||
public ProjectVersionMigrator (String projectPath, ProjectVO projectVo) {
|
||||
this.projectPath = projectPath;
|
||||
@@ -58,7 +59,8 @@ public class ProjectVersionMigrator {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
projectInfoVO = json.fromJson(ProjectInfoVO.class, projectInfoContents);
|
||||
if (!projectVo.projectVersion.equals("0.2.0"))
|
||||
projectInfoVO = json.fromJson(ProjectInfoVO.class, projectInfoContents);
|
||||
|
||||
json.setOutputType(JsonWriter.OutputType.json);
|
||||
}
|
||||
@@ -104,6 +106,10 @@ public class ProjectVersionMigrator {
|
||||
IVersionMigrator vmt = new VersionMigTo020();
|
||||
doMigration(vmt, "0.2.0");
|
||||
}
|
||||
if (projectVo.projectVersion.equals("0.2.0")) {
|
||||
IVersionMigrator vmt = new VersionMigTo100();
|
||||
doMigration(vmt, "1.0.0");
|
||||
}
|
||||
}
|
||||
|
||||
private void doMigration (IVersionMigrator vmt, String nextVersion) {
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package games.rednblack.editor.data.migrations.data020;
|
||||
|
||||
import games.rednblack.editor.renderer.data.MainItemVO;
|
||||
|
||||
public class CompositeItemVO extends MainItemVO {
|
||||
public CompositeVO composite;
|
||||
|
||||
public float width;
|
||||
public float height;
|
||||
public boolean automaticResize = true;
|
||||
public boolean scissorsEnabled = false;
|
||||
public boolean renderToFBO = false;
|
||||
|
||||
@Override
|
||||
public String getResourceName() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package games.rednblack.editor.data.migrations.data020;
|
||||
|
||||
import games.rednblack.editor.renderer.data.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class CompositeVO {
|
||||
public ArrayList<SimpleImageVO> sImages = new ArrayList<>(1);
|
||||
public ArrayList<Image9patchVO> sImage9patchs = new ArrayList<>(1);
|
||||
public ArrayList<LabelVO> sLabels = new ArrayList<>(1);
|
||||
public ArrayList<CompositeItemVO> sComposites = new ArrayList<>(1);
|
||||
public ArrayList<ParticleEffectVO> sParticleEffects = new ArrayList<>(1);
|
||||
public ArrayList<TalosVO> sTalosVFX = new ArrayList<>(1);
|
||||
public ArrayList<LightVO> sLights = new ArrayList<>(1);
|
||||
public ArrayList<SpineVO> sSpineAnimations = new ArrayList<>(1);
|
||||
public ArrayList<SpriteAnimationVO> sSpriteAnimations = new ArrayList<>(1);
|
||||
public ArrayList<ColorPrimitiveVO> sColorPrimitives = new ArrayList<>(1);
|
||||
|
||||
public ArrayList<LayerItemVO> layers = new ArrayList<LayerItemVO>();
|
||||
|
||||
public HashMap<String, StickyNoteVO> sStickyNotes = new HashMap<>(1);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package games.rednblack.editor.data.migrations.data020;
|
||||
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import games.rednblack.editor.renderer.data.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class ProjectInfoVO {
|
||||
public int pixelToWorld = 1;
|
||||
|
||||
public ResolutionEntryVO originalResolution = new ResolutionEntryVO();
|
||||
|
||||
public Array<ResolutionEntryVO> resolutions = new Array<ResolutionEntryVO>();
|
||||
public ArrayList<SceneVO> scenes = new ArrayList<SceneVO>();
|
||||
|
||||
public HashMap<String, CompositeItemVO> libraryItems = new HashMap<>();
|
||||
public HashMap<String, GraphVO> libraryActions = new HashMap<>();
|
||||
|
||||
public HashMap<String, TexturePackVO> imagesPacks = new HashMap<>();
|
||||
public HashMap<String, TexturePackVO> animationsPacks = new HashMap<>();
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package games.rednblack.editor.data.migrations.data020;
|
||||
|
||||
import games.rednblack.editor.renderer.data.LightsPropertiesVO;
|
||||
import games.rednblack.editor.renderer.data.PhysicsPropertiesVO;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class SceneVO {
|
||||
public String sceneName = "";
|
||||
|
||||
public CompositeVO composite;
|
||||
|
||||
public PhysicsPropertiesVO physicsPropertiesVO = new PhysicsPropertiesVO();
|
||||
public LightsPropertiesVO lightsPropertiesVO = new LightsPropertiesVO();
|
||||
|
||||
public ArrayList<Float> verticalGuides = new ArrayList<Float>();
|
||||
public ArrayList<Float> horizontalGuides = new ArrayList<Float>();
|
||||
}
|
||||
@@ -0,0 +1,202 @@
|
||||
package games.rednblack.editor.data.migrations.migrators;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.math.Circle;
|
||||
import com.badlogic.gdx.utils.Json;
|
||||
import com.badlogic.gdx.utils.JsonWriter;
|
||||
import games.rednblack.editor.data.migrations.IVersionMigrator;
|
||||
import games.rednblack.editor.data.migrations.data020.CompositeVO;
|
||||
import games.rednblack.editor.renderer.data.*;
|
||||
import games.rednblack.h2d.common.vo.ProjectVO;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class VersionMigTo100 implements IVersionMigrator {
|
||||
private final Json json = new Json();
|
||||
|
||||
private String projectPath;
|
||||
private ProjectVO projectVO;
|
||||
private games.rednblack.editor.data.migrations.data020.ProjectInfoVO projectInfoVO;
|
||||
|
||||
@Override
|
||||
public void setProject(String path, ProjectVO vo, ProjectInfoVO projectInfoVO) {
|
||||
projectPath = path;
|
||||
projectVO = vo;
|
||||
|
||||
json.setOutputType(JsonWriter.OutputType.json);
|
||||
String prjInfoFilePath = projectPath + "/project.dt";
|
||||
FileHandle projectInfoFile = Gdx.files.internal(prjInfoFilePath);
|
||||
String projectInfoContents = "{}";
|
||||
try {
|
||||
projectInfoContents = FileUtils.readFileToString(projectInfoFile.file(), "utf-8");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
this.projectInfoVO = json.fromJson(games.rednblack.editor.data.migrations.data020.ProjectInfoVO.class, projectInfoContents);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doMigration() {
|
||||
String srcPath = projectPath + File.separator + "scenes";
|
||||
FileHandle scenesDirectoryHandle = Gdx.files.absolute(srcPath);
|
||||
try {
|
||||
for (File scene : scenesDirectoryHandle.file().listFiles()) {
|
||||
games.rednblack.editor.data.migrations.data020.SceneVO sceneToExport = json.fromJson(games.rednblack.editor.data.migrations.data020.SceneVO.class, FileUtils.readFileToString(scene, "utf-8"));
|
||||
|
||||
SceneVO newVO = new SceneVO();
|
||||
newVO.sceneName = sceneToExport.sceneName;
|
||||
newVO.lightsPropertiesVO = sceneToExport.lightsPropertiesVO;
|
||||
newVO.physicsPropertiesVO = sceneToExport.physicsPropertiesVO;
|
||||
newVO.verticalGuides = sceneToExport.verticalGuides;
|
||||
newVO.horizontalGuides = sceneToExport.horizontalGuides;
|
||||
CompositeItemVO compositeItemVO = new CompositeItemVO();
|
||||
compositeItemVO.automaticResize = false;
|
||||
newVO.composite = compositeItemVO;
|
||||
|
||||
copyRecursiveElements(sceneToExport.composite, newVO.composite);
|
||||
|
||||
FileUtils.writeStringToFile(new File(projectPath + File.separator + "scenes" + File.separator + newVO.sceneName + ".dt"),
|
||||
newVO.constructJsonString(), "utf-8");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
ProjectInfoVO newProjectInfoVO = new ProjectInfoVO();
|
||||
newProjectInfoVO.pixelToWorld = projectInfoVO.pixelToWorld;
|
||||
newProjectInfoVO.originalResolution = projectInfoVO.originalResolution;
|
||||
newProjectInfoVO.resolutions = projectInfoVO.resolutions;
|
||||
for (games.rednblack.editor.data.migrations.data020.SceneVO sceneVO : projectInfoVO.scenes) {
|
||||
SceneVO newSceneVO = new SceneVO();
|
||||
newSceneVO.sceneName = sceneVO.sceneName;
|
||||
newProjectInfoVO.scenes.add(newSceneVO);
|
||||
}
|
||||
newProjectInfoVO.libraryActions = projectInfoVO.libraryActions;
|
||||
newProjectInfoVO.imagesPacks = projectInfoVO.imagesPacks;
|
||||
newProjectInfoVO.animationsPacks = projectInfoVO.animationsPacks;
|
||||
|
||||
HashMap<String, games.rednblack.editor.data.migrations.data020.CompositeItemVO> libraryItems = projectInfoVO.libraryItems;
|
||||
for (String key : libraryItems.keySet()) {
|
||||
games.rednblack.editor.data.migrations.data020.CompositeItemVO item = libraryItems.get(key);
|
||||
CompositeItemVO newLibraryItem = new CompositeItemVO();
|
||||
copyMainItemField(item, newLibraryItem);
|
||||
newLibraryItem.width = item.width;
|
||||
newLibraryItem.height = item.height;
|
||||
newLibraryItem.automaticResize = item.automaticResize;
|
||||
newLibraryItem.scissorsEnabled = item.scissorsEnabled;
|
||||
newLibraryItem.renderToFBO = item.renderToFBO;
|
||||
newProjectInfoVO.libraryItems.put(key, newLibraryItem);
|
||||
copyRecursiveElements(item.composite, newLibraryItem);
|
||||
}
|
||||
|
||||
try {
|
||||
FileUtils.writeStringToFile(new File(projectPath + File.separator + "project.dt"),
|
||||
newProjectInfoVO.constructJsonString(), "utf-8");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void copyRecursiveElements(CompositeVO vo, CompositeItemVO target) {
|
||||
for (int i = 0; i < vo.sImages.size(); i++) {
|
||||
target.addItem(vo.sImages.get(i));
|
||||
}
|
||||
for (int i = 0; i < vo.sImage9patchs.size(); i++) {
|
||||
target.addItem(vo.sImage9patchs.get(i));
|
||||
}
|
||||
for (int i = 0; i < vo.sLabels.size(); i++) {
|
||||
target.addItem(vo.sLabels.get(i));
|
||||
}
|
||||
for (int i = 0; i < vo.sParticleEffects.size(); i++) {
|
||||
target.addItem(vo.sParticleEffects.get(i));
|
||||
}
|
||||
for (int i = 0; i < vo.sTalosVFX.size(); i++) {
|
||||
target.addItem(vo.sTalosVFX.get(i));
|
||||
}
|
||||
for (int i = 0; i < vo.sImages.size(); i++) {
|
||||
target.addItem(vo.sImages.get(i));
|
||||
}
|
||||
for (int i = 0; i < vo.sLights.size(); i++) {
|
||||
target.addItem(vo.sLights.get(i));
|
||||
}
|
||||
for (int i = 0; i < vo.sSpineAnimations.size(); i++) {
|
||||
target.addItem(vo.sSpineAnimations.get(i));
|
||||
}
|
||||
for (int i = 0; i < vo.sSpriteAnimations.size(); i++) {
|
||||
target.addItem(vo.sSpriteAnimations.get(i));
|
||||
}
|
||||
for (int i = 0; i < vo.sColorPrimitives.size(); i++) {
|
||||
target.addItem(vo.sColorPrimitives.get(i));
|
||||
}
|
||||
for (String key : vo.sStickyNotes.keySet()) {
|
||||
target.sStickyNotes.put(key, vo.sStickyNotes.get(key));
|
||||
}
|
||||
for (int i = 0; i < vo.layers.size(); i++) {
|
||||
target.layers.add(vo.layers.get(i));
|
||||
}
|
||||
for (int i = 0; i < vo.sComposites.size(); i++) {
|
||||
games.rednblack.editor.data.migrations.data020.CompositeItemVO compositeItemVO = vo.sComposites.get(i);
|
||||
CompositeItemVO newCompositeItemVO = new CompositeItemVO();
|
||||
copyMainItemField(compositeItemVO, newCompositeItemVO);
|
||||
newCompositeItemVO.width = compositeItemVO.width;
|
||||
newCompositeItemVO.height = compositeItemVO.height;
|
||||
newCompositeItemVO.automaticResize = compositeItemVO.automaticResize;
|
||||
newCompositeItemVO.scissorsEnabled = compositeItemVO.scissorsEnabled;
|
||||
newCompositeItemVO.renderToFBO = compositeItemVO.renderToFBO;
|
||||
target.addItem(newCompositeItemVO);
|
||||
copyRecursiveElements(compositeItemVO.composite, newCompositeItemVO);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
target.customVars = vo.customVars;
|
||||
target.x = vo.x;
|
||||
target.y = vo.y;
|
||||
target.rotation = vo.rotation;
|
||||
target.zIndex = vo.zIndex;
|
||||
target.layerName = vo.layerName;
|
||||
if(vo.tint != null) target.tint = Arrays.copyOf(vo.tint, vo.tint.length);
|
||||
target.scaleX = vo.scaleX;
|
||||
target.scaleY = vo.scaleY;
|
||||
target.originX = vo.originX;
|
||||
target.originY = vo.originY;
|
||||
target.flipX = vo.flipX;
|
||||
target.flipY = vo.flipY;
|
||||
|
||||
if(vo.shape != null) {
|
||||
target.shape = vo.shape.clone();
|
||||
}
|
||||
|
||||
if(vo.circle != null) {
|
||||
target.circle = new Circle(vo.circle);
|
||||
}
|
||||
|
||||
if(vo.physics != null){
|
||||
target.physics = new PhysicsBodyDataVO(vo.physics);
|
||||
}
|
||||
|
||||
if (vo.sensor != null) {
|
||||
target.sensor = new SensorDataVO(vo.sensor);
|
||||
}
|
||||
|
||||
if(vo.light != null){
|
||||
target.light = new LightBodyDataVO(vo.light);
|
||||
}
|
||||
|
||||
target.shaderName = vo.shaderName;
|
||||
target.shaderUniforms.clear();
|
||||
target.shaderUniforms.putAll(vo.shaderUniforms);
|
||||
|
||||
target.renderingLayer = vo.renderingLayer;
|
||||
}
|
||||
}
|
||||
@@ -168,8 +168,7 @@ public class ItemFactory implements IFactory {
|
||||
HashMap<String, CompositeItemVO> libraryItems = projectManager.currentProjectInfoVO.libraryItems;
|
||||
|
||||
CompositeItemVO itemVO = libraryItems.get(libraryName);
|
||||
itemVO.uniqueId = -1;
|
||||
PasteItemsCommand.forceIdChange(itemVO.composite);
|
||||
itemVO.cleanIds();
|
||||
createdEntity = createCompositeItem(itemVO, position);
|
||||
|
||||
if (createdEntity == -1) return false;
|
||||
@@ -188,7 +187,7 @@ public class ItemFactory implements IFactory {
|
||||
|
||||
int entity = entityFactory.createEntity(sandbox.getCurrentViewingEntity(), vo);
|
||||
EntityFactory factory = sceneLoader.getEntityFactory();
|
||||
factory.initAllChildren(entity, vo.composite);
|
||||
factory.initAllChildren(entity, vo);
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import games.rednblack.editor.data.manager.PreferencesManager;
|
||||
import games.rednblack.editor.data.migrations.ProjectVersionMigrator;
|
||||
import games.rednblack.editor.renderer.data.*;
|
||||
import games.rednblack.editor.renderer.resources.FontSizePair;
|
||||
import games.rednblack.editor.renderer.utils.HyperJson;
|
||||
import games.rednblack.editor.utils.HyperLap2DUtils;
|
||||
import games.rednblack.editor.utils.RecursiveFileSuffixFilter;
|
||||
import games.rednblack.editor.view.menu.HyperLap2DMenuBar;
|
||||
@@ -202,7 +203,7 @@ public class ProjectManager extends Proxy {
|
||||
String projectContents = null;
|
||||
try {
|
||||
projectContents = FileUtils.readFileToString(projectFile.file(), "utf-8");
|
||||
Json json = new Json();
|
||||
Json json = HyperJson.getJson();
|
||||
json.setIgnoreUnknownFields(true);
|
||||
ProjectVO vo = json.fromJson(ProjectVO.class, projectContents);
|
||||
goThroughVersionMigrationProtocol(projectPath, vo);
|
||||
@@ -289,15 +290,15 @@ public class ProjectManager extends Proxy {
|
||||
FileHandle sourceDir = new FileHandle(projectPath + "/scenes/");
|
||||
for (FileHandle entry : sourceDir.list(HyperLap2DUtils.DT_FILTER)) {
|
||||
if (!entry.file().isDirectory()) {
|
||||
Json json = new Json();
|
||||
Json json = HyperJson.getJson();
|
||||
json.setIgnoreUnknownFields(true);
|
||||
SceneVO sceneVO = json.fromJson(SceneVO.class, entry);
|
||||
if (sceneVO.composite == null) continue;
|
||||
ArrayList<MainItemVO> items = sceneVO.composite.getAllItems();
|
||||
Array<MainItemVO> items = sceneVO.composite.getAllItems();
|
||||
|
||||
for (CompositeItemVO libraryItem : currentProjectInfoVO.libraryItems.values()) {
|
||||
if (libraryItem.composite == null) continue;
|
||||
items = libraryItem.composite.getAllItems();
|
||||
if (libraryItem == null) continue;
|
||||
items = libraryItem.getAllItems();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,10 +11,7 @@ import com.badlogic.gdx.graphics.g2d.*;
|
||||
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
|
||||
import com.badlogic.gdx.graphics.glutils.ShaderProgram;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Json;
|
||||
import com.badlogic.gdx.utils.ObjectMap;
|
||||
import com.badlogic.gdx.utils.*;
|
||||
import com.kotcrab.vis.ui.VisUI;
|
||||
import com.talosvfx.talos.runtime.ParticleEffectDescriptor;
|
||||
import com.talosvfx.talos.runtime.utils.ShaderDescriptor;
|
||||
@@ -25,6 +22,7 @@ import games.rednblack.editor.renderer.data.*;
|
||||
import games.rednblack.editor.renderer.resources.FontSizePair;
|
||||
import games.rednblack.editor.renderer.resources.IResourceRetriever;
|
||||
import games.rednblack.editor.renderer.utils.H2DSkinLoader;
|
||||
import games.rednblack.editor.renderer.utils.HyperJson;
|
||||
import games.rednblack.editor.renderer.utils.ShadedDistanceFieldFont;
|
||||
import games.rednblack.editor.view.ui.widget.actors.basic.WhitePixel;
|
||||
import games.rednblack.h2d.extension.talos.ResourceRetrieverAssetProvider;
|
||||
@@ -209,8 +207,7 @@ public class ResourceManager extends Proxy implements IResourceRetriever {
|
||||
SceneDataManager sceneDataManager = facade.retrieveProxy(SceneDataManager.NAME);
|
||||
// TODO: this should be cached
|
||||
FileHandle file = Gdx.files.internal(sceneDataManager.getCurrProjectScenePathByName(name));
|
||||
Json json = new Json();
|
||||
json.setIgnoreUnknownFields(true);
|
||||
Json json = HyperJson.getJson();
|
||||
return json.fromJson(SceneVO.class, file.readString());
|
||||
}
|
||||
|
||||
@@ -343,23 +340,26 @@ public class ResourceManager extends Proxy implements IResourceRetriever {
|
||||
}
|
||||
|
||||
public ArrayList<FontSizePair> getProjectRequiredFontsList() {
|
||||
HashSet<FontSizePair> fontsToLoad = new HashSet<>();
|
||||
ObjectSet<FontSizePair> fontsToLoad = new ObjectSet<>();
|
||||
|
||||
for (int i = 0; i < getProjectVO().scenes.size(); i++) {
|
||||
SceneVO scene = getSceneVO(getProjectVO().scenes.get(i).sceneName);
|
||||
CompositeVO composite = scene.composite;
|
||||
CompositeItemVO composite = scene.composite;
|
||||
if (composite == null) {
|
||||
continue;
|
||||
}
|
||||
FontSizePair[] fonts = composite.getRecursiveFontList();
|
||||
Array<FontSizePair> fonts = composite.getRecursiveFontList();
|
||||
for (CompositeItemVO library : getProjectVO().libraryItems.values()) {
|
||||
FontSizePair[] libFonts = library.composite.getRecursiveFontList();
|
||||
Collections.addAll(fontsToLoad, libFonts);
|
||||
Array<FontSizePair> libFonts = library.getRecursiveFontList();
|
||||
fontsToLoad.addAll(libFonts);
|
||||
}
|
||||
Collections.addAll(fontsToLoad, fonts);
|
||||
fontsToLoad.addAll(fonts);
|
||||
}
|
||||
|
||||
return new ArrayList<>(fontsToLoad);
|
||||
ArrayList<FontSizePair> result = new ArrayList<>();
|
||||
for (FontSizePair fontSizePair : fontsToLoad)
|
||||
result.add(fontSizePair);
|
||||
return result;
|
||||
}
|
||||
|
||||
public void loadCurrentProjectBitmapFonts(String path, String curResolution) {
|
||||
|
||||
@@ -20,11 +20,13 @@ package games.rednblack.editor.proxy;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Json;
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.renderer.data.CompositeItemVO;
|
||||
import games.rednblack.editor.renderer.data.CompositeVO;
|
||||
import games.rednblack.editor.renderer.data.MainItemVO;
|
||||
import games.rednblack.editor.renderer.data.SceneVO;
|
||||
import games.rednblack.editor.renderer.utils.HyperJson;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.puremvc.java.patterns.proxy.Proxy;
|
||||
|
||||
@@ -121,7 +123,7 @@ public class SceneDataManager extends Proxy {
|
||||
try {
|
||||
for (File scene : scenesDirectoryHandle.file().listFiles()) {
|
||||
File fileTarget = new File(targetPath + File.separator + scenesDirectoryHandle.name() + File.separator + scene.getName());
|
||||
Json json = new Json();
|
||||
Json json = HyperJson.getJson();
|
||||
SceneVO sceneToExport = json.fromJson(SceneVO.class, FileUtils.readFileToString(scene, "utf-8"));
|
||||
clearCompositesForExport(sceneToExport.composite);
|
||||
FileUtils.writeStringToFile(fileTarget, sceneToExport.constructJsonString(), "utf-8");
|
||||
@@ -137,13 +139,17 @@ public class SceneDataManager extends Proxy {
|
||||
}
|
||||
}
|
||||
|
||||
private void clearCompositesForExport(CompositeVO compositeVO) {
|
||||
private void clearCompositesForExport(CompositeItemVO compositeVO) {
|
||||
if (compositeVO == null)
|
||||
return;
|
||||
|
||||
compositeVO.sStickyNotes.clear();
|
||||
for (CompositeItemVO c : compositeVO.sComposites) {
|
||||
clearCompositesForExport(c.composite);
|
||||
Array<MainItemVO> sComposites = compositeVO.content.get(CompositeItemVO.class.getName());
|
||||
if (sComposites != null) {
|
||||
for (MainItemVO mainItemVO : sComposites) {
|
||||
CompositeItemVO c = (CompositeItemVO) mainItemVO;
|
||||
clearCompositesForExport(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.badlogic.gdx.utils.Json;
|
||||
import games.rednblack.editor.CustomExceptionHandler;
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.Main;
|
||||
import games.rednblack.editor.renderer.utils.HyperJson;
|
||||
import games.rednblack.editor.utils.HyperLap2DUtils;
|
||||
import games.rednblack.editor.utils.KeyBindingsLayout;
|
||||
import games.rednblack.h2d.common.vo.EditorConfigVO;
|
||||
@@ -99,11 +100,11 @@ public class SettingsManager extends Proxy {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
Json gson = new Json();
|
||||
Json json = HyperJson.getJson();
|
||||
String editorConfigJson;
|
||||
try {
|
||||
editorConfigJson = FileUtils.readFileToString(configFile, "utf-8");
|
||||
editorConfig = gson.fromJson(EditorConfigVO.class, editorConfigJson);
|
||||
editorConfig = json.fromJson(EditorConfigVO.class, editorConfigJson);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.proxy.ProjectManager;
|
||||
import games.rednblack.editor.proxy.ResolutionManager;
|
||||
import games.rednblack.editor.proxy.ResourceManager;
|
||||
import games.rednblack.editor.renderer.data.MainItemVO;
|
||||
import games.rednblack.editor.renderer.data.SceneVO;
|
||||
import games.rednblack.editor.utils.ImportUtils;
|
||||
import games.rednblack.editor.view.stage.Sandbox;
|
||||
@@ -25,7 +24,7 @@ public abstract class Asset implements IAsset {
|
||||
protected ResourceManager resourceManager;
|
||||
|
||||
protected final ArrayList<Integer> tmpEntityList = new ArrayList<>();
|
||||
protected final ArrayList<MainItemVO> tmpImageList = new ArrayList<>();
|
||||
protected final Array tmpImageList = new Array<>();
|
||||
|
||||
public Asset() {
|
||||
facade = HyperLap2DFacade.getInstance();
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Json;
|
||||
import games.rednblack.editor.renderer.data.GraphVO;
|
||||
import games.rednblack.editor.renderer.utils.HyperJson;
|
||||
import games.rednblack.editor.utils.ImportUtils;
|
||||
import games.rednblack.editor.utils.asset.Asset;
|
||||
import games.rednblack.h2d.common.ProgressHandler;
|
||||
@@ -11,7 +12,7 @@ import games.rednblack.h2d.common.ProgressHandler;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class HyperLap2DActionAsset extends Asset {
|
||||
private final Json json = new Json();
|
||||
private final Json json = HyperJson.getJson();
|
||||
|
||||
@Override
|
||||
protected boolean matchMimeType(FileHandle file) {
|
||||
|
||||
+3
-2
@@ -7,6 +7,7 @@ import games.rednblack.editor.renderer.data.CompositeItemVO;
|
||||
import games.rednblack.editor.renderer.data.Image9patchVO;
|
||||
import games.rednblack.editor.renderer.data.LabelVO;
|
||||
import games.rednblack.editor.renderer.data.MainItemVO;
|
||||
import games.rednblack.editor.renderer.utils.HyperJson;
|
||||
import games.rednblack.editor.utils.ImportUtils;
|
||||
import games.rednblack.editor.utils.asset.Asset;
|
||||
import games.rednblack.h2d.common.ProgressHandler;
|
||||
@@ -34,7 +35,7 @@ public class HyperLap2DInternalLibraryAsset extends Asset {
|
||||
@Override
|
||||
public void importAsset(Array<FileHandle> files, ProgressHandler progressHandler, boolean skipRepack) {
|
||||
for (FileHandle handle : new Array.ArrayIterator<>(files)) {
|
||||
Json json = new Json();
|
||||
Json json = HyperJson.getJson();
|
||||
String projectInfoContents = null;
|
||||
try {
|
||||
projectInfoContents = FileUtils.readFileToString(handle.file(), "utf-8");
|
||||
@@ -58,7 +59,7 @@ public class HyperLap2DInternalLibraryAsset extends Asset {
|
||||
|
||||
private void adjustPPWCoordinates(CompositeItemVO compositeItemVO) {
|
||||
int ppwu = projectManager.getCurrentProjectInfoVO().pixelToWorld;
|
||||
for (MainItemVO item : compositeItemVO.composite.getAllItems()) {
|
||||
for (MainItemVO item : compositeItemVO.getAllItems()) {
|
||||
item.originX = item.originX / ppwu;
|
||||
item.originY = item.originY / ppwu;
|
||||
item.x = item.x / ppwu;
|
||||
|
||||
@@ -9,6 +9,7 @@ import games.rednblack.editor.proxy.ResolutionManager;
|
||||
import games.rednblack.editor.renderer.components.MainItemComponent;
|
||||
import games.rednblack.editor.renderer.data.CompositeItemVO;
|
||||
import games.rednblack.editor.renderer.data.SceneVO;
|
||||
import games.rednblack.editor.renderer.utils.HyperJson;
|
||||
import games.rednblack.editor.utils.AssetImporter;
|
||||
import games.rednblack.editor.utils.ImportUtils;
|
||||
import games.rednblack.editor.utils.ZipUtils;
|
||||
@@ -73,8 +74,7 @@ public class HyperLap2DLibraryAsset extends Asset {
|
||||
FileUtils.deleteDirectory(tmpDir);
|
||||
FileUtils.forceMkdir(tmpDir);
|
||||
FileHandle mapper = ZipUtils.saveZipContent(fileHandle.file(), tmpDir);
|
||||
Json json = new Json();
|
||||
json.setIgnoreUnknownFields(true);
|
||||
Json json = HyperJson.getJson();
|
||||
ExportMapperVO exportMapperVO = json.fromJson(ExportMapperVO.class, mapper);
|
||||
|
||||
recursiveProgressHandler = new ProgressHandler() {
|
||||
|
||||
@@ -128,11 +128,10 @@ public class ImageAsset extends Asset {
|
||||
}
|
||||
|
||||
for (SceneVO scene : projectManager.currentProjectInfoVO.scenes) {
|
||||
CompositeItemVO tmpVo = new CompositeItemVO();
|
||||
SceneVO loadedScene = resourceManager.getSceneVO(scene.sceneName);
|
||||
tmpVo.composite = loadedScene.composite;
|
||||
CompositeItemVO tmpVo = new CompositeItemVO(loadedScene.composite);
|
||||
deleteAllImagesOfItem(tmpVo, imageName);
|
||||
loadedScene.composite = tmpVo.composite;
|
||||
loadedScene.composite = tmpVo;
|
||||
SceneDataManager sceneDataManager = facade.retrieveProxy(SceneDataManager.NAME);
|
||||
sceneDataManager.saveScene(loadedScene);
|
||||
}
|
||||
@@ -145,23 +144,25 @@ public class ImageAsset extends Asset {
|
||||
|
||||
private void deleteCurrentItemImage(CompositeItemVO compositeItemVO, String imageName) {
|
||||
tmpImageList.clear();
|
||||
if (compositeItemVO.composite != null && compositeItemVO.composite.sImages.size() != 0) {
|
||||
ArrayList<SimpleImageVO> simpleImageVOs = compositeItemVO.composite.sImages;
|
||||
tmpImageList.addAll(simpleImageVOs
|
||||
.stream()
|
||||
.filter(simpleImageVO -> simpleImageVO.imageName.equals(imageName))
|
||||
.collect(Collectors.toList()));
|
||||
simpleImageVOs.removeAll(tmpImageList);
|
||||
if (compositeItemVO != null && compositeItemVO.getElementsArray(SimpleImageVO.class).size != 0) {
|
||||
Array<SimpleImageVO> simpleImageVOs = compositeItemVO.getElementsArray(SimpleImageVO.class);
|
||||
|
||||
for (SimpleImageVO simpleImageVO : simpleImageVOs)
|
||||
if (simpleImageVO.getResourceName().equals(imageName))
|
||||
tmpImageList.add(simpleImageVO);
|
||||
|
||||
simpleImageVOs.removeAll(tmpImageList, true);
|
||||
}
|
||||
|
||||
tmpImageList.clear();
|
||||
if (compositeItemVO.composite != null && compositeItemVO.composite.sImage9patchs.size() != 0) {
|
||||
ArrayList<Image9patchVO> simple9PatchesVOs = compositeItemVO.composite.sImage9patchs;
|
||||
tmpImageList.addAll(simple9PatchesVOs
|
||||
.stream()
|
||||
.filter(simple9PatchVO -> simple9PatchVO.imageName.equals(imageName))
|
||||
.collect(Collectors.toList()));
|
||||
simple9PatchesVOs.removeAll(tmpImageList);
|
||||
if (compositeItemVO != null && compositeItemVO.getElementsArray(Image9patchVO.class).size != 0) {
|
||||
Array<Image9patchVO> simple9PatchesVOs = compositeItemVO.getElementsArray(Image9patchVO.class);
|
||||
|
||||
for (Image9patchVO simpleImageVO : simple9PatchesVOs)
|
||||
if (simpleImageVO.getResourceName().equals(imageName))
|
||||
tmpImageList.add(simpleImageVO);
|
||||
|
||||
simple9PatchesVOs.removeAll(tmpImageList, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -158,11 +158,10 @@ public class ParticleEffectAsset extends Asset {
|
||||
}
|
||||
|
||||
for (SceneVO scene : projectManager.currentProjectInfoVO.scenes) {
|
||||
CompositeItemVO tmpVo = new CompositeItemVO();
|
||||
SceneVO loadedScene = resourceManager.getSceneVO(scene.sceneName);
|
||||
tmpVo.composite = loadedScene.composite;
|
||||
CompositeItemVO tmpVo = new CompositeItemVO(loadedScene.composite);
|
||||
deleteAllParticles(tmpVo, name);
|
||||
loadedScene.composite = tmpVo.composite;
|
||||
loadedScene.composite = tmpVo;
|
||||
SceneDataManager sceneDataManager = facade.retrieveProxy(SceneDataManager.NAME);
|
||||
sceneDataManager.saveScene(loadedScene);
|
||||
}
|
||||
@@ -175,14 +174,14 @@ public class ParticleEffectAsset extends Asset {
|
||||
|
||||
private void getParticles(CompositeItemVO compositeItemVO, String name) {
|
||||
tmpImageList.clear();
|
||||
if (compositeItemVO.composite != null && compositeItemVO.composite.sParticleEffects.size() != 0) {
|
||||
ArrayList<ParticleEffectVO> particleEffectList = compositeItemVO.composite.sParticleEffects;
|
||||
for (ParticleEffectVO particleEffectVO : particleEffectList) {
|
||||
if (particleEffectVO.particleName.equals(name)) {
|
||||
tmpImageList.add(particleEffectVO);
|
||||
}
|
||||
}
|
||||
particleEffectList.removeAll(tmpImageList);
|
||||
if (compositeItemVO != null && compositeItemVO.getElementsArray(ParticleEffectVO.class).size != 0) {
|
||||
Array<ParticleEffectVO> particleEffectList = compositeItemVO.getElementsArray(ParticleEffectVO.class);
|
||||
|
||||
for (ParticleEffectVO spriteVO :particleEffectList)
|
||||
if (spriteVO.getResourceName().equals(name))
|
||||
tmpImageList.add(spriteVO);
|
||||
|
||||
particleEffectList.removeAll(tmpImageList, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,10 +9,7 @@ import com.kotcrab.vis.ui.util.dialog.Dialogs;
|
||||
import games.rednblack.editor.proxy.ProjectManager;
|
||||
import games.rednblack.editor.proxy.SceneDataManager;
|
||||
import games.rednblack.editor.renderer.components.SpineDataComponent;
|
||||
import games.rednblack.editor.renderer.data.CompositeItemVO;
|
||||
import games.rednblack.editor.renderer.data.ResolutionEntryVO;
|
||||
import games.rednblack.editor.renderer.data.SceneVO;
|
||||
import games.rednblack.editor.renderer.data.SpineVO;
|
||||
import games.rednblack.editor.renderer.data.*;
|
||||
import games.rednblack.editor.renderer.utils.Version;
|
||||
import games.rednblack.editor.utils.HyperLap2DUtils;
|
||||
import games.rednblack.editor.utils.ImportUtils;
|
||||
@@ -27,11 +24,9 @@ import org.apache.commons.io.FilenameUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class SpineAsset extends Asset {
|
||||
@Override
|
||||
@@ -217,11 +212,10 @@ public class SpineAsset extends Asset {
|
||||
}
|
||||
|
||||
for (SceneVO scene : projectManager.currentProjectInfoVO.scenes) {
|
||||
CompositeItemVO tmpVo = new CompositeItemVO();
|
||||
SceneVO loadedScene = resourceManager.getSceneVO(scene.sceneName);
|
||||
tmpVo.composite = loadedScene.composite;
|
||||
CompositeItemVO tmpVo = new CompositeItemVO(loadedScene.composite);
|
||||
deleteAllSpineAnimationsOfItem(tmpVo, spineAnimationName);
|
||||
loadedScene.composite = tmpVo.composite;
|
||||
loadedScene.composite = tmpVo;
|
||||
SceneDataManager sceneDataManager = facade.retrieveProxy(SceneDataManager.NAME);
|
||||
sceneDataManager.saveScene(loadedScene);
|
||||
}
|
||||
@@ -234,13 +228,14 @@ public class SpineAsset extends Asset {
|
||||
|
||||
private void deleteCurrentItemSpineAnimations(CompositeItemVO compositeItemVO, String spineAnimationName) {
|
||||
tmpImageList.clear();
|
||||
if (compositeItemVO.composite != null && compositeItemVO.composite.sSpineAnimations.size() != 0) {
|
||||
ArrayList<SpineVO> spineAnimations = compositeItemVO.composite.sSpineAnimations;
|
||||
tmpImageList.addAll(spineAnimations
|
||||
.stream()
|
||||
.filter(spineVO -> spineVO.animationName.equals(spineAnimationName))
|
||||
.collect(Collectors.toList()));
|
||||
spineAnimations.removeAll(tmpImageList);
|
||||
if (compositeItemVO != null && compositeItemVO.getElementsArray(SpineVO.class).size != 0) {
|
||||
Array<SpineVO> spineAnimations = compositeItemVO.getElementsArray(SpineVO.class);
|
||||
|
||||
for (SpineVO spriteVO :spineAnimations)
|
||||
if (spriteVO.getResourceName().equals(spineAnimationName))
|
||||
tmpImageList.add(spriteVO);
|
||||
|
||||
spineAnimations.removeAll(tmpImageList, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+8
-10
@@ -140,11 +140,10 @@ public class SpriteAnimationAtlasAsset extends Asset {
|
||||
}
|
||||
|
||||
for (SceneVO scene : projectManager.currentProjectInfoVO.scenes) {
|
||||
CompositeItemVO tmpVo = new CompositeItemVO();
|
||||
SceneVO loadedScene = resourceManager.getSceneVO(scene.sceneName);
|
||||
tmpVo.composite = loadedScene.composite;
|
||||
CompositeItemVO tmpVo = new CompositeItemVO(loadedScene.composite);
|
||||
deleteAllSpriteAnimationsOfItem(tmpVo, spriteAnimationName);
|
||||
loadedScene.composite = tmpVo.composite;
|
||||
loadedScene.composite = tmpVo;
|
||||
SceneDataManager sceneDataManager = facade.retrieveProxy(SceneDataManager.NAME);
|
||||
sceneDataManager.saveScene(loadedScene);
|
||||
}
|
||||
@@ -157,15 +156,14 @@ public class SpriteAnimationAtlasAsset extends Asset {
|
||||
|
||||
private void deleteCurrentItemSpriteAnimations(CompositeItemVO compositeItemVO, String spriteAnimationName) {
|
||||
tmpImageList.clear();
|
||||
if (compositeItemVO.composite != null && compositeItemVO.composite.sSpriteAnimations.size() != 0) {
|
||||
ArrayList<SpriteAnimationVO> spriteAnimations = compositeItemVO.composite.sSpriteAnimations;
|
||||
if (compositeItemVO != null && compositeItemVO.getElementsArray(SpriteAnimationVO.class).size != 0) {
|
||||
Array<SpriteAnimationVO> spriteAnimations = compositeItemVO.getElementsArray(SpriteAnimationVO.class);
|
||||
|
||||
tmpImageList.addAll(spriteAnimations
|
||||
.stream()
|
||||
.filter(spriteVO -> spriteVO.animationName.equals(spriteAnimationName))
|
||||
.collect(Collectors.toList()));
|
||||
for (SpriteAnimationVO spriteVO :spriteAnimations)
|
||||
if (spriteVO.getResourceName().equals(spriteAnimationName))
|
||||
tmpImageList.add(spriteVO);
|
||||
|
||||
spriteAnimations.removeAll(tmpImageList);
|
||||
spriteAnimations.removeAll(tmpImageList, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import games.rednblack.editor.proxy.SceneDataManager;
|
||||
import games.rednblack.editor.renderer.components.particle.TalosDataComponent;
|
||||
import games.rednblack.editor.renderer.data.CompositeItemVO;
|
||||
import games.rednblack.editor.renderer.data.SceneVO;
|
||||
import games.rednblack.editor.renderer.data.SpriteAnimationVO;
|
||||
import games.rednblack.editor.renderer.data.TalosVO;
|
||||
import games.rednblack.editor.utils.ImportUtils;
|
||||
import games.rednblack.editor.utils.asset.Asset;
|
||||
@@ -200,11 +201,10 @@ public class TalosVFXAsset extends Asset {
|
||||
}
|
||||
|
||||
for (SceneVO scene : projectManager.currentProjectInfoVO.scenes) {
|
||||
CompositeItemVO tmpVo = new CompositeItemVO();
|
||||
SceneVO loadedScene = resourceManager.getSceneVO(scene.sceneName);
|
||||
tmpVo.composite = loadedScene.composite;
|
||||
CompositeItemVO tmpVo = new CompositeItemVO(loadedScene.composite);
|
||||
deleteAllParticles(tmpVo, name);
|
||||
loadedScene.composite = tmpVo.composite;
|
||||
loadedScene.composite = tmpVo;
|
||||
SceneDataManager sceneDataManager = facade.retrieveProxy(SceneDataManager.NAME);
|
||||
sceneDataManager.saveScene(loadedScene);
|
||||
}
|
||||
@@ -217,14 +217,14 @@ public class TalosVFXAsset extends Asset {
|
||||
|
||||
private void getParticles(CompositeItemVO compositeItemVO, String name) {
|
||||
tmpImageList.clear();
|
||||
if (compositeItemVO.composite != null && compositeItemVO.composite.sTalosVFX.size() != 0) {
|
||||
ArrayList<TalosVO> particleEffectList = compositeItemVO.composite.sTalosVFX;
|
||||
for (TalosVO particleEffectVO : particleEffectList) {
|
||||
if (particleEffectVO.particleName.equals(name)) {
|
||||
tmpImageList.add(particleEffectVO);
|
||||
}
|
||||
}
|
||||
particleEffectList.removeAll(tmpImageList);
|
||||
if (compositeItemVO != null && compositeItemVO.getElementsArray(TalosVO.class).size != 0) {
|
||||
Array<TalosVO> particleEffectList = compositeItemVO.getElementsArray(TalosVO.class);
|
||||
|
||||
for (TalosVO spriteVO :particleEffectList)
|
||||
if (spriteVO.getResourceName().equals(name))
|
||||
tmpImageList.add(spriteVO);
|
||||
|
||||
particleEffectList.removeAll(tmpImageList, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,12 +25,14 @@ import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.Drawable;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Json;
|
||||
import com.badlogic.gdx.utils.reflect.ReflectionException;
|
||||
import com.kotcrab.vis.ui.VisUI;
|
||||
import games.rednblack.editor.renderer.components.*;
|
||||
import games.rednblack.editor.renderer.components.light.LightBodyComponent;
|
||||
import games.rednblack.editor.renderer.components.physics.PhysicsBodyComponent;
|
||||
import games.rednblack.editor.renderer.data.*;
|
||||
import games.rednblack.editor.renderer.factory.EntityFactory;
|
||||
import games.rednblack.editor.renderer.utils.HyperJson;
|
||||
import games.rednblack.editor.view.stage.Sandbox;
|
||||
|
||||
import java.util.*;
|
||||
@@ -301,8 +303,8 @@ public class EntityUtils {
|
||||
|
||||
public static void applyActionRecursivelyOnLibraryItems(CompositeItemVO rootCompositeItemVo, Consumer<CompositeItemVO> action) {
|
||||
action.accept(rootCompositeItemVo);
|
||||
if (rootCompositeItemVo.composite != null && rootCompositeItemVo.composite.sComposites.size() != 0) {
|
||||
for (CompositeItemVO currentCompositeItemVo : rootCompositeItemVo.composite.sComposites) {
|
||||
if (rootCompositeItemVo != null && rootCompositeItemVo.getElementsArray(CompositeItemVO.class).size != 0) {
|
||||
for (CompositeItemVO currentCompositeItemVo : rootCompositeItemVo.getElementsArray(CompositeItemVO.class)) {
|
||||
applyActionRecursivelyOnLibraryItems(currentCompositeItemVo, action);
|
||||
}
|
||||
}
|
||||
@@ -333,167 +335,41 @@ public class EntityUtils {
|
||||
}
|
||||
|
||||
public static int getEntityFromJson(String jsonString, int entityType, EntityFactory factory, int parent) {
|
||||
Json json = new Json();
|
||||
if(entityType == EntityFactory.COMPOSITE_TYPE) {
|
||||
CompositeItemVO vo = json.fromJson(CompositeItemVO.class, jsonString);
|
||||
return factory.createEntity(parent, vo);
|
||||
}
|
||||
if(entityType == EntityFactory.IMAGE_TYPE) {
|
||||
SimpleImageVO vo = json.fromJson(SimpleImageVO.class, jsonString);
|
||||
return factory.createEntity(parent, vo);
|
||||
}
|
||||
if(entityType == EntityFactory.NINE_PATCH) {
|
||||
Image9patchVO vo = json.fromJson(Image9patchVO.class, jsonString);
|
||||
return factory.createEntity(parent, vo);
|
||||
}
|
||||
if(entityType == EntityFactory.LABEL_TYPE) {
|
||||
LabelVO vo = json.fromJson(LabelVO.class, jsonString);
|
||||
return factory.createEntity(parent, vo);
|
||||
}
|
||||
if(entityType == EntityFactory.PARTICLE_TYPE) {
|
||||
ParticleEffectVO vo = json.fromJson(ParticleEffectVO.class, jsonString);
|
||||
return factory.createEntity(parent, vo);
|
||||
}
|
||||
if(entityType == EntityFactory.TALOS_TYPE) {
|
||||
TalosVO vo = json.fromJson(TalosVO.class, jsonString);
|
||||
return factory.createEntity(parent, vo);
|
||||
}
|
||||
if(entityType == EntityFactory.SPRITE_TYPE) {
|
||||
SpriteAnimationVO vo = json.fromJson(SpriteAnimationVO.class, jsonString);
|
||||
return factory.createEntity(parent, vo);
|
||||
}
|
||||
if(entityType == EntityFactory.SPINE_TYPE) {
|
||||
SpineVO vo = json.fromJson(SpineVO.class, jsonString);
|
||||
return factory.createEntity(parent, vo);
|
||||
}
|
||||
if(entityType == EntityFactory.COLOR_PRIMITIVE) {
|
||||
ColorPrimitiveVO vo = json.fromJson(ColorPrimitiveVO.class, jsonString);
|
||||
return factory.createEntity(parent, vo);
|
||||
}
|
||||
if(entityType == EntityFactory.LIGHT_TYPE) {
|
||||
LightVO vo = json.fromJson(LightVO.class, jsonString);
|
||||
return factory.createEntity(parent, vo);
|
||||
}
|
||||
return -1;
|
||||
return factory.createEntity(parent, factory.instantiateVOFromJson(jsonString, entityType));
|
||||
}
|
||||
|
||||
public static String getJsonStringFromEntity(int entity) {
|
||||
Json json = new Json();
|
||||
Json json = HyperJson.getJson();
|
||||
com.artemis.World engine = Sandbox.getInstance().getEngine();
|
||||
EntityFactory entityFactory = Sandbox.getInstance().sceneControl.sceneLoader.getEntityFactory();
|
||||
int entityType = SandboxComponentRetriever.get(entity, MainItemComponent.class).entityType;
|
||||
if(entityType == EntityFactory.COMPOSITE_TYPE) {
|
||||
CompositeItemVO vo = new CompositeItemVO();
|
||||
vo.loadFromEntity(entity, engine);
|
||||
return json.toJson(vo);
|
||||
}
|
||||
if(entityType == EntityFactory.IMAGE_TYPE) {
|
||||
SimpleImageVO vo = new SimpleImageVO();
|
||||
vo.loadFromEntity(entity, engine);
|
||||
return json.toJson(vo);
|
||||
}
|
||||
if(entityType == EntityFactory.NINE_PATCH) {
|
||||
Image9patchVO vo = new Image9patchVO();
|
||||
vo.loadFromEntity(entity, engine);
|
||||
return json.toJson(vo);
|
||||
}
|
||||
if(entityType == EntityFactory.LABEL_TYPE) {
|
||||
LabelVO vo = new LabelVO();
|
||||
vo.loadFromEntity(entity, engine);
|
||||
return json.toJson(vo);
|
||||
}
|
||||
if(entityType == EntityFactory.PARTICLE_TYPE) {
|
||||
ParticleEffectVO vo = new ParticleEffectVO();
|
||||
vo.loadFromEntity(entity, engine);
|
||||
return json.toJson(vo);
|
||||
}
|
||||
if(entityType == EntityFactory.TALOS_TYPE) {
|
||||
TalosVO vo = new TalosVO();
|
||||
vo.loadFromEntity(entity, engine);
|
||||
return json.toJson(vo);
|
||||
}
|
||||
if(entityType == EntityFactory.SPRITE_TYPE) {
|
||||
SpriteAnimationVO vo = new SpriteAnimationVO();
|
||||
vo.loadFromEntity(entity, engine);
|
||||
return json.toJson(vo);
|
||||
}
|
||||
if(entityType == EntityFactory.SPINE_TYPE) {
|
||||
SpineVO vo = new SpineVO();
|
||||
vo.loadFromEntity(entity, engine);
|
||||
return json.toJson(vo);
|
||||
}
|
||||
if(entityType == EntityFactory.COLOR_PRIMITIVE) {
|
||||
ColorPrimitiveVO vo = new ColorPrimitiveVO();
|
||||
vo.loadFromEntity(entity, engine);
|
||||
return json.toJson(vo);
|
||||
}
|
||||
if(entityType == EntityFactory.LIGHT_TYPE) {
|
||||
LightVO vo = new LightVO();
|
||||
vo.loadFromEntity(entity, engine);
|
||||
return json.toJson(vo);
|
||||
try {
|
||||
MainItemVO entityVO = entityFactory.instantiateEmptyVO(entityType);
|
||||
entityVO.loadFromEntity(entity, engine, entityFactory);
|
||||
return json.toJson(entityVO);
|
||||
} catch (ReflectionException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getJsonStringFromEntities(Set<Integer> entities) {
|
||||
CompositeVO holderComposite = new CompositeVO();
|
||||
CompositeItemVO holderComposite = new CompositeItemVO();
|
||||
com.artemis.World engine = Sandbox.getInstance().getEngine();
|
||||
for(int entity : entities) {
|
||||
EntityFactory entityFactory = Sandbox.getInstance().sceneControl.sceneLoader.getEntityFactory();
|
||||
for (int entity : entities) {
|
||||
int entityType = SandboxComponentRetriever.get(entity, MainItemComponent.class).entityType;
|
||||
if(entityType == EntityFactory.COMPOSITE_TYPE) {
|
||||
CompositeItemVO vo = new CompositeItemVO();
|
||||
vo.loadFromEntity(entity, engine);
|
||||
holderComposite.sComposites.add(vo);
|
||||
}
|
||||
if(entityType == EntityFactory.IMAGE_TYPE) {
|
||||
SimpleImageVO vo = new SimpleImageVO();
|
||||
vo.loadFromEntity(entity, engine);
|
||||
holderComposite.sImages.add(vo);
|
||||
}
|
||||
if(entityType == EntityFactory.NINE_PATCH) {
|
||||
Image9patchVO vo = new Image9patchVO();
|
||||
vo.loadFromEntity(entity, engine);
|
||||
holderComposite.sImage9patchs.add(vo);
|
||||
}
|
||||
if(entityType == EntityFactory.LABEL_TYPE) {
|
||||
LabelVO vo = new LabelVO();
|
||||
vo.loadFromEntity(entity, engine);
|
||||
holderComposite.sLabels.add(vo);
|
||||
}
|
||||
if(entityType == EntityFactory.PARTICLE_TYPE) {
|
||||
ParticleEffectVO vo = new ParticleEffectVO();
|
||||
vo.loadFromEntity(entity, engine);
|
||||
holderComposite.sParticleEffects.add(vo);
|
||||
}
|
||||
if(entityType == EntityFactory.TALOS_TYPE) {
|
||||
TalosVO vo = new TalosVO();
|
||||
vo.loadFromEntity(entity, engine);
|
||||
holderComposite.sTalosVFX.add(vo);
|
||||
}
|
||||
if(entityType == EntityFactory.SPRITE_TYPE) {
|
||||
SpriteAnimationVO vo = new SpriteAnimationVO();
|
||||
vo.loadFromEntity(entity, engine);
|
||||
holderComposite.sSpriteAnimations.add(vo);
|
||||
}
|
||||
if(entityType == EntityFactory.SPINE_TYPE) {
|
||||
SpineVO vo = new SpineVO();
|
||||
vo.loadFromEntity(entity, engine);
|
||||
holderComposite.sSpineAnimations.add(vo);
|
||||
}
|
||||
if(entityType == EntityFactory.COLOR_PRIMITIVE) {
|
||||
ColorPrimitiveVO vo = new ColorPrimitiveVO();
|
||||
vo.loadFromEntity(entity, engine);
|
||||
holderComposite.sColorPrimitives.add(vo);
|
||||
}
|
||||
if(entityType == EntityFactory.LIGHT_TYPE) {
|
||||
LightVO vo = new LightVO();
|
||||
vo.loadFromEntity(entity, engine);
|
||||
holderComposite.sLights.add(vo);
|
||||
try {
|
||||
MainItemVO entityVO = entityFactory.instantiateEmptyVO(entityType);
|
||||
entityVO.loadFromEntity(entity, engine, entityFactory);
|
||||
holderComposite.addItem(entityVO);
|
||||
} catch (ReflectionException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
Json json = new Json();
|
||||
String result = json.toJson(holderComposite);
|
||||
Json json = HyperJson.getJson();
|
||||
|
||||
return result;
|
||||
return json.toJson(holderComposite);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,12 +39,13 @@ import games.rednblack.editor.renderer.SceneConfiguration;
|
||||
import games.rednblack.editor.renderer.SceneLoader;
|
||||
import games.rednblack.editor.renderer.components.ViewPortComponent;
|
||||
import games.rednblack.editor.renderer.components.additional.ButtonComponent;
|
||||
import games.rednblack.editor.renderer.data.CompositeVO;
|
||||
import games.rednblack.editor.renderer.data.CompositeItemVO;
|
||||
import games.rednblack.editor.renderer.data.SceneVO;
|
||||
import games.rednblack.editor.renderer.physics.PhysicsBodyLoader;
|
||||
import games.rednblack.editor.renderer.systems.LightSystem;
|
||||
import games.rednblack.editor.renderer.systems.ParticleSystem;
|
||||
import games.rednblack.editor.renderer.systems.PhysicsSystem;
|
||||
import games.rednblack.editor.renderer.utils.HyperJson;
|
||||
import games.rednblack.editor.system.ParticleContinuousSystem;
|
||||
import games.rednblack.editor.system.PhysicsAdjustSystem;
|
||||
import games.rednblack.editor.system.TalosContinuousSystem;
|
||||
@@ -313,26 +314,11 @@ public class Sandbox {
|
||||
* @return SceneVO
|
||||
*/
|
||||
public SceneVO sceneVoFromItems() {
|
||||
CompositeVO newVo = new CompositeVO();
|
||||
newVo.loadFromEntity(getRootEntity(), getEngine());
|
||||
CompositeItemVO newVo = new CompositeItemVO();
|
||||
newVo.loadFromEntity(getRootEntity(), getEngine(), sceneControl.sceneLoader.getEntityFactory());
|
||||
newVo.sStickyNotes.putAll(sceneControl.getCurrentSceneVO().composite.sStickyNotes);
|
||||
sceneControl.getCurrentSceneVO().composite = newVo;
|
||||
|
||||
//TODO WIP Artemis serialization
|
||||
/*try {
|
||||
//Serialize
|
||||
FileOutputStream fos = new FileOutputStream("level.json");
|
||||
manager.save(fos, new SaveFileFormat(getEngine().getAspectSubscriptionManager().get(Aspect.all())));
|
||||
fos.close();
|
||||
|
||||
//Deserialize
|
||||
final InputStream is = new FileInputStream("level.json");
|
||||
SaveFileFormat sff = manager.load(is, SaveFileFormat.class);
|
||||
sceneLoader.getEntityFactoryV2().loadEntities(getCurrentViewingEntity(), sff.entities);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}*/
|
||||
|
||||
return sceneControl.getCurrentSceneVO();
|
||||
}
|
||||
|
||||
@@ -519,13 +505,13 @@ public class Sandbox {
|
||||
payload[1] = data;
|
||||
|
||||
Lwjgl3Application app = (Lwjgl3Application) Gdx.app;
|
||||
Json json = new Json();
|
||||
Json json = HyperJson.getJson();
|
||||
app.getClipboard().setContents(json.toJson(payload));
|
||||
}
|
||||
|
||||
public static Object retrieveFromClipboard() {
|
||||
Lwjgl3Application app = (Lwjgl3Application) Gdx.app;
|
||||
Json json = new Json();
|
||||
Json json = HyperJson.getJson();
|
||||
Object[] data = null;
|
||||
try {
|
||||
data = json.fromJson(Object[].class, app.getClipboard().getContents());
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package games.rednblack.editor.view.ui.box;
|
||||
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.kotcrab.vis.ui.util.dialog.Dialogs;
|
||||
import com.kotcrab.vis.ui.util.dialog.InputDialogListener;
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
@@ -46,7 +47,7 @@ public class UILayerBoxMediator extends PanelMediator<UILayerBox> {
|
||||
private static final String TAG = UILayerBoxMediator.class.getCanonicalName();
|
||||
public static final String NAME = TAG;
|
||||
|
||||
private ArrayList<LayerItemVO> layers;
|
||||
private Array<LayerItemVO> layers;
|
||||
|
||||
public UILayerBoxMediator() {
|
||||
super(NAME, new UILayerBox());
|
||||
@@ -214,7 +215,7 @@ public class UILayerBoxMediator extends PanelMediator<UILayerBox> {
|
||||
|
||||
private void setSelectedByName(String name) {
|
||||
String deletedLayerName = name;
|
||||
for (int i = 0; i < layers.size(); i++) {
|
||||
for (int i = 0; i < layers.size; i++) {
|
||||
if (layers.get(i).layerName.equals(deletedLayerName)) {
|
||||
viewComponent.setCurrentSelectedLayer(i);
|
||||
viewComponent.currentSelectedLayerIndex = i;
|
||||
@@ -289,7 +290,7 @@ public class UILayerBoxMediator extends PanelMediator<UILayerBox> {
|
||||
}
|
||||
|
||||
private int findLayerByName(String name) {
|
||||
for (int i = 0; i < layers.size(); i++) {
|
||||
for (int i = 0; i < layers.size; i++) {
|
||||
if (layers.get(i).layerName.equals(name)) {
|
||||
return i;
|
||||
}
|
||||
@@ -299,7 +300,7 @@ public class UILayerBoxMediator extends PanelMediator<UILayerBox> {
|
||||
}
|
||||
|
||||
private boolean checkIfNameIsUnique(String name) {
|
||||
for (int i = 0; i < layers.size(); i++) {
|
||||
for (int i = 0; i < layers.size; i++) {
|
||||
if (layers.get(i).layerName.equals(name)) {
|
||||
return false;
|
||||
}
|
||||
@@ -309,7 +310,7 @@ public class UILayerBoxMediator extends PanelMediator<UILayerBox> {
|
||||
}
|
||||
|
||||
private int getFirstFreeLayer() {
|
||||
for(int i = 0; i < layers.size(); i++) {
|
||||
for(int i = 0; i < layers.size; i++) {
|
||||
if(!layers.get(i).isLocked) {
|
||||
return i;
|
||||
}
|
||||
@@ -325,7 +326,7 @@ public class UILayerBoxMediator extends PanelMediator<UILayerBox> {
|
||||
|
||||
viewComponent.clearItems();
|
||||
|
||||
for (int i = (layers.size()-1); i >=0; i--) {
|
||||
for (int i = (layers.size-1); i >=0; i--) {
|
||||
viewComponent.addItem(layers.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ public class UICompositeItemPropertiesMediator extends UIItemPropertiesMediator<
|
||||
@Override
|
||||
protected void translateViewToItemData() {
|
||||
CompositeItemVO payloadVo = new CompositeItemVO();
|
||||
payloadVo.loadFromEntity(observableReference, sandbox.getEngine());
|
||||
payloadVo.loadFromEntity(observableReference, sandbox.getEngine(), sandbox.sceneControl.sceneLoader.getEntityFactory());
|
||||
|
||||
payloadVo.automaticResize = viewComponent.isAutomaticResizeIsEnabled();
|
||||
payloadVo.scissorsEnabled = viewComponent.isScissorsEnabled();
|
||||
|
||||
+2
-2
@@ -60,10 +60,10 @@ public class UILightItemPropertiesMediator extends UIItemPropertiesMediator<UILi
|
||||
@Override
|
||||
protected void translateViewToItemData() {
|
||||
LightVO oldPayloadVo = new LightVO();
|
||||
oldPayloadVo.loadFromEntity(observableReference, sandbox.getEngine());
|
||||
oldPayloadVo.loadFromEntity(observableReference, sandbox.getEngine(), sandbox.sceneControl.sceneLoader.getEntityFactory());
|
||||
|
||||
LightVO payloadVo = new LightVO();
|
||||
payloadVo.loadFromEntity(observableReference, sandbox.getEngine());
|
||||
payloadVo.loadFromEntity(observableReference, sandbox.getEngine(), sandbox.sceneControl.sceneLoader.getEntityFactory());
|
||||
|
||||
payloadVo.rays = viewComponent.getRayCount();
|
||||
payloadVo.isStatic = viewComponent.isStatic();
|
||||
|
||||
Reference in New Issue
Block a user