diff --git a/overlap2d/src/com/uwsoft/editor/proxy/ProjectManager.java b/overlap2d/src/com/uwsoft/editor/proxy/ProjectManager.java index 7dedb1161..b2fa8f662 100755 --- a/overlap2d/src/com/uwsoft/editor/proxy/ProjectManager.java +++ b/overlap2d/src/com/uwsoft/editor/proxy/ProjectManager.java @@ -407,13 +407,10 @@ public void importSpriteAnimationsIntoProject(final Array fileHandle return; } handler = progressHandler; - ExecutorService executor = Executors.newSingleThreadExecutor(); executor.execute(() -> { - String newAnimName = null; - String rawFileName = fileHandles.get(0).name(); String fileExtension = FilenameUtils.getExtension(rawFileName); if (fileExtension.equals("png")) { @@ -425,59 +422,24 @@ public void importSpriteAnimationsIntoProject(final Array fileHandle String fileNameWithoutExt = FilenameUtils.removeExtension(rawFileName); String fileNameWithoutFrame = fileNameWithoutExt.replaceAll("\\d*$", ""); - boolean noFileNameWithoutFrame = false; if (Objects.equals(fileNameWithoutFrame, "")) { fileNameWithoutFrame = fileHandles.get(0).parent().name(); - noFileNameWithoutFrame = true; } String targetPath = currentProjectPath + "/assets/orig/sprite-animations" + File.separator + fileNameWithoutFrame; - - for (FileHandle file : fileHandles) { - File src = file.file(); - - String destName; - if (noFileNameWithoutFrame) { - destName = targetPath + File.separator + fileNameWithoutFrame + src.getName(); - } else { - destName = targetPath + File.separator + src.getName(); - } - - File dest = new File(destName); - try { - FileUtils.copyFile(src, dest); - } catch (IOException e) { - e.printStackTrace(); - } - } - - FileHandle pngsDir = new FileHandle(targetPath); - for (FileHandle entry : pngsDir.list(Overlap2DUtils.PNG_FILTER)) { - texturePacker.addImage(entry.file()); - } - - String packName = "Pack"; - targetPath = targetPath + packName; - File targetDir = new File(targetPath); - if (targetDir.exists()) { - try { - FileUtils.deleteDirectory(targetDir); - } catch (IOException e) { - e.printStackTrace(); - } + if (targetDir.exists()) + { + JOptionPane.showMessageDialog(null, "Animation already exists!", "Error", JOptionPane.ERROR_MESSAGE); + return; } - - texturePacker.pack(targetDir, fileNameWithoutFrame + packName); - - //delete newly created directory and images - try { - FileUtils.deleteDirectory(pngsDir.file()); - } catch (IOException e) { - e.printStackTrace(); + for (FileHandle file : fileHandles) { + File src = file.file(); + texturePacker.addImage(src); } - - newAnimName = fileNameWithoutFrame + packName; + + texturePacker.pack(targetDir, fileNameWithoutFrame); + newAnimName = fileNameWithoutFrame; } else { for (FileHandle fileHandle : fileHandles) { try { @@ -486,7 +448,9 @@ public void importSpriteAnimationsIntoProject(final Array fileHandle String targetPath = currentProjectPath + "/assets/orig/sprite-animations" + File.separator + fileNameWithoutExt; File targetDir = new File(targetPath); if (targetDir.exists()) { - FileUtils.deleteDirectory(targetDir); + //FileUtils.deleteDirectory(targetDir); + JOptionPane.showMessageDialog(null, "Animation already exists!", "Error", JOptionPane.ERROR_MESSAGE); + return; } for (File img : imgs) { FileUtils.copyFileToDirectory(img, targetDir); @@ -1219,4 +1183,4 @@ private boolean deleteDirectory(String path) { } return false; } -} \ No newline at end of file +}