Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2003:
[Freeciv-Dev] (PR#6379) implement get_mapview_corners for iso-maps
Home

[Freeciv-Dev] (PR#6379) implement get_mapview_corners for iso-maps

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#6379) implement get_mapview_corners for iso-maps
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 2 Oct 2003 12:14:28 -0700
Reply-to: rt@xxxxxxxxxxxxxx

get_mapview_corners() returns the overview positions of the four corners 
of the mapview window.  It is used for drawing the mapview rectangle 
onto the overview minimap.

Currently it implemented for iso-view and non-iso-view, but only for 
non-iso-maps.  With this patch it is implemented for iso-maps as well.

Of course this cannot be tested without actually using iso-maps, and 
they are not enabled in Freeciv yet.  This patch comes straight from the 
gen-topologies.diff patch in the patches module of the freeciv-test 
repository, where it can be tested.

It should at least be obvious from the patch that it doesn't change the 
current behavior at all.

jason

Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.65
diff -u -r1.65 mapview_common.c
--- client/mapview_common.c     2003/10/02 17:04:55     1.65
+++ client/mapview_common.c     2003/10/02 19:10:48
@@ -1434,7 +1434,8 @@
   map_to_overview_pos(&x[0], &y[0],
                      mapview_canvas.map_x0, mapview_canvas.map_y0);
 
-  if (is_isometric) {
+  /* Note: these calculations manipulate native coordinates directly. */
+  if (is_isometric && !topo_has_flag(TF_ISO)) {
     /* We start with the west corner. */
 
     /* North */
@@ -1448,16 +1449,32 @@
     /* South */
     x[3] = x[0] + OVERVIEW_TILE_WIDTH * mapview_canvas.tile_height;
     y[3] = y[0] + OVERVIEW_TILE_HEIGHT * mapview_canvas.tile_height;
+  } else if (!is_isometric && topo_has_flag(TF_ISO)) {
+    /* We start with the west corner.  Note the X scale is smaller. */
+
+    /* North */
+    x[1] = x[0] + OVERVIEW_TILE_WIDTH * mapview_canvas.tile_width / 2;
+    y[1] = y[0] + OVERVIEW_TILE_HEIGHT * mapview_canvas.tile_width;
+
+    /* East */
+    x[2] = x[1] - OVERVIEW_TILE_WIDTH * mapview_canvas.tile_height / 2;
+    y[2] = y[1] + OVERVIEW_TILE_HEIGHT * mapview_canvas.tile_height;
+
+    /* South */
+    x[3] = x[2] - OVERVIEW_TILE_WIDTH * mapview_canvas.tile_width / 2;
+    y[3] = y[2] - OVERVIEW_TILE_HEIGHT * mapview_canvas.tile_width;
   } else {
     /* We start with the northwest corner. */
+    int screen_width = mapview_canvas.tile_width;
+    int screen_height = mapview_canvas.tile_height * (is_isometric ? 2 : 1);
 
     /* Northeast */
-    x[1] = x[0] + OVERVIEW_TILE_WIDTH * mapview_canvas.tile_width - 1;
+    x[1] = x[0] + OVERVIEW_TILE_WIDTH * screen_width - 1;
     y[1] = y[0];
 
     /* Southeast */
     x[2] = x[1];
-    y[2] = y[0] + OVERVIEW_TILE_HEIGHT * mapview_canvas.tile_height - 1;
+    y[2] = y[0] + OVERVIEW_TILE_HEIGHT * screen_height - 1;
 
     /* Southwest */
     x[3] = x[0];

[Prev in Thread] Current Thread [Next in Thread]