Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2004:
[Freeciv-Dev] (PR#8405) mapview scrolling with the arrow keys
Home

[Freeciv-Dev] (PR#8405) mapview scrolling with the arrow keys

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#8405) mapview scrolling with the arrow keys
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 27 Mar 2004 11:19:56 -0800
Reply-to: rt@xxxxxxxxxxx

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

Scrolling with the arrow keys should work straight in GUI coordinates. 
Otherwise we have granularity problems and the scrolling may zig-zag in 
iso-view (this has always happened).

This patch changes it.

jason

? Womoks
Index: client/mapctrl_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapctrl_common.c,v
retrieving revision 1.29
diff -u -r1.29 mapctrl_common.c
--- client/mapctrl_common.c     19 Mar 2004 20:22:07 -0000      1.29
+++ client/mapctrl_common.c     27 Mar 2004 19:18:51 -0000
@@ -456,20 +456,15 @@
 **************************************************************************/
 void scroll_mapview(enum direction8 gui_dir)
 {
-  int map_x, map_y, canvas_x, canvas_y;
+  int gui_x = mapview_canvas.gui_x0, gui_y = mapview_canvas.gui_y0;
 
   if (!can_client_change_view()) {
     return;
   }
 
-  canvas_x = mapview_canvas.width / 2;
-  canvas_y = mapview_canvas.height / 2;
-  canvas_x += DIR_DX[gui_dir] * mapview_canvas.width / 2;
-  canvas_y += DIR_DY[gui_dir] * mapview_canvas.height / 2;
-  if (!canvas_to_map_pos(&map_x, &map_y, canvas_x, canvas_y)) {
-    nearest_real_pos(&map_x, &map_y);
-  }
-  center_tile_mapcanvas(map_x, map_y);
+  gui_x += DIR_DX[gui_dir] * mapview_canvas.width / 2;
+  gui_y += DIR_DY[gui_dir] * mapview_canvas.height / 2;
+  set_mapview_origin(gui_x, gui_y);
 }
 
 /**************************************************************************
Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.97
diff -u -r1.97 mapview_common.c
--- client/mapview_common.c     27 Mar 2004 19:08:40 -0000      1.97
+++ client/mapview_common.c     27 Mar 2004 19:18:51 -0000
@@ -360,7 +360,7 @@
 /****************************************************************************
   Change the mapview origin, clip it, and update everything.
 ****************************************************************************/
-static void set_mapview_origin(int gui_x0, int gui_y0)
+void set_mapview_origin(int gui_x0, int gui_y0)
 {
   int xmin, xmax, ymin, ymax, xsize, ysize;
 
Index: client/mapview_common.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.h,v
retrieving revision 1.52
diff -u -r1.52 mapview_common.h
--- client/mapview_common.h     19 Mar 2004 20:22:08 -0000      1.52
+++ client/mapview_common.h     27 Mar 2004 19:18:51 -0000
@@ -152,6 +152,7 @@
 void get_mapview_scroll_pos(int *scroll_x, int *scroll_y);
 void set_mapview_scroll_pos(int scroll_x, int scroll_y);
 
+void set_mapview_origin(int gui_x0, int gui_y0);
 void get_center_tile_mapcanvas(int *map_x, int *map_y);
 void center_tile_mapcanvas(int map_x, int map_y);
 

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#8405) mapview scrolling with the arrow keys, Jason Short <=