Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2004:
[Freeciv-Dev] (PR#8539) Too wide players dialog (solution)
Home

[Freeciv-Dev] (PR#8539) Too wide players dialog (solution)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#8539) Too wide players dialog (solution)
From: "Mateusz Stefek" <mstefek@xxxxxxxxx>
Date: Sun, 18 Apr 2004 04:52:27 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=8539 >

Attached patch allows user to select which column should be visible in  
players dialog (sometimes it becomes to wide for 1024x800). It is done  
in the same way as in city report.

The patch moves much code into plrdlg_common.c . New common code is  
used currently only by gtk-2 client. Other clients still compile and  
work ok, but lack the new functionality.

--
mateusz
Tylko w freeciv: civ
diff -ur -Xdiff_ignore freeorig/client/civclient.c freeciv/client/civclient.c
--- freeorig/client/civclient.c 2004-04-12 21:17:26.000000000 +0200
+++ freeciv/client/civclient.c  2004-04-18 11:13:38.000000000 +0200
@@ -217,6 +217,7 @@
   my_init_network();
   init_messages_where();
   init_city_report_data();
+  init_player_dlg_common();
   settable_options_init();
 
   load_general_options();
diff -ur -Xdiff_ignore freeorig/client/gui-gtk-2.0/plrdlg.c 
freeciv/client/gui-gtk-2.0/plrdlg.c
--- freeorig/client/gui-gtk-2.0/plrdlg.c        2004-04-02 08:34:42.000000000 
+0200
+++ freeciv/client/gui-gtk-2.0/plrdlg.c 2004-04-18 13:39:30.000000000 +0200
@@ -63,10 +63,8 @@
 static void players_intel_callback(GtkMenuItem *item, gpointer data);
 static void players_sship_callback(GtkMenuItem *item, gpointer data);
 
-#define NUM_COLUMNS 14                /* number of columns in total */
-#define DEF_SORT_COLUMN 2             /* default sort column (2 = nation) */
-#define COLOR_COLUMN (NUM_COLUMNS)    /* color column */
-#define PLRNO_COLUMN (NUM_COLUMNS+1)  /* plrno column */
+
+static void update_views(void);
 
 /**************************************************************************
 popup the dialog 10% inside the main-window 
@@ -110,7 +108,7 @@
     struct player *plr;
     gint plrno;
 
-    gtk_tree_model_get(model, &it, PLRNO_COLUMN, &plrno, -1);
+    gtk_tree_model_get(model, &it, (NUM_PLAYER_DLG_COLUMNS+1), &plrno, -1);
     plr = &game.players[plrno];
   
     if (plr->spaceship.state != SSHIP_NONE) {
@@ -168,7 +166,7 @@
       gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &it, path);
       gtk_tree_path_free(path);
 
-      gtk_tree_model_get(GTK_TREE_MODEL(store), &it, PLRNO_COLUMN, &id, -1);
+      gtk_tree_model_get(GTK_TREE_MODEL(store), &it, 
(NUM_PLAYER_DLG_COLUMNS+1), &id, -1);
       plr = get_player(id);
 
       if (ev->button == 1) {
@@ -183,59 +181,72 @@
   return FALSE;
 }
 
+static void create_store(void)
+{
+  int num = NUM_PLAYER_DLG_COLUMNS;
+  GType* model_types = fc_malloc((num + 2) * sizeof(GType));
+  int i;
+  for (i = 0; i < num; i++) {
+    switch (player_dlg_columns[i].type) {
+    case COL_FLAG:
+      model_types[i] = GDK_TYPE_PIXBUF; break;
+    case COL_COLOR:
+      model_types[i] = GDK_TYPE_COLOR; break;
+    case COL_BOOLEAN:
+      model_types[i] = G_TYPE_BOOLEAN; break;
+    case COL_TEXT:
+    case COL_RIGHT_TEXT:
+      model_types[i] = G_TYPE_STRING; break;
+    }
+  }
+  /* special (invisible rows) - Text color and player id */
+  model_types[num] = GDK_TYPE_COLOR;
+  model_types[num+1] = G_TYPE_INT;
+  
+  store = gtk_list_store_newv(num+2, model_types);  
+  free(model_types);
+}
+
 /**************************************************************************
 ...
 **************************************************************************/
-void create_players_dialog(void)
+static void toggle_view(GtkCheckMenuItem* item, gpointer data)
 {
-  static char *titles[NUM_COLUMNS] = {
-    N_("Name"),
-    N_("Flag"),
-    N_("Nation"),
-    N_("Border"),
-    N_("Team"),
-    N_("AI"),
-    N_("Embassy"),
-    N_("Dipl.State"),
-    N_("Vision"),
-    N_("Reputation"),
-    N_("State"),
-    N_("Host"),
-    N_("Idle"),
-    N_("Ping")
-  };
-  static bool titles_done;
-
-  static GType model_types[NUM_COLUMNS+2] = {
-    G_TYPE_STRING,
-    G_TYPE_NONE,
-    G_TYPE_STRING,
-    G_TYPE_NONE,
-    G_TYPE_STRING,
-    G_TYPE_BOOLEAN,
-    G_TYPE_STRING,
-    G_TYPE_STRING,
-    G_TYPE_STRING,
-    G_TYPE_STRING,
-    G_TYPE_STRING,
-    G_TYPE_STRING,
-    G_TYPE_INT,
-    G_TYPE_STRING,
-    G_TYPE_NONE,
-    G_TYPE_INT
-  };
+  struct player_dlg_column* pcol = data;
+  pcol->show = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item));
+  update_views();
+}
 
+/**************************************************************************
+...
+**************************************************************************/
+static GtkWidget* create_show_menu(void)
+{
+  int i;
+  GtkWidget* menu = gtk_menu_new();
+  for (i = 1; i < NUM_PLAYER_DLG_COLUMNS; i++) {
+    GtkWidget* item;    
+    struct player_dlg_column* pcol;
+    
+    pcol = &player_dlg_columns[i];
+    item = gtk_check_menu_item_new_with_label(pcol->title);
+    gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), pcol->show);
+    gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
+    g_signal_connect(item, "toggled", G_CALLBACK(toggle_view), (gpointer)pcol);
+  }
+  return menu;
+}
+
+/**************************************************************************
+...
+**************************************************************************/
+void create_players_dialog(void)
+{
   int i;
   GtkAccelGroup *accel = gtk_accel_group_new();
   GtkWidget *sep, *sw;
   GtkWidget *menubar, *menu, *item;
 
-  model_types[1] = GDK_TYPE_PIXBUF;
-  model_types[3] = GDK_TYPE_COLOR;
-  model_types[COLOR_COLUMN] = GDK_TYPE_COLOR;
-
-  intl_slist(ARRAY_SIZE(titles), titles, &titles_done);
-
   players_dialog_shell = gtk_dialog_new_with_buttons(_("Players"),
     NULL,
     0,
@@ -254,7 +265,7 @@
   g_signal_connect_swapped(players_dialog_shell, "response",
     G_CALLBACK(gtk_widget_destroy), GTK_OBJECT(players_dialog_shell));
 
-  store = gtk_list_store_newv(ARRAY_SIZE(model_types), model_types);
+  create_store();
 
   players_list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
   g_object_unref(store);
@@ -265,35 +276,42 @@
   g_signal_connect(players_list, "button_press_event",
       G_CALLBACK(button_press_callback), NULL);
 
-  for (i = 0; i < NUM_COLUMNS; i++) {
+  for (i = 0; i < NUM_PLAYER_DLG_COLUMNS; i++) {
+    struct player_dlg_column* pcol = &player_dlg_columns[i];
     GtkCellRenderer *renderer;
     GtkTreeViewColumn *col;
 
-    if (model_types[i] == GDK_TYPE_PIXBUF) {
+    switch (pcol->type) {
+    case COL_FLAG:
       renderer = gtk_cell_renderer_pixbuf_new();
 
-      col = gtk_tree_view_column_new_with_attributes(titles[i], renderer,
-        "pixbuf", i, NULL);
-    } else if (model_types[i] == G_TYPE_BOOLEAN) {
+      col = gtk_tree_view_column_new_with_attributes(pcol->title,
+         renderer, "pixbuf", i, NULL);
+      break;
+    case COL_BOOLEAN:
       renderer = gtk_cell_renderer_toggle_new();
 
-      col = gtk_tree_view_column_new_with_attributes(titles[i], renderer,
+      col = gtk_tree_view_column_new_with_attributes(pcol->title, renderer,
         "active", i, NULL);
-    } else if (model_types[i] == GDK_TYPE_COLOR) {
+      break;
+    case COL_COLOR:
       renderer = gtk_cell_renderer_text_new();
 
-      col = gtk_tree_view_column_new_with_attributes(titles[i], renderer,
+      col = gtk_tree_view_column_new_with_attributes(pcol->title, renderer,
              "background-gdk", i, NULL);
-    } else {
+      break;
+    case COL_TEXT:
+    case COL_RIGHT_TEXT:
       renderer = gtk_cell_renderer_text_new();
       g_object_set(renderer, "weight", "bold", NULL);
 
-      col = gtk_tree_view_column_new_with_attributes(titles[i], renderer,
-        "text", i, "foreground-gdk", COLOR_COLUMN, NULL);
+      col = gtk_tree_view_column_new_with_attributes(pcol->title, renderer,
+        "text", i, "foreground-gdk", NUM_PLAYER_DLG_COLUMNS, NULL);
       gtk_tree_view_column_set_sort_column_id(col, i);
+      break;
     }
-
-    if (model_types[i] == G_TYPE_INT || i == 12) {
+    
+    if (pcol->type == COL_RIGHT_TEXT) {
       g_object_set(renderer, "xalign", 1.0, NULL);
       gtk_tree_view_column_set_alignment(col, 1.0);
     }
@@ -301,7 +319,8 @@
     gtk_tree_view_append_column(GTK_TREE_VIEW(players_list), col);
   }
 
-  gtk_tree_view_set_search_column(GTK_TREE_VIEW(players_list), 
DEF_SORT_COLUMN);
+  gtk_tree_view_set_search_column(GTK_TREE_VIEW(players_list),
+                                  player_dlg_default_sort_column());
 
   sw = gtk_scrolled_window_new(NULL, NULL);
   gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
@@ -349,6 +368,11 @@
   gtk_widget_set_sensitive(players_sship_command, FALSE);
   gtk_menu_shell_append(GTK_MENU_SHELL(menu), players_sship_command);
 
+  item = gtk_menu_item_new_with_mnemonic(_("S_how"));
+  menu = create_show_menu();
+  gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu);
+  gtk_menu_shell_append(GTK_MENU_SHELL(menubar), item);
+
   gtk_widget_add_accelerator(players_int_command,
     "activate", accel, GDK_I, 0, GTK_ACCEL_VISIBLE);
   gtk_widget_add_accelerator(players_meet_command,
@@ -431,87 +455,40 @@
  */
 static void build_row(GtkTreeIter *it, int i)
 {
-  static char dsbuf[32];
-  gchar *team, *state;
-  const struct player_diplstate *pds;
-  gint idle;
   struct player *plr = get_player(i);
   GdkPixbuf *flag;
   GdkColor *state_col;
-  GValue value = { 0, };
-
-  /* the team */
-  if (plr->team != TEAM_NONE) {
-    team = team_get_by_id(plr->team)->name;
-  } else {
-    team = "";
-  }
-
-  gtk_list_store_set(store, it,
-    0, (gchar *)plr->name,                   /* the playername */
-    2, (gchar *)get_nation_name(plr->nation), /* the nation */
-    3, colors_standard[player_color(plr)],    /* the color */
-    4, (gchar *)team,
-    PLRNO_COLUMN, (gint)i,                   /* the playerid */
-    -1);
-
-  /* text for diplstate type and turns -- not applicable if this is me */
-  if (i == game.player_idx) {
-    strcpy(dsbuf, "-");
-  } else {
-    pds = pplayer_get_diplstate(game.player_ptr, plr);
-    if (pds->type == DS_CEASEFIRE) {
-      my_snprintf(dsbuf, sizeof(dsbuf), "%s (%d)",
-                 diplstate_text(pds->type), pds->turns_left);
-    } else {
-      my_snprintf(dsbuf, sizeof(dsbuf), "%s", diplstate_text(pds->type));
-    }
-  }
+  int k;
+  gchar* p;
 
-  /* text for state */
-  if (plr->is_alive) {
-    if (plr->is_connected) {
-      if (plr->turn_done) {
-       state = _("done");
-      } else {
-       state = _("moving");
-      }
-    } else {
-      state = "";
+  for (k = 0; k < NUM_PLAYER_DLG_COLUMNS; k++) {
+    struct player_dlg_column* pcol = &player_dlg_columns[k];
+    switch(pcol->type) {
+      case COL_TEXT:
+      case COL_RIGHT_TEXT:
+        p = (gchar*)(pcol->func(plr));
+       gtk_list_store_set(store, it, k, p, -1);
+       break;
+      case COL_FLAG:
+        flag = get_flag(get_nation_by_plr(plr));
+        gtk_list_store_set(store, it, k, flag, -1);
+        g_object_unref(flag);
+       break;
+      case COL_COLOR:
+        gtk_list_store_set(store, it, k,
+                          colors_standard[player_color(plr)], -1);
+       break;
+      case COL_BOOLEAN:
+        gtk_list_store_set(store, it, k, (gboolean)pcol->bool_func(plr), -1);
+       break;
     }
-  } else {
-    state = _("R.I.P");
   }
 
-  /* text for idleness */
-  if (plr->nturns_idle > 3) {
-    idle = plr->nturns_idle - 1;
-  } else {
-    idle = 0;
-  }
-
-  /* assemble the whole lot */
-  g_value_init(&value, G_TYPE_STRING);
-  g_value_set_static_string(&value, state);
-  gtk_list_store_set_value(store, it, 10, &value);
-  g_value_unset(&value);
-
+  /* The playerid */
   gtk_list_store_set(store, it,
-     5, (gboolean)plr->ai.control,
-     6, (gchar *)get_embassy_status(game.player_ptr, plr),
-     7, (gchar *)dsbuf,
-     8, (gchar *)get_vision_status(game.player_ptr, plr),
-     9, (gchar *)reputation_text(plr->reputation),
-    11, (gchar *)player_addr_hack(plr),                    /* Fixme */
-    12, (gint)idle,
-    13, (gchar *)get_ping_time_text(plr),
+    NUM_PLAYER_DLG_COLUMNS+1, (gint)i,
     -1);
 
-   /* set flag. */
-   flag = get_flag(get_nation_by_plr(plr));
-   gtk_list_store_set(store, it, 1, flag, -1);
-   g_object_unref(flag);
-
    /* now add some eye candy ... */
    switch (pplayer_get_diplstate(game.player_ptr, plr)->type) {
    case DS_WAR:
@@ -524,7 +501,7 @@
    default:
      state_col = colors_standard[COLOR_STD_BLACK];
    }
-   gtk_list_store_set(store, it, COLOR_COLUMN, state_col, -1);
+   gtk_list_store_set(store, it, NUM_PLAYER_DLG_COLUMNS, state_col, -1);
 }
 
 
@@ -549,7 +526,7 @@
       it_next = it;
       itree_next(&it_next);
 
-      itree_get(&it, PLRNO_COLUMN, &plrno, -1);
+      itree_get(&it, (NUM_PLAYER_DLG_COLUMNS+1), &plrno, -1);
 
       /*
        * The nation already had a row in the player report. In that
@@ -586,6 +563,7 @@
     }
 
     update_players_menu();
+    update_views();
   }
 }
 
@@ -602,7 +580,7 @@
   if (!gtk_tree_selection_get_selected(players_selection, &model, &it)) {
     return;
   }
-  gtk_tree_model_get(model, &it, PLRNO_COLUMN, &plrno, -1);
+  gtk_tree_model_get(model, &it, (NUM_PLAYER_DLG_COLUMNS+1), &plrno, -1);
 
   dsend_packet_diplomacy_init_meeting_req(&aconnection, plrno);
 }
@@ -618,7 +596,7 @@
   if (gtk_tree_selection_get_selected(players_selection, &model, &it)) {
     gint plrno;
 
-    gtk_tree_model_get(model, &it, PLRNO_COLUMN, &plrno, -1);
+    gtk_tree_model_get(model, &it, (NUM_PLAYER_DLG_COLUMNS+1), &plrno, -1);
 
     /* can be any pact clause */
     dsend_packet_diplomacy_cancel_pact(&aconnection, plrno,
@@ -637,7 +615,7 @@
   if (gtk_tree_selection_get_selected(players_selection, &model, &it)) {
     gint plrno;
 
-    gtk_tree_model_get(model, &it, PLRNO_COLUMN, &plrno, -1);
+    gtk_tree_model_get(model, &it, (NUM_PLAYER_DLG_COLUMNS+1), &plrno, -1);
 
     dsend_packet_diplomacy_cancel_pact(&aconnection, plrno, CLAUSE_VISION);
   }
@@ -654,7 +632,7 @@
 
   if (!gtk_tree_selection_get_selected(players_selection, &model, &it))
     return;
-  gtk_tree_model_get(model, &it, PLRNO_COLUMN, &plrno, -1);
+  gtk_tree_model_get(model, &it, (NUM_PLAYER_DLG_COLUMNS+1), &plrno, -1);
 
   if (can_intel_with_player(&game.players[plrno])) {
     popup_intel_dialog(&game.players[plrno]);
@@ -672,7 +650,17 @@
 
   if (!gtk_tree_selection_get_selected(players_selection, &model, &it))
     return;
-  gtk_tree_model_get(model, &it, PLRNO_COLUMN, &plrno, -1);
+  gtk_tree_model_get(model, &it, (NUM_PLAYER_DLG_COLUMNS+1), &plrno, -1);
 
   popup_spaceship_dialog(&game.players[plrno]);
 }
+
+static void update_views(void)
+{
+  int i;
+  for (i = 0; i < NUM_PLAYER_DLG_COLUMNS; i++) {
+    GtkTreeViewColumn *col;
+    col = gtk_tree_view_get_column(GTK_TREE_VIEW(players_list), i);
+    gtk_tree_view_column_set_visible(col, player_dlg_columns[i].show);
+  }
+};
diff -ur -Xdiff_ignore freeorig/client/options.c freeciv/client/options.c
--- freeorig/client/options.c   2004-04-03 09:26:41.000000000 +0200
+++ freeciv/client/options.c    2004-04-18 11:23:55.000000000 +0200
@@ -37,6 +37,7 @@
 #include "civclient.h"
 #include "clinet.h"
 #include "cma_fec.h"
+#include "plrdlg_common.h"
 #include "tilespec.h"
 
 #include "options.h"
@@ -478,6 +479,12 @@
     *ip = secfile_lookup_bool_default(&sf, *ip, "%s.city_report_%s", prefix,
                                     city_report_spec_tagname(i));
   }
+  
+  for(i = 1; i < NUM_PLAYER_DLG_COLUMNS; i++) {
+    bool *show = &(player_dlg_columns[i].show);
+    *show = secfile_lookup_bool_default(&sf, *show, "%s.player_dlg_%s", prefix,
+                                        player_dlg_columns[i].tagname);
+  }
 
   /* Load cma presets. If cma.number_of_presets doesn't exist, don't load 
    * any, the order here should be reversed to keep the order the same */
@@ -573,6 +580,12 @@
                       "client.city_report_%s",
                       city_report_spec_tagname(i));
   }
+  
+  for (i = 1; i < NUM_PLAYER_DLG_COLUMNS; i++) {
+    secfile_insert_bool(&sf, player_dlg_columns[i].show,
+                        "client.player_dlg_%s",
+                        player_dlg_columns[i].tagname);
+  }
 
   /* insert global worklists */
   for(i = 0; i < MAX_NUM_WORKLISTS; i++){
diff -ur -Xdiff_ignore freeorig/client/plrdlg_common.c 
freeciv/client/plrdlg_common.c
--- freeorig/client/plrdlg_common.c     2002-11-14 10:14:51.000000000 +0100
+++ freeciv/client/plrdlg_common.c      2004-04-18 13:42:14.000000000 +0200
@@ -22,6 +22,8 @@
 #include "game.h"
 #include "support.h"
 
+#include "climisc.h"
+
 #include "plrdlg_g.h"
 
 #include "plrdlg_common.h"
@@ -65,8 +67,102 @@
   return frozen_level > 0;
 }
 
+static const char *col_name(struct player *player)
+{
+  return player->name;
+}
+
+static const char *col_nation(struct player *player)
+{
+  return get_nation_name(player->nation);
+}
+
+static const char *col_team(struct player *player)
+{
+  if (player->team != TEAM_NONE) {
+    return team_get_by_id(player->team)->name;
+  } else {
+    return "";
+  }
+}
+
+static bool col_ai(struct player *plr)
+{
+  return plr->ai.control;
+}
+
+static const char *col_embassy(struct player *player)
+{
+  return get_embassy_status(game.player_ptr, player);
+}
+
+static const char *col_diplstate(struct player *player)
+{
+  static char buf[100];
+  const struct player_diplstate *pds;
+
+  if (player == game.player_ptr) {
+    return "-";
+  } else {
+    pds = pplayer_get_diplstate(game.player_ptr, player);
+    if (pds->type == DS_CEASEFIRE) {
+      my_snprintf(buf, sizeof(buf), "%s (%d)",
+                 diplstate_text(pds->type), pds->turns_left);
+      return buf;
+    } else {
+      return diplstate_text(pds->type);
+    }
+  }
+}
+
+static const char *col_vision(struct player *player)
+{
+  return get_vision_status(game.player_ptr, player);
+}
+
+static const char *col_reputation(struct player *player)
+{
+  return reputation_text(player->reputation);
+}
+
+static const char *col_state(struct player *plr)
+{
+  if (plr->is_alive) {
+    if (plr->is_connected) {
+      if (plr->turn_done) {
+       return _("done");
+      } else {
+       return _("moving");
+      }
+    } else {
+      return "";
+    }
+  } else {
+    return _("R.I.P");
+  }
+}
+
+static const char *col_host(struct player *player)
+{
+  return player_addr_hack(player);
+}
+
+static const char *col_idle(struct player *plr)
+{
+  int idle;
+  static char buf[100];
+  if (plr->nturns_idle > 3) {
+    idle = plr->nturns_idle - 1;
+  } else {
+    idle = 0;
+  }
+  my_snprintf(buf, sizeof(buf), "%d", idle);
+  return buf;
+}
+
 /******************************************************************
- ...
+  TODO: When the new common code for players dialog is finally used
+  by all clients make this function static and name it col_ping().
 *******************************************************************/
 const char *get_ping_time_text(struct player *pplayer)
 {
@@ -85,3 +181,36 @@
   }
   return buffer;
 }
+
+struct player_dlg_column player_dlg_columns[NUM_PLAYER_DLG_COLUMNS] = {
+  {TRUE, COL_TEXT, N_("?Player:Name"), col_name, NULL, "name"},
+  {TRUE, COL_FLAG, N_("Flag"), NULL, NULL, "flag"},
+  {TRUE, COL_TEXT, N_("Nation"), col_nation, NULL, "nation"},
+  {TRUE, COL_COLOR, N_("Border"), NULL, NULL, "border"},
+  {TRUE, COL_TEXT, N_("Team"), col_team, NULL, "team"},
+  {TRUE, COL_BOOLEAN, N_("AI"), NULL, col_ai, "ai"},
+  {TRUE, COL_TEXT, N_("Embassy"), col_embassy, NULL, "embassy"},
+  {TRUE, COL_TEXT, N_("Dipl.State"), col_diplstate, NULL, "diplstate"},
+  {TRUE, COL_TEXT, N_("Vision"), col_vision, NULL, "vision"},
+  {TRUE, COL_TEXT, N_("Reputation"), col_reputation, NULL, "reputation"},
+  {TRUE, COL_TEXT, N_("State"), col_state, NULL, "state"},
+  {TRUE, COL_TEXT, N_("?Player_dlg:Host"), col_host, NULL, "host"},
+  {TRUE, COL_RIGHT_TEXT, N_("?Player_dlg:Idle"), col_idle, NULL, "idle"},
+  {TRUE, COL_RIGHT_TEXT, N_("Ping"), get_ping_time_text, NULL, "ping"}
+};
+
+int player_dlg_default_sort_column(void)
+{
+  return 2;
+}
+
+/****************************************************************************
+  Translate all titles
+****************************************************************************/
+void init_player_dlg_common()
+{
+  int i;
+  for (i = 0; i < NUM_PLAYER_DLG_COLUMNS; i++) {
+    player_dlg_columns[i].title = Q_(player_dlg_columns[i].title);
+  }
+}
diff -ur -Xdiff_ignore freeorig/client/plrdlg_common.h 
freeciv/client/plrdlg_common.h
--- freeorig/client/plrdlg_common.h     2002-11-11 11:00:47.000000000 +0100
+++ freeciv/client/plrdlg_common.h      2004-04-18 13:11:34.000000000 +0200
@@ -21,6 +21,29 @@
 void plrdlg_thaw(void);
 void plrdlg_force_thaw(void);
 bool is_plrdlg_frozen(void);
+
+enum player_dlg_column_type {
+    COL_FLAG,
+    COL_COLOR,
+    COL_BOOLEAN,
+    COL_TEXT,
+    COL_RIGHT_TEXT    /* right aligned text */
+};
+
+struct player_dlg_column {
+    bool show;
+    enum player_dlg_column_type type;
+    const char *title;               /* already translated */
+    const char *(*func)(struct player*); /* if type = COL_*TEXT */
+    bool (*bool_func)(struct player*);   /* if type = COL_BOOLEAN */
+    const char *tagname;             /* for save_options */
+};
+
+extern struct player_dlg_column player_dlg_columns[];
+#define NUM_PLAYER_DLG_COLUMNS 14
+
 const char *get_ping_time_text(struct player *pplayer);
+void init_player_dlg_common(void);
+int player_dlg_default_sort_column(void);
 
 #endif  /* FC__PLRDLG_COMMON_H */
Tylko w freeciv: ser

[Prev in Thread] Current Thread [Next in Thread]