MakeTiles: generalize the XML output of image descriptors
This commit is contained in:
parent
f278a8bc19
commit
1824fc2e64
1 changed files with 25 additions and 20 deletions
|
@ -255,26 +255,7 @@ public class MakeTiles
|
||||||
out.writeStartElement("tile");
|
out.writeStartElement("tile");
|
||||||
out.writeAttribute("name", m.tileName);
|
out.writeAttribute("name", m.tileName);
|
||||||
|
|
||||||
assert (m.dest instanceof Animation) || (m.dest instanceof TileImageSprite);
|
writeImageTags(out, m.dest);
|
||||||
if (m.dest instanceof Animation) {
|
|
||||||
|
|
||||||
Animation ani = (Animation) m.dest;
|
|
||||||
out.writeStartElement("animation");
|
|
||||||
for (Animation.Frame f : ani.frames) {
|
|
||||||
TileImageSprite s = (TileImageSprite) f.frame;
|
|
||||||
out.writeStartElement("frame");
|
|
||||||
out.writeAttribute("at", String.format("%d,%d", s.offsetX, s.offsetY));
|
|
||||||
out.writeEndElement();
|
|
||||||
}
|
|
||||||
out.writeEndElement();
|
|
||||||
}
|
|
||||||
else { //assume it is a simple sprite
|
|
||||||
|
|
||||||
TileImageSprite s = (TileImageSprite ) m.dest;
|
|
||||||
out.writeStartElement("image");
|
|
||||||
out.writeAttribute("at", String.format("%d,%d", s.offsetX, s.offsetY));
|
|
||||||
out.writeEndElement();
|
|
||||||
}
|
|
||||||
|
|
||||||
out.writeEndElement();
|
out.writeEndElement();
|
||||||
}
|
}
|
||||||
|
@ -289,6 +270,30 @@ public class MakeTiles
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void writeImageTags(XMLStreamWriter out, TileImage dest)
|
||||||
|
throws XMLStreamException
|
||||||
|
{
|
||||||
|
if (dest instanceof Animation) {
|
||||||
|
|
||||||
|
Animation ani = (Animation) dest;
|
||||||
|
out.writeStartElement("animation");
|
||||||
|
for (Animation.Frame f : ani.frames) {
|
||||||
|
TileImageSprite s = (TileImageSprite) f.frame;
|
||||||
|
out.writeStartElement("frame");
|
||||||
|
out.writeAttribute("duration", Integer.toString(f.duration));
|
||||||
|
writeImageTags(out, f.frame);
|
||||||
|
out.writeEndElement();
|
||||||
|
}
|
||||||
|
out.writeEndElement();
|
||||||
|
}
|
||||||
|
else { //assume it is a simple sprite
|
||||||
|
|
||||||
|
TileImageSprite s = (TileImageSprite ) dest;
|
||||||
|
out.writeStartElement("image");
|
||||||
|
out.writeAttribute("at", String.format("%d,%d", s.offsetX, s.offsetY));
|
||||||
|
out.writeEndElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
static TileImage parseFrameSpec(TileSpec spec)
|
static TileImage parseFrameSpec(TileSpec spec)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
|
|
Reference in a new issue