(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.
authortron
Tue, 14 Dec 2004 08:01:12 +0000
changeset 647 0a3dabcc1082
parent 646 2e8a3763ebe5
child 648 7e27485116c6
(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.
window.c
--- a/window.c	Tue Dec 14 00:45:24 2004 +0000
+++ b/window.c	Tue Dec 14 08:01:12 2004 +0000
@@ -968,6 +968,10 @@
 		return false;
 	} else {
 		// scroll the smallmap ?
+		int hx;
+		int hy;
+		int hvx;
+		int hvy;
 
 		_cursor.fix_at = true;
 
@@ -996,10 +1000,14 @@
 			}
 		}
 
-		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;