Allow a parameter to TileSetBundlerTask to keep the pngs in the bundle instead of converting to raw and trimming them.
git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@931 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
@@ -132,6 +132,18 @@ public class TileSetBundler
|
|||||||
public TileSetBundler (File configFile)
|
public TileSetBundler (File configFile)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
|
this(configFile, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a tileset bundler with the specified bundler config
|
||||||
|
* file and whether to keep pngs as-is or if not, re-encode them.
|
||||||
|
*/
|
||||||
|
public TileSetBundler (File configFile, boolean keepRawPngs)
|
||||||
|
throws IOException
|
||||||
|
{
|
||||||
|
_keepRawPngs = keepRawPngs;
|
||||||
|
|
||||||
// we parse our configuration with a digester
|
// we parse our configuration with a digester
|
||||||
Digester digester = new Digester();
|
Digester digester = new Digester();
|
||||||
|
|
||||||
@@ -340,7 +352,7 @@ public class TileSetBundler
|
|||||||
File target, TileSetBundle bundle, ImageProvider improv, String imageBase, long newestMod)
|
File target, TileSetBundle bundle, ImageProvider improv, String imageBase, long newestMod)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
return createBundleJar(target, bundle, improv, imageBase);
|
return createBundleJar(target, bundle, improv, imageBase, _keepRawPngs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -353,7 +365,8 @@ public class TileSetBundler
|
|||||||
* ObjectTileSet tilesets.
|
* ObjectTileSet tilesets.
|
||||||
*/
|
*/
|
||||||
public static boolean createBundleJar (
|
public static boolean createBundleJar (
|
||||||
File target, TileSetBundle bundle, ImageProvider improv, String imageBase)
|
File target, TileSetBundle bundle, ImageProvider improv, String imageBase,
|
||||||
|
boolean keepRawPngs)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
// now we have to create the actual bundle file
|
// now we have to create the actual bundle file
|
||||||
@@ -383,7 +396,7 @@ public class TileSetBundler
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if this is an object tileset, trim it
|
// if this is an object tileset, trim it
|
||||||
if (set instanceof ObjectTileSet) {
|
if (!keepRawPngs && (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);
|
||||||
@@ -418,7 +431,7 @@ public class TileSetBundler
|
|||||||
File ifile = new File(imageBase, imagePath);
|
File ifile = new File(imageBase, imagePath);
|
||||||
try {
|
try {
|
||||||
BufferedImage image = ImageIO.read(ifile);
|
BufferedImage image = ImageIO.read(ifile);
|
||||||
if (FastImageIO.canWrite(image)) {
|
if (!keepRawPngs && FastImageIO.canWrite(image)) {
|
||||||
imagePath = adjustImagePath(imagePath);
|
imagePath = adjustImagePath(imagePath);
|
||||||
jar.putNextEntry(new JarEntry(imagePath));
|
jar.putNextEntry(new JarEntry(imagePath));
|
||||||
set.setImagePath(imagePath);
|
set.setImagePath(imagePath);
|
||||||
@@ -475,6 +488,7 @@ public class TileSetBundler
|
|||||||
int didx = imagePath.lastIndexOf(".");
|
int didx = imagePath.lastIndexOf(".");
|
||||||
return ((didx == -1) ? imagePath :
|
return ((didx == -1) ? imagePath :
|
||||||
imagePath.substring(0, didx)) + ".raw";
|
imagePath.substring(0, didx)) + ".raw";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Used to parse our configuration. */
|
/** Used to parse our configuration. */
|
||||||
@@ -498,4 +512,7 @@ public class TileSetBundler
|
|||||||
|
|
||||||
/** The digester we use to parse bundle descriptions. */
|
/** The digester we use to parse bundle descriptions. */
|
||||||
protected Digester _digester;
|
protected Digester _digester;
|
||||||
|
|
||||||
|
/** Whether we should keep pngs as-is rather than re-encoding. */
|
||||||
|
protected boolean _keepRawPngs;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,6 +66,15 @@ public class TileSetBundlerTask extends Task
|
|||||||
_filesets.add(set);
|
_filesets.add(set);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Note whether we are supposed to use the raw png files directly in the bundle or try to
|
||||||
|
* re-encode them.
|
||||||
|
*/
|
||||||
|
public void setKeepRawPngs (boolean keep)
|
||||||
|
{
|
||||||
|
_keepRawPngs = keep;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs the actual work of the task.
|
* Performs the actual work of the task.
|
||||||
*/
|
*/
|
||||||
@@ -137,7 +146,7 @@ public class TileSetBundlerTask extends Task
|
|||||||
protected TileSetBundler createBundler ()
|
protected TileSetBundler createBundler ()
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
return new TileSetBundler(_config);
|
return new TileSetBundler(_config, _keepRawPngs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -161,4 +170,7 @@ public class TileSetBundlerTask extends Task
|
|||||||
|
|
||||||
/** A list of filesets that contain tileset bundle definitions. */
|
/** A list of filesets that contain tileset bundle definitions. */
|
||||||
protected ArrayList<FileSet> _filesets = Lists.newArrayList();
|
protected ArrayList<FileSet> _filesets = Lists.newArrayList();
|
||||||
|
|
||||||
|
/** Whether we should keep raw pngs rather than reencoding them in the bundle. */
|
||||||
|
protected boolean _keepRawPngs;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user