diff --git a/build.gradle b/build.gradle index 8c988b6f3..09780f7e5 100755 --- a/build.gradle +++ b/build.gradle @@ -19,7 +19,7 @@ allprojects { version = '0.1.3' ext { appName = 'Overlap2D' - gdxVersion = '1.7.1' + gdxVersion = '1.9.3' box2DLightsVersion = '1.4' visuiVersion = '0.9.2' diff --git a/overlap2d-common-api/src/com/commons/MsgAPI.java b/overlap2d-common-api/src/com/commons/MsgAPI.java index 3cbe07062..5649e1997 100644 --- a/overlap2d-common-api/src/com/commons/MsgAPI.java +++ b/overlap2d-common-api/src/com/commons/MsgAPI.java @@ -88,6 +88,9 @@ public class MsgAPI { public static final String ACTION_ADD_TO_LIBRARY = SANDBOX_PREFIX + "ACTION_ADD_TO_LIBRARY"; public static final String ACTION_EDIT_PHYSICS = SANDBOX_PREFIX + "ACTION_EDIT_PHYSICS"; public static final String ACTION_SET_GRID_SIZE_FROM_ITEM = SANDBOX_PREFIX + "ACTION_SET_GRID_SIZE_FROM_ITEM"; + public static final String ACTION_EXPORT_AS_LIBRARY_ITEM = SANDBOX_PREFIX + "ACTION_EXPORT_AS_LIBRARY_ITEM"; + public static final String ACTION_EXPORT_AS_LIBRARY_ITEM_FROM_RES_PANEL = SANDBOX_PREFIX + "ACTION_EXPORT_AS_LIBRARY_ITEM_FROM_RES_PANEL"; + public static final String ACTION_ITEMS_MOVE_TO = SANDBOX_PREFIX + "ACTION_ITEMS_MOVE_TO"; public static final String ACTION_ITEM_AND_CHILDREN_TO = GLOBAL_PREFIX + "ACTION_ITEM_AND_CHILDREN_TO"; public static final String ACTION_ITEM_TRANSFORM_TO = SANDBOX_PREFIX + "ACTION_ITEM_TRANSFORM_TO"; diff --git a/overlap2d/src/com/uwsoft/editor/controller/BootstrapCommand.java b/overlap2d/src/com/uwsoft/editor/controller/BootstrapCommand.java index 1ddc84c51..6450184ad 100644 --- a/overlap2d/src/com/uwsoft/editor/controller/BootstrapCommand.java +++ b/overlap2d/src/com/uwsoft/editor/controller/BootstrapCommand.java @@ -44,6 +44,7 @@ public void execute(Notification notification) { facade.registerCommand(MsgAPI.ACTION_CREATE_ITEM, CreateItemCommand.class); facade.registerCommand(MsgAPI.ACTION_CAMERA_CHANGE_COMPOSITE, CompositeCameraChangeCommand.class); facade.registerCommand(MsgAPI.ACTION_CREATE_PRIMITIVE, CreatePrimitiveCommand.class); + facade.registerCommand(MsgAPI.ACTION_EXPORT_AS_LIBRARY_ITEM, ExportLibraryItemCommand.class); facade.registerCommand(MsgAPI.ACTION_DELETE_LAYER, DeleteLayerCommand.class); facade.registerCommand(MsgAPI.ACTION_NEW_LAYER, NewLayerCommand.class); @@ -84,6 +85,8 @@ public void execute(Notification notification) { facade.registerCommand(MsgAPI.ACTION_PLUGIN_PROXY_COMMAND, PluginItemCommand.class); // Resources + facade.registerCommand(MsgAPI.ACTION_EXPORT_AS_LIBRARY_ITEM_FROM_RES_PANEL, ExportLibraryItemFromResPanelCommand.class); + facade.registerCommand(MsgAPI.ACTION_DELETE_IMAGE_RESOURCE, DeleteImageResource.class); facade.registerCommand(MsgAPI.ACTION_DELETE_LIBRARY_ITEM, DeleteLibraryItem.class); facade.registerCommand(MsgAPI.ACTION_DELETE_PARTICLE_EFFECT, DeleteParticleEffect.class); diff --git a/overlap2d/src/com/uwsoft/editor/controller/commands/ExportLibraryItemCommand.java b/overlap2d/src/com/uwsoft/editor/controller/commands/ExportLibraryItemCommand.java new file mode 100644 index 000000000..76eaea0ae --- /dev/null +++ b/overlap2d/src/com/uwsoft/editor/controller/commands/ExportLibraryItemCommand.java @@ -0,0 +1,78 @@ +package com.uwsoft.editor.controller.commands; + +import com.badlogic.ashley.core.Entity; +import com.badlogic.gdx.utils.Json; +import com.badlogic.gdx.utils.JsonWriter; +import com.puremvc.patterns.observer.Notification; +import com.uwsoft.editor.renderer.components.*; +import com.uwsoft.editor.renderer.data.*; +import com.uwsoft.editor.renderer.factory.EntityFactory; +import com.uwsoft.editor.renderer.utils.ComponentRetriever; +import org.apache.commons.io.FileUtils; + +import java.io.File; +import java.io.IOException; +import java.util.Set; + +/** + * Created by Sasun Poghosyan on 11/28/2016. + */ +public class ExportLibraryItemCommand extends NonRevertibleCommand { + private final Json json = new Json(JsonWriter.OutputType.json); + + public ExportLibraryItemCommand() { + super(); + } + + @Override + public void execute(Notification notification) { + super.execute(notification); + } + + @Override + public void doAction() { + getJsonStringFromEntities(sandbox.getSelector().getSelectedItems()); + } + + private void getJsonStringFromEntities(Set entities) { + CompositeVO holderComposite = new CompositeVO(); + for (Entity entity : entities) { + int entityType = ComponentRetriever.get(entity, MainItemComponent.class).entityType; + if (entityType == EntityFactory.COMPOSITE_TYPE) { + CompositeItemVO vo = new CompositeItemVO(); + vo.loadFromEntity(entity); + if (vo.itemName.length() == 0) { + System.out.println("item is not a library item"); + return; + } + holderComposite.sComposites.add(vo); + vo.cleanIds(); + } else { + System.out.println("item is not a composite"); + return; + } + } + + for (int i = 0; i < holderComposite.sComposites.size(); i++) { + CompositeItemVO compositeItemVO = holderComposite.sComposites.get(i); + String jsonString = json.toJson(compositeItemVO); + String currentProjectPath = projectManager.getCurrentProjectPath(); + + try { + FileUtils.writeStringToFile(new File(currentProjectPath + "\\export\\libraryItems\\" + compositeItemVO.itemName + ".json"), jsonString, "utf-8"); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + @Override + public void callDoAction() { + super.callDoAction(); + } + + @Override + public void cancel() { + super.cancel(); + } +} diff --git a/overlap2d/src/com/uwsoft/editor/controller/commands/ExportLibraryItemFromResPanelCommand.java b/overlap2d/src/com/uwsoft/editor/controller/commands/ExportLibraryItemFromResPanelCommand.java new file mode 100644 index 000000000..e641e2929 --- /dev/null +++ b/overlap2d/src/com/uwsoft/editor/controller/commands/ExportLibraryItemFromResPanelCommand.java @@ -0,0 +1,66 @@ +package com.uwsoft.editor.controller.commands; + +import com.badlogic.ashley.core.Entity; +import com.badlogic.gdx.utils.Array; +import com.badlogic.gdx.utils.Json; +import com.badlogic.gdx.utils.JsonWriter; +import com.puremvc.patterns.observer.Notification; +import com.uwsoft.editor.Overlap2DFacade; +import com.uwsoft.editor.proxy.ProjectManager; +import com.uwsoft.editor.renderer.components.MainItemComponent; +import com.uwsoft.editor.renderer.data.CompositeItemVO; +import com.uwsoft.editor.renderer.utils.ComponentRetriever; +import com.uwsoft.editor.utils.runtime.EntityUtils; +import org.apache.commons.io.FileUtils; + +import java.io.File; +import java.io.IOException; +import java.util.HashMap; + +/** + * Created by Sasun Poghosyan on 11/28/2016. + */ +public class ExportLibraryItemFromResPanelCommand extends NonRevertibleCommand { + private static final String CLASS_NAME = "com.uwsoft.editor.controller.commands.resource.ExportLibraryItemFromResPanelCommand"; + public static final String DONE = CLASS_NAME + "DONE"; + private final Json json = new Json(JsonWriter.OutputType.json); + + public ExportLibraryItemFromResPanelCommand() { + super(); + } + + @Override + public void execute(Notification notification) { + super.execute(notification); + String libraryItemName = notification.getBody(); + String currentProjectPath = projectManager.getCurrentProjectPath(); + + ProjectManager projectManager = Overlap2DFacade.getInstance().retrieveProxy(ProjectManager.NAME); + HashMap libraryItems = projectManager.currentProjectInfoVO.libraryItems; + CompositeItemVO compositeItemVO = libraryItems.get(libraryItemName); + + String jsonString = json.toJson(compositeItemVO); + json.prettyPrint(jsonString); + + try { + FileUtils.writeStringToFile(new File(currentProjectPath + "\\export\\libraryItems\\" + libraryItemName + ".json"), jsonString, "utf-8"); + } catch (IOException e) { + e.printStackTrace(); + } + } + + @Override + public void doAction() { + + } + + @Override + public void callDoAction() { + super.callDoAction(); + } + + @Override + public void cancel() { + super.cancel(); + } +} diff --git a/overlap2d/src/com/uwsoft/editor/controller/commands/resource/DeleteImageResource.java b/overlap2d/src/com/uwsoft/editor/controller/commands/resource/DeleteImageResource.java index 1aca665f6..94855cda8 100644 --- a/overlap2d/src/com/uwsoft/editor/controller/commands/resource/DeleteImageResource.java +++ b/overlap2d/src/com/uwsoft/editor/controller/commands/resource/DeleteImageResource.java @@ -2,7 +2,6 @@ import com.badlogic.ashley.core.Entity; import com.uwsoft.editor.controller.commands.NonRevertibleCommand; -import com.uwsoft.editor.proxy.ResolutionManager; import com.uwsoft.editor.renderer.components.TextureRegionComponent; import com.uwsoft.editor.renderer.data.CompositeItemVO; import com.uwsoft.editor.renderer.data.SceneVO; @@ -31,8 +30,9 @@ public void doAction() { if (projectManager.deleteSingleImage(imageName)) { deleteEntitiesWithImages(sandbox.getRootEntity(), imageName); deleteAllItemsImages(imageName); - ResolutionManager resolutionManager = facade.retrieveProxy(ResolutionManager.NAME); - resolutionManager.rePackProjectImagesForAllResolutions(); + //TODO open 34 and 35 lines for repacking project images after image deletion +// ResolutionManager resolutionManager = facade.retrieveProxy(ResolutionManager.NAME); +// resolutionManager.rePackProjectImagesForAllResolutions(); projectManager.loadProjectData(projectManager.getCurrentProjectPath()); sendNotification(DONE, imageName); SceneVO vo = sandbox.sceneVoFromItems(); diff --git a/overlap2d/src/com/uwsoft/editor/proxy/ProjectManager.java b/overlap2d/src/com/uwsoft/editor/proxy/ProjectManager.java index 7dedb1161..0aa0a2e6d 100755 --- a/overlap2d/src/com/uwsoft/editor/proxy/ProjectManager.java +++ b/overlap2d/src/com/uwsoft/editor/proxy/ProjectManager.java @@ -24,8 +24,11 @@ import com.badlogic.gdx.tools.texturepacker.TexturePacker.Settings; import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.Json; +import com.badlogic.gdx.utils.JsonWriter; import com.google.common.collect.Lists; import com.kotcrab.vis.ui.util.dialog.DialogUtils; +import com.kotcrab.vis.ui.widget.file.FileChooser; +import com.kotcrab.vis.ui.widget.file.FileChooserAdapter; import com.puremvc.patterns.proxy.BaseProxy; import com.uwsoft.editor.Overlap2DFacade; import com.uwsoft.editor.data.manager.PreferencesManager; @@ -50,7 +53,10 @@ import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import java.awt.image.BufferedImage; -import java.io.*; +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStreamReader; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; @@ -140,6 +146,7 @@ public void createEmptyProject(String projectPath, int width, int height, int pi FileUtils.forceMkdir(new File(projPath)); FileUtils.forceMkdir(new File(projPath + File.separator + "export")); + FileUtils.forceMkdir(new File(projPath + File.separator + "export/libraryItems")); FileUtils.forceMkdir(new File(projPath + File.separator + "assets")); FileUtils.forceMkdir(new File(projPath + File.separator + "scenes")); FileUtils.forceMkdir(new File(projPath + File.separator + "assets/orig")); @@ -213,7 +220,7 @@ public void openProjectAndLoadAllData(String projectPath, String resolution) { String prjInfoFilePath = projectPath + "/project.dt"; FileHandle projectInfoFile = Gdx.files.internal(prjInfoFilePath); String projectInfoContents = FileUtils.readFileToString(projectInfoFile.file()); - ProjectInfoVO voInfo = json.fromJson(ProjectInfoVO.class, projectInfoContents); + ProjectInfoVO voInfo = json.fromJson(ProjectInfoVO.class, projectInfoContents);// here project reads all data from json currentProjectInfoVO = voInfo; } catch (IOException e) { @@ -274,6 +281,7 @@ public void loadProjectData(String projectPath) { public void saveCurrentProject() { try { + //here project saves all necessary files FileUtils.writeStringToFile(new File(currentProjectPath + "/project.pit"), currentProjectVO.constructJsonString(), "utf-8"); FileUtils.writeStringToFile(new File(currentProjectPath + "/project.dt"), currentProjectInfoVO.constructJsonString(), "utf-8"); } catch (IOException e) { @@ -281,6 +289,56 @@ public void saveCurrentProject() { } } + public void exportAllLibraryItems() { + Json json = new Json(JsonWriter.OutputType.json); + String jsonString; + for (String libraryItemName : currentProjectInfoVO.libraryItems.keySet()) { + CompositeItemVO compositeItemVO = currentProjectInfoVO.libraryItems.get(libraryItemName); + jsonString = json.toJson(compositeItemVO); + json.prettyPrint(jsonString); + try { + FileUtils.writeStringToFile(new File(currentProjectPath + "\\export\\libraryItems\\" + libraryItemName + ".json"), jsonString, "utf-8"); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + public void importLibraryItems() { + Sandbox sandbox = Sandbox.getInstance(); + //chooser creation + FileChooser fileChooser = new FileChooser(FileChooser.Mode.OPEN); + fileChooser.setMultiSelectionEnabled(true); + fileChooser.setListener(new FileChooserAdapter() { + @Override + public void selected(Array files) { + System.out.println("file chosen"); + for (FileHandle fileHandle : files) { + String path = fileHandle.file().getAbsolutePath(); + if (fileHandle.extension().equals("json")) { + openFromLibraryItem(path); + } + } + } + }); + sandbox.getUIStage().addActor(fileChooser.fadeIn()); + } + + private void openFromLibraryItem(String projectPath) { + Json json = new Json(); + FileHandle projectInfoFile = Gdx.files.internal(projectPath); + String projectInfoContents = null; + try { + projectInfoContents = FileUtils.readFileToString(projectInfoFile.file()); + } catch (IOException e) { + e.printStackTrace(); + } + CompositeItemVO voInfo = json.fromJson(CompositeItemVO.class, projectInfoContents); + String fileNameAndExtension = projectInfoFile.name(); + String fileName = FilenameUtils.removeExtension(fileNameAndExtension); + this.currentProjectInfoVO.libraryItems.put(fileName, voInfo); + } + public void saveCurrentProject(SceneVO vo) { saveCurrentProject(); SceneDataManager sceneDataManager = facade.retrieveProxy(SceneDataManager.NAME); @@ -1166,18 +1224,29 @@ public boolean deleteImage(String imageName) { path.resolveSibling(path.getFileName() + ".png"), path.resolveSibling(path.getFileName() + ".9.png")); - for(Path p : possibleFiles) { + for (Path p : possibleFiles) { if (p.toFile().exists()) return p.toFile().delete(); } - throw new IllegalStateException(String.format("The file %s is not found",path.toString())); + throw new IllegalStateException(String.format("The file %s is not found", path.toString())); } public boolean deleteSingleImage(String imageName) { - String imagesPath = currentProjectPath + File.separator + IMAGE_DIR_PATH + File.separator; - String filePath = imagesPath + imageName + ".png"; + String imagesPath; + String filePath; + + for (ResolutionEntryVO resolutionEntryVO : currentProjectInfoVO.resolutions) { + imagesPath = currentProjectPath + File.separator + "assets/" + resolutionEntryVO.name + "/images" + File.separator; + filePath = imagesPath + imageName + ".png"; + File file = new File(filePath); + if (file.delete()) { + System.out.println("deleted " + resolutionEntryVO.name + "'s resolution " + imageName + ".png" + " image"); + } + } + imagesPath = currentProjectPath + File.separator + IMAGE_DIR_PATH + File.separator; + filePath = imagesPath + imageName + ".png"; return (new File(filePath)).delete(); } diff --git a/overlap2d/src/com/uwsoft/editor/view/menu/Overlap2DMenuBar.java b/overlap2d/src/com/uwsoft/editor/view/menu/Overlap2DMenuBar.java index d12100eef..5167bb7eb 100644 --- a/overlap2d/src/com/uwsoft/editor/view/menu/Overlap2DMenuBar.java +++ b/overlap2d/src/com/uwsoft/editor/view/menu/Overlap2DMenuBar.java @@ -18,26 +18,27 @@ package com.uwsoft.editor.view.menu; -import java.io.File; -import java.util.ArrayList; - -import org.apache.commons.lang3.SystemUtils; - import com.badlogic.gdx.scenes.scene2d.ui.Cell; import com.badlogic.gdx.utils.Array; import com.kotcrab.vis.ui.widget.MenuItem; import com.kotcrab.vis.ui.widget.PopupMenu; -import com.uwsoft.editor.data.manager.PreferencesManager; import com.uwsoft.editor.Overlap2DFacade; +import com.uwsoft.editor.data.manager.PreferencesManager; import com.uwsoft.editor.event.MenuItemListener; import com.uwsoft.editor.renderer.data.SceneVO; import com.uwsoft.editor.view.ui.widget.CustomMenu; import com.uwsoft.editor.view.ui.widget.CustomMenuBar; +import org.apache.commons.lang3.SystemUtils; + +import java.io.File; +import java.util.ArrayList; public class Overlap2DMenuBar extends CustomMenuBar { public static final String prefix = "com.uwsoft.editor.view.Overlap2DMenuBar"; + public static final String IMPORT_LIBRARY_ITEM = prefix + ".IMPORT_LIBRARY_ITEM"; + public static final String EXPORT_LIBRARY_ITEM = prefix + ".EXPORT_LIBRARY_ITEM"; public static final String FILE_MENU = prefix + ".FILE_MENU"; public static final String NEW_PROJECT = prefix + ".NEW_PROJECT"; public static final String OPEN_PROJECT = prefix + ".OPEN_PROJECT"; @@ -171,6 +172,9 @@ private class FileMenu extends O2DMenu { private final MenuItem export; private final MenuItem exportSettings; + private final MenuItem importLibraryItem; + private final MenuItem exportLibraryItem; + private final PopupMenu recentProjectsPopupMenu; private final Array recentProjectsMenuItems; private final MenuItem recentProjectsMenuItem; @@ -195,6 +199,12 @@ public FileMenu() { addItem(importToLibrary); addItem(export); addItem(exportSettings); + + addSeparator(); + importLibraryItem = new MenuItem("Import Library Item(s)", new MenuItemListener(IMPORT_LIBRARY_ITEM, null, FILE_MENU)); + exportLibraryItem = new MenuItem("Export Library Items", new MenuItemListener(EXPORT_LIBRARY_ITEM, null, FILE_MENU)); + addItem(importLibraryItem); + addItem(exportLibraryItem); // addSeparator(); recentProjectsMenuItem = new MenuItem("Recent Projects..."); @@ -263,6 +273,8 @@ public void setProjectOpen(boolean open) { importToLibrary.setDisabled(!open); export.setDisabled(!open); exportSettings.setDisabled(!open); + importLibraryItem.setDisabled(!open); + exportLibraryItem.setDisabled(!open); } // private class RecentProjectListener extends ChangeListener { diff --git a/overlap2d/src/com/uwsoft/editor/view/menu/Overlap2DMenuBarMediator.java b/overlap2d/src/com/uwsoft/editor/view/menu/Overlap2DMenuBarMediator.java index 193402f56..ea71ba75d 100644 --- a/overlap2d/src/com/uwsoft/editor/view/menu/Overlap2DMenuBarMediator.java +++ b/overlap2d/src/com/uwsoft/editor/view/menu/Overlap2DMenuBarMediator.java @@ -58,6 +58,8 @@ public void onRegister() { public String[] listNotificationInterests() { return new String[]{ //FILE + Overlap2DMenuBar.IMPORT_LIBRARY_ITEM, + Overlap2DMenuBar.EXPORT_LIBRARY_ITEM, Overlap2DMenuBar.NEW_PROJECT, Overlap2DMenuBar.OPEN_PROJECT, Overlap2DMenuBar.SAVE_PROJECT, @@ -154,6 +156,12 @@ private void handleFileMenuNotification(Notification notification) { case Overlap2DMenuBar.IMPORT_TO_LIBRARY: //showDialog("showImportDialog"); break; + case Overlap2DMenuBar.IMPORT_LIBRARY_ITEM: + projectManager.importLibraryItems(); + break; + case Overlap2DMenuBar.EXPORT_LIBRARY_ITEM: + projectManager.exportAllLibraryItems(); + break; case Overlap2DMenuBar.RECENT_PROJECTS: recentProjectItemClicked(notification.getBody()); //showDialog("showImportDialog"); diff --git a/overlap2d/src/com/uwsoft/editor/view/ui/UIDropDownMenu.java b/overlap2d/src/com/uwsoft/editor/view/ui/UIDropDownMenu.java index f0af3b909..da2cce95f 100644 --- a/overlap2d/src/com/uwsoft/editor/view/ui/UIDropDownMenu.java +++ b/overlap2d/src/com/uwsoft/editor/view/ui/UIDropDownMenu.java @@ -51,11 +51,13 @@ public UIDropDownMenu() { actionNames.put(MsgAPI.ACTION_PASTE, "Paste"); actionNames.put(MsgAPI.ACTION_DELETE, "Delete"); actionNames.put(MsgAPI.SHOW_ADD_LIBRARY_DIALOG, "Add to library"); + actionNames.put(MsgAPI.ACTION_EXPORT_AS_LIBRARY_ITEM, "Export as library item"); //actionNames.put(MsgAPI.ACTION_EDIT_PHYSICS, "Edit physics"); //actionNames.put(ACTION_EDIT_RESOURCE_PHYSICS, "Edit physics"); actionNames.put(MsgAPI.ACTION_SET_GRID_SIZE_FROM_ITEM, "Set grid size"); actionNames.put(MsgAPI.ACTION_CREATE_PRIMITIVE, "Create Primitive"); + actionNames.put(MsgAPI.ACTION_EXPORT_AS_LIBRARY_ITEM_FROM_RES_PANEL, "Export"); actionNames.put(MsgAPI.ACTION_DELETE_IMAGE_RESOURCE, "Delete"); actionNames.put(MsgAPI.ACTION_DELETE_LIBRARY_ITEM, "Delete"); actionNames.put(MsgAPI.ACTION_DELETE_PARTICLE_EFFECT, "Delete"); @@ -85,7 +87,7 @@ private void setListeners() { private void initView() { clear(); - for(int i = 0; i < currentActionList.size; i++) { + for (int i = 0; i < currentActionList.size; i++) { String itemName = actionNames.get(currentActionList.get(i)); MenuItem menuItem = new MenuItem(itemName, new MenuItemListener(ITEM_CLICKED, currentActionList.get(i))); addItem(menuItem); diff --git a/overlap2d/src/com/uwsoft/editor/view/ui/UIDropDownMenuMediator.java b/overlap2d/src/com/uwsoft/editor/view/ui/UIDropDownMenuMediator.java index 1efa4b3ff..2f9b1591e 100644 --- a/overlap2d/src/com/uwsoft/editor/view/ui/UIDropDownMenuMediator.java +++ b/overlap2d/src/com/uwsoft/editor/view/ui/UIDropDownMenuMediator.java @@ -74,6 +74,7 @@ public void onRegister() { actionSets.get(IMAGE_RESOURCE_ACTION_SET).add(MsgAPI.ACTION_DELETE_IMAGE_RESOURCE); actionSets.put(LIBRARY_ITEM_ACTION_SET, new Array<>()); actionSets.get(LIBRARY_ITEM_ACTION_SET).add(MsgAPI.ACTION_DELETE_LIBRARY_ITEM); + actionSets.get(LIBRARY_ITEM_ACTION_SET).add(MsgAPI.ACTION_EXPORT_AS_LIBRARY_ITEM_FROM_RES_PANEL); actionSets.put(SPINE_ANIMATION_ACTION_SET, new Array<>()); actionSets.get(SPINE_ANIMATION_ACTION_SET).add(MsgAPI.ACTION_DELETE_SPINE_ANIMATION_RESOURCE); @@ -94,6 +95,7 @@ public void onRegister() { actionSets.get(ITEMS_ACTIONS_SET).add(MsgAPI.ACTION_DELETE); actionSets.get(ITEMS_ACTIONS_SET).add(MsgAPI.ACTION_GROUP_ITEMS); actionSets.get(ITEMS_ACTIONS_SET).add(MsgAPI.ACTION_CONVERT_TO_BUTTON); + actionSets.get(ITEMS_ACTIONS_SET).add(MsgAPI.ACTION_EXPORT_AS_LIBRARY_ITEM); actionSets.put(RULER_RESOURCE_ACTION_SET, new Array<>()); actionSets.get(RULER_RESOURCE_ACTION_SET).add(MsgAPI.ACTION_UPDATE_RULER_POSITION); diff --git a/overlap2d/src/com/uwsoft/editor/view/ui/box/resourcespanel/UILibraryItemsTabMediator.java b/overlap2d/src/com/uwsoft/editor/view/ui/box/resourcespanel/UILibraryItemsTabMediator.java index 4638c395b..99761be4d 100644 --- a/overlap2d/src/com/uwsoft/editor/view/ui/box/resourcespanel/UILibraryItemsTabMediator.java +++ b/overlap2d/src/com/uwsoft/editor/view/ui/box/resourcespanel/UILibraryItemsTabMediator.java @@ -22,6 +22,7 @@ import com.commons.MsgAPI; import com.puremvc.patterns.observer.Notification; import com.uwsoft.editor.Overlap2DFacade; +import com.uwsoft.editor.controller.commands.ExportLibraryItemFromResPanelCommand; import com.uwsoft.editor.controller.commands.resource.DeleteLibraryItem; import com.uwsoft.editor.factory.ItemFactory; import com.uwsoft.editor.proxy.ProjectManager; @@ -51,6 +52,7 @@ public String[] listNotificationInterests() { listNotification = ArrayUtils.add(listNotification, MsgAPI.LIBRARY_LIST_UPDATED); listNotification = ArrayUtils.add(listNotification, DeleteLibraryItem.DONE); + listNotification = ArrayUtils.add(listNotification, ExportLibraryItemFromResPanelCommand.DONE); return listNotification; } diff --git a/overlap2d/src/com/uwsoft/editor/view/ui/widget/actors/SpineActor.java b/overlap2d/src/com/uwsoft/editor/view/ui/widget/actors/SpineActor.java index 1791003b8..a617fe763 100644 --- a/overlap2d/src/com/uwsoft/editor/view/ui/widget/actors/SpineActor.java +++ b/overlap2d/src/com/uwsoft/editor/view/ui/widget/actors/SpineActor.java @@ -8,14 +8,13 @@ import com.esotericsoftware.spine.attachments.Attachment; import com.esotericsoftware.spine.attachments.MeshAttachment; import com.esotericsoftware.spine.attachments.RegionAttachment; -import com.esotericsoftware.spine.attachments.WeightedMeshAttachment; import com.uwsoft.editor.renderer.resources.IResourceRetriever; public class SpineActor extends Actor { private String animationName; public SkeletonData skeletonData; - private SkeletonRenderer renderer; + private SkeletonMeshRenderer renderer; private Skeleton skeleton; private AnimationState state; private IResourceRetriever irr; @@ -26,7 +25,7 @@ public class SpineActor extends Actor { public SpineActor(String animationName, IResourceRetriever irr) { this.irr = irr; - this.renderer = new SkeletonRenderer(); + this.renderer = new SkeletonMeshRenderer(); this.animationName = animationName; initSkeletonData(); initSpine(); @@ -41,7 +40,7 @@ private void computeBoundBox() { Slot slot = skeleton.getSlots().get(i); Attachment attachment = slot.getAttachment(); if (attachment == null) continue; - if (!((attachment instanceof RegionAttachment) || (attachment instanceof MeshAttachment) || (attachment instanceof WeightedMeshAttachment))) continue; + if (!((attachment instanceof RegionAttachment) || (attachment instanceof MeshAttachment) || (attachment instanceof MeshAttachment))) continue; float[] vertices = new float[0]; if ((attachment instanceof RegionAttachment)) { RegionAttachment region = (RegionAttachment) attachment; @@ -53,8 +52,8 @@ private void computeBoundBox() { region.updateWorldVertices(slot, false); vertices = region.getWorldVertices(); } - if ((attachment instanceof WeightedMeshAttachment)) { - WeightedMeshAttachment region = (WeightedMeshAttachment) attachment; + if ((attachment instanceof MeshAttachment)) { + MeshAttachment region = (MeshAttachment) attachment; region.updateWorldVertices(slot, false); vertices = region.getWorldVertices(); }