Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2004:
[Freeciv-Dev] (PR#8358) a better center_tile_mapcanvas
Home

[Freeciv-Dev] (PR#8358) a better center_tile_mapcanvas

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#8358) a better center_tile_mapcanvas
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 24 Mar 2004 11:37:29 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=8358 >

This patch changes center_tile_mapcanvas to center the tile more 
accurately.  The tile being centered is now put at the exact center of 
the mapview.  Incidentally this is easier to do since we can work 
straight in GUI coordinates.

jason

? diff
Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.94
diff -u -r1.94 mapview_common.c
--- client/mapview_common.c     19 Mar 2004 20:22:07 -0000      1.94
+++ client/mapview_common.c     24 Mar 2004 19:35:48 -0000
@@ -491,22 +491,16 @@
 **************************************************************************/
 void center_tile_mapcanvas(int map_center_x, int map_center_y)
 {
-  int map_x = map_center_x, map_y = map_center_y, gui_x, gui_y;
+  int gui_x, gui_y;
 
   CHECK_MAP_POS(map_center_x, map_center_y);
 
-  /* Find top-left corner. */
-  if (is_isometric) {
-    map_x -= mapview_canvas.tile_width / 2;
-    map_y += mapview_canvas.tile_width / 2;
-    map_x -= mapview_canvas.tile_height / 2;
-    map_y -= mapview_canvas.tile_height / 2;
-  } else {
-    map_x -= mapview_canvas.tile_width / 2;
-    map_y -= mapview_canvas.tile_height / 2;
-  }
+  map_to_gui_pos(&gui_x, &gui_y, map_center_x, map_center_y);
+
+  /* Put the center pixel of the tile at the exact center of the mapview. */
+  gui_x -= (mapview_canvas.width - NORMAL_TILE_WIDTH) / 2;
+  gui_y -= (mapview_canvas.height - NORMAL_TILE_HEIGHT) / 2;
 
-  map_to_gui_pos(&gui_x, &gui_y, map_x, map_y);
   set_mapview_origin(gui_x, gui_y);
 }
 

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#8358) a better center_tile_mapcanvas, Jason Short <=