drawing-area: allow zooming from 8px to 32px, using unique graphics source for each level
git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@756 d9718cc8-9f43-0410-858b-315f434eb58c
This commit is contained in:
parent
ee449d59a4
commit
1ce5080705
3 changed files with 18 additions and 7 deletions
|
@ -50,6 +50,12 @@
|
|||
<arg file="graphics/tiles.rc" />
|
||||
<arg file="${builddir}/tiles.png" />
|
||||
</java>
|
||||
<java classname="micropolisj.build_tool.MakeTiles" classpath="${builddir}"
|
||||
fork="true" failonerror="true" dir="graphics">
|
||||
<sysproperty key="tile_size" value="8" />
|
||||
<arg file="graphics/tiles.rc" />
|
||||
<arg file="${builddir}/tiles_8x8.png" />
|
||||
</java>
|
||||
<java classname="micropolisj.build_tool.MakeTiles" classpath="${builddir}"
|
||||
fork="true" failonerror="true" dir="graphics">
|
||||
<sysproperty key="tile_size" value="32" />
|
||||
|
|
|
@ -996,7 +996,7 @@ public class MainWindow extends JFrame
|
|||
|
||||
int oldZoom = drawingArea.getTileSize();
|
||||
int newZoom = zoomOut ? (oldZoom / 2) : (oldZoom * 2);
|
||||
if (newZoom < 16) { newZoom = 16; }
|
||||
if (newZoom < 8) { newZoom = 8; }
|
||||
if (newZoom > 32) { newZoom = 32; }
|
||||
|
||||
if (oldZoom != newZoom)
|
||||
|
|
|
@ -29,17 +29,22 @@ public class TileImages
|
|||
this.TILE_WIDTH = size;
|
||||
this.TILE_HEIGHT = size;
|
||||
|
||||
//if (size != 16) {
|
||||
// this.images = loadTileImages("/tiles_"+size+"x"+size+".png", size);
|
||||
//}
|
||||
//else {
|
||||
if (size != 16) {
|
||||
this.images = loadTileImages("/tiles_"+size+"x"+size+".png", size);
|
||||
}
|
||||
else {
|
||||
this.images = loadTileImages("/tiles.png", 16);
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
static Map<Integer,TileImages> savedInstances = new HashMap<Integer,TileImages>();
|
||||
|
||||
public static TileImages getInstance(int size)
|
||||
{
|
||||
return new TileImages(size);
|
||||
if (!savedInstances.containsKey(size)) {
|
||||
savedInstances.put(size, new TileImages(size));
|
||||
}
|
||||
return savedInstances.get(size);
|
||||
}
|
||||
|
||||
public Image getTileImage(int cell)
|
||||
|
|
Reference in a new issue