Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2004:
[Freeciv-Dev] (PR#3572) unification of put_one_tile_iso
Home

[Freeciv-Dev] (PR#3572) unification of put_one_tile_iso

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#3572) unification of put_one_tile_iso
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 24 Jul 2004 01:49:08 -0700
Reply-to: rt@xxxxxxxxxxx

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

Here is a new version of put_one_tile_iso.  It is now in a new and much
improved (and shorter) version.

I think it is ready.  The old concerns (speed) with gui-sdl are still
there, but should be allayed because the drawing code is overall much
faster now.

jason

Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.136
diff -u -r1.136 mapview_common.c
--- client/mapview_common.c     23 Jul 2004 21:08:53 -0000      1.136
+++ client/mapview_common.c     24 Jul 2004 08:47:57 -0000
@@ -1171,10 +1171,10 @@
 /**************************************************************************
   Draw an array of drawn sprites onto the canvas.
 **************************************************************************/
-void put_drawn_sprites(struct canvas *pcanvas,
-                      int canvas_x, int canvas_y,
-                      int count, struct drawn_sprite *pdrawn, bool fog,
-                      int map_x, int map_y, bool citymode)
+static void put_drawn_sprites(struct canvas *pcanvas,
+                             int canvas_x, int canvas_y,
+                             int count, struct drawn_sprite *pdrawn,
+                             bool fog, int map_x, int map_y, bool citymode)
 {
   int i;
 
@@ -1376,6 +1376,48 @@
 }
 
 /**************************************************************************
+  Draw some or all of a tile onto the canvas, in iso-view.
+**************************************************************************/
+void put_one_tile_iso(struct canvas *pcanvas, int map_x, int map_y,
+                     int canvas_x, int canvas_y, bool citymode)
+{
+  struct drawn_sprite tile_sprs[80];
+  int count;
+  bool solid_bg, fog;
+  enum color_std bg_color;
+
+  count = fill_tile_sprite_array(tile_sprs, &solid_bg, &bg_color,
+                                map_x, map_y, citymode);
+
+  if (count == -1) { /* tile is unknown */
+    canvas_fill_sprite_area(pcanvas, sprites.black_tile, COLOR_STD_BLACK,
+                           canvas_x, canvas_y);
+    return;
+  }
+
+  /* Replace with check for is_normal_tile later */
+  if (!normalize_map_pos(&map_x, &map_y)) {
+    assert(0);
+    return;
+  }
+
+  fog = tile_get_known(map_x, map_y) == TILE_KNOWN_FOGGED && draw_fog_of_war;
+
+  if (solid_bg) {
+    canvas_fill_sprite_area(pcanvas, sprites.black_tile, COLOR_STD_BLACK,
+                           canvas_x, canvas_y);
+    if (fog) {
+      canvas_fog_sprite_area(pcanvas, sprites.black_tile,
+                            canvas_x, canvas_y);
+    }
+  }
+
+  /*** Draw terrain and specials ***/
+  put_drawn_sprites(pcanvas, canvas_x, canvas_y,
+                   count, tile_sprs, fog, map_x, map_y, citymode);
+}
+
+/**************************************************************************
   Draw the unique tile for the given map position, in isometric view.
   The coordinates have not been normalized, and are not guaranteed to be
   real (we have to draw unreal tiles too).
Index: client/mapview_common.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.h,v
retrieving revision 1.71
diff -u -r1.71 mapview_common.h
--- client/mapview_common.h     23 Jul 2004 21:08:53 -0000      1.71
+++ client/mapview_common.h     24 Jul 2004 08:47:57 -0000
@@ -160,12 +160,10 @@
 
 void put_nuke_mushroom_pixmaps(int map_x, int map_y);
 
-void put_drawn_sprites(struct canvas *pcanvas,
-                      int canvas_x, int canvas_y,
-                      int count, struct drawn_sprite *pdrawn, bool fog,
-                      int map_x, int map_y, bool citymode);
 void put_one_tile(struct canvas *pcanvas, int map_x, int map_y,
                  int canvas_x, int canvas_y, bool citymode);
+void put_one_tile_iso(struct canvas *pcanvas, int map_x, int map_y,
+                     int canvas_x, int canvas_y, bool citymode);
 void tile_draw_grid(struct canvas *pcanvas, int map_x, int map_y,
                    int canvas_x, int canvas_y, bool citymode);
 
Index: client/gui-gtk/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/mapview.c,v
retrieving revision 1.228
diff -u -r1.228 mapview.c
--- client/gui-gtk/mapview.c    23 Jul 2004 21:08:53 -0000      1.228
+++ client/gui-gtk/mapview.c    24 Jul 2004 08:47:57 -0000
@@ -61,13 +61,6 @@
                                         int canvas_x, int canvas_y,
                                         struct Sprite *ssprite,
                                         bool fog);
-static void pixmap_put_tile_iso(GdkDrawable *pm, int x, int y,
-                               int canvas_x, int canvas_y,
-                               int citymode);
-static void pixmap_put_black_tile_iso(GdkDrawable *pm,
-                                     int canvas_x, int canvas_y,
-                                     int offset_x, int offset_y,
-                                     int width, int height);
 
 /* the intro picture is held in this pixmap, which is scaled to
    the screen size */
@@ -388,18 +381,6 @@
 }
 
 /**************************************************************************
-  Draw some or all of a tile onto the canvas.
-**************************************************************************/
-void put_one_tile_iso(struct canvas *pcanvas,
-                     int map_x, int map_y,
-                     int canvas_x, int canvas_y, bool citymode)
-{
-  pixmap_put_tile_iso(pcanvas->pixmap,
-                     map_x, map_y, canvas_x, canvas_y,
-                     citymode);
-}
-
-/**************************************************************************
   Flush the given part of the canvas buffer (if there is one) to the
   screen.
 **************************************************************************/
@@ -708,6 +689,40 @@
   }
 }
 
