Support fancier packing of trimmed tilesets.
By default, it still does the same thing, but now you can pass in a fancier packer. Provided a SLIGHTLY fancier one that's still pretty dumb and wasteful, but allows row wrapping instead of gluing everything together into one super wide image; I've got some that otherwise wind up SO insanely wide that it causes problems decoding them.
This commit is contained in:
committed by
Michael Bayne
parent
bce83d858e
commit
ddf07dc905
@@ -31,6 +31,7 @@ import java.io.OutputStream;
|
||||
import java.awt.image.BufferedImage;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
@@ -56,6 +57,7 @@ import com.threerings.media.tile.TrimmedObjectTileSet;
|
||||
import com.threerings.media.tile.bundle.BundleUtil;
|
||||
import com.threerings.media.tile.bundle.TileSetBundle;
|
||||
import com.threerings.media.tile.tools.xml.TileSetRuleSet;
|
||||
import com.threerings.media.tile.util.TileSetTrimmer;
|
||||
|
||||
import static com.threerings.media.Log.log;
|
||||
|
||||
@@ -153,6 +155,15 @@ public class TileSetBundler
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Packer to use when trimming.
|
||||
*/
|
||||
public Writer usePacker (Supplier<TileSetTrimmer.Packer> packer)
|
||||
{
|
||||
this.packer = packer;
|
||||
return trimImages(packer != null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether or not we write out raw images.
|
||||
*/
|
||||
@@ -194,6 +205,7 @@ public class TileSetBundler
|
||||
|
||||
boolean trim = true;
|
||||
boolean raw = true;
|
||||
Supplier<TileSetTrimmer.Packer> packer;
|
||||
String imageBase;
|
||||
JSONConversion.Config json;
|
||||
}
|
||||
@@ -429,7 +441,7 @@ public class TileSetBundler
|
||||
// write the trimmed tileset image to the target file
|
||||
TrimmedObjectTileSet tset =
|
||||
TrimmedObjectTileSet.trimObjectTileSet((ObjectTileSet)set, dest,
|
||||
target.raw ? FastImageIO.FILE_SUFFIX : "png");
|
||||
target.raw ? FastImageIO.FILE_SUFFIX : "png", target.packer.get());
|
||||
tset.setImagePath(imagePath);
|
||||
// replace the original set with the trimmed
|
||||
// tileset in the tileset bundle
|
||||
|
||||
Reference in New Issue
Block a user