From f986aecbce4a954e05382caa5698ea2710385654 Mon Sep 17 00:00:00 2001 From: fgnm Date: Sat, 21 May 2022 10:16:01 +0200 Subject: [PATCH] Supports Spine atlas with paths as file name --- h2d-libgdx-spine-extension | 2 +- src/main/java/games/rednblack/editor/utils/TextureUnpacker.java | 2 ++ .../games/rednblack/editor/utils/asset/impl/SpineAsset.java | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/h2d-libgdx-spine-extension b/h2d-libgdx-spine-extension index 2753ca63..4ba740db 160000 --- a/h2d-libgdx-spine-extension +++ b/h2d-libgdx-spine-extension @@ -1 +1 @@ -Subproject commit 2753ca637385e46f5205ebaca28a1897edb326d9 +Subproject commit 4ba740dbb212e4723453b233dbc601cadb5239d5 diff --git a/src/main/java/games/rednblack/editor/utils/TextureUnpacker.java b/src/main/java/games/rednblack/editor/utils/TextureUnpacker.java index 2d91b8b9..4065ab9b 100644 --- a/src/main/java/games/rednblack/editor/utils/TextureUnpacker.java +++ b/src/main/java/games/rednblack/editor/utils/TextureUnpacker.java @@ -11,6 +11,7 @@ import java.awt.image.AffineTransformOp; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; +import java.util.regex.Matcher; /** Unpacks a texture atlas into individual image files. * @author Geert Konijnendijk @@ -98,6 +99,7 @@ public class TextureUnpacker { // check if the parent directories of this image file exist and create them if not File imgOutput; + region.name = region.name.replaceAll("/", Matcher.quoteReplacement("$")); if (prefix != null) { imgOutput = new File(outputDirFile, String.format("%s%s.%s", prefix, region.index == -1 ? region.name : region.name + "_" + region.index, extension)); diff --git a/src/main/java/games/rednblack/editor/utils/asset/impl/SpineAsset.java b/src/main/java/games/rednblack/editor/utils/asset/impl/SpineAsset.java index 97d7b7a3..91d6bc2f 100644 --- a/src/main/java/games/rednblack/editor/utils/asset/impl/SpineAsset.java +++ b/src/main/java/games/rednblack/editor/utils/asset/impl/SpineAsset.java @@ -184,6 +184,7 @@ public class SpineAsset extends Asset { for (JsonValue slotEntry = skinMap.getChild("attachments"); slotEntry != null; slotEntry = slotEntry.next) { for (JsonValue entry = slotEntry.child; entry != null; entry = entry.next) { String name = spineName + entry.getString("name", entry.name); + name = name.replaceAll("/", Matcher.quoteReplacement("$")); deleteSingleImage(resolutionName, name); projectManager.deleteRegionFromPack(projectManager.getCurrentProjectInfoVO().animationsPacks, name); }