+/****************************************************************************
+  Fill the area covered by the sprite with the given color.
+****************************************************************************/
+void canvas_fill_sprite_area(struct canvas *pcanvas,
+                            struct Sprite *psprite, enum color_std color,
+                            int canvas_x, int canvas_y)
+{
+  gdk_gc_set_clip_origin(fill_bg_gc, canvas_x, canvas_y);
+  gdk_gc_set_clip_mask(fill_bg_gc, psprite->mask);
+  gdk_gc_set_foreground(fill_bg_gc, colors_standard[color]);
+
+  gdk_draw_rectangle(pcanvas->pixmap, fill_bg_gc, TRUE,
+                    canvas_x, canvas_y, psprite->width, psprite->height);
+
+  gdk_gc_set_clip_mask(fill_bg_gc, NULL);
+}
+
+/****************************************************************************
+  Fill the area covered by the sprite with the given color.
+****************************************************************************/
+void canvas_fog_sprite_area(struct canvas *pcanvas, struct Sprite *psprite,
+                           int canvas_x, int canvas_y)
+{
+  gdk_gc_set_clip_origin(fill_tile_gc, canvas_x, canvas_y);
+  gdk_gc_set_clip_mask(fill_tile_gc, psprite->mask);
+  gdk_gc_set_foreground(fill_tile_gc, colors_standard[COLOR_STD_BLACK]);
+  gdk_gc_set_stipple(fill_tile_gc, black50);
+
+  gdk_draw_rectangle(pcanvas->pixmap, fill_tile_gc, TRUE,
+                    canvas_x, canvas_y, psprite->width, psprite->height);
+
+  gdk_gc_set_clip_mask(fill_tile_gc, NULL); 
+}
+
 /**************************************************************************
   Draw a colored line onto the mapview or citydialog canvas.
 **************************************************************************/
@@ -896,83 +911,6 @@
 }
 
 /**************************************************************************
-Only used for isometric view.
-**************************************************************************/
-static void pixmap_put_black_tile_iso(GdkDrawable *pm,
-                                     int canvas_x, int canvas_y,
-                                     int offset_x, int offset_y,
-                                     int width, int height)
-{
-  gdk_gc_set_clip_origin(civ_gc, canvas_x, canvas_y);
-  gdk_gc_set_clip_mask(civ_gc, sprites.black_tile->mask);
-
-  assert(width <= NORMAL_TILE_WIDTH);
-  assert(height <= NORMAL_TILE_HEIGHT);
-  gdk_draw_pixmap(pm, civ_gc, sprites.black_tile->pixmap,
-                 offset_x, offset_y,
-                 canvas_x+offset_x, canvas_y+offset_y,
-                 width, height);
-
-  gdk_gc_set_clip_mask(civ_gc, NULL);
-}
-
-/**************************************************************************
-Only used for isometric view.
-**************************************************************************/
-static void pixmap_put_tile_iso(GdkDrawable *pm, int x, int y,
-                               int canvas_x, int canvas_y,
-                               int citymode)
-{
-  struct drawn_sprite tile_sprs[80];
-  int count;
-  bool solid_bg, fog;
-  enum color_std bg_color;
-  struct canvas canvas_store = {pm};
-
-  count = fill_tile_sprite_array(tile_sprs, &solid_bg, &bg_color,
-                                x, y, citymode);
-
-  if (count == -1) { /* tile is unknown */
-    pixmap_put_black_tile_iso(pm, canvas_x, canvas_y,
-                             0, 0, NORMAL_TILE_WIDTH, NORMAL_TILE_HEIGHT);
-    return;
-  }
-
-  /* Replace with check for is_normal_tile later */
-  assert(is_real_map_pos(x, y));
-  normalize_map_pos(&x, &y);
-
-  fog = tile_get_known(x, y) == TILE_KNOWN_FOGGED && draw_fog_of_war;
-
-  if (solid_bg) {
-    gdk_gc_set_clip_origin(fill_bg_gc, canvas_x, canvas_y);
-    gdk_gc_set_clip_mask(fill_bg_gc, sprites.black_tile->mask);
-    gdk_gc_set_foreground(fill_bg_gc, colors_standard[bg_color]);
-
-    gdk_draw_rectangle(pm, fill_bg_gc, TRUE,
-                      canvas_x, canvas_y,
-                      sprites.black_tile->width,
-                      sprites.black_tile->height);
-    gdk_gc_set_clip_mask(fill_bg_gc, NULL);
-    if (fog) {
-      gdk_gc_set_clip_origin(fill_tile_gc, canvas_x, canvas_y);
-      gdk_gc_set_clip_mask(fill_tile_gc, sprites.black_tile->mask);
-      gdk_gc_set_foreground(fill_tile_gc, colors_standard[COLOR_STD_BLACK]);
-      gdk_gc_set_stipple(fill_tile_gc, black50);
-
-      gdk_draw_rectangle(pm, fill_tile_gc, TRUE,
-                        canvas_x, canvas_y,
-                        sprites.black_tile->width,
-                        sprites.black_tile->height);
-      gdk_gc_set_clip_mask(fill_tile_gc, NULL);
-    }
-  }
-
-  put_drawn_sprites(&canvas_store, canvas_x, canvas_y,
-                   count, tile_sprs, fog, x, y, citymode);
-}
-
-/**************************************************************************
   This function is called when the tileset is changed.
 **************************************************************************/
 void tileset_changed(void)
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.134
diff -u -r1.134 mapview.c
--- client/gui-gtk-2.0/mapview.c        23 Jul 2004 21:08:54 -0000      1.134
+++ client/gui-gtk-2.0/mapview.c        24 Jul 2004 08:47:57 -0000
@@ -62,13 +62,6 @@
                                         int canvas_x, int canvas_y,
                                         struct Sprite *ssprite,
                                         bool fog);
-static void pixmap_put_tile_iso(GdkDrawable *pm, int x, int y,
-                               int canvas_x, int canvas_y,
-                               int citymode);
-static void pixmap_put_black_tile_iso(GdkDrawable *pm,
-                                     int canvas_x, int canvas_y,
-                                     int offset_x, int offset_y,
-                                     int width, int height);
 
 /* the intro picture is held in this pixmap, which is scaled to
    the screen size */
@@ -404,19 +397,6 @@
 }
 
 /**************************************************************************
-  Draw some or all of a tile onto the canvas.
-**************************************************************************/
-void put_one_tile_iso(struct canvas *pcanvas,
-                     int map_x, int map_y,
-                     int canvas_x, int canvas_y,
-                     bool citymode)
-{
-  pixmap_put_tile_iso(pcanvas->v.pixmap,
-                     map_x, map_y, canvas_x, canvas_y,
-                     citymode);
-}
-
-/**************************************************************************
   Flush the given part of the canvas buffer (if there is one) to the
   screen.
 **************************************************************************/
@@ -761,6 +741,40 @@
   }
 }
 
+/****************************************************************************
+  Fill the area covered by the sprite with the given color.
+****************************************************************************/
+void canvas_fill_sprite_area(struct canvas *pcanvas,
+                            struct Sprite *psprite, enum color_std color,
+                            int canvas_x, int canvas_y)
+{
+  gdk_gc_set_clip_origin(fill_bg_gc, canvas_x, canvas_y);
+  gdk_gc_set_clip_mask(fill_bg_gc, psprite->mask);
+  gdk_gc_set_foreground(fill_bg_gc, colors_standard[color]);
+
+  gdk_draw_rectangle(pcanvas->v.pixmap, fill_bg_gc, TRUE,
+                    canvas_x, canvas_y, psprite->width, psprite->height);
+
+  gdk_gc_set_clip_mask(fill_bg_gc, NULL);
+}
+
+/****************************************************************************
+  Fill the area covered by the sprite with the given color.
+****************************************************************************/
+void canvas_fog_sprite_area(struct canvas *pcanvas, struct Sprite *psprite,
+                           int canvas_x, int canvas_y)
+{
+  gdk_gc_set_clip_origin(fill_tile_gc, canvas_x, canvas_y);
+  gdk_gc_set_clip_mask(fill_tile_gc, psprite->mask);
+  gdk_gc_set_foreground(fill_tile_gc, colors_standard[COLOR_STD_BLACK]);
+  gdk_gc_set_stipple(fill_tile_gc, black50);
+
+  gdk_draw_rectangle(pcanvas->v.pixmap, fill_tile_gc, TRUE,
+                    canvas_x, canvas_y, psprite->width, psprite->height);
+
+  gdk_gc_set_clip_mask(fill_tile_gc, NULL); 
+}
+
 /**************************************************************************
   Draw a colored line onto the mapview or citydialog canvas.
 **************************************************************************/
@@ -960,84 +974,6 @@
 }
 
 /**************************************************************************
-Only used for isometric view.
-**************************************************************************/
-static void pixmap_put_black_tile_iso(GdkDrawable *pm,
-                                     int canvas_x, int canvas_y,
-                                     int offset_x, int offset_y,
-                                     int width, int height)
-{
-  gdk_gc_set_clip_origin(civ_gc, canvas_x, canvas_y);
-  gdk_gc_set_clip_mask(civ_gc, sprites.black_tile->mask);
-
-  assert(width <= NORMAL_TILE_WIDTH);
-  assert(height <= NORMAL_TILE_HEIGHT);
-  gdk_draw_drawable(pm, civ_gc, sprites.black_tile->pixmap,
-                   offset_x, offset_y,
-                   canvas_x+offset_x, canvas_y+offset_y,
-                   width, height);
-
-  gdk_gc_set_clip_mask(civ_gc, NULL);
-}
-
-/**************************************************************************
-Only used for isometric view.
-**************************************************************************/
-static void pixmap_put_tile_iso(GdkDrawable *pm, int x, int y,
-                               int canvas_x, int canvas_y,
-                               int citymode)
-{
-  struct drawn_sprite tile_sprs[80];
-  int count;
-  bool solid_bg, fog;
-  enum color_std bg_color;
-  struct canvas canvas_store = {.type = CANVAS_PIXMAP, .v.pixmap = pm};
-
-  count = fill_tile_sprite_array(tile_sprs, &solid_bg, &bg_color,
-                                x, y, citymode);
-
-  if (count == -1) { /* tile is unknown */
-    pixmap_put_black_tile_iso(pm, canvas_x, canvas_y,
-                             0, 0, NORMAL_TILE_WIDTH, NORMAL_TILE_HEIGHT);
-    return;
-  }
-
-  /* Replace with check for is_normal_tile later */
-  assert(is_real_map_pos(x, y));
-  normalize_map_pos(&x, &y);
-
-  fog = tile_get_known(x, y) == TILE_KNOWN_FOGGED && draw_fog_of_war;
-
-  if (solid_bg) {
-    gdk_gc_set_clip_origin(fill_bg_gc, canvas_x, canvas_y);
-    gdk_gc_set_clip_mask(fill_bg_gc, sprites.black_tile->mask);
-    gdk_gc_set_foreground(fill_bg_gc, colors_standard[bg_color]);
-
-    gdk_draw_rectangle(pm, fill_bg_gc, TRUE,
-                      canvas_x, canvas_y,
-                      sprites.black_tile->width,
-                      sprites.black_tile->height);
-    gdk_gc_set_clip_mask(fill_bg_gc, NULL);
-    if (fog) {
-      gdk_gc_set_clip_origin(fill_tile_gc, canvas_x, canvas_y);
-      gdk_gc_set_clip_mask(fill_tile_gc, sprites.black_tile->mask);
-      gdk_gc_set_foreground(fill_tile_gc, colors_standard[COLOR_STD_BLACK]);
-      gdk_gc_set_stipple(fill_tile_gc, black50);
-
-      gdk_draw_rectangle(pm, fill_tile_gc, TRUE,
-                        canvas_x, canvas_y,
-                        sprites.black_tile->width,
-                        sprites.black_tile->height);
-      gdk_gc_set_clip_mask(fill_tile_gc, NULL);
-    }
-  }
-
-  /*** Draw terrain and specials ***/
-  put_drawn_sprites(&canvas_store, canvas_x, canvas_y,
-                   count, tile_sprs, fog, x, y, citymode);
-}
-
-/**************************************************************************
   This function is called when the tileset is changed.
 **************************************************************************/
 void tileset_changed(void)
Index: client/gui-stub/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-stub/mapview.c,v
retrieving revision 1.46
diff -u -r1.46 mapview.c
--- client/gui-stub/mapview.c   23 Jul 2004 21:08:54 -0000      1.46
+++ client/gui-stub/mapview.c   24 Jul 2004 08:47:57 -0000
@@ -200,6 +200,25 @@
 }
 
 /****************************************************************************
+  Fill the area covered by the sprite with the given color.
+****************************************************************************/
+void canvas_fill_sprite_area(struct canvas *pcanvas,
+                            struct Sprite *psprite, enum color_std color,
+                            int canvas_x, int canvas_y)
+{
+  /* PORTME */
+}
+
+/****************************************************************************
+  Fill the area covered by the sprite with the given color.
+****************************************************************************/
+void canvas_fog_sprite_area(struct canvas *pcanvas, struct Sprite *psprite,
+                           int canvas_x, int canvas_y)
+{
+  /* PORTME */
+}
+
+/****************************************************************************
   Draw a 1-pixel-width colored line onto the mapview or citydialog canvas.
 ****************************************************************************/
 void canvas_put_line(struct canvas *pcanvas, enum color_std color,
@@ -220,17 +239,6 @@
 }
 
 /****************************************************************************
-  Draw some or all of a tile onto the canvas.
-****************************************************************************/
-void put_one_tile_iso(struct canvas *pcanvas,
-                     int map_x, int map_y,
-                     int canvas_x, int canvas_y,
-                     bool citymode)
-{
-  /* PORTME */
-}
-
-/****************************************************************************
   Return a canvas that is the overview window.
 ****************************************************************************/
 struct canvas *get_overview_window(void)
Index: client/gui-win32/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/mapview.c,v
retrieving revision 1.129
diff -u -r1.129 mapview.c
--- client/gui-win32/mapview.c  23 Jul 2004 21:08:54 -0000      1.129
+++ client/gui-win32/mapview.c  24 Jul 2004 08:47:58 -0000
@@ -62,9 +62,6 @@
 extern int seconds_to_turndone;   
 void update_map_canvas_scrollbars_size(void);
 void refresh_overview_viewrect_real(HDC hdcp);
-static void pixmap_put_tile_iso(HDC hdc, int x, int y,
-                                int canvas_x, int canvas_y,
-                                int citymode);
 static void draw_rates(HDC hdc);
 
 
@@ -748,32 +745,6 @@
 }
 
 /**************************************************************************
-  Draw some or all of a tile onto the canvas.
-**************************************************************************/
-void put_one_tile_iso(struct canvas *pcanvas,
-                     int map_x, int map_y,
-                     int canvas_x, int canvas_y,
-                     bool citymode)
-{
-  HDC hdc;
-  HBITMAP old = NULL; /*Remove warning*/
-
-  /* FIXME: we don't want to have to recreate the hdc each time! */
-  if (pcanvas->bitmap) {
-    hdc = CreateCompatibleDC(pcanvas->hdc);
-    old = SelectObject(hdc, pcanvas->bitmap);
-  } else {
-    hdc = pcanvas->hdc;
-  }
-  pixmap_put_tile_iso(hdc, map_x, map_y,
-                     canvas_x, canvas_y, 0);
-  if (pcanvas->bitmap) {
-    SelectObject(hdc, old);
-    DeleteDC(hdc);
-  }
-}
-
-/**************************************************************************
   Draw some or all of a sprite onto the mapview or citydialog canvas.
 **************************************************************************/
 void canvas_put_sprite(struct canvas *pcanvas,
@@ -853,6 +824,58 @@
     DeleteDC(hdc);
   }
 }
+/****************************************************************************
+  Fill the area covered by the sprite with the given color.
+****************************************************************************/
+void canvas_fill_sprite_area(struct canvas *pcanvas,
+                            struct Sprite *psprite, enum color_std color,
+                            int canvas_x, int canvas_y)
+{
+  /* FIXME: this may be inefficient */
+  HDC hdc;
+  HBITMAP old = NULL; /*Remove warning*/
+  HPEN oldpen;
+  HBRUSH oldbrush;
+  POINT points[4];
+
+  if (pcanvas->bitmap) {
+    hdc = CreateCompatibleDC(pcanvas->hdc);
+    old = SelectObject(hdc, pcanvas->bitmap);
+  } else {
+    hdc = pcanvas->hdc;
+  }
+
+  /* FIXME: give a real implementation of this function. */
+  assert(psprite == sprites.black_tile);
+
+  points[0].x = canvas_x + NORMAL_TILE_WIDTH / 2;
+  points[0].y = canvas_y;
+  points[1].x = canvas_x;
+  points[1].y = canvas_y + NORMAL_TILE_HEIGHT / 2;
+  points[2].x = canvas_x + NORMAL_TILE_WIDTH / 2;
+  points[2].y = canvas_y + NORMAL_TILE_HEIGHT;
+  points[3].x = canvas_x + NORMAL_TILE_WIDTH;
+  points[3].y = canvas_y + NORMAL_TILE_HEIGHT / 2;
+  oldpen = SelectObject(hdc, pen_std[color]); 
+  oldbrush = SelectObject(hdc, brush_std[color]);
+  Polygon(hdc, points, 4);
+  SelectObject(hdc, oldpen);
+  SelectObject(hdc, oldbrush);
+
+  if (pcanvas->bitmap) {
+    SelectObject(hdc, old);
+    DeleteDC(hdc);
+  }
+}
+
+/****************************************************************************
+  Fill the area covered by the sprite with the given color.
+****************************************************************************/
+void canvas_fog_sprite_area(struct canvas *pcanvas, struct Sprite *psprite,
+                           int canvas_x, int canvas_y)
+{
+  /* PORTME */
+}
 
 /**************************************************************************
   Draw a 1-pixel-width colored line onto the mapview or citydialog canvas.
@@ -892,55 +915,6 @@
 }
 
 /**************************************************************************
-Only used for isometric view.
-**************************************************************************/
-static void pixmap_put_tile_iso(HDC hdc, int x, int y,
-                                int canvas_x, int canvas_y,
-                                int citymode)
-{
-  struct drawn_sprite tile_sprs[80];
-  struct canvas canvas_store={hdc,NULL};
-  int count;
-  bool fog, solid_bg, is_real;
-  enum color_std bg_color;
-
-  count = fill_tile_sprite_array(tile_sprs, &solid_bg, &bg_color,
-                                x, y, citymode);
-
-  if (count == -1) { /* tile is unknown */
-    pixmap_put_black_tile_iso(hdc, canvas_x, canvas_y,
-                             0, 0, NORMAL_TILE_WIDTH, NORMAL_TILE_HEIGHT);
-    return;
-  }
-  is_real = normalize_map_pos(&x, &y);
-  assert(is_real);
-  fog = tile_get_known(x, y) == TILE_KNOWN_FOGGED && draw_fog_of_war;
-
-  if (solid_bg) {
-    HPEN oldpen;
-    HBRUSH oldbrush;
-    POINT points[4];
-    points[0].x = canvas_x + NORMAL_TILE_WIDTH / 2;
-    points[0].y = canvas_y;
-    points[1].x = canvas_x;
-    points[1].y = canvas_y + NORMAL_TILE_HEIGHT / 2;
-    points[2].x = canvas_x + NORMAL_TILE_WIDTH / 2;
-    points[2].y = canvas_y + NORMAL_TILE_HEIGHT;
-    points[3].x = canvas_x + NORMAL_TILE_WIDTH;
-    points[3].y = canvas_y + NORMAL_TILE_HEIGHT / 2;
-    oldpen = SelectObject(hdc, pen_std[bg_color]); 
-    oldbrush = SelectObject(hdc, brush_std[bg_color]);
-    Polygon(hdc, points, 4);
-    SelectObject(hdc, oldpen);
-    SelectObject(hdc, oldbrush);
-  }
-
-  /*** Draw terrain and specials ***/
-  put_drawn_sprites(&canvas_store, canvas_x, canvas_y,
-                   count, tile_sprs, fog, x, y, citymode);
-}
-
-/**************************************************************************
  Area Selection
 **************************************************************************/
 void draw_selection_rectangle(int canvas_x, int canvas_y, int w, int h)
