drawing-area: hold in-memory tile images in an object, rather than static variables

This will allow changing tile sizes on a per-window basis.

git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@752 d9718cc8-9f43-0410-858b-315f434eb58c
This commit is contained in:
jason@long.name 2013-07-20 21:29:40 +00:00
parent 8a9af13de9
commit d452c45d21
3 changed files with 131 additions and 65 deletions

View file

@ -991,8 +991,8 @@ public class MainWindow extends JFrame
private void onToolDown(MouseEvent ev)
{
if (ev.getButton() == MouseEvent.BUTTON3) {
doQueryTool(ev.getX() / MicropolisDrawingArea.TILE_WIDTH,
ev.getY() / MicropolisDrawingArea.TILE_HEIGHT);
CityLocation loc = drawingArea.getCityLocation(ev.getX(), ev.getY());
doQueryTool(loc.x, loc.y);
return;
}
@ -1002,8 +1002,9 @@ public class MainWindow extends JFrame
if (currentTool == null)
return;
int x = ev.getX() / MicropolisDrawingArea.TILE_WIDTH;
int y = ev.getY() / MicropolisDrawingArea.TILE_HEIGHT;
CityLocation loc = drawingArea.getCityLocation(ev.getX(), ev.getY());
int x = loc.x;
int y = loc.y;
if (currentTool == MicropolisTool.QUERY) {
doQueryTool(x, y);
@ -1058,8 +1059,9 @@ public class MainWindow extends JFrame
if ((ev.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) == 0)
return;
int x = ev.getX() / MicropolisDrawingArea.TILE_WIDTH;
int y = ev.getY() / MicropolisDrawingArea.TILE_HEIGHT;
CityLocation loc = drawingArea.getCityLocation(ev.getX(), ev.getY());
int x = loc.x;
int y = loc.y;
if (x == lastX && y == lastY)
return;
@ -1083,8 +1085,9 @@ public class MainWindow extends JFrame
return;
}
int x = ev.getX() / MicropolisDrawingArea.TILE_WIDTH;
int y = ev.getY() / MicropolisDrawingArea.TILE_HEIGHT;
CityLocation loc = drawingArea.getCityLocation(ev.getX(), ev.getY());
int x = loc.x;
int y = loc.y;
int w = currentTool.getWidth();
int h = currentTool.getHeight();