Bring over the options from TileSetBundler to ComponentBundler so we can get jars with uncompressed, untrimmed pngs.
git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@966 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
@@ -132,6 +132,24 @@ public class ComponentBundlerTask 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Note whether we are supposed to leave the jar uncompressed rather than the normal process
|
||||||
|
* of zipping it at maximum compression.
|
||||||
|
*/
|
||||||
|
public void setUncompressed (boolean uncompressed)
|
||||||
|
{
|
||||||
|
_uncompressed = uncompressed;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs the actual work of the task.
|
* Performs the actual work of the task.
|
||||||
*/
|
*/
|
||||||
@@ -268,29 +286,47 @@ public class ComponentBundlerTask extends Task
|
|||||||
|
|
||||||
fout = nextEntry(fout, ipath);
|
fout = nextEntry(fout, ipath);
|
||||||
|
|
||||||
// create a trimmed tileset based on the source action tileset and
|
|
||||||
// stuff the new trimmed image into the jar file at the same time
|
|
||||||
aset.setImagePath(cfile.getPath());
|
aset.setImagePath(cfile.getPath());
|
||||||
|
|
||||||
TrimmedTileSet tset;
|
TileSet tset;
|
||||||
try {
|
if (_keepRawPngs) {
|
||||||
tset = trim(aset, fout);
|
// We've elected to keep the pngs as they are and just stuff them into the jar.
|
||||||
tset.setImagePath(ipath);
|
try {
|
||||||
} catch (Throwable t) {
|
tset = aset;
|
||||||
System.err.println(
|
BufferedImage image = aset.getRawTileSetImage();
|
||||||
"Failure trimming tileset " +
|
ImageIO.write(image, "png", fout);
|
||||||
"[class=" + info[0] + ", name=" + info[1] +
|
} catch (Throwable t) {
|
||||||
", action=" + info[2] +
|
System.err.println(
|
||||||
", srcimg=" + aset.getImagePath() + "].");
|
"Failure storing tileset in jar" +
|
||||||
t.printStackTrace(System.err);
|
"[class=" + info[0] + ", name=" + info[1] +
|
||||||
|
", action=" + info[2] +
|
||||||
|
", srcimg=" + aset.getImagePath() + "].");
|
||||||
|
t.printStackTrace(System.err);
|
||||||
|
|
||||||
String errmsg = "Failure trimming tileset.";
|
String errmsg = "Failure trimming tileset.";
|
||||||
throw new BuildException(errmsg, t);
|
throw new BuildException(errmsg, t);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// create a trimmed tileset based on the source action tileset and
|
||||||
|
// stuff the new trimmed image into the jar file at the same time
|
||||||
|
try {
|
||||||
|
tset = trim(aset, fout);
|
||||||
|
tset.setImagePath(ipath);
|
||||||
|
} catch (Throwable t) {
|
||||||
|
System.err.println(
|
||||||
|
"Failure trimming tileset " +
|
||||||
|
"[class=" + info[0] + ", name=" + info[1] +
|
||||||
|
", action=" + info[2] +
|
||||||
|
", srcimg=" + aset.getImagePath() + "].");
|
||||||
|
t.printStackTrace(System.err);
|
||||||
|
|
||||||
|
String errmsg = "Failure trimming tileset.";
|
||||||
|
throw new BuildException(errmsg, t);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// then write our trimmed tileset bundle data
|
// then write our trimmed tileset bundle data
|
||||||
String tpath = composePath(info, BundleUtil.TILESET_EXTENSION);
|
String tpath = composePath(info, BundleUtil.TILESET_EXTENSION);
|
||||||
if (!skipEntry(tpath, newest)) {
|
if (!skipEntry(tpath, newest) && !_keepRawPngs) {
|
||||||
fout = nextEntry(fout, tpath);
|
fout = nextEntry(fout, tpath);
|
||||||
|
|
||||||
ObjectOutputStream oout = new ObjectOutputStream(fout);
|
ObjectOutputStream oout = new ObjectOutputStream(fout);
|
||||||
@@ -456,7 +492,7 @@ public class ComponentBundlerTask extends Task
|
|||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
JarOutputStream jout = new JarOutputStream(new FileOutputStream(target));
|
JarOutputStream jout = new JarOutputStream(new FileOutputStream(target));
|
||||||
jout.setLevel(Deflater.BEST_COMPRESSION);
|
jout.setLevel(_uncompressed ? Deflater.NO_COMPRESSION : Deflater.BEST_COMPRESSION);
|
||||||
return jout;
|
return jout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -671,6 +707,12 @@ public class ComponentBundlerTask extends Task
|
|||||||
/** A list of filesets that contain tile images. */
|
/** A list of filesets that contain tile images. */
|
||||||
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;
|
||||||
|
|
||||||
|
/** Whether we should keep the bundle jars uncompressed rather than zipped. */
|
||||||
|
protected boolean _uncompressed;
|
||||||
|
|
||||||
/** Used to separate keys and values in the map file. */
|
/** Used to separate keys and values in the map file. */
|
||||||
protected static final String SEP_STR = " := ";
|
protected static final String SEP_STR = " := ";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user