MakeTiles: output to a graphics directory instead of a specific file
This commit is contained in:
parent
eb97e1c27c
commit
c0f1d6a486
2 changed files with 15 additions and 13 deletions
|
@ -48,25 +48,25 @@
|
||||||
<java classname="micropolisj.build_tool.MakeTiles" classpath="${builddir}"
|
<java classname="micropolisj.build_tool.MakeTiles" classpath="${builddir}"
|
||||||
fork="true" failonerror="true" dir="graphics" inputstring="">
|
fork="true" failonerror="true" dir="graphics" inputstring="">
|
||||||
<arg file="graphics/tiles.rc" />
|
<arg file="graphics/tiles.rc" />
|
||||||
<arg file="${builddir}/tiles.png" />
|
<arg file="${builddir}/16x16" />
|
||||||
</java>
|
</java>
|
||||||
<java classname="micropolisj.build_tool.MakeTiles" classpath="${builddir}"
|
<java classname="micropolisj.build_tool.MakeTiles" classpath="${builddir}"
|
||||||
fork="true" failonerror="true" dir="graphics" inputstring="">
|
fork="true" failonerror="true" dir="graphics" inputstring="">
|
||||||
<sysproperty key="tile_size" value="8" />
|
<sysproperty key="tile_size" value="8" />
|
||||||
<arg file="graphics/tiles.rc" />
|
<arg file="graphics/tiles.rc" />
|
||||||
<arg file="${builddir}/tiles_8x8.png" />
|
<arg file="${builddir}/8x8" />
|
||||||
</java>
|
</java>
|
||||||
<java classname="micropolisj.build_tool.MakeTiles" classpath="${builddir}"
|
<java classname="micropolisj.build_tool.MakeTiles" classpath="${builddir}"
|
||||||
fork="true" failonerror="true" dir="graphics" inputstring="">
|
fork="true" failonerror="true" dir="graphics" inputstring="">
|
||||||
<sysproperty key="tile_size" value="32" />
|
<sysproperty key="tile_size" value="32" />
|
||||||
<arg file="graphics/tiles.rc" />
|
<arg file="graphics/tiles.rc" />
|
||||||
<arg file="${builddir}/tiles_32x32.png" />
|
<arg file="${builddir}/32x32" />
|
||||||
</java>
|
</java>
|
||||||
<java classname="micropolisj.build_tool.MakeTiles" classpath="${builddir}"
|
<java classname="micropolisj.build_tool.MakeTiles" classpath="${builddir}"
|
||||||
fork="true" failonerror="true" dir="graphics" inputstring="">
|
fork="true" failonerror="true" dir="graphics" inputstring="">
|
||||||
<sysproperty key="tile_size" value="3" />
|
<sysproperty key="tile_size" value="3" />
|
||||||
<arg file="graphics/tiles.rc" />
|
<arg file="graphics/tiles.rc" />
|
||||||
<arg file="${builddir}/tilessm.png" />
|
<arg file="${builddir}/sm" />
|
||||||
</java>
|
</java>
|
||||||
<copy todir="${builddir}" file="graphics/tiles.rc" />
|
<copy todir="${builddir}" file="graphics/tiles.rc" />
|
||||||
</target>
|
</target>
|
||||||
|
|
|
@ -39,12 +39,12 @@ public class MakeTiles
|
||||||
}
|
}
|
||||||
|
|
||||||
File recipeFile = new File(args[0]);
|
File recipeFile = new File(args[0]);
|
||||||
File outputFile = new File(args[1]);
|
File outputDir = new File(args[1]);
|
||||||
|
|
||||||
generateFromRecipe(recipeFile, outputFile);
|
generateFromRecipe(recipeFile, outputDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void generateFromRecipe(File recipeFile, File outputFile)
|
static void generateFromRecipe(File recipeFile, File outputDir)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
Properties recipe = new Properties();
|
Properties recipe = new Properties();
|
||||||
|
@ -82,15 +82,17 @@ public class MakeTiles
|
||||||
drawTo(ref, gr, 0, TILE_SIZE*i);
|
drawTo(ref, gr, 0, TILE_SIZE*i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// make parent directories if necessary
|
||||||
|
outputDir.mkdirs();
|
||||||
|
|
||||||
|
// output the composed images
|
||||||
|
File outputFile = new File(outputDir, "tiles.png");
|
||||||
System.out.println("Generating tiles array: "+outputFile);
|
System.out.println("Generating tiles array: "+outputFile);
|
||||||
ImageIO.write(buf, "png", outputFile);
|
ImageIO.write(buf, "png", outputFile);
|
||||||
|
|
||||||
File indexFile = new File(
|
// output an index of all tile names and their offset into
|
||||||
outputFile.getParentFile(),
|
// the composed tile array
|
||||||
outputFile.getName()
|
File indexFile = new File(outputDir, "tiles.idx");
|
||||||
.replaceFirst("\\.png$","")
|
|
||||||
+ ".idx"
|
|
||||||
);
|
|
||||||
System.out.println("Generating tiles index: "+indexFile);
|
System.out.println("Generating tiles index: "+indexFile);
|
||||||
writeIndexFile(tileNames, indexFile);
|
writeIndexFile(tileNames, indexFile);
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue