Complete.Org: Mailing Lists: Archives: freeciv-dev: September 1999:
[Freeciv-Dev] patch: fix solid background colors (PR#130)
Home

[Freeciv-Dev] patch: fix solid background colors (PR#130)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Cc: bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] patch: fix solid background colors (PR#130)
From: David Pfitzner <dwp@xxxxxxxxxxxxxx>
Date: Sat, 18 Sep 1999 21:06:41 -0700 (PDT)

Solid background colors are currently broken for nations >= 14,
since there are only 14 nation colors defined.

This patch fixes this by making the color depend on the player
number instead of the nation number, since the player number
is still restricted to less than 14.

It would be nice to make this more customisable (eg, players
choose preferred colors) but this will at least do something
sensible in the meantime.

(Except I wasn't sure what module to put player_color() in;
it would sort of be nice to return a color instead of the
enum color_std, but then it would become gui-dependent.)

-- David
diff -u -r --exclude-from exclude freeciv-cvs/client/climisc.c 
freeciv-mod/client/climisc.c
--- freeciv-cvs/client/climisc.c        Wed Sep 15 20:18:31 1999
+++ freeciv-mod/client/climisc.c        Sun Sep 19 13:01:35 1999
@@ -259,3 +259,16 @@
   }
   city_list_iterate_end;
 }
+
+
+/**********************************************************************
+  Not sure which module to put this...
+  It used to be that each nation had a color, when there was
+  fixed number of nations.  Now base on player number instead,
+  since will be limited to less than 14.  Could possibly improve
+  to allow players to choose their preferred color etc.
+***********************************************************************/
+enum color_std player_color(struct player *pplayer)
+{
+  return COLOR_STD_RACE0 + pplayer->player_no;
+}
diff -u -r --exclude-from exclude freeciv-cvs/client/climisc.h 
freeciv-mod/client/climisc.h
--- freeciv-cvs/client/climisc.h        Sat Aug 28 00:04:30 1999
+++ freeciv-mod/client/climisc.h        Sun Sep 19 13:01:44 1999
@@ -13,6 +13,8 @@
 #ifndef FC__CLIMISC_H
 #define FC__CLIMISC_H
 
+#include "colors_g.h"          /* enum color_std */
+
 struct city;
 
 void client_remove_player(int plr_id);
@@ -22,6 +24,8 @@
 void climap_init_continents(void);
 void climap_update_continents(int x, int y);
 void client_change_all(int x, int y);
+
+enum color_std player_color(struct player *pplayer);
 
 #define CITY_NAMES_FONT "10x20"
 
diff -u -r --exclude-from exclude freeciv-cvs/client/gui-gtk/mapview.c 
freeciv-mod/client/gui-gtk/mapview.c
--- freeciv-cvs/client/gui-gtk/mapview.c        Sun Sep 19 11:17:52 1999
+++ freeciv-mod/client/gui-gtk/mapview.c        Sun Sep 19 13:11:00 1999
@@ -31,6 +31,7 @@
 #include "shared.h"            /* myusleep() */
 
 #include "civclient.h"
+#include "climisc.h"           /* player_color() */
 #include "colors.h"
 #include "control.h" /* set_unit_focus_no_center and get_unit_in_focus */
 #include "graphics.h"
