Throw a sensible error message if we choke trimming a tileset.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2214 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2003-01-24 19:32:56 +00:00
parent cc680cbd17
commit 18d0266055
@@ -1,5 +1,5 @@
// //
// $Id: TileSetBundler.java,v 1.10 2003/01/13 22:49:47 mdb Exp $ // $Id: TileSetBundler.java,v 1.11 2003/01/24 19:32:56 mdb Exp $
package com.threerings.media.tile.bundle.tools; package com.threerings.media.tile.bundle.tools;
@@ -308,27 +308,37 @@ public class TileSetBundler
jar.putNextEntry(new JarEntry(imagePath)); jar.putNextEntry(new JarEntry(imagePath));
// if this is an object tileset, we can't trim it! // if this is an object tileset, we can't trim it!
try {
if (set instanceof ObjectTileSet) { if (set instanceof ObjectTileSet) {
// set the tileset up with an image provider; we need to // set the tileset up with an image provider; we
// do this so that we can trim it! // need to do this so that we can trim it!
set.setImageProvider(improv); set.setImageProvider(improv);
// create a trimmed object tileset, which will write // create a trimmed object tileset, which will
// the trimmed tileset image to the jar output stream // write the trimmed tileset image to the jar
// output stream
System.out.println("Trimming " + imagePath);
TrimmedObjectTileSet tset = TrimmedObjectTileSet tset =
TrimmedObjectTileSet.trimObjectTileSet( TrimmedObjectTileSet.trimObjectTileSet(
(ObjectTileSet)set, jar); (ObjectTileSet)set, jar);
tset.setImagePath(imagePath); tset.setImagePath(imagePath);
// replace the original set with the trimmed tileset // replace the original set with the trimmed
// in the tileset bundle // tileset in the tileset bundle
bundle.addTileSet(tileSetId, tset); bundle.addTileSet(tileSetId, tset);
} else { } else {
// open the image and pipe it into the jar file // open the image and pipe it into the jar file
File imgfile = new File(bundleDesc.getParent(), imagePath); File imgfile = new File(bundleDesc.getParent(),
imagePath);
FileInputStream imgin = new FileInputStream(imgfile); FileInputStream imgin = new FileInputStream(imgfile);
StreamUtils.pipe(imgin, jar); StreamUtils.pipe(imgin, jar);
} }
} catch (Exception e) {
String errmsg = "Error adding tileset to bundle " +
"[set=" + set.getName() + ", ipath=" + imagePath + "]";
throw (IOException)new IOException(errmsg).initCause(e);
}
} }
// now write a serialized representation of the tileset bundle // now write a serialized representation of the tileset bundle