TileImage: xml: replace offsetX/offsetY attrs with single 'at' attribute

I.e. instead of
<image offsetY="32"/>

we use
<image at="0,32"/>
This commit is contained in:
Jason Long 2015-01-11 11:28:30 -05:00
parent 33de15568a
commit 455fc004de
2 changed files with 14 additions and 4 deletions

View file

@ -263,7 +263,7 @@ public class MakeTiles
for (Animation.Frame f : ani.frames) {
TileImageSprite s = (TileImageSprite) f.frame;
out.writeStartElement("frame");
out.writeAttribute("offsetY", Integer.toString(s.offsetY));
out.writeAttribute("at", String.format("%d,%d", s.offsetX, s.offsetY));
out.writeEndElement();
}
out.writeEndElement();
@ -272,7 +272,7 @@ public class MakeTiles
TileImageSprite s = (TileImageSprite ) m.dest;
out.writeStartElement("image");
out.writeAttribute("offsetY", Integer.toString(s.offsetY));
out.writeAttribute("at", String.format("%d,%d", s.offsetX, s.offsetY));
out.writeEndElement();
}

View file

@ -148,8 +148,18 @@ public abstract class TileImage
catch (IOException e) {
throw new XMLStreamException("image source not found", e);
}
String tmp = in.getAttributeValue(null, "offsetY");
img.offsetY = tmp != null ? Integer.parseInt(tmp) : 0;
String tmp = in.getAttributeValue(null, "at");
if (tmp != null) {
String [] coords = tmp.split(",");
if (coords.length == 2) {
img.offsetX = Integer.parseInt(coords[0]);
img.offsetY = Integer.parseInt(coords[1]);
}
else {
throw new XMLStreamException("Invalid 'at' syntax");
}
}
skipToEndElement(in);
return img;