Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2004:
[Freeciv-Dev] (PR#11444) make selection markers a sprite
Home

[Freeciv-Dev] (PR#11444) make selection markers a sprite

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#11444) make selection markers a sprite
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 9 Dec 2004 14:55:12 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=11444 >

The city selection labels should be sprites.

This patch does that.  However I didn't add isophex support because 
after I wrote isotrident support I realized it won't work.  The problem 
is that lower tiles will overwrite the selection rectangle.  The 
solution is a layered drawing system (PR#10865).

-jason

? core.6273
? core.6664
Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.164
diff -u -r1.164 mapview_common.c
--- client/mapview_common.c     9 Dec 2004 21:28:53 -0000       1.164
+++ client/mapview_common.c     9 Dec 2004 22:52:47 -0000
@@ -1402,46 +1402,6 @@
 }
 
 /****************************************************************************
-   Draw the selection rectangle the given map tile at the given canvas
-   position.
-****************************************************************************/
-static void tile_draw_selection(struct canvas *pcanvas,
-                               struct tile *ptile,
-                               int canvas_x, int canvas_y, bool citymode)
-{
-  const int inset = (is_isometric ? 0 : 1);
-  enum direction8 dir;
-
-  if (citymode) {
-    return;
-  }
-
-  for (dir = 0; dir < 8; dir++) {
-    int start_x, start_y, end_x, end_y;
-    struct tile *adjc_tile;
-
-    /* In non-iso view we draw the rectangle with an inset of 1.  This makes
-     * it easy to distinguish from the map grid.
-     *
-     * In iso-view the inset doesn't work perfectly (see comments about
-     * this elsewhere) so we draw without an inset.  This may cover up the
-     * map grid if it is drawn. */
-    if (get_tile_boundaries(dir, inset, 1,
-                           &start_x, &start_y, &end_x, &end_y)) {
-      if (map_deco[ptile->index].hilite == HILITE_CITY
-         || (is_isometric
-             && (adjc_tile = mapstep(ptile, dir))
-             && map_deco[adjc_tile->index].hilite == HILITE_CITY)) {
-       canvas_put_line(pcanvas, COLOR_STD_YELLOW, LINE_NORMAL,
-                       canvas_x + start_x, canvas_y + start_y,
-                       end_x - start_x, end_y - start_y);
-      }
-    }
-  }
-}
-
-
-/****************************************************************************
    Draw the grid lines of the given map tile at the given canvas position
    in isometric view.  (This include the map grid, borders, and coastline).
 ****************************************************************************/
@@ -1451,7 +1411,6 @@
   tile_draw_map_grid(pcanvas, ptile, canvas_x, canvas_y);
   tile_draw_borders(pcanvas, ptile, canvas_x, canvas_y);
   tile_draw_coastline(pcanvas, ptile, canvas_x, canvas_y);
-  tile_draw_selection(pcanvas, ptile, canvas_x, canvas_y, citymode);
 }
 
 /**************************************************************************
Index: client/tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
retrieving revision 1.218
diff -u -r1.218 tilespec.c
--- client/tilespec.c   9 Dec 2004 02:21:46 -0000       1.218
+++ client/tilespec.c   9 Dec 2004 22:52:48 -0000
@@ -1390,6 +1390,7 @@
     sprites.unit.vet_lev[i] = load_sprite(buffer);
   }
 
+  SET_SPRITE(city.selected, "city.selected");
   SET_SPRITE(city.disorder, "city.disorder");
 
   for(i=0; i<NUM_TILES_DIGITS; i++) {
@@ -2722,6 +2723,11 @@
     ADD_GRID(ptile, citymode);
   }
 
+  if (ptile && !citymode && sprites.city.selected
+      && map_deco[ptile->index].hilite == HILITE_CITY) {
+    ADD_SPRITE_SIMPLE(sprites.city.selected);
+  }
+
   /* City.  Some city sprites are drawn later. */
   if (pcity && draw_cities) {
     if (!solid_color_behind_units) {
Index: client/tilespec.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.h,v
retrieving revision 1.92
diff -u -r1.92 tilespec.h
--- client/tilespec.h   3 Dec 2004 09:39:39 -0000       1.92
+++ client/tilespec.h   9 Dec 2004 22:52:48 -0000
@@ -228,6 +228,7 @@
   } upkeep;
   struct {
     struct Sprite
+      *selected,
       *occupied,
       *disorder,
       *size[NUM_TILES_DIGITS],
Index: data/isotrident/tiles.png
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/isotrident/tiles.png,v
retrieving revision 1.3
diff -u -r1.3 tiles.png
Binary files /tmp/cvs6dQshU and tiles.png differ
Index: data/isotrident/tiles.spec
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/isotrident/tiles.spec,v
retrieving revision 1.4
diff -u -r1.4 tiles.spec
--- data/isotrident/tiles.spec  20 Nov 2004 17:45:52 -0000      1.4
+++ data/isotrident/tiles.spec  9 Dec 2004 22:52:48 -0000
@@ -80,6 +80,7 @@
   5, 16, "city.size_70"
   5, 17, "city.size_80"
   5, 18, "city.size_90"
+  0, 6,  "city.selected"
 
 ; Numbers: city tile food/shields/trade y/g/b
 
Index: data/trident/tiles.png
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/trident/tiles.png,v
retrieving revision 1.7
diff -u -r1.7 tiles.png
Binary files /tmp/cvs8tvXXb and tiles.png differ
Index: data/trident/tiles.spec
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/trident/tiles.spec,v
retrieving revision 1.23
diff -u -r1.23 tiles.spec
--- data/trident/tiles.spec     20 Nov 2004 17:45:52 -0000      1.23
+++ data/trident/tiles.spec     9 Dec 2004 22:52:50 -0000
@@ -424,6 +424,7 @@
  14, 16, "city.size_70"
  14, 17, "city.size_80"
  14, 18, "city.size_90"
+ 18, 17, "city.selected"
 
 ; Numbers: city tile food/shields/trade y/g/b
 

Attachment: selection.tgz
Description: GNU Unix tar archive


[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#11444) make selection markers a sprite, Jason Short <=