Index: client/gui-xaw/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/mapview.c,v
retrieving revision 1.178
diff -u -r1.178 mapview.c
--- client/gui-xaw/mapview.c    23 Jul 2004 21:08:54 -0000      1.178
+++ client/gui-xaw/mapview.c    24 Jul 2004 08:47:58 -0000
@@ -377,18 +377,6 @@
 }
 
 /**************************************************************************
-  Draw some or all of a tile onto the canvas.
-**************************************************************************/
-void put_one_tile_iso(struct canvas *pcanvas,
-                     int map_x, int map_y,
-                     int canvas_x, int canvas_y,
-                     bool citymode)
-{
-  /* PORTME */
-  assert(0);
-}
-
-/**************************************************************************
   Draw a single masked sprite to the pixmap.
 **************************************************************************/
 static void pixmap_put_sprite(Pixmap pixmap,
@@ -460,6 +448,48 @@
                 canvas_x, canvas_y, width, height);
 }
 
+/****************************************************************************
+  Fill the area covered by the sprite with the given color.
+****************************************************************************/
+void canvas_fill_sprite_area(struct canvas *pcanvas,
+                            struct Sprite *psprite, enum color_std color,
+                            int canvas_x, int canvas_y)
+{
+  if (psprite->mask) {
+    XSetClipOrigin(display, fill_tile_gc, canvas_x, canvas_y);
+    XSetClipMask(display, fill_tile_gc, psprite->mask);
+  }
+  XSetForeground(display, fill_tile_gc, colors_standard[color]);
+
+  XFillRectangle(display, pcanvas->pixmap, fill_tile_gc,
+                canvas_x, canvas_y, psprite->width, psprite->height);
+
+  if (psprite->mask) {
+    XSetClipMask(display, fill_tile_gc, None);
+  }
+}
+
+/****************************************************************************
+  Fill the area covered by the sprite with the given color.
+****************************************************************************/
+void canvas_fog_sprite_area(struct canvas *pcanvas, struct Sprite *psprite,
+                           int canvas_x, int canvas_y)
+{
+  if (psprite->mask) {
+    XSetClipOrigin(display, fill_tile_gc, canvas_x, canvas_y);
+    XSetClipMask(display, fill_tile_gc, psprite->mask);
+  }
+  XSetStipple(display, fill_tile_gc, gray50);
+  XSetForeground(display, fill_tile_gc, colors_standard[COLOR_STD_BLACK]);
+
+  XFillRectangle(display, pcanvas->pixmap, fill_tile_gc,
+                canvas_x, canvas_y, psprite->width, psprite->height);
+
+  if (psprite->mask) {
+    XSetClipMask(display, fill_tile_gc, None);
+  }
+}
+
 /**************************************************************************
   Draw a 1-pixel-width colored line onto the mapview or citydialog canvas.
 **************************************************************************/
Index: client/include/mapview_g.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/include/mapview_g.h,v
retrieving revision 1.55
diff -u -r1.55 mapview_g.h
--- client/include/mapview_g.h  23 Jul 2004 21:08:54 -0000      1.55
+++ client/include/mapview_g.h  24 Jul 2004 08:47:58 -0000
@@ -37,9 +37,6 @@
                    struct city *pcity, int *width, int *height);
 void prepare_show_city_descriptions(void);
 
-void put_one_tile_iso(struct canvas *pcanvas,
-                     int map_x, int map_y,
-                     int canvas_x, int canvas_y, bool citymode);
 void canvas_put_sprite(struct canvas *pcanvas,
                       int canvas_x, int canvas_y, struct Sprite *sprite,
                       int offset_x, int offset_y, int width, int height);
@@ -53,6 +50,11 @@
 void canvas_put_rectangle(struct canvas *pcanvas,
                          enum color_std color,
                          int canvas_x, int canvas_y, int width, int height);
+void canvas_fill_sprite_area(struct canvas *pcanvas,
+                            struct Sprite *psprite, enum color_std color,
+                            int canvas_x, int canvas_y);
+void canvas_fog_sprite_area(struct canvas *pcanvas, struct Sprite *psprite,
+                           int canvas_x, int canvas_y);
 void canvas_put_line(struct canvas *pcanvas, enum color_std color,
                     enum line_type ltype, int start_x, int start_y,
                     int dx, int dy);

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#3572) unification of put_one_tile_iso, Jason Short <=