@@ -930,8 +931,8 @@
   SPRITE *mysprite;
 
   if(use_solid_color_behind_units) {
-    gdk_gc_set_foreground( fill_bg_gc, colors_standard[COLOR_STD_RACE0+
-                                       game.players[pcity->owner].nation] );
+    gdk_gc_set_foreground( fill_bg_gc,
+                          colors_standard[player_color(city_owner(pcity))]);
     gdk_draw_rectangle( pm, fill_bg_gc, TRUE,
                    xtile*NORMAL_TILE_WIDTH, ytile*NORMAL_TILE_HEIGHT, 
                    NORMAL_TILE_WIDTH, NORMAL_TILE_HEIGHT );
@@ -1013,8 +1014,8 @@
       }
     } else
     {
-      gdk_gc_set_foreground( fill_bg_gc, colors_standard[COLOR_STD_RACE0+
-                             game.players[punit->owner].nation] );
+      gdk_gc_set_foreground( fill_bg_gc,
+                            
colors_standard[player_color(get_player(punit->owner))]);
       gdk_draw_rectangle( pm, fill_bg_gc, TRUE,
                           xtile*NORMAL_TILE_WIDTH, ytile*NORMAL_TILE_HEIGHT, 
                           NORMAL_TILE_WIDTH, NORMAL_TILE_HEIGHT );
@@ -1043,8 +1044,9 @@
 
     if(!sprites[0])
     {
-      gtk_pixcomm_fill(p, colors_standard[COLOR_STD_RACE0+
-                       game.players[punit->owner].nation], FALSE);
+      gtk_pixcomm_fill(p,
+                      colors_standard[player_color(get_player(punit->owner))],
+                      FALSE);
     }
 
     for(i=0;i<count;i++)
@@ -1190,8 +1192,8 @@
 
       if(pplayer)
       {
-        gdk_gc_set_foreground( fill_bg_gc, colors_standard[COLOR_STD_RACE0+
-                    pplayer->nation] );
+        gdk_gc_set_foreground( fill_bg_gc,
+                              colors_standard[player_color(pplayer)] );
         gdk_draw_rectangle( pm, fill_bg_gc, TRUE,
                     x1, y1, NORMAL_TILE_WIDTH, NORMAL_TILE_HEIGHT );
       }
diff -u -r --exclude-from exclude freeciv-cvs/client/gui-xaw/mapview.c 
freeciv-mod/client/gui-xaw/mapview.c
--- freeciv-cvs/client/gui-xaw/mapview.c        Sun Sep 19 11:17:55 1999
+++ freeciv-mod/client/gui-xaw/mapview.c        Sun Sep 19 13:10:47 1999
@@ -31,6 +31,7 @@
 #include "unit.h"
 
 #include "civclient.h"
+#include "climisc.h"           /* player_color() */
 #include "colors.h"
 #include "control.h" /* set_unit_focus_no_center and get_unit_in_focus */
 #include "graphics.h"
@@ -876,8 +877,8 @@
   struct Sprite *mysprite;
 
   if(use_solid_color_behind_units) {
-    XSetForeground(display, fill_bg_gc, colors_standard[COLOR_STD_RACE0+
-                   game.players[pcity->owner].nation]);
+    XSetForeground(display, fill_bg_gc,
+                  colors_standard[player_color(city_owner(pcity))]);
     XFillRectangle(display, pm, fill_bg_gc, 
                   xtile*NORMAL_TILE_WIDTH, ytile*NORMAL_TILE_HEIGHT, 
                   NORMAL_TILE_WIDTH, NORMAL_TILE_HEIGHT);
@@ -956,8 +957,8 @@
                        }
     } else
     {
-      XSetForeground(display, fill_bg_gc, colors_standard[COLOR_STD_RACE0+
-                     game.players[punit->owner].nation]);
+      XSetForeground(display, fill_bg_gc,
+                    colors_standard[player_color(get_player(punit->owner))]);
       XFillRectangle(display, pm, fill_bg_gc, 
                      xtile*NORMAL_TILE_WIDTH, ytile*NORMAL_TILE_HEIGHT, 
                      NORMAL_TILE_WIDTH, NORMAL_TILE_HEIGHT);
@@ -1105,8 +1106,8 @@
 
       if(pplayer)
       {
-        XSetForeground(display, fill_bg_gc, colors_standard[COLOR_STD_RACE0+
-                       pplayer->nation]);
+        XSetForeground(display, fill_bg_gc,
+                      colors_standard[player_color(pplayer)]);
         XFillRectangle(display, pm, fill_bg_gc, 
                        x1,y1,NORMAL_TILE_WIDTH, NORMAL_TILE_HEIGHT);
       }

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] patch: fix solid background colors (PR#130), David Pfitzner <=