Not to freak out if we get to a tileset image that we can't trim because
its hosed. Instead write an error image/tileset to the bundle and keep on truckin'. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2219 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: TileSetBundler.java,v 1.12 2003/01/24 19:34:25 mdb Exp $
|
// $Id: TileSetBundler.java,v 1.13 2003/01/24 21:51:26 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.media.tile.bundle.tools;
|
package com.threerings.media.tile.bundle.tools;
|
||||||
|
|
||||||
@@ -33,6 +33,7 @@ import com.samskivert.io.PersistenceException;
|
|||||||
|
|
||||||
import com.threerings.media.Log;
|
import com.threerings.media.Log;
|
||||||
import com.threerings.media.image.Colorization;
|
import com.threerings.media.image.Colorization;
|
||||||
|
import com.threerings.media.image.ImageUtil;
|
||||||
import com.threerings.media.image.Mirage;
|
import com.threerings.media.image.Mirage;
|
||||||
|
|
||||||
import com.threerings.media.tile.ObjectTileSet;
|
import com.threerings.media.tile.ObjectTileSet;
|
||||||
@@ -40,6 +41,7 @@ import com.threerings.media.tile.SimpleCachingImageProvider;
|
|||||||
import com.threerings.media.tile.TileSet;
|
import com.threerings.media.tile.TileSet;
|
||||||
import com.threerings.media.tile.TileSetIDBroker;
|
import com.threerings.media.tile.TileSetIDBroker;
|
||||||
import com.threerings.media.tile.TrimmedObjectTileSet;
|
import com.threerings.media.tile.TrimmedObjectTileSet;
|
||||||
|
import com.threerings.media.tile.UniformTileSet;
|
||||||
|
|
||||||
import com.threerings.media.tile.bundle.BundleUtil;
|
import com.threerings.media.tile.bundle.BundleUtil;
|
||||||
import com.threerings.media.tile.bundle.TileSetBundle;
|
import com.threerings.media.tile.bundle.TileSetBundle;
|
||||||
@@ -308,12 +310,12 @@ 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
|
||||||
// set the tileset up with an image provider; we
|
// need to do this so that we can trim it!
|
||||||
// need to do this so that we can trim it!
|
set.setImageProvider(improv);
|
||||||
set.setImageProvider(improv);
|
|
||||||
|
|
||||||
|
try {
|
||||||
// create a trimmed object tileset, which will
|
// create a trimmed object tileset, which will
|
||||||
// write the trimmed tileset image to the jar
|
// write the trimmed tileset image to the jar
|
||||||
// output stream
|
// output stream
|
||||||
@@ -325,18 +327,30 @@ public class TileSetBundler
|
|||||||
// tileset in the tileset bundle
|
// tileset in the tileset bundle
|
||||||
bundle.addTileSet(tileSetId, tset);
|
bundle.addTileSet(tileSetId, tset);
|
||||||
|
|
||||||
} else {
|
} catch (Exception e) {
|
||||||
// open the image and pipe it into the jar file
|
System.err.println("Error adding tileset to bundle " +
|
||||||
File imgfile = new File(bundleDesc.getParent(),
|
"[set=" + set.getName() +
|
||||||
imagePath);
|
", ipath=" + imagePath + "].");
|
||||||
FileInputStream imgin = new FileInputStream(imgfile);
|
e.printStackTrace(System.err);
|
||||||
StreamUtils.pipe(imgin, jar);
|
// replace the tileset with an error tileset
|
||||||
|
UniformTileSet ets = new UniformTileSet();
|
||||||
|
ets.setName(set.getName());
|
||||||
|
ets.setWidth(50);
|
||||||
|
ets.setHeight(50);
|
||||||
|
ets.setTileCount(1);
|
||||||
|
ets.setImagePath(imagePath);
|
||||||
|
bundle.addTileSet(tileSetId, ets);
|
||||||
|
// and write an error image to the jar file
|
||||||
|
ImageIO.write(ImageUtil.createErrorImage(50, 50),
|
||||||
|
"PNG", jar);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} else {
|
||||||
String errmsg = "Error adding tileset to bundle " +
|
// open the image and pipe it into the jar file
|
||||||
"[set=" + set.getName() + ", ipath=" + imagePath + "]";
|
File imgfile = new File(
|
||||||
throw (IOException)new IOException(errmsg).initCause(e);
|
bundleDesc.getParent(), imagePath);
|
||||||
|
FileInputStream imgin = new FileInputStream(imgfile);
|
||||||
|
StreamUtils.pipe(imgin, jar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user