Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Texture Packer page indexes #6630

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES
Expand Up @@ -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.
Expand Down
Expand Up @@ -201,7 +201,7 @@ private void writeImages (File outputDir, String scaledPackFileName, Array<Page>
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);

Expand Down Expand Up @@ -233,9 +233,9 @@ private void writeImages (File outputDir, String scaledPackFileName, Array<Page>
page.imageHeight = height;

File outputFile;
while (true) {
do {
String name = imageName;
if (fileIndex > 1) {
if (settings.legacyPages && fileIndex > 1 || !settings.legacyPages && pages.size > 1) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs parenthesis to make it clear.

// Last character is a digit or a digit + 'x'.
char last = name.charAt(name.length() - 1);
if (Character.isDigit(last)
Expand All @@ -246,8 +246,7 @@ private void writeImages (File outputDir, String scaledPackFileName, Array<Page>
}
fileIndex++;
outputFile = new File(packDir, name + "." + settings.outputFormat);
if (!outputFile.exists()) break;
}
} while (outputFile.exists());
new FileHandle(outputFile).parent().mkdirs();
page.imageName = outputFile.getName();

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -802,10 +800,10 @@ static public boolean processIfModified (Settings settings, String input, String
return false;
}

static public interface Packer {
public Array<Page> pack (Array<Rect> inputRects);
public interface Packer {
Array<Page> pack(Array<Rect> inputRects);

public Array<Page> pack (ProgressListener progress, Array<Rect> inputRects);
Array<Page> pack(ProgressListener progress, Array<Rect> inputRects);
}

static final class InputImage {
Expand Down Expand Up @@ -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 () {
}
Expand Down Expand Up @@ -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) {
Expand Down
Expand Up @@ -38,9 +38,9 @@
public class TexturePackerFileProcessor extends FileProcessor {
private final Settings defaultSettings;
private final ProgressListener progress;
private ObjectMap<File, Settings> dirToSettings = new ObjectMap();
private Json json = new Json();
private String packFileName;
private final ObjectMap<File, Settings> dirToSettings = new ObjectMap();
private final Json json = new Json();
private final String packFileName;
private File root;
ArrayList<File> ignoreDirs = new ArrayList();
boolean countOnly;
Expand Down