Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2005:
[Freeciv-Dev] (PR#12374) grid sprites for hexagonal tilesets
Home

[Freeciv-Dev] (PR#12374) grid sprites for hexagonal tilesets

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#12374) grid sprites for hexagonal tilesets
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 27 Feb 2005 03:16:41 -0800
Reply-to: bugs@xxxxxxxxxxx

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

This patch:

1.  Implements corner sprites for hexagonal tilesets.

2.  Uses this to reimplement the isophex grid using sprites.

-jason

? data/isophex/grid.png
? data/isophex/grid.xcf
Index: client/mapview_common.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.h,v
retrieving revision 1.98
diff -u -r1.98 mapview_common.h
--- client/mapview_common.h     25 Feb 2005 17:31:49 -0000      1.98
+++ client/mapview_common.h     27 Feb 2005 11:15:47 -0000
@@ -143,6 +143,17 @@
                                               (GRI_diff + 2) / 4);         \
            pcorner->tile[3] = map_pos_to_tile((GRI_sum - 6) / 4,           \
                                               (GRI_diff + 2) / 4);         \
+           if (hex_width > 0) {                                        \
+             pedge = &GRI_edge;                                        \
+             pedge->type = EDGE_UD;                                    \
+             pedge->tile[0] = pcorner->tile[0];                        \
+             pedge->tile[1] = pcorner->tile[2];                        \
+           } else if (hex_height > 0) {                                \
+             pedge = &GRI_edge;                                        \
+             pedge->type = EDGE_LR;                                    \
+             pedge->tile[0] = pcorner->tile[1];                        \
+             pedge->tile[1] = pcorner->tile[3];                        \
+           }                                                           \
          }                                                                 \
        } else {                                                            \
          /* Edge. */                                                       \
Index: client/tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
retrieving revision 1.244
diff -u -r1.244 tilespec.c
--- client/tilespec.c   27 Feb 2005 08:41:06 -0000      1.244
+++ client/tilespec.c   27 Feb 2005 11:15:47 -0000
@@ -1475,9 +1475,15 @@
     SET_SPRITE(grid.unavailable, "grid.unavailable");
 
     for (i = 0; i < EDGE_COUNT; i++) {
-      char *name[EDGE_COUNT] = {"ns", "we"};
+      char *name[EDGE_COUNT] = {"ns", "we", "ud", "lr"};
       int j, p;
 
+      if (i == EDGE_UD && hex_width == 0) {
+       continue;
+      } else if (i == EDGE_LR && hex_height == 0) {
+       continue;
+      }
+
       my_snprintf(buffer, sizeof(buffer), "grid.main.%s", name[i]);
       SET_SPRITE(grid.main[i], buffer);
 
@@ -2811,12 +2817,12 @@
       ADD_GRID(ptile, citymode);
     }
   } else if (pedge) {
-    bool known[EDGE_COUNT], city[EDGE_COUNT], unit[EDGE_COUNT];
-    bool worked[EDGE_COUNT];
+    bool known[NUM_EDGE_TILES], city[NUM_EDGE_TILES];
+    bool unit[NUM_EDGE_TILES], worked[NUM_EDGE_TILES];
     int i;
     struct unit *pfocus = get_unit_in_focus();
 
-    for (i = 0; i < 2; i++) {
+    for (i = 0; i < NUM_EDGE_TILES; i++) {
       const struct tile *tile = pedge->tile[i];
       struct player *powner = tile ? map_get_owner(tile) : NULL;
       int dummy_x, dummy_y;
Index: client/tilespec.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.h,v
retrieving revision 1.109
diff -u -r1.109 tilespec.h
--- client/tilespec.h   27 Feb 2005 08:41:06 -0000      1.109
+++ client/tilespec.h   27 Feb 2005 11:15:47 -0000
@@ -32,6 +32,8 @@
   enum {
     EDGE_NS, /* North and south */
     EDGE_WE, /* West and east */
+    EDGE_UD, /* Up and down (nw/se), for hex_width tilesets */
+    EDGE_LR, /* Left and right (ne/sw), for hex_height tilesets */
     EDGE_COUNT
   } type;
 #define NUM_EDGE_TILES 2
Index: data/isophex.tilespec
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/isophex.tilespec,v
retrieving revision 1.7
diff -u -r1.7 isophex.tilespec
--- data/isophex.tilespec       25 Feb 2005 20:55:00 -0000      1.7
+++ data/isophex.tilespec       27 Feb 2005 11:15:48 -0000
@@ -57,10 +57,12 @@
 ; low-color systems, and if there are any duplicate tags (lattermost
 ; tag is used).
 files = 
+  "misc/colors.spec",
   "isophex/terrain1.spec",
   "isophex/terrain2.spec",
   "isophex/darkness.spec",
   "isophex/tiles.spec",
+  "isophex/grid.spec",
   "isophex/rivers.spec",
   "misc/small.spec",
   "misc/buildings.spec",
Index: data/isophex/Makefile.am
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/isophex/Makefile.am,v
retrieving revision 1.1
diff -u -r1.1 Makefile.am
--- data/isophex/Makefile.am    20 Oct 2004 03:45:20 -0000      1.1
+++ data/isophex/Makefile.am    27 Feb 2005 11:15:48 -0000
@@ -7,6 +7,8 @@
        darkness.png    \
        darkness.spec   \
        gold.spec       \
+       grid.png        \
+       grid.spec       \
        rivers.png      \
        rivers.spec     \
        terrain1.png    \
Index: data/isophex/grid.spec
===================================================================
RCS file: data/isophex/grid.spec
diff -N data/isophex/grid.spec
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ data/isophex/grid.spec      27 Feb 2005 11:15:48 -0000
@@ -0,0 +1,53 @@
+
+[spec]
+
+; Format and options of this spec file:
+options = "+spec3"
+
+[info]
+
+artists = "
+    Jason Dorje Short <jdorje@xxxxxxxxxxx>
+"
+
+[file]
+gfx = "isophex/grid"
+
+[grid_main]
+
+x_top_left = 1
+y_top_left = 1
+dx = 64
+dy = 32
+pixel_border = 1
+
+tiles = { "row", "column", "tag"
+  0, 0, "grid.main.we"
+  1, 0, "grid.main.ns"
+  2, 0, "grid.main.ud"
+
+  0, 1, "grid.city.we"
+  1, 1, "grid.city.ns"
+  2, 1, "grid.city.ud"
+
+  0, 2, "grid.worked.we"
+  1, 2, "grid.worked.ns"
+  2, 2, "grid.worked.ud"
+
+  0, 3, "grid.unavailable"
+
+  0, 4, "grid.selected.we"
+  1, 4, "grid.selected.ns"
+  2, 4, "grid.selected.ud"
+
+  0, 5, "grid.coastline.we"
+  1, 5, "grid.coastline.ns"
+  2, 5, "grid.coastline.ud"
+
+  3, 0, "grid.borders.n"
+  3, 1, "grid.borders.s"
+  3, 2, "grid.borders.w"
+  3, 3, "grid.borders.e"
+  3, 4, "grid.borders.u"
+  3, 5, "grid.borders.d"
+}

PNG image


[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#12374) grid sprites for hexagonal tilesets, Jason Short <=