TileImage: new method readTileImage() to read a top-level image tag
This commit is contained in:
parent
860faa1081
commit
33de15568a
1 changed files with 22 additions and 5 deletions
|
@ -190,6 +190,23 @@ public abstract class TileImage
|
||||||
return anim;
|
return anim;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static TileImage readTileImage(XMLStreamReader in, LoaderContext ctx)
|
||||||
|
throws XMLStreamException
|
||||||
|
{
|
||||||
|
assert in.isStartElement();
|
||||||
|
String tagName = in.getLocalName();
|
||||||
|
|
||||||
|
if (tagName.equals("image")) {
|
||||||
|
return readSimpleImage(in, ctx);
|
||||||
|
}
|
||||||
|
else if (tagName.equals("animation")) {
|
||||||
|
return readAnimation(in, ctx);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new XMLStreamException("unrecognized tag: "+tagName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param in an XML stream reader with the parent tag of the tag to be read
|
* @param in an XML stream reader with the parent tag of the tag to be read
|
||||||
* still selected
|
* still selected
|
||||||
|
@ -201,11 +218,11 @@ public abstract class TileImage
|
||||||
|
|
||||||
while (in.nextTag() != XMLStreamConstants.END_ELEMENT) {
|
while (in.nextTag() != XMLStreamConstants.END_ELEMENT) {
|
||||||
assert in.isStartElement();
|
assert in.isStartElement();
|
||||||
if (in.getLocalName().equals("image")) {
|
String tagName = in.getLocalName();
|
||||||
img = readSimpleImage(in, ctx);
|
if (tagName.equals("image") ||
|
||||||
}
|
tagName.equals("animation"))
|
||||||
else if (in.getLocalName().equals("animation")) {
|
{
|
||||||
img = readAnimation(in, ctx);
|
img = readTileImage(in, ctx);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
skipToEndElement(in);
|
skipToEndElement(in);
|
||||||
|
|
Reference in a new issue