Complete.Org: Mailing Lists: Archives: freeciv-dev: May 2005:
[Freeciv-Dev] (PR#13152) put enumerated colors into the tileset
Home

[Freeciv-Dev] (PR#13152) put enumerated colors into the tileset

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#13152) put enumerated colors into the tileset
From: "Jason Dorje Short" <jdorje@xxxxxxxxx>
Date: Sat, 21 May 2005 00:31:15 -0700
Reply-to: bugs@xxxxxxxxxxx

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

This patch puts the enumerated colors into the tileset.  This allows the
artists to easily change the colors.  This will be particularly useful
for the player colors.

Note there is already a colors.spec and colors.png containing some of
the colors.  These should be kept in sync with the RGB listing of the
colors (the sprite forms are needed for crop_sprite, since there's no
way to *write* a color - or anything else - into a sprite).

-jason

Index: client/citydlg_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/citydlg_common.c,v
retrieving revision 1.79
diff -u -r1.79 citydlg_common.c
--- client/citydlg_common.c     14 May 2005 22:49:02 -0000      1.79
+++ client/citydlg_common.c     21 May 2005 07:30:22 -0000
@@ -173,7 +173,8 @@
                            struct canvas *pcanvas)
 {
   /* First make it all black. */
-  canvas_put_rectangle(pcanvas, get_color(COLOR_MAPVIEW_UNKNOWN), 0, 0,
+  canvas_put_rectangle(pcanvas, get_color(tileset, COLOR_MAPVIEW_UNKNOWN),
+                      0, 0,
                       get_citydlg_canvas_width(),
                       get_citydlg_canvas_height());
 
Index: client/colors_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/colors_common.c,v
retrieving revision 1.4
diff -u -r1.4 colors_common.c
--- client/colors_common.c      18 May 2005 14:12:35 -0000      1.4
+++ client/colors_common.c      21 May 2005 07:30:22 -0000
@@ -17,6 +17,7 @@
 
 #include <assert.h>
 
+#include "log.h"
 #include "shared.h"
 
 #include "player.h"
@@ -24,123 +25,147 @@
 #include "colors_g.h"
 
 #include "colors_common.h"
+#include "tilespec.h"
 
-struct rgbtriple {
+struct rgbcolor {
   int r, g, b;
+  struct color *color;
 };
 
-struct rgbtriple colors_standard_rgb[] = {
+struct color_system {
+  struct rgbcolor colors[COLOR_LAST];
 
+  int num_player_colors;
+  struct rgbcolor *player_colors;
+};
+
+char *color_names[] = {
   /* Mapview */
-  {  0,   0,   0},  /* unknown */
-  {255, 255, 255},  /* citytext */
-  {255,   0,   0},  /* citytext/blocked growth */
-  {  0, 255, 200},  /* goto */
-  {255, 255,   0},  /* selection */
+  "mapview_unknown",
+  "mapview_citytext",
+  "mapview_cityblocked",
+  "mapview_goto",
+  "mapview_selection",
 
   /* Spaceship */
-  {  0,   0,   0},  /* background */
+  "spaceship_background",
 
   /* Overview */
-  {  0,   0,   0},  /* unknown */
-  {255, 255, 255},  /* my city */
-  {  0, 255, 200},  /* enemy city */
-  {255, 255,   0},  /* my unit */
-  {255,   0,   0},  /* enemy unit */
-  {  0,   0, 200},  /* ocean */
-  {  0,   0, 128},  /* fogged ocean */
-  {  0, 200,   0},  /* ground */
-  { 86,  86,  86},  /* fogged ground */
-  {255, 255, 255},  /* viewrect */
+  "overview_unknown",
+  "overview_mycity",
+  "overview_enemycity",
+  "overview_myunit",
+  "overview_enemyunit",
+  "overview_ocean",
+  "overview_foggedocean",
+  "overview_ground",
+  "overview_foggedground",
+  "overview_viewrect",
 
   /* Reqtree */
-  {  0, 255, 200},  /* researching */
-  {  0, 200,   0},  /* known */
-  {255, 128, 128},  /* reachable goal */
-  {255,   0, 128},  /* unreachable goal */
-  {255, 255,   0},  /* reachable */
-  {255,   0,   0},  /* unreachable */
-  {  0,   0,   0},  /* background */
-  {  0,   0,   0},  /* text */
-  
-  /* Player dialog */
-  {  0,   0,   0},  /* player color background */
-
-};
+  "reqtree_researching",
+  "reqtree_known",
+  "reqtree_reachablegoal",
+  "reqtree_unreachablegoal",
+  "reqtree_reachable",
+  "reqtree_unreachable",
+  "reqtree_background",
+  "reqtree_text",
 
-struct rgbtriple colors_player_rgb[] = {
-  {128,   0,   0},  /* race0 */
-  {128, 255, 255},  /* race1 */
-  {255,   0,   0},  /* race2 */
-  {255,   0, 128},  /* race3 */
-  {  0,   0, 128},  /* race4 */
-  {255,   0, 255},  /* race5 */
-  {255, 128,   0},  /* race6 */
-  {255, 255, 128},  /* race7 */
-  {255, 128, 128},  /* race8 */
-  {  0,   0, 255},  /* race9 */
-  {  0, 255,   0},  /* race10 */
-  {  0, 128, 128},  /* race11 */
-  {  0,  64,  64},  /* race12 */
-  {198, 198, 198},  /* race13 */
+  /* Player dialog */
+  "playerdlg_background"
 };
 
-static struct color *colors[COLOR_LAST];
-static struct color *player_colors[ARRAY_SIZE(colors_player_rgb)];
-
-static bool initted = FALSE;
-
 /****************************************************************************
   Called when the client first starts to allocate the default colors.
 
   Currently this must be called in ui_main, generally after UI
   initialization.
 ****************************************************************************/
-void init_color_system(void)
+struct color_system *color_system_read(struct section_file *file)
 {
   int i;
+  struct color_system *colors = fc_malloc(sizeof(*colors));
 
-  assert(!initted);
-  initted = TRUE;
-
-  assert(ARRAY_SIZE(colors) == COLOR_LAST);
+  assert(ARRAY_SIZE(color_names) == COLOR_LAST);
   for (i = 0; i < COLOR_LAST; i++) {
-    colors[i] = color_alloc(colors_standard_rgb[i].r,
-                           colors_standard_rgb[i].g,
-                           colors_standard_rgb[i].b);
+    colors->colors[i].r
+      = secfile_lookup_int(file, "colors.%s0.r", color_names[i]);
+    colors->colors[i].g
+      = secfile_lookup_int(file, "colors.%s0.g", color_names[i]);
+    colors->colors[i].b
+      = secfile_lookup_int(file, "colors.%s0.b", color_names[i]);
+    colors->colors[i].color = NULL;
+  }
+
+  for (i = 0; i < MAX_NUM_PLAYERS + MAX_NUM_BARBARIANS; i++) {
+    if (!section_file_lookup(file, "colors.player%d.r", i)) {
+      break;
+    }
   }
+  colors->num_player_colors = MAX(i, 1);
+  colors->player_colors = fc_malloc(colors->num_player_colors
+                                   * sizeof(*colors->player_colors));
+  if (i == 0) {
+    /* Use a simple fallback. */
+    freelog(LOG_ERROR,
+           "Missing colors.player.  See misc/colors.tilespec.");
+    colors->player_colors[0].r = 128;
+    colors->player_colors[0].g = 0;
+    colors->player_colors[0].b = 0;
+    colors->player_colors[0].color = NULL;
+  } else {
+    for (i = 0; i < colors->num_player_colors; i++) {
+      struct rgbcolor *rgb = &colors->player_colors[i];
 
-  for (i = 0; i < ARRAY_SIZE(player_colors); i++) {
-    player_colors[i] = color_alloc(colors_player_rgb[i].r,
-                                  colors_player_rgb[i].g,
-                                  colors_player_rgb[i].b);
+      rgb->r = secfile_lookup_int(file, "colors.player%d.r", i);
+      rgb->g = secfile_lookup_int(file, "colors.player%d.g", i);
+      rgb->b = secfile_lookup_int(file, "colors.player%d.b", i);
+      rgb->color = NULL;
+    }
   }
+
+  return colors;
 }
 
 /****************************************************************************
   Called when the client first starts to free any allocated colors.
 ****************************************************************************/
-void color_free_system(void)
+void color_system_free(struct color_system *colors)
 {
   int i;
 
-  assert(initted);
-  initted = FALSE;
-
   for (i = 0; i < COLOR_LAST; i++) {
-    color_free(colors[i]);
+    if (colors->colors[i].color) {
+      color_free(colors->colors[i].color);
+    }
+  }
+  for (i = 0; i < colors->num_player_colors; i++) {
+    if (colors->player_colors[i].color) {
+      color_free(colors->player_colors[i].color);
+    }
   }
-  for (i = 0; i < ARRAY_SIZE(player_colors); i++) {
-    color_free(player_colors[i]);
+  free(colors->player_colors);
+  free(colors);
+}
+
+/****************************************************************************
+  Return the RGB color, allocating it if necessary.
+****************************************************************************/
+static struct color *ensure_color(struct rgbcolor *rgb)
+{
+  if (!rgb->color) {
+    rgb->color = color_alloc(rgb->r, rgb->g, rgb->b);
   }
+  return rgb->color;
 }
 
 /****************************************************************************
   Return a pointer to the given "standard" color.
 ****************************************************************************/
-struct color *get_color(enum color_std color)
+struct color *get_color(const struct tileset *t, enum color_std color)
 {
-  return colors[color];
+  return ensure_color(&get_color_system(t)->colors[color]);
 }
 
 /**********************************************************************
@@ -152,14 +177,16 @@
   A hack added to avoid returning more that COLOR_STD_RACE13.
   But really there should be more colors available -- jk.
 ***********************************************************************/
-struct color *get_player_color(const struct player *pplayer)
+struct color *get_player_color(const struct tileset *t,
+                              const struct player *pplayer)
 {
   if (pplayer) {
+    struct color_system *colors = get_color_system(t);
     int index = pplayer->player_no;
 
-    assert(index >= 0);
-    index %= ARRAY_SIZE(player_colors);
-    return player_colors[index];
+    assert(index >= 0 && colors->num_player_colors > 0);
+    index %= colors->num_player_colors;
+    return ensure_color(&colors->player_colors[index]);
   } else {
     assert(0);
     return NULL;
Index: client/colors_common.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/colors_common.h,v
retrieving revision 1.4
diff -u -r1.4 colors_common.h
--- client/colors_common.h      18 May 2005 14:12:35 -0000      1.4
+++ client/colors_common.h      21 May 2005 07:30:22 -0000
@@ -14,12 +14,16 @@
 #ifndef FC__COLORS_COMMON_H
 #define FC__COLORS_COMMON_H
 
+#include "registry.h"
+
 #include "fc_types.h"
 
 /* The color system is designed on the assumption that almost, but
  * not quite, all displays will be truecolor. */
 
 struct color;
+struct color_system;
+struct tileset;
 
 enum color_std {
   /* Mapview colors */
@@ -60,10 +64,12 @@
   COLOR_LAST
 };
 
-void init_color_system(void);
-void color_free_system(void);
-
-struct color *get_color(enum color_std color);
-struct color *get_player_color(const struct player *pplayer);
+struct color *get_color(const struct tileset *t, enum color_std color);
+struct color *get_player_color(const struct tileset *t,
+                              const struct player *pplayer);
+
+/* Functions used by the tileset to allocate the color system. */
+struct color_system *color_system_read(struct section_file *file);
+void color_system_free(struct color_system *colors);
 
 #endif /* FC__COLORS_COMMON_H */
Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.238
diff -u -r1.238 mapview_common.c
--- client/mapview_common.c     14 May 2005 22:49:02 -0000      1.238
+++ client/mapview_common.c     21 May 2005 07:30:23 -0000
@@ -1119,7 +1119,8 @@
    *
    * Of course it's necessary to draw to the whole area to cover up any old
    * drawing that was done there. */
-  canvas_put_rectangle(mapview.store, get_color(COLOR_MAPVIEW_UNKNOWN),
+  canvas_put_rectangle(mapview.store,
+                      get_color(tileset, COLOR_MAPVIEW_UNKNOWN),
                       canvas_x, canvas_y, width, height);
 
   mapview_layer_iterate(layer) {
@@ -1331,7 +1332,7 @@
                        bg, 0, 0, *width - x, *height - y);
     }
   }
-  owner_color = get_player_color(city_owner(pcity));
+  owner_color = get_player_color(tileset, city_owner(pcity));
   if (line1) {
     canvas_put_sprite_full(pcanvas, flag_rect.x, flag_rect.y, flag);
     canvas_put_line(pcanvas, owner_color, LINE_NORMAL,
@@ -1339,22 +1340,27 @@
                    0, height1);
     canvas_put_sprite_full(pcanvas, occupy_rect.x, occupy_rect.y, occupy);
     canvas_put_text(pcanvas, name_rect.x, name_rect.y,
-                   FONT_CITY_NAME, get_color(COLOR_MAPVIEW_CITYTEXT), name);
+                   FONT_CITY_NAME,
+                   get_color(tileset, COLOR_MAPVIEW_CITYTEXT),
+                   name);
 
     canvas_put_rectangle(pcanvas, owner_color,
                         size_rect.x - border / 2, canvas_y,
                         size_rect.w + border, height1);
     canvas_put_text(pcanvas, size_rect.x, size_rect.y,
-                   FONT_CITY_NAME, get_color(COLOR_MAPVIEW_CITYTEXT), size);
+                   FONT_CITY_NAME,
+                   get_color(tileset, COLOR_MAPVIEW_CITYTEXT), size);
   }
   if (line2) {
     canvas_put_sprite_full(pcanvas, shield_rect.x, shield_rect.y,
                           citybar->shields);
     canvas_put_text(pcanvas, prod_rect.x, prod_rect.y,
-                   FONT_CITY_PROD, get_color(COLOR_MAPVIEW_CITYTEXT), prod);
+                   FONT_CITY_PROD,
+                   get_color(tileset, COLOR_MAPVIEW_CITYTEXT), prod);
     canvas_put_sprite_full(pcanvas, food_rect.x, food_rect.y, citybar->food);
     canvas_put_text(pcanvas, growth_rect.x, growth_rect.y,
-                   FONT_CITY_PROD, get_color(growth_color), growth);
+                   FONT_CITY_PROD,
+                   get_color(tileset, growth_color), growth);
   }
   canvas_put_line(pcanvas, owner_color, LINE_NORMAL,
                  canvas_x - *width / 2, canvas_y,
@@ -1412,12 +1418,14 @@
     total_height = MAX(name_rect.h, growth_rect.h);
     canvas_put_text(pcanvas,
                    canvas_x - total_width / 2, canvas_y,
-                   FONT_CITY_NAME, get_color(COLOR_MAPVIEW_CITYTEXT), name);
+                   FONT_CITY_NAME,
+                   get_color(tileset, COLOR_MAPVIEW_CITYTEXT), name);
     if (growth[0] != '\0') {
       canvas_put_text(pcanvas,
                      canvas_x - total_width / 2 + name_rect.w + extra_width,
                      canvas_y + total_height - growth_rect.h,
-                     FONT_CITY_PROD, get_color(growth_color), growth);
+                     FONT_CITY_PROD,
+                     get_color(tileset, growth_color), growth);
     }
     canvas_y += total_height + 3;
 
@@ -1432,7 +1440,8 @@
     total_height = prod_rect.h;
 
     canvas_put_text(pcanvas, canvas_x - total_width / 2, canvas_y,
-                   FONT_CITY_PROD, get_color(COLOR_MAPVIEW_CITYTEXT), prod);
+                   FONT_CITY_PROD,
+                   get_color(tileset, COLOR_MAPVIEW_CITYTEXT), prod);
 
     canvas_y += total_height;
     *width = MAX(*width, total_width);
@@ -1578,7 +1587,8 @@
   map_to_gui_vector(tileset, &canvas_dx, &canvas_dy, DIR_DX[dir], DIR_DY[dir]);
 
   /* Draw the segment. */
-  canvas_put_line(mapview.store, get_color(COLOR_MAPVIEW_GOTO), LINE_GOTO,
+  canvas_put_line(mapview.store,
+                 get_color(tileset, COLOR_MAPVIEW_GOTO), LINE_GOTO,
                  canvas_x, canvas_y, canvas_dx, canvas_dy);
 
   /* The actual area drawn will extend beyond the base rectangle, since
@@ -2245,7 +2255,8 @@
       canvas_free(mapview.tmp_store);
     }
     mapview.store = canvas_create(full_width, full_height);
-    canvas_put_rectangle(mapview.store, get_color(COLOR_MAPVIEW_UNKNOWN),
+    canvas_put_rectangle(mapview.store,
+                        get_color(tileset, COLOR_MAPVIEW_UNKNOWN),
                         0, 0, full_width, full_height);
 
     mapview.tmp_store = canvas_create(full_width, full_height);
@@ -2309,7 +2320,8 @@
   sprite = get_spaceship_sprite(t, SPACESHIP_HABITATION);
   get_sprite_dimensions(sprite, &w, &h);
 
-  canvas_put_rectangle(pcanvas, get_color(COLOR_SPACESHIP_BACKGROUND),
+  canvas_put_rectangle(pcanvas,
+                      get_color(tileset, COLOR_SPACESHIP_BACKGROUND),
                       0, 0, w * 7, h * 7);
 
   for (i = 0; i < NUM_SS_MODULES; i++) {
Index: client/overview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/overview_common.c,v
retrieving revision 1.9
diff -u -r1.9 overview_common.c
--- client/overview_common.c    14 May 2005 22:49:02 -0000      1.9
+++ client/overview_common.c    21 May 2005 07:30:23 -0000
@@ -176,7 +176,8 @@
     int dst_x = x[(i + 1) % 4];
     int dst_y = y[(i + 1) % 4];
 
-    canvas_put_line(overview.window, get_color(COLOR_OVERVIEW_VIEWRECT),
+    canvas_put_line(overview.window,
+                   get_color(tileset, COLOR_OVERVIEW_VIEWRECT),
                    LINE_NORMAL,
                    src_x, src_y, dst_x - src_x, dst_y - src_y);
   }
@@ -333,7 +334,8 @@
          /* This tile is shown half on the left and half on the right
           * side of the overview.  So we have to draw it in two parts. */
          canvas_put_rectangle(overview.map,
-                              get_color(overview_tile_color(ptile)),
+                              get_color(tileset,
+                                        overview_tile_color(ptile)),
                               overview_x - overview.width, overview_y,
                               OVERVIEW_TILE_WIDTH, OVERVIEW_TILE_HEIGHT); 
        }     
@@ -345,7 +347,7 @@
     } 
 
     canvas_put_rectangle(overview.map,
-                        get_color(overview_tile_color(ptile)),
+                        get_color(tileset, overview_tile_color(ptile)),
                         overview_x, overview_y,
                         OVERVIEW_TILE_WIDTH, OVERVIEW_TILE_HEIGHT);
 
@@ -395,7 +397,8 @@
   }
   overview.map = canvas_create(overview.width, overview.height);
   overview.window = canvas_create(overview.width, overview.height);
-  canvas_put_rectangle(overview.map, get_color(COLOR_OVERVIEW_UNKNOWN),
+  canvas_put_rectangle(overview.map,
+                      get_color(tileset, COLOR_OVERVIEW_UNKNOWN),
                       0, 0, overview.width, overview.height);
   update_map_canvas_scrollbars_size();
 
Index: client/reqtree.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/reqtree.c,v
retrieving revision 1.6
diff -u -r1.6 reqtree.c
--- client/reqtree.c    14 May 2005 22:49:02 -0000      1.6
+++ client/reqtree.c    21 May 2005 07:30:23 -0000
@@ -26,6 +26,7 @@
 #include "colors_g.h"
 
 #include "reqtree.h"
+#include "tilespec.h"
 
 /****************************************************************************
   This structure desribes a node in a technology tree diagram.
@@ -786,7 +787,8 @@
       width = node->node_width;
       height = node->node_height;
 
-      canvas_put_rectangle(pcanvas, get_color(COLOR_REQTREE_BACKGROUND),
+      canvas_put_rectangle(pcanvas,
+                          get_color(tileset, COLOR_REQTREE_BACKGROUND),
                           startx, starty, width, height);
 
       if (!node->is_dummy) {
@@ -794,7 +796,7 @@
        int text_w, text_h;
 
        /* Print color rectangle with text inside. */
-       canvas_put_rectangle(pcanvas, get_color(node_color(node)),
+       canvas_put_rectangle(pcanvas, get_color(tileset, node_color(node)),
                             startx + 1, starty + 1,
                             width - 2, height - 2);
        get_text_size(&text_w, &text_h, FONT_REQTREE_TEXT, text);
@@ -802,7 +804,8 @@
        canvas_put_text(pcanvas,
                        startx + (width - text_w) / 2,
                        starty + (height - text_h) / 2,
-                       FONT_REQTREE_TEXT, get_color(COLOR_REQTREE_TEXT),
+                       FONT_REQTREE_TEXT,
+                       get_color(tileset, COLOR_REQTREE_TEXT),
                        text);
       }
 
@@ -815,7 +818,8 @@
        endx = dest_node->node_x;
        endy = dest_node->node_y + dest_node->node_height / 2;
 
-       canvas_put_line(pcanvas, get_color(COLOR_REQTREE_BACKGROUND),
+       canvas_put_line(pcanvas,
+                       get_color(tileset, COLOR_REQTREE_BACKGROUND),
                        LINE_NORMAL,
                        startx, starty, endx - startx, endy - starty);
       }
Index: client/tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
retrieving revision 1.306
diff -u -r1.306 tilespec.c
--- client/tilespec.c   19 May 2005 16:22:08 -0000      1.306
+++ client/tilespec.c   21 May 2005 07:30:24 -0000
@@ -380,11 +380,13 @@
   struct hash_table *terrain_hash;
 
   struct named_sprites sprites;
+
+  struct color_system *color_system;
 };
 
 struct tileset *tileset;
 
-#define TILESPEC_CAPSTR "+tilespec3 duplicates_ok +Freeciv.Devel.2005.Apr.27"
+#define TILESPEC_CAPSTR "+tilespec3 duplicates_ok +Freeciv.Devel.2005.May.21"
 /*
  * Tilespec capabilities acceptable to this program:
  *
@@ -579,6 +581,9 @@
 {
   specfile_list_free(t->specfiles);
   small_sprite_list_free(t->small_sprites);
+  if (t->color_system) {
+    color_system_free(t->color_system);
+  }
   free(t);
 }
 
@@ -1510,6 +1515,8 @@
   }
   free(spec_filenames);
 
+  t->color_system = color_system_read(file);
+
   section_file_check_unused(file, fname);
   
   section_file_free(file);
@@ -4536,3 +4543,11 @@
     return NULL;
   }
 }
+
+/****************************************************************************
+  Return the tileset's color system.
+****************************************************************************/
+struct color_system *get_color_system(const struct tileset *t)
+{
+  return t->color_system;
+}
Index: client/tilespec.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.h,v
retrieving revision 1.153
diff -u -r1.153 tilespec.h
--- client/tilespec.h   11 May 2005 20:35:29 -0000      1.153
+++ client/tilespec.h   21 May 2005 07:30:24 -0000
@@ -218,6 +218,9 @@
                                      Output_type_id otype,
                                      const struct unit *punit);
 
+struct color_system;
+struct color_system *get_color_system(const struct tileset *t);
+
 /* Tileset accessor functions. */
 const char *tileset_get_name(const struct tileset *t);
 bool tileset_is_isometric(const struct tileset *t);
Index: client/gui-gtk-2.0/canvas.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/canvas.c,v
retrieving revision 1.6
diff -u -r1.6 canvas.c
--- client/gui-gtk-2.0/canvas.c 14 May 2005 22:49:02 -0000      1.6
+++ client/gui-gtk-2.0/canvas.c 21 May 2005 07:30:24 -0000
@@ -222,7 +222,7 @@
     gdk_gc_set_clip_origin(fill_tile_gc, canvas_x, canvas_y);
     gdk_gc_set_clip_mask(fill_tile_gc, sprite_get_mask(psprite));
     gdk_gc_set_foreground(fill_tile_gc,
-                         &get_color(COLOR_MAPVIEW_UNKNOWN)->color);
+                         &get_color(tileset, COLOR_MAPVIEW_UNKNOWN)->color);
     gdk_gc_set_stipple(fill_tile_gc, black50);
     gdk_gc_set_ts_origin(fill_tile_gc, canvas_x, canvas_y);
 
Index: client/gui-gtk-2.0/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/gui_main.c,v
retrieving revision 1.124
diff -u -r1.124 gui_main.c
--- client/gui-gtk-2.0/gui_main.c       14 May 2005 22:49:02 -0000      1.124
+++ client/gui-gtk-2.0/gui_main.c       21 May 2005 07:30:24 -0000
@@ -943,9 +943,9 @@
 
   for (i = 0; i < 5; i++) {
     gtk_widget_modify_bg(GTK_WIDGET(overview_canvas), i,
-                        &get_color(COLOR_OVERVIEW_UNKNOWN)->color);
+                        &get_color(tileset, COLOR_OVERVIEW_UNKNOWN)->color);
     gtk_widget_modify_bg(GTK_WIDGET(map_canvas), i,
-                        &get_color(COLOR_MAPVIEW_UNKNOWN)->color);
+                        &get_color(tileset, COLOR_MAPVIEW_UNKNOWN)->color);
   }
 
   gtk_widget_add_events(map_canvas, GDK_EXPOSURE_MASK
@@ -1111,7 +1111,6 @@
 
 
   display_color_type = get_visual();
-  init_color_system();
 
   civ_gc = gdk_gc_new(root_window);
 
@@ -1215,7 +1214,6 @@
   happiness_dialog_done();
   diplomacy_dialog_done();
   cma_fe_done();
-  color_free_system();
   tileset_free_tiles(tileset);
 }
 
Index: client/gui-gtk-2.0/helpdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/helpdlg.c,v
retrieving revision 1.50
diff -u -r1.50 helpdlg.c
--- client/gui-gtk-2.0/helpdlg.c        14 May 2005 22:49:02 -0000      1.50
+++ client/gui-gtk-2.0/helpdlg.c        21 May 2005 07:30:25 -0000
@@ -200,7 +200,7 @@
     gtk_tree_store_set(tstore, &l,
                       1, -1,
                       2, tech,
-                      3, &get_color(bg)->color
+                      3, &get_color(tileset, bg)->color
                       -1);
     return;
   }
@@ -233,7 +233,7 @@
   gtk_tree_store_set(tstore, &l,
                     1, turns_to_tech,
                     2, tech,
-                    3, &get_color(bg)->color,
+                    3, &get_color(tileset, bg)->color,
                     -1);
 
   if (--levels <= 0)
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.175
diff -u -r1.175 mapview.c
--- client/gui-gtk-2.0/mapview.c        14 May 2005 22:49:02 -0000      1.175
+++ client/gui-gtk-2.0/mapview.c        21 May 2005 07:30:25 -0000
@@ -651,7 +651,7 @@
     gdk_gc_set_clip_origin(fill_tile_gc, canvas_x, canvas_y);
     gdk_gc_set_clip_mask(fill_tile_gc, sprite_get_mask(ssprite));
     gdk_gc_set_foreground(fill_tile_gc,
-                         &get_color(COLOR_MAPVIEW_UNKNOWN)->color);
+                         &get_color(tileset, COLOR_MAPVIEW_UNKNOWN)->color);
     gdk_gc_set_ts_origin(fill_tile_gc, canvas_x, canvas_y);
     gdk_gc_set_stipple(fill_tile_gc, black50);
 
@@ -743,7 +743,7 @@
   GdkPoint points[5];
 
   gdk_gc_set_foreground(civ_gc,
-                       &get_color(COLOR_MAPVIEW_SELECTION)->color);
+                       &get_color(tileset, COLOR_MAPVIEW_SELECTION)->color);
 
   /* gdk_draw_rectangle() must start top-left.. */
   points[0].x = canvas_x;
Index: client/gui-gtk-2.0/plrdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/plrdlg.c,v
retrieving revision 1.62
diff -u -r1.62 plrdlg.c
--- client/gui-gtk-2.0/plrdlg.c 18 May 2005 14:12:35 -0000      1.62
+++ client/gui-gtk-2.0/plrdlg.c 21 May 2005 07:30:25 -0000
@@ -111,10 +111,11 @@
   pixmap = gdk_pixmap_new(root_window, width, height, -1);
 
   gdk_gc_set_foreground(civ_gc,
-                        &get_color(COLOR_PLAYER_COLOR_BACKGROUND)->color);
+                        &get_color(tileset,
+                                  COLOR_PLAYER_COLOR_BACKGROUND)->color);
   gdk_draw_rectangle(pixmap, civ_gc, TRUE, 0, 0, width, height);
 
-  gdk_gc_set_foreground(civ_gc, &get_player_color(plr)->color);
+  gdk_gc_set_foreground(civ_gc, &get_player_color(tileset, plr)->color);
   gdk_draw_rectangle(pixmap, civ_gc, TRUE, 1, 1, width - 2, height - 2);
 
   tmp = gdk_pixbuf_get_from_drawable(NULL, pixmap, NULL, 
Index: data/isophex.tilespec
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/isophex.tilespec,v
retrieving revision 1.16
diff -u -r1.16 isophex.tilespec
--- data/isophex.tilespec       29 Apr 2005 17:58:10 -0000      1.16
+++ data/isophex.tilespec       21 May 2005 07:30:25 -0000
@@ -2,7 +2,7 @@
 [tilespec]
 
 ; Format and options of this tilespec file:
-options = "+tilespec3 +Freeciv.Devel.2005.Apr.27"
+options = "+tilespec3 +Freeciv.Devel.2005.May.21"
 
 ; A simple name for the tileset specified by this file:
 name = "isophex"
@@ -85,6 +85,9 @@
   "isotrident/morecities.spec"
 
 
+; Include color definitions
+*include "misc/colors.tilespec"
+
 ; Terrain info - see README.graphics
 
 [layer0]
Index: data/isotrident.tilespec
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/isotrident.tilespec,v
retrieving revision 1.39
diff -u -r1.39 isotrident.tilespec
--- data/isotrident.tilespec    29 Apr 2005 17:58:10 -0000      1.39
+++ data/isotrident.tilespec    21 May 2005 07:30:25 -0000
@@ -2,7 +2,7 @@
 [tilespec]
 
 ; Format and options of this tilespec file:
-options = "+tilespec3 +Freeciv.Devel.2005.Apr.27"
+options = "+tilespec3 +Freeciv.Devel.2005.May.21"
 
 ; A simple name for the tileset specified by this file:
 name = "MacroIsoTrident"
@@ -78,6 +78,9 @@
   "isotrident/morecities.spec"
 
 
+; Include color definitions
+*include "misc/colors.tilespec"
+
 ; Terrain info - see README.graphics
 
 [layer0]
Index: data/trident.tilespec
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/trident.tilespec,v
retrieving revision 1.39
diff -u -r1.39 trident.tilespec
--- data/trident.tilespec       29 Apr 2005 17:58:10 -0000      1.39
+++ data/trident.tilespec       21 May 2005 07:30:25 -0000
@@ -2,7 +2,7 @@
 [tilespec]
 
 ; Format and options of this tilespec file:
-options = "+tilespec3 +Freeciv.Devel.2005.Apr.27"
+options = "+tilespec3 +Freeciv.Devel.2005.May.21"
 
 ; A simple name for the tileset specified by this file:
 name = "Trident"
@@ -68,6 +68,8 @@
   "trident/cities.spec",
   "trident/explosions.spec"
 
+; Include color definitions
+*include "misc/colors.tilespec"
 
 ; Terrain info - see README.graphics
 
Index: data/misc/Makefile.am
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/misc/Makefile.am,v
retrieving revision 1.13
diff -u -r1.13 Makefile.am
--- data/misc/Makefile.am       25 Apr 2005 06:19:32 -0000      1.13
+++ data/misc/Makefile.am       21 May 2005 07:30:25 -0000
@@ -14,6 +14,7 @@
        civicon.png     \
        colors.png      \
        colors.spec     \
+       colors.tilespec \
        cursors.png     \
        cursors.spec    \
        flags.spec      \
Index: data/misc/colors.tilespec
===================================================================
RCS file: data/misc/colors.tilespec
diff -N data/misc/colors.tilespec
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ data/misc/colors.tilespec   21 May 2005 07:30:25 -0000
@@ -0,0 +1,104 @@
+[colors]
+
+; Player colors should match those in colors.spec
+player = {"r", "g", "b"
+  128,   0,   0  ; race0
+  128, 255, 255  ; race1
+  255,   0,   0  ; race2
+  255,   0, 128  ; race3
+    0,   0, 128  ; race4
+  255,   0, 255  ; race5
+  255, 128,   0  ; race6
+  255, 255, 128  ; race7
+  255, 128, 128  ; race8
+    0,   0, 255  ; race9
+    0, 255,   0  ; race10
+    0, 128, 128  ; race11
+    0,  64,  64  ; race12
+  198, 198, 198  ; race13
+}
+
+; Mapview
+mapview_unknown = {"r", "g", "b"
+    0,     0,   0
+}
+mapview_citytext = {"r", "g", "b"
+    255, 255, 255
+}
+mapview_cityblocked = {"r", "g", "b"
+    255,   0,   0
+}
+mapview_goto = {"r", "g", "b"
+    0,   255, 200
+}
+mapview_selection = {"r", "g", "b"
+    255, 255,   0
+}
+
+; Spaceship
+spaceship_background = {"r", "g", "b"
+    0,   0,   0
+}
+
+; Overview
+overview_unknown = {"r", "g", "b"
+    0,     0,   0
+}
+overview_mycity = {"r", "g", "b"
+    255, 255, 255
+}
+overview_enemycity = {"r", "g", "b"
+    0,   255, 200
+}
+overview_myunit = {"r", "g", "b"
+    255, 255,   0
+}
+overview_enemyunit = {"r", "g", "b"
+    255,   0,   0
+}
+overview_ocean = {"r", "g", "b"
+    0,     0, 200
+}
+overview_foggedocean = {"r", "g", "b"
+    0,     0, 128
+}
+overview_ground = {"r", "g", "b"
+    0,   200,   0
+}
+overview_foggedground = {"r", "g", "b"
+    86,   86,  86
+}
+overview_viewrect = {"r", "g", "b"
+    255, 255, 255
+}
+
+; Reqtree
+reqtree_researching = {"r", "g", "b"
+    0, 255, 200
+}
+reqtree_known = {"r", "g", "b"
+    0, 200,   0
+}
+reqtree_reachablegoal = {"r", "g", "b"
+    255, 128, 128
+}
+reqtree_unreachablegoal = {"r", "g", "b"
+    255,   0, 128
+}
+reqtree_reachable = {"r", "g", "b"
+    255, 255,   0
+}
+reqtree_unreachable = {"r", "g", "b"
+    255,   0,   0
+}
+reqtree_background = {"r", "g", "b"
+    0,   0,   0
+}
+reqtree_text = {"r", "g", "b"
+    0,   0,   0
+}
+  
+; Player dialog
+playerdlg_background = {"r", "g", "b"
+    0,   0,   0
+}

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#13152) put enumerated colors into the tileset, Jason Dorje Short <=