Animation: catch IOExceptions from loading dependent images
This commit is contained in:
parent
3f2b4957a9
commit
ba4a159e34
1 changed files with 12 additions and 4 deletions
|
@ -45,7 +45,7 @@ public class Animation extends TileImage
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Animation read(XMLStreamReader in, LoaderContext ctx)
|
public static Animation read(XMLStreamReader in, LoaderContext ctx)
|
||||||
throws XMLStreamException, IOException
|
throws XMLStreamException
|
||||||
{
|
{
|
||||||
Animation a = new Animation();
|
Animation a = new Animation();
|
||||||
a.load(in, ctx);
|
a.load(in, ctx);
|
||||||
|
@ -60,7 +60,7 @@ public class Animation extends TileImage
|
||||||
}
|
}
|
||||||
|
|
||||||
void load(XMLStreamReader in, LoaderContext ctx)
|
void load(XMLStreamReader in, LoaderContext ctx)
|
||||||
throws XMLStreamException, IOException
|
throws XMLStreamException
|
||||||
{
|
{
|
||||||
while (in.nextTag() != XMLStreamConstants.END_ELEMENT) {
|
while (in.nextTag() != XMLStreamConstants.END_ELEMENT) {
|
||||||
assert in.isStartElement();
|
assert in.isStartElement();
|
||||||
|
@ -71,8 +71,16 @@ public class Animation extends TileImage
|
||||||
String tmp = in.getAttributeValue(null, "duration");
|
String tmp = in.getAttributeValue(null, "duration");
|
||||||
int duration = tmp != null ? Integer.parseInt(tmp) : DEFAULT_DURATION;
|
int duration = tmp != null ? Integer.parseInt(tmp) : DEFAULT_DURATION;
|
||||||
|
|
||||||
tmp = in.getElementText();
|
String text = in.getElementText();
|
||||||
addFrame( ctx.parseFrameSpec(tmp), duration );
|
TileImage frameImage;
|
||||||
|
try {
|
||||||
|
frameImage = ctx.parseFrameSpec(text);
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
throw new XMLStreamException("Unable to load frame image: "+text, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
addFrame( frameImage, duration );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// unrecognized element
|
// unrecognized element
|
||||||
|
|
Reference in a new issue