From 695e2b4e94b226569c13e8df2ae5690fba0d86d1 Mon Sep 17 00:00:00 2001 From: Frosty-J Date: Mon, 16 Aug 2021 05:09:07 +0100 Subject: [PATCH 1/4] Texture Packer indexes --- CHANGES | 1 + .../tools/texturepacker/TexturePacker.java | 22 +++++++++---------- .../TexturePackerFileProcessor.java | 6 ++--- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/CHANGES b/CHANGES index 840c2dc34b9..49989f5eb2d 100755 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,6 @@ [1.10.1] - [BREAKING CHANGE] Android Moved natives loading out of static init block, see #5795 +- [BREAKING CHANGE] Texture Packer: Filenames are now zero-indexed, including the first file (when there are multiple pages) - e.g. pack.png, pack2.png would now be pack0.png, pack1.png - API Addition: ObjLoader now supports ambientColor, ambientTexture, transparencyTexture, specularTexture and shininessTexture - API Addition: PointSpriteParticleBatch blending is now configurable. - TOOLS Features: Blending mode and sort mode can be changed in Flame particle 3D editor. diff --git a/extensions/gdx-tools/src/com/badlogic/gdx/tools/texturepacker/TexturePacker.java b/extensions/gdx-tools/src/com/badlogic/gdx/tools/texturepacker/TexturePacker.java index 32f56e023b2..9c498afe7e3 100644 --- a/extensions/gdx-tools/src/com/badlogic/gdx/tools/texturepacker/TexturePacker.java +++ b/extensions/gdx-tools/src/com/badlogic/gdx/tools/texturepacker/TexturePacker.java @@ -201,7 +201,7 @@ private void writeImages (File outputDir, String scaledPackFileName, Array File packDir = packFileNoExt.getParentFile(); String imageName = packFileNoExt.getName(); - int fileIndex = 1; + int fileIndex = 0; for (int p = 0, pn = pages.size; p < pn; p++) { Page page = pages.get(p); @@ -233,9 +233,9 @@ private void writeImages (File outputDir, String scaledPackFileName, Array page.imageHeight = height; File outputFile; - while (true) { + do { String name = imageName; - if (fileIndex > 1) { + if (pages.size > 1) { // Last character is a digit or a digit + 'x'. char last = name.charAt(name.length() - 1); if (Character.isDigit(last) @@ -246,8 +246,7 @@ private void writeImages (File outputDir, String scaledPackFileName, Array } fileIndex++; outputFile = new File(packDir, name + "." + settings.outputFormat); - if (!outputFile.exists()) break; - } + } while (outputFile.exists()); new FileHandle(outputFile).parent().mkdirs(); page.imageName = outputFile.getName(); @@ -704,9 +703,8 @@ public boolean equals (Object obj) { if (getClass() != obj.getClass()) return false; Rect other = (Rect)obj; if (name == null) { - if (other.name != null) return false; - } else if (!name.equals(other.name)) return false; - return true; + return other.name == null; + } else return name.equals(other.name); } @Override @@ -719,7 +717,7 @@ static public String getAtlasName (String name, boolean flattenPaths) { } } - static public enum Resampling { + public enum Resampling { nearest(RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR), // bilinear(RenderingHints.VALUE_INTERPOLATION_BILINEAR), // bicubic(RenderingHints.VALUE_INTERPOLATION_BICUBIC); @@ -802,10 +800,10 @@ static public boolean processIfModified (Settings settings, String input, String return false; } - static public interface Packer { - public Array pack (Array inputRects); + public interface Packer { + Array pack(Array inputRects); - public Array pack (ProgressListener progress, Array inputRects); + Array pack(ProgressListener progress, Array inputRects); } static final class InputImage { diff --git a/extensions/gdx-tools/src/com/badlogic/gdx/tools/texturepacker/TexturePackerFileProcessor.java b/extensions/gdx-tools/src/com/badlogic/gdx/tools/texturepacker/TexturePackerFileProcessor.java index f61745263b8..3d10811bbc4 100644 --- a/extensions/gdx-tools/src/com/badlogic/gdx/tools/texturepacker/TexturePackerFileProcessor.java +++ b/extensions/gdx-tools/src/com/badlogic/gdx/tools/texturepacker/TexturePackerFileProcessor.java @@ -38,9 +38,9 @@ public class TexturePackerFileProcessor extends FileProcessor { private final Settings defaultSettings; private final ProgressListener progress; - private ObjectMap dirToSettings = new ObjectMap(); - private Json json = new Json(); - private String packFileName; + private final ObjectMap dirToSettings = new ObjectMap(); + private final Json json = new Json(); + private final String packFileName; private File root; ArrayList ignoreDirs = new ArrayList(); boolean countOnly; From bcc0742c9753d41ae5da91d453685cc93226566d Mon Sep 17 00:00:00 2001 From: Frosty-J Date: Mon, 16 Aug 2021 08:40:54 +0100 Subject: [PATCH 2/4] Add legacyPages flag - default true (wish it was false but this matches the other) --- CHANGES | 2 +- .../com/badlogic/gdx/tools/texturepacker/TexturePacker.java | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 49989f5eb2d..2004be1e4d2 100755 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,5 @@ [1.10.1] - [BREAKING CHANGE] Android Moved natives loading out of static init block, see #5795 -- [BREAKING CHANGE] Texture Packer: Filenames are now zero-indexed, including the first file (when there are multiple pages) - e.g. pack.png, pack2.png would now be pack0.png, pack1.png - API Addition: ObjLoader now supports ambientColor, ambientTexture, transparencyTexture, specularTexture and shininessTexture - API Addition: PointSpriteParticleBatch blending is now configurable. - TOOLS Features: Blending mode and sort mode can be changed in Flame particle 3D editor. @@ -22,6 +21,7 @@ - Brought the official and third-party extensions in gdx-setup up to date. Removed some unmaintained ones and added gdx-websockets & jbump. - API Fix: Escaped characters in XML attributes are now properly un-escaped - Bug Fix: AssetManager backslash conversion removed - fixes use of filenames containing backslashes +- TOOLS Features: legacyPages flag added to Texture Packer. When set to false, filenames for multiple-page atlases are zero-indexed, including the first file. [1.10.0] - [BREAKING CHANGE] Android armeabi support has been removed. To migrate your projects: remove any dependency with natives-armeabi qualifier from your gradle build file, this apply to gdx-platform, gdx-bullet-platform, gdx-freetype-platform and gdx-box2d-platform. diff --git a/extensions/gdx-tools/src/com/badlogic/gdx/tools/texturepacker/TexturePacker.java b/extensions/gdx-tools/src/com/badlogic/gdx/tools/texturepacker/TexturePacker.java index 9c498afe7e3..936cc4dfcc8 100644 --- a/extensions/gdx-tools/src/com/badlogic/gdx/tools/texturepacker/TexturePacker.java +++ b/extensions/gdx-tools/src/com/badlogic/gdx/tools/texturepacker/TexturePacker.java @@ -201,7 +201,7 @@ private void writeImages (File outputDir, String scaledPackFileName, Array File packDir = packFileNoExt.getParentFile(); String imageName = packFileNoExt.getName(); - int fileIndex = 0; + int fileIndex = settings.legacyPages ? 1 : 0; for (int p = 0, pn = pages.size; p < pn; p++) { Page page = pages.get(p); @@ -235,7 +235,7 @@ private void writeImages (File outputDir, String scaledPackFileName, Array File outputFile; do { String name = imageName; - if (pages.size > 1) { + if (settings.legacyPages && fileIndex > 1 || !settings.legacyPages && pages.size > 1) { // Last character is a digit or a digit + 'x'. char last = name.charAt(name.length() - 1); if (Character.isDigit(last) @@ -930,6 +930,7 @@ static public class Settings { public String atlasExtension = ".atlas"; public boolean prettyPrint = true; public boolean legacyOutput = true; + public boolean legacyPages = true; public Settings () { } @@ -983,6 +984,7 @@ public void set (Settings settings) { atlasExtension = settings.atlasExtension; prettyPrint = settings.prettyPrint; legacyOutput = settings.legacyOutput; + legacyPages = settings.legacyPages; } public String getScaledPackFileName (String packFileName, int scaleIndex) { From dc738ae718f0fa0399137fc527e7316b719241ca Mon Sep 17 00:00:00 2001 From: Frosty-J Date: Mon, 16 Aug 2021 08:52:17 +0100 Subject: [PATCH 3/4] Revert the static enum change --- .../src/com/badlogic/gdx/tools/texturepacker/TexturePacker.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/gdx-tools/src/com/badlogic/gdx/tools/texturepacker/TexturePacker.java b/extensions/gdx-tools/src/com/badlogic/gdx/tools/texturepacker/TexturePacker.java index 936cc4dfcc8..ceb9aec96aa 100644 --- a/extensions/gdx-tools/src/com/badlogic/gdx/tools/texturepacker/TexturePacker.java +++ b/extensions/gdx-tools/src/com/badlogic/gdx/tools/texturepacker/TexturePacker.java @@ -717,7 +717,7 @@ static public String getAtlasName (String name, boolean flattenPaths) { } } - public enum Resampling { + static public enum Resampling { nearest(RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR), // bilinear(RenderingHints.VALUE_INTERPOLATION_BILINEAR), // bicubic(RenderingHints.VALUE_INTERPOLATION_BICUBIC); From efbabb253a5db8375576971154573d09e7cff405 Mon Sep 17 00:00:00 2001 From: Frosty-J Date: Sun, 22 Aug 2021 23:24:39 +0100 Subject: [PATCH 4/4] Parenthesis to make it clear --- .../src/com/badlogic/gdx/tools/texturepacker/TexturePacker.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/gdx-tools/src/com/badlogic/gdx/tools/texturepacker/TexturePacker.java b/extensions/gdx-tools/src/com/badlogic/gdx/tools/texturepacker/TexturePacker.java index ceb9aec96aa..46275d35d3e 100644 --- a/extensions/gdx-tools/src/com/badlogic/gdx/tools/texturepacker/TexturePacker.java +++ b/extensions/gdx-tools/src/com/badlogic/gdx/tools/texturepacker/TexturePacker.java @@ -235,7 +235,7 @@ private void writeImages (File outputDir, String scaledPackFileName, Array File outputFile; do { String name = imageName; - if (settings.legacyPages && fileIndex > 1 || !settings.legacyPages && pages.size > 1) { + if ((settings.legacyPages && fileIndex > 1) || (!settings.legacyPages && pages.size > 1)) { // Last character is a digit or a digit + 'x'. char last = name.charAt(name.length() - 1); if (Character.isDigit(last)