summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortron <tron@openttd.org>2004-12-14 08:01:12 +0000
committertron <tron@openttd.org>2004-12-14 08:01:12 +0000
commit1fcf823d66439c68fe85998d76de083d60fa53e7 (patch)
tree5835d927ec8da0b3df1e2c8e58d3f28b197bfb87
parent043b8bc5addf34641cc0f8ad5d223d59b57a8a7f (diff)
downloadopenttd-1fcf823d66439c68fe85998d76de083d60fa53e7.tar.xz
(svn r1080) Improve mini-map scrolling in a similar way as viewport scrolling (r1063): now the centre of the mini-map window is the region of interest instead some arbitrary coordinate.
-rw-r--r--window.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/window.c b/window.c
index 01b54becc..c61e6921b 100644
--- a/window.c
+++ b/window.c
@@ -968,6 +968,10 @@ stop_capt:;
return false;
} else {
// scroll the smallmap ?
+ int hx;
+ int hy;
+ int hvx;
+ int hvy;
_cursor.fix_at = true;
@@ -996,10 +1000,14 @@ stop_capt:;
}
}
- if (x < 16) { x = 16; sub = 0; }
- if (x > (TILES_X-2)*16) { x = (TILES_X-2)*16; sub = 0; }
- if (y < -1120) { y = -1120; sub = 0; }
- if (y > (TILE_X_MAX-40) * 16) { y = (TILE_X_MAX-40) * 16; sub = 0; }
+ hx = (w->widget[4].right - w->widget[4].left) / 2;
+ hy = (w->widget[4].bottom - w->widget[4].top ) / 2;
+ hvx = hx * -4 + hy * 8;
+ hvy = hx * 4 + hy * 8;
+ if (x < -hvx) { x = -hvx; sub = 0; }
+ if (x > TILE_X_MAX * 16 - hvx) { x = TILE_X_MAX * 16 - hvx; sub = 0; }
+ if (y < -hvy) { y = -hvy; sub = 0; }
+ if (y > TILE_Y_MAX * 16 - hvy) { y = TILE_Y_MAX * 16 - hvy; sub = 0; }
WP(w,smallmap_d).scroll_x = x;
WP(w,smallmap_d).scroll_y = y;