Author: jtn
Date: Thu Dec 24 11:19:15 2015
New Revision: 31191

URL: http://svn.gna.org/viewcvs/freeciv?rev=31191&view=rev
Log:
Display player colors in pregame in Gtk clients.

See gna patch #6719.

Modified:
    branches/S2_6/client/gui-gtk-2.0/pages.c
    branches/S2_6/client/gui-gtk-2.0/plrdlg.c
    branches/S2_6/client/gui-gtk-2.0/plrdlg.h
    branches/S2_6/client/gui-gtk-3.0/pages.c
    branches/S2_6/client/gui-gtk-3.0/plrdlg.c
    branches/S2_6/client/gui-gtk-3.0/plrdlg.h

Modified: branches/S2_6/client/gui-gtk-2.0/pages.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-2.0/pages.c?rev=31191&r1=31190&r2=31191&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-2.0/pages.c    (original)
+++ branches/S2_6/client/gui-gtk-2.0/pages.c    Thu Dec 24 11:19:15 2015
@@ -1362,13 +1362,14 @@
 static GtkWidget *start_aifill_spin = NULL;
 
 
-/* NB: Must match creation arugments in connection_list_store_new(). */
+/* NB: Must match creation arguments in connection_list_store_new(). */
 enum connection_list_columns {
   CL_COL_PLAYER_NUMBER = 0,
   CL_COL_USER_NAME,
   CL_COL_READY_STATE,
   CL_COL_PLAYER_NAME,
   CL_COL_FLAG,
+  CL_COL_COLOR,
   CL_COL_NATION,
   CL_COL_TEAM,
   CL_COL_CONN_ID,
@@ -1390,6 +1391,7 @@
                             G_TYPE_BOOLEAN,     /* CL_COL_READY_STATE */
                             G_TYPE_STRING,      /* CL_COL_PLAYER_NAME */
                             GDK_TYPE_PIXBUF,    /* CL_COL_FLAG */
+                            GDK_TYPE_PIXBUF,    /* CL_COL_COLOR */
                             G_TYPE_STRING,      /* CL_COL_NATION */
                             G_TYPE_STRING,      /* CL_COL_TEAM */
                             G_TYPE_INT,         /* CL_COL_CONN_ID */
@@ -2249,7 +2251,7 @@
     GtkTreePath *path;
     GtkTreeIter child, prev_child, *pprev_child;
     GtkTreeIter parent, prev_parent, *pprev_parent = NULL;
-    GdkPixbuf *pixbuf;
+    GdkPixbuf *flag, *color;
     gboolean collapsed;
     struct player *pselected_player;
     struct connection *pselected_conn;
@@ -2266,7 +2268,8 @@
     players_iterate(pplayer) {
       conn_id = -1;
       access_level = ALLOW_NONE;
-      pixbuf = pplayer->nation ? get_flag(pplayer->nation) : NULL;
+      flag = pplayer->nation ? get_flag(pplayer->nation) : NULL;
+      color = create_player_icon(pplayer);
 
       conn_list_iterate(pplayer->connections, pconn) {
         if (pconn->playing == pplayer && !pconn->observer) {
@@ -2315,7 +2318,8 @@
                          CL_COL_USER_NAME, name,
                          CL_COL_READY_STATE, is_ready,
                          CL_COL_PLAYER_NAME, plr_name,
-                         CL_COL_FLAG, pixbuf,
+                         CL_COL_FLAG, flag,
+                         CL_COL_COLOR, color,
                          CL_COL_NATION, nation,
                          CL_COL_TEAM, team,
                          CL_COL_CONN_ID, conn_id,
@@ -2376,8 +2380,11 @@
 
       prev_parent = parent;
       pprev_parent = &prev_parent;
-      if (pixbuf) {
-        g_object_unref(pixbuf);
+      if (flag) {
+        g_object_unref(flag);
+      }
+      if (color) {
+        g_object_unref(color);
       }
     } players_iterate_end;
 
@@ -2629,6 +2636,8 @@
                CL_COL_PLAYER_NAME, NULL);
   add_tree_col(view, GDK_TYPE_PIXBUF, _("Flag"),
                CL_COL_FLAG, NULL);
+  add_tree_col(view, GDK_TYPE_PIXBUF, _("Border"),
+               CL_COL_COLOR, NULL);
   add_tree_col(view, G_TYPE_STRING, _("Nation"),
                CL_COL_NATION, NULL);
   add_tree_col(view, G_TYPE_STRING, _("Team"),

Modified: branches/S2_6/client/gui-gtk-2.0/plrdlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-2.0/plrdlg.c?rev=31191&r1=31190&r2=31191&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-2.0/plrdlg.c   (original)
+++ branches/S2_6/client/gui-gtk-2.0/plrdlg.c   Thu Dec 24 11:19:15 2015
@@ -101,14 +101,20 @@
   }
 }
 
-/**************************************************************************
-  Create pixbuf for player
-**************************************************************************/
-static GdkPixbuf *create_player_icon(const struct player *plr)
+/***************************************************************************
+  Create a small colored square representing the player color, for use
+  in player lists. 
+  May return NULL if the player has no color yet.
+***************************************************************************/
+GdkPixbuf *create_player_icon(const struct player *plr)
 {
   int width, height;
   GdkPixbuf *tmp;
   GdkPixmap *pixmap;
+
+  if (!player_has_color(tileset, plr)) {
+    return NULL;
+  }
 
   gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height);
 

Modified: branches/S2_6/client/gui-gtk-2.0/plrdlg.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-2.0/plrdlg.h?rev=31191&r1=31190&r2=31191&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-2.0/plrdlg.h   (original)
+++ branches/S2_6/client/gui-gtk-2.0/plrdlg.h   Thu Dec 24 11:19:15 2015
@@ -19,6 +19,7 @@
 
 /* Misc helper functions */
 GdkPixbuf *get_flag(const struct nation_type *pnation);
+GdkPixbuf *create_player_icon(const struct player *plr);
 
 extern struct gui_dialog *players_dialog_shell;
 #endif  /* FC__PLRDLG_H */

Modified: branches/S2_6/client/gui-gtk-3.0/pages.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.0/pages.c?rev=31191&r1=31190&r2=31191&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-3.0/pages.c    (original)
+++ branches/S2_6/client/gui-gtk-3.0/pages.c    Thu Dec 24 11:19:15 2015
@@ -1433,13 +1433,14 @@
 static GtkWidget *start_aifill_spin = NULL;
 
 
-/* NB: Must match creation arugments in connection_list_store_new(). */
+/* NB: Must match creation arguments in connection_list_store_new(). */
 enum connection_list_columns {
   CL_COL_PLAYER_NUMBER = 0,
   CL_COL_USER_NAME,
   CL_COL_READY_STATE,
   CL_COL_PLAYER_NAME,
   CL_COL_FLAG,
+  CL_COL_COLOR,
   CL_COL_NATION,
   CL_COL_TEAM,
   CL_COL_CONN_ID,
@@ -1461,6 +1462,7 @@
                             G_TYPE_BOOLEAN,     /* CL_COL_READY_STATE */
                             G_TYPE_STRING,      /* CL_COL_PLAYER_NAME */
                             GDK_TYPE_PIXBUF,    /* CL_COL_FLAG */
+                            GDK_TYPE_PIXBUF,    /* CL_COL_COLOR */
                             G_TYPE_STRING,      /* CL_COL_NATION */
                             G_TYPE_STRING,      /* CL_COL_TEAM */
                             G_TYPE_INT,         /* CL_COL_CONN_ID */
@@ -2306,7 +2308,7 @@
     GtkTreePath *path;
     GtkTreeIter child, prev_child, *pprev_child;
     GtkTreeIter parent, prev_parent, *pprev_parent = NULL;
-    GdkPixbuf *pixbuf;
+    GdkPixbuf *flag, *color;
     gboolean collapsed;
     struct player *pselected_player;
     struct connection *pselected_conn;
@@ -2323,7 +2325,8 @@
     players_iterate(pplayer) {
       conn_id = -1;
       access_level = ALLOW_NONE;
-      pixbuf = pplayer->nation ? get_flag(pplayer->nation) : NULL;
+      flag = pplayer->nation ? get_flag(pplayer->nation) : NULL;
+      color = create_player_icon(pplayer);
 
       conn_list_iterate(pplayer->connections, pconn) {
         if (pconn->playing == pplayer && !pconn->observer) {
@@ -2372,7 +2375,8 @@
                          CL_COL_USER_NAME, name,
                          CL_COL_READY_STATE, is_ready,
                          CL_COL_PLAYER_NAME, plr_name,
-                         CL_COL_FLAG, pixbuf,
+                         CL_COL_FLAG, flag,
+                         CL_COL_COLOR, color,
                          CL_COL_NATION, nation,
                          CL_COL_TEAM, team,
                          CL_COL_CONN_ID, conn_id,
@@ -2433,8 +2437,11 @@
 
       prev_parent = parent;
       pprev_parent = &prev_parent;
-      if (pixbuf) {
-        g_object_unref(pixbuf);
+      if (flag) {
+        g_object_unref(flag);
+      }
+      if (color) {
+        g_object_unref(color);
       }
     } players_iterate_end;
 
@@ -2683,6 +2690,8 @@
                CL_COL_PLAYER_NAME, NULL);
   add_tree_col(view, GDK_TYPE_PIXBUF, _("Flag"),
                CL_COL_FLAG, NULL);
+  add_tree_col(view, GDK_TYPE_PIXBUF, _("Border"),
+               CL_COL_COLOR, NULL);
   add_tree_col(view, G_TYPE_STRING, _("Nation"),
                CL_COL_NATION, NULL);
   add_tree_col(view, G_TYPE_STRING, _("Team"),

Modified: branches/S2_6/client/gui-gtk-3.0/plrdlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.0/plrdlg.c?rev=31191&r1=31190&r2=31191&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-3.0/plrdlg.c   (original)
+++ branches/S2_6/client/gui-gtk-3.0/plrdlg.c   Thu Dec 24 11:19:15 2015
@@ -105,16 +105,22 @@
   }
 }
 
-/**************************************************************************
-  Create pixbuf for player
-**************************************************************************/
-static GdkPixbuf *create_player_icon(const struct player *plr)
+/***************************************************************************
+  Create a small colored square representing the player color, for use
+  in player lists. 
+  May return NULL if the player has no color yet.
+***************************************************************************/
+GdkPixbuf *create_player_icon(const struct player *plr)
 {
   int width, height;
   GdkPixbuf *tmp;
   cairo_surface_t *surface;
   struct color *color;
   cairo_t *cr;
+
+  if (!player_has_color(tileset, plr)) {
+    return NULL;
+  }
 
   gtk_icon_size_lookup_for_settings(
       gtk_settings_get_for_screen(gtk_widget_get_screen(top_notebook)), 

Modified: branches/S2_6/client/gui-gtk-3.0/plrdlg.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.0/plrdlg.h?rev=31191&r1=31190&r2=31191&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-3.0/plrdlg.h   (original)
+++ branches/S2_6/client/gui-gtk-3.0/plrdlg.h   Thu Dec 24 11:19:15 2015
@@ -19,6 +19,7 @@
 
 /* Misc helper functions */
 GdkPixbuf *get_flag(const struct nation_type *pnation);
+GdkPixbuf *create_player_icon(const struct player *plr);
 
 extern struct gui_dialog *players_dialog_shell;
 


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to