Fix few things for particles
This commit is contained in:
+2
@@ -3,6 +3,7 @@ package games.rednblack.editor.controller.commands.resource;
|
||||
import games.rednblack.editor.renderer.data.SceneVO;
|
||||
import games.rednblack.editor.utils.AssetIOManager;
|
||||
import games.rednblack.editor.utils.AssetsUtils;
|
||||
import games.rednblack.editor.view.stage.Sandbox;
|
||||
|
||||
/**
|
||||
* Created by Sasun Poghosyan on 5/10/2016.
|
||||
@@ -25,6 +26,7 @@ public class DeleteParticleEffect extends DeleteResourceCommand {
|
||||
sendNotification(DONE, particleName);
|
||||
SceneVO vo = sandbox.sceneVoFromItems();
|
||||
projectManager.saveCurrentProject(vo);
|
||||
Sandbox.getInstance().loadCurrentProject();
|
||||
} else {
|
||||
cancel();
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package games.rednblack.editor.controller.commands.resource;
|
||||
import games.rednblack.editor.renderer.data.SceneVO;
|
||||
import games.rednblack.editor.utils.AssetIOManager;
|
||||
import games.rednblack.editor.utils.AssetsUtils;
|
||||
import games.rednblack.editor.view.stage.Sandbox;
|
||||
|
||||
public class DeleteTalosVFX extends DeleteResourceCommand {
|
||||
|
||||
@@ -22,6 +23,7 @@ public class DeleteTalosVFX extends DeleteResourceCommand {
|
||||
sendNotification(DONE, particleName);
|
||||
SceneVO vo = sandbox.sceneVoFromItems();
|
||||
projectManager.saveCurrentProject(vo);
|
||||
Sandbox.getInstance().loadCurrentProject();
|
||||
} else {
|
||||
cancel();
|
||||
}
|
||||
|
||||
@@ -4,10 +4,10 @@ import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Json;
|
||||
import com.kotcrab.vis.ui.util.dialog.Dialogs;
|
||||
import games.rednblack.editor.utils.runtime.TalosExportFormat;
|
||||
import games.rednblack.talos.runtime.ParticleEffectDescriptor;
|
||||
import games.rednblack.talos.runtime.ParticleEmitterDescriptor;
|
||||
import games.rednblack.talos.runtime.modules.*;
|
||||
import games.rednblack.talos.runtime.serialization.ExportData;
|
||||
import games.rednblack.editor.proxy.ProjectManager;
|
||||
import games.rednblack.editor.proxy.ResolutionManager;
|
||||
import games.rednblack.editor.proxy.SceneDataManager;
|
||||
@@ -32,6 +32,16 @@ import java.util.function.Consumer;
|
||||
|
||||
public class TalosVFXAsset extends Asset {
|
||||
|
||||
Json talosJson = new Json();
|
||||
|
||||
public TalosVFXAsset() {
|
||||
talosJson.setIgnoreUnknownFields(true);
|
||||
ParticleEmitterDescriptor.registerModules();
|
||||
for (Class clazz: ParticleEmitterDescriptor.registeredModules) {
|
||||
talosJson.addClassTag(clazz.getSimpleName(), TalosExportFormat.Module.class);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean matchMimeType(FileHandle file) {
|
||||
try {
|
||||
@@ -60,20 +70,13 @@ public class TalosVFXAsset extends Asset {
|
||||
|
||||
@Override
|
||||
public void importAsset(Array<FileHandle> files, ProgressHandler progressHandler, boolean skipRepack) {
|
||||
Json json = new Json();
|
||||
json.setIgnoreUnknownFields(true);
|
||||
ParticleEmitterDescriptor.registerModules();
|
||||
for (Class clazz: ParticleEmitterDescriptor.registeredModules) {
|
||||
json.addClassTag(clazz.getSimpleName(), clazz);
|
||||
}
|
||||
|
||||
final String targetPath = projectManager.getCurrentProjectPath() + File.separator + ProjectManager.TALOS_VFX_DIR_PATH;
|
||||
Array<FileHandle> images = new Array<>();
|
||||
Array<FileHandle> assetsRes = new Array<>();
|
||||
for (FileHandle fileHandle : new Array.ArrayIterator<>(files)) {
|
||||
if (!fileHandle.isDirectory() && fileHandle.exists()) {
|
||||
try {
|
||||
ExportData talosResources = json.fromJson(ExportData.class, fileHandle);
|
||||
TalosExportFormat talosResources = talosJson.fromJson(TalosExportFormat.class, fileHandle);
|
||||
//copy images
|
||||
boolean allImagesFound = addTalosImages(talosResources, fileHandle, images);
|
||||
if (allImagesFound) {
|
||||
@@ -123,15 +126,26 @@ public class TalosVFXAsset extends Asset {
|
||||
String particlePath = projectManager.getCurrentProjectPath() + File.separator + ProjectManager.TALOS_VFX_DIR_PATH + File.separator;
|
||||
String filePath = particlePath + name;
|
||||
|
||||
if ((new File(filePath)).delete()) {
|
||||
FileHandle fileHandle = new FileHandle(filePath);
|
||||
|
||||
TalosExportFormat talosResources = talosJson.fromJson(TalosExportFormat.class, fileHandle);
|
||||
|
||||
if (fileHandle.delete()) {
|
||||
deleteEntitiesWithParticleEffects(root, name); // delete entities from scene
|
||||
deleteAllItemsWithParticleName(name);
|
||||
|
||||
Array<String> resources = talosResources.metadata.resources;
|
||||
for (String res : resources) {
|
||||
String resPath = particlePath + res;
|
||||
FileHandle resHandle = new FileHandle(resPath);
|
||||
resHandle.delete();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean addTalosImages(ExportData talosResources, FileHandle fileHandle, Array<FileHandle> imgs) {
|
||||
private boolean addTalosImages(TalosExportFormat talosResources, FileHandle fileHandle, Array<FileHandle> imgs) {
|
||||
try {
|
||||
Array<String> resources = talosResources.metadata.resources;
|
||||
for (String res : resources) {
|
||||
@@ -157,7 +171,7 @@ public class TalosVFXAsset extends Asset {
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean addTalosRes(ExportData talosResources, FileHandle fileHandle, Array<FileHandle> imgs) {
|
||||
private boolean addTalosRes(TalosExportFormat talosResources, FileHandle fileHandle, Array<FileHandle> imgs) {
|
||||
try {
|
||||
Array<String> resources = talosResources.metadata.resources;
|
||||
for (String res : resources) {
|
||||
@@ -260,7 +274,7 @@ public class TalosVFXAsset extends Asset {
|
||||
}
|
||||
|
||||
if (module instanceof VectorFieldModule) {
|
||||
String path = ((VectorFieldModule) module).fgaFileName + ".fga";
|
||||
String path = ((VectorFieldModule) module).fgaFileName;
|
||||
File f = new File(currentProjectPath + ProjectManager.TALOS_VFX_DIR_PATH + File.separator + path);
|
||||
FileUtils.copyFileToDirectory(f, tmpDir);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package games.rednblack.editor.utils.runtime;
|
||||
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class TalosExportFormat {
|
||||
|
||||
public Metadata metadata = new Metadata();
|
||||
|
||||
public Array<Emitter> emitters = new Array<>();
|
||||
|
||||
public static class Metadata {
|
||||
public Array<String> resources = new Array<>();
|
||||
}
|
||||
|
||||
public static class Emitter {
|
||||
public Array<Module> modules = new Array<>();
|
||||
}
|
||||
|
||||
public static class Module extends HashMap<String, Object> {
|
||||
|
||||
}
|
||||
}
|
||||
+1
-3
@@ -77,9 +77,7 @@ public class UIAnimationsTabMediator extends UIResourcesTabMediator<UIAnimations
|
||||
animationBoxes.clear();
|
||||
ResourceManager resourceManager = facade.retrieveProxy(ResourceManager.NAME);
|
||||
|
||||
if (new SpineItemType().getTypeId() == SpineItemType.SPINE_TYPE) {
|
||||
createAnimationResources(resourceManager.getProjectSpineAnimationsList().keySet(), SpineResource.class, ItemFactory.get()::createSpineAnimation, searchText);
|
||||
}
|
||||
createAnimationResources(resourceManager.getProjectSpineAnimationsList().keySet(), SpineResource.class, ItemFactory.get()::createSpineAnimation, searchText);
|
||||
createAnimationResources(resourceManager.getProjectSpriteAnimationsList().keySet(), SpriteResource.class, ItemFactory.get()::createSpriteAnimation, searchText);
|
||||
animationBoxes.sort();
|
||||
viewComponent.setThumbnailBoxes(animationBoxes);
|
||||
|
||||
+2
-4
@@ -78,11 +78,9 @@ public class UIParticleEffectsTabMediator extends UIResourcesTabMediator<UIParti
|
||||
particlesList.clear();
|
||||
ResourceManager resourceManager = facade.retrieveProxy(ResourceManager.NAME);
|
||||
|
||||
if (new TalosItemType().getTypeId() == TalosItemType.TALOS_TYPE) {
|
||||
createParticleResources(resourceManager.getProjectTalosList().keySet(), TalosResource.class, ItemFactory.get()::tryCreateTalosItem, searchText);
|
||||
}
|
||||
|
||||
createParticleResources(resourceManager.getProjectTalosList().keySet(), TalosResource.class, ItemFactory.get()::tryCreateTalosItem, searchText);
|
||||
createParticleResources(resourceManager.getProjectParticleList().keySet(), ParticleEffectResource.class, ItemFactory.get()::tryCreateParticleItem, searchText);
|
||||
|
||||
particlesList.sort();
|
||||
viewComponent.setItems(particlesList);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user