Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2002:
[Freeciv-Dev] (PR#2352) unification of update_map_canvas_visible
Home

[Freeciv-Dev] (PR#2352) unification of update_map_canvas_visible

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients:;
Subject: [Freeciv-Dev] (PR#2352) unification of update_map_canvas_visible
From: "Jason Short via RT" <rt@xxxxxxxxxxxxxx>
Date: Fri, 15 Nov 2002 16:29:23 -0800
Reply-to: rt@xxxxxxxxxxxxxx

The attached patch unifies update_map_canvas_visible over all GUIs.  In 
its place, show_city_descriptions becomes a GUI stub function.

For most GUIs this is a simple replacement.  But note:

- In XAW, we add isometric support to this function (by default).

- In Win32, the prototype of show_city_descriptions must change 
slightly.  This needs to be tested; I'm not entirely sure it is correct 
for when update_map_canvas_visible is called from within the expose 
function.  See comment.

jason

? client/gui-gtk/diff
? client/gui-stub/stub-update.diff
? client/gui-xaw/diff
Index: client//mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.13
diff -u -r1.13 mapview_common.c
--- client//mapview_common.c    2002/11/15 09:24:51     1.13
+++ client//mapview_common.c    2002/11/16 00:20:12
@@ -294,6 +294,36 @@
 }
 
 /**************************************************************************
+ Update (only) the visible part of the map
+**************************************************************************/
+void update_map_canvas_visible(void)
+{
+  int map_view_x0, map_view_y0, map_win_width, map_win_height;
+  int map_tile_width, map_tile_height;
+
+  get_mapview_dimensions(&map_view_x0, &map_view_y0,
+                        &map_win_width, &map_win_height);
+  map_tile_width = (map_win_width - 1) / NORMAL_TILE_WIDTH + 1;
+  map_tile_height = (map_win_height - 1) / NORMAL_TILE_HEIGHT + 1;
+
+  if (is_isometric) {
+    /* just find a big rectangle that includes the whole visible area. The
+       invisible tiles will not be drawn. */
+    int width, height;
+
+    width = height = map_tile_width + map_tile_height;
+    update_map_canvas(map_view_x0,
+                     map_view_y0 - map_tile_width,
+                     width, height, TRUE);
+  } else {
+    update_map_canvas(map_view_x0, map_view_y0,
+                     map_tile_width, map_tile_height, TRUE);
+  }
+
+  show_city_descriptions();
+}
+
+/**************************************************************************
   Find the "best" city to associate with the selected tile.
     a.  A city working the tile is the best
     b.  If another player is working the tile, return NULL.
Index: client//mapview_common.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.h,v
retrieving revision 1.8
diff -u -r1.8 mapview_common.h
--- client//mapview_common.h    2002/11/15 09:24:51     1.8
+++ client//mapview_common.h    2002/11/16 00:20:12
@@ -52,6 +52,8 @@
                                int *map_view_topleft_map_y,
                                int map_view_map_width,
                                int map_view_map_height);
+
+void update_map_canvas_visible(void);
                                
 struct city *find_city_near_tile(int x, int y);
 
Index: client//gui-gtk/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/mapview.c,v
retrieving revision 1.130
diff -u -r1.130 mapview.c
--- client//gui-gtk/mapview.c   2002/11/15 09:24:51     1.130
+++ client//gui-gtk/mapview.c   2002/11/16 00:20:13
@@ -89,7 +89,6 @@
 static void put_unit_pixmap(struct unit *punit, GdkPixmap *pm,
                            int canvas_x, int canvas_y);
 static void put_line(GdkDrawable *pm, int x, int y, int dir);
-static void show_city_descriptions(void);
 
 static void put_unit_pixmap_draw(struct unit *punit, GdkPixmap *pm,
                                 int canvas_x, int canvas_y,
@@ -1272,28 +1271,6 @@
 }
 
 /**************************************************************************
- Update (only) the visible part of the map
-**************************************************************************/
-void update_map_canvas_visible(void)
-{
-  if (is_isometric) {
-    /* just find a big rectangle that includes the whole visible area. The
-       invisible tiles will not be drawn. */
-    int width, height;
-
-    width = height = map_canvas_store_twidth + map_canvas_store_theight;
-    update_map_canvas(map_view_x0,
-                     map_view_y0 - map_canvas_store_twidth,
-                     width, height, TRUE);
-  } else {
-    update_map_canvas(map_view_x0, map_view_y0,
-                     map_canvas_store_twidth,map_canvas_store_theight, TRUE);
-  }
-
-  show_city_descriptions();
-}
-
-/**************************************************************************
  Update display of descriptions associated with cities on the main map.
 **************************************************************************/
 void update_city_descriptions(void)
@@ -1348,7 +1325,7 @@
 /**************************************************************************
 ...
 **************************************************************************/
-static void show_city_descriptions(void)
+void show_city_descriptions(void)
 {
   if (!draw_city_names && !draw_city_productions)
     return;
Index: client//gui-gtk-2.0/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/mapview.c,v
retrieving revision 1.17
diff -u -r1.17 mapview.c
--- client//gui-gtk-2.0/mapview.c       2002/11/15 09:24:52     1.17
+++ client//gui-gtk-2.0/mapview.c       2002/11/16 00:20:14
@@ -89,7 +89,6 @@
 static void put_unit_pixmap(struct unit *punit, GdkPixmap *pm,
                            int canvas_x, int canvas_y);
 static void put_line(GdkDrawable *pm, int x, int y, int dir);
-static void show_city_descriptions(void);
 
 static void put_unit_pixmap_draw(struct unit *punit, GdkPixmap *pm,
                                 int canvas_x, int canvas_y,
@@ -1297,28 +1296,6 @@
 }
 
 /**************************************************************************
- Update (only) the visible part of the map
-**************************************************************************/
-void update_map_canvas_visible(void)
-{
-  if (is_isometric) {
-    /* just find a big rectangle that includes the whole visible area. The
-       invisible tiles will not be drawn. */
-    int width, height;
-
-    width = height = map_canvas_store_twidth + map_canvas_store_theight;
-    update_map_canvas(map_view_x0,
-                     map_view_y0 - map_canvas_store_twidth,
-                     width, height, TRUE);
-  } else {
-    update_map_canvas(map_view_x0, map_view_y0,
-                     map_canvas_store_twidth,map_canvas_store_theight, TRUE);
-  }
-
-  show_city_descriptions();
-}
-
-/**************************************************************************
  Update display of descriptions associated with cities on the main map.
 **************************************************************************/
 void update_city_descriptions(void)
@@ -1380,7 +1357,7 @@
 /**************************************************************************
 ...
 **************************************************************************/
-static void show_city_descriptions()
+void show_city_descriptions(void)
 {
   PangoLayout *layout;
 
Index: client//gui-mui/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-mui/mapview.c,v
retrieving revision 1.44
diff -u -r1.44 mapview.c
--- client//gui-mui/mapview.c   2002/11/15 09:24:52     1.44
+++ client//gui-mui/mapview.c   2002/11/16 00:20:15
@@ -519,7 +519,7 @@
 /**************************************************************************
 ...
 **************************************************************************/
-static void show_city_descriptions(void)
+void show_city_descriptions(void)
 {
   if (!draw_city_names && !draw_city_productions)
     return;
@@ -543,33 +543,6 @@
                       bool write_to_screen)
 {
   DoMethod(main_map_area, MUIM_Map_Refresh, x, y, width, height, 
write_to_screen);
-}
-
-/**************************************************************************
- Update (only) the visible part of the map
-**************************************************************************/
-void update_map_canvas_visible(void)
-{
-  int map_view_x0 = xget(main_map_area, MUIA_Map_HorizFirst);
-  int map_view_y0 = xget(main_map_area, MUIA_Map_VertFirst);
-  int map_canvas_store_twidth = get_map_x_visible();
-  int map_canvas_store_theight = get_map_y_visible();
-
-  if (is_isometric) {
-    /* just find a big rectangle that includes the whole visible area. The
-       invisible tiles will not be drawn. */
-    int width, height;
-
-    width = height = map_canvas_store_twidth + map_canvas_store_theight;
-    update_map_canvas(map_view_x0,
-                     map_view_y0 - map_canvas_store_twidth,
-                     width, height, TRUE);
-  } else {
-    update_map_canvas(map_view_x0, map_view_y0,
-                     map_canvas_store_twidth,map_canvas_store_theight, TRUE);
-  }
-
-  show_city_descriptions();
 }
 
 /**************************************************************************
Index: client//gui-stub/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-stub/mapview.c,v
retrieving revision 1.14
diff -u -r1.14 mapview.c
--- client//gui-stub/mapview.c  2002/11/14 09:45:17     1.14
+++ client//gui-stub/mapview.c  2002/11/16 00:20:15
@@ -88,15 +88,17 @@
        /* PORTME */
 }
 
-void
-update_map_canvas(int tile_x, int tile_y, int width, int height,
-                 bool write_to_screen)
+/**************************************************************************
+  Show descriptions for all cities visible on the map canvas.
+**************************************************************************/
+void show_city_descriptions(void)
 {
        /* PORTME */
 }
 
 void
-update_map_canvas_visible(void)
+update_map_canvas(int tile_x, int tile_y, int width, int height,
+                 bool write_to_screen)
 {
        /* PORTME */
 }
Index: client//gui-win32/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/mapview.c,v
retrieving revision 1.32
diff -u -r1.32 mapview.c
--- client//gui-win32/mapview.c 2002/11/15 09:24:52     1.32
+++ client//gui-win32/mapview.c 2002/11/16 00:20:16
@@ -88,7 +88,6 @@
 
 extern int seconds_to_turndone;   
 void update_map_canvas_scrollbars_size(void);
-static void show_city_descriptions(HDC hdc);     
 void refresh_overview_viewrect_real(HDC hdcp);
 void set_overview_win_dim(int w,int h);
 static void put_one_tile(HDC mapstoredc,int x, int y, enum draw_type draw);
@@ -202,7 +201,7 @@
             mapstoredc,0,0,SRCCOPY);
       SelectObject(mapstoredc,old);
       DeleteDC(mapstoredc);
-      show_city_descriptions(hdc);
+      show_city_descriptions();
     }
 } 
 
@@ -766,7 +765,7 @@
               scr_x,
               scr_y,
               SRCCOPY);
-       show_city_descriptions(whdc);
+       show_city_descriptions(); /* is this necessary? */
        ReleaseDC(map_window,whdc);
       }
   } else {
@@ -861,7 +860,7 @@
             (height + width) * NORMAL_TILE_HEIGHT/2 + NORMAL_TILE_HEIGHT/2,
             mapstoredc,
             canvas_start_x,canvas_start_y,SRCCOPY);
-      show_city_descriptions(hdc);
+      show_city_descriptions(); /* is this necessary? */
       ReleaseDC(map_window,hdc);
     }
 
@@ -874,29 +873,6 @@
 /**************************************************************************
 
 **************************************************************************/
-void
-update_map_canvas_visible(void)
-{
-  if (is_isometric)
-    {
-      int width,height;
-      width=height=map_view_width+map_view_height;
-      update_map_canvas(map_view_x,
-                       map_view_y-map_view_width,
-                       width,height, TRUE); 
-      /*
-       update_map_canvas(0,0,map.xsize,map.ysize,1); */
-    }
-  else
-    {
-      update_map_canvas(map_view_x,map_view_y,
-                       map_view_width,map_view_height, TRUE);
-    }
-}
-
-/**************************************************************************
-
-**************************************************************************/
 void update_map_canvas_scrollbars_size(void)
 {
   ScrollBar_SetRange(map_scroll_h,0,map.xsize,TRUE);
@@ -984,10 +960,15 @@
 /**************************************************************************
 
 **************************************************************************/
-static void show_city_descriptions(HDC hdc)
+void show_city_descriptions(void)
 {
+  HDC hdc;
+
   if (!draw_city_names && !draw_city_productions)
     return;
+
+  /* TODO: hdc should be stored statically */
+  hdc = GetDC(map_window);
   SetBkMode(hdc,TRANSPARENT);
 
   if (is_isometric ) {
@@ -1018,7 +999,8 @@
       }
     }
   }
-  
+
+  ReleaseDC(map_window, hdc);
 }
 
 /**************************************************************************
Index: client//gui-xaw/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/mapview.c,v
retrieving revision 1.102
diff -u -r1.102 mapview.c
--- client//gui-xaw/mapview.c   2002/11/15 09:24:52     1.102
+++ client//gui-xaw/mapview.c   2002/11/16 00:20:16
@@ -55,7 +55,6 @@
 
 static void pixmap_put_overlay_tile(Pixmap pixmap, int x, int y,
                                    struct Sprite *ssprite);
-static void show_city_descriptions(void);
 static void put_line(Pixmap pm, int x, int y, int dir);
 
 /* the intro picture is held in this pixmap, which is scaled to
@@ -701,16 +700,6 @@
 }
 
 /**************************************************************************
- Update (only) the visible part of the map
-**************************************************************************/
-void update_map_canvas_visible(void)
-{
-  update_map_canvas(map_view_x0, map_view_y0,
-                   map_canvas_store_twidth, map_canvas_store_theight, 1);
-  show_city_descriptions();
-}
-
-/**************************************************************************
 ...
 **************************************************************************/
 void update_map_canvas_scrollbars(void)
@@ -754,7 +743,7 @@
 /**************************************************************************
 ...
 **************************************************************************/
-static void show_city_descriptions(void)
+void show_city_descriptions(void)
 {
   int x, y;
 
Index: client//include/mapview_g.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/include/mapview_g.h,v
retrieving revision 1.20
diff -u -r1.20 mapview_g.h
--- client//include/mapview_g.h 2002/11/14 09:45:18     1.20
+++ client//include/mapview_g.h 2002/11/16 00:20:16
@@ -40,9 +40,10 @@
 void center_tile_mapcanvas(int x, int y);
 void get_center_tile_mapcanvas(int *x, int *y);
 
+void show_city_descriptions(void);
+
 void update_map_canvas(int x, int y, int width, int height,
                       bool write_to_screen);
-void update_map_canvas_visible(void);
 void update_map_canvas_scrollbars(void);
 
 void put_cross_overlay_tile(int x,int y);

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#2352) unification of update_map_canvas_visible, Jason Short via RT <=