Complete.Org: Mailing Lists: Archives: freeciv-dev: March 1999:
[Freeciv-Dev] Patch: Displaying the map as a grid
Home

[Freeciv-Dev] Patch: Displaying the map as a grid

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Patch: Displaying the map as a grid
From: Rizos Sakellariou <rizos@xxxxxxxxxxx>
Date: Tue, 9 Mar 1999 20:37:34 -0600 (CST)

The following patch adds a grid capability to the client.
Pressing <ctrl>g or <shift>g, the client will display (or stop
displaying) the known(*) portion of the map as a grid, making 
distance calculations easier.

--rizos
(*) this is because the grid is displayed in black. Any other
    colour would display a grid for the unknown tiles too, but
    it seemed to me that black is the natural choice. Of course,
    one can easily add code to display the grid in a different
    colour for unknown tiles.


Files affected:
        client/mapctrl.c
        client/mapview.c
        client/xmain.c
        client/civclient.c
        client/mapctrl.h
        data/Freeciv


--- mapctrl-orig.c      Tue Mar  9 18:35:05 1999
+++ mapctrl.c   Tue Mar  9 19:35:38 1999
@@ -52,6 +52,8 @@
 extern int map_canvas_store_twidth, map_canvas_store_theight;
 extern int overview_canvas_store_width, overview_canvas_store_height;
 
+extern int map_draw_grid;
+
 /* unit_focus points to the current unit in focus */
 struct unit *punit_focus;
 
@@ -1176,3 +1178,16 @@
   unit_list_iterate_end;
   return best_candidate;
 }
+
+/**************************************************************************
+set the flag to display the map as a grid or not.
+**************************************************************************/
+void draw_map_grid(Widget w, XEvent *event, String *argv, Cardinal *argc)
+{
+  if(get_client_state()!=CLIENT_GAME_RUNNING_STATE)
+     return;
+
+  map_draw_grid = 1-map_draw_grid;
+  update_map_canvas(0, 0, map_canvas_store_twidth, map_canvas_store_theight, 
1);
+}
+ 



--- mapview-orig.c      Tue Mar  9 16:17:58 1999
+++ mapview.c   Tue Mar  9 19:31:19 1999
@@ -65,6 +65,7 @@
 extern int flags_are_transparent;
 extern int ai_manual_turn_done;
 extern int draw_diagonal_roads;
+extern int map_draw_grid;
 
 extern struct Sprite *intro_gfx_sprite;
 extern struct Sprite *radar_gfx_sprite;
@@ -765,9 +766,17 @@
   int x, y;
 
   for(y=tile_y; y<tile_y+height; y++)
-    for(x=tile_x; x<tile_x+width; x++)
+    for(x=tile_x; x<tile_x+width; x++) {
       pixmap_put_tile(map_canvas_store, x, y, 
                      (map_view_x0+x)%map.xsize, map_view_y0+y, 0);
+      if (map_draw_grid) {
+         XSetForeground(display, fill_bg_gc, colors_standard[COLOR_STD_BLACK]);
+         XDrawRectangle(display, map_canvas_store, fill_bg_gc, 
+                        x*NORMAL_TILE_WIDTH, y*NORMAL_TILE_HEIGHT, 
+                        NORMAL_TILE_WIDTH, NORMAL_TILE_HEIGHT);
+      }
+  }
 
   if(write_to_screen) {
     XCopyArea(display, map_canvas_store, XtWindow(map_canvas), 



--- xmain-orig.c        Tue Mar  9 18:28:40 1999
+++ xmain.c     Tue Mar  9 18:36:58 1999
@@ -240,6 +240,7 @@
   { "key-goto-dialog", popup_goto_dialog_action },
   { "key-city-workers", key_city_workers },
   { "adjust-workers", adjust_workers },
+  { "draw-map-grid", draw_map_grid},
   { "close-spaceshipdialog", close_spaceship_dialog_action },
   { "spaceship-dialog-returnkey", spaceship_dialog_returnkey }
 };



--- civclient-orig.c    Tue Mar  9 18:34:22 1999
+++ civclient.c Tue Mar  9 18:34:47 1999
@@ -56,6 +56,7 @@
 int wakeup_focus=1;
 int draw_diagonal_roads=1;
 int center_when_popup_city=1;
+int map_draw_grid=0;
 
 int seconds_to_turndone;
 


--- mapctrl-orig.h      Tue Mar  9 18:54:51 1999
+++ mapctrl.h   Tue Mar  9 18:55:35 1999
@@ -77,6 +77,7 @@
 void do_move_unit(struct unit *punit, struct packet_unit_info *pinfo);
 void key_city_workers(Widget w, XEvent *event, String *argv, Cardinal *argc);
 void adjust_workers(Widget w, XEvent *event, String *argv, Cardinal *argc);
+void draw_map_grid(Widget w, XEvent *event, String *argv, Cardinal *argc);
 
 void city_new_name_return(Widget w, XEvent *event, String *params,
                          Cardinal *num_params);



--- Freeciv     Tue Mar  9 20:04:17 1999
+++ Freeciv.orig        Tue Mar  9 20:02:52 1999
@@ -2194,8 +2194,6 @@
    <BtnDown>:         select-mapcanvas()    \n\
    <Key>Tab:          focus-to-next-unit()  \n\
    <Key>c:            center-on-unit()      \n\
-   Shift<Key>g:       draw-map-grid()       \\n\
-   Ctrl<Key>g:        draw-map-grid()       \\n\
    <Key>KP_8:         key-unit-north()      \n\
    <Key>Up:           key-unit-north()      \n\
    <Key>KP_9:         key-unit-north-east() \n\


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