diff --git a/CHANGES b/CHANGES index 840c2dc34b9..2004be1e4d2 100755 --- a/CHANGES +++ b/CHANGES @@ -21,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 32f56e023b2..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 @@ -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 = settings.legacyPages ? 1 : 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 ((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) @@ -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 @@ -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 { @@ -932,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 () { } @@ -985,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) { 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;