From af26dca2b81c574f249b6f99077dacd9fe03b643 Mon Sep 17 00:00:00 2001 From: NathanSweet Date: Sun, 20 Dec 2020 14:02:27 -0800 Subject: [PATCH] TextureAtlas, a couple places needed trim. #6316 --- .../gdx/graphics/g2d/TextureAtlas.java | 40 +++++++++---------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/gdx/src/com/badlogic/gdx/graphics/g2d/TextureAtlas.java b/gdx/src/com/badlogic/gdx/graphics/g2d/TextureAtlas.java index a68a1b60898..f4073da32fd 100644 --- a/gdx/src/com/badlogic/gdx/graphics/g2d/TextureAtlas.java +++ b/gdx/src/com/badlogic/gdx/graphics/g2d/TextureAtlas.java @@ -16,8 +16,6 @@ package com.badlogic.gdx.graphics.g2d; -import static com.badlogic.gdx.graphics.Texture.TextureWrap.*; - import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; @@ -280,9 +278,8 @@ public void parse (Page page) { }); pageFields.put("repeat", new Field() { public void parse (Page page) { - String direction = entry[1]; - if (direction.indexOf('x') != -1) page.uWrap = Repeat; - if (direction.indexOf('y') != -1) page.vWrap = Repeat; + if (entry[1].indexOf('x') != -1) page.uWrap = TextureWrap.Repeat; + if (entry[1].indexOf('y') != -1) page.vWrap = TextureWrap.Repeat; } }); pageFields.put("pma", new Field() { @@ -313,18 +310,18 @@ public void parse (Region region) { region.height = Integer.parseInt(entry[4]); } }); - regionFields.put("orig", new Field() { // Deprecated, use offsets. - public void parse (Region region) { - region.originalWidth = Integer.parseInt(entry[1]); - region.originalHeight = Integer.parseInt(entry[2]); - } - }); regionFields.put("offset", new Field() { // Deprecated, use offsets. public void parse (Region region) { region.offsetX = Integer.parseInt(entry[1]); region.offsetY = Integer.parseInt(entry[2]); } }); + regionFields.put("orig", new Field() { // Deprecated, use offsets. + public void parse (Region region) { + region.originalWidth = Integer.parseInt(entry[1]); + region.originalHeight = Integer.parseInt(entry[2]); + } + }); regionFields.put("offsets", new Field() { public void parse (Region region) { region.offsetX = Integer.parseInt(entry[1]); @@ -339,7 +336,7 @@ public void parse (Region region) { if (value.equals("true")) region.degrees = 90; else if (!value.equals("false")) // - region.degrees = Integer.valueOf(value); + region.degrees = Integer.parseInt(value); region.rotate = region.degrees == 90; } }); @@ -382,7 +379,7 @@ public void parse (Region region) { } else { Region region = new Region(); region.page = page; - region.name = line; + region.name = line.trim(); if (flip) region.flip = true; while (true) { int count = readEntry(entry, line = reader.readLine()); @@ -446,8 +443,10 @@ public Array getRegions () { return regions; } - static private int readEntry (String[] entry, String line) throws IOException { - if (line == null || line.length() == 0) return 0; + static private int readEntry (String[] entry, @Null String line) throws IOException { + if (line == null) return 0; + line = line.trim(); + if (line.length() == 0) return 0; int colon = line.indexOf(':'); if (colon == -1) return 0; entry[0] = line.substring(0, colon).trim(); @@ -476,23 +475,22 @@ static public class Page { public boolean useMipMaps; public Format format = Format.RGBA8888; public TextureFilter minFilter = TextureFilter.Nearest, magFilter = TextureFilter.Nearest; - public TextureWrap uWrap = ClampToEdge, vWrap = ClampToEdge; + public TextureWrap uWrap = TextureWrap.ClampToEdge, vWrap = TextureWrap.ClampToEdge; public boolean pma; } static public class Region { public Page page; public String name; - public boolean flip; - public int index = -1; + public int left, top, width, height; public float offsetX, offsetY; public int originalWidth, originalHeight; - public boolean rotate; public int degrees; - public int left, top; - public int width, height; + public boolean rotate; + public int index = -1; public @Null String[] names; public @Null int[][] values; + public boolean flip; public @Null int[] findValue (String name) { if (names != null) {