Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2003:
[Freeciv-Dev] Re: (PR#3736) Pregame player list
Home

[Freeciv-Dev] Re: (PR#3736) Pregame player list

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients:;
Subject: [Freeciv-Dev] Re: (PR#3736) Pregame player list
From: "andrearo@xxxxxxxxxxxx" <andrearo@xxxxxxxxxxxx>
Date: Sat, 19 Apr 2003 11:59:53 -0700
Reply-to: rt@xxxxxxxxxxxxxx

Vasco Alexandre da Silva Costa wrote:

>[andrearo@xxxxxxxxxxxx - Sun Mar 16 10:18:19 2003]:
>
>I like it. I want some more IRC like features for the chat part.
>Nothing too fancy for now. Easy things first.
>
>But:
>* lose the icons. they are providing no info. they only confuse.
>* remove the TreeView header and use a label with a mnemonic for the list
>  instead (checkout the find dialog for this).
>
Sure, now I've made the list text-only and added a label instead.

To make sure that game.est_connections always contains
a correct list of connections, I had to change connecthand.c:
 -  struct conn_list *dest = &pconn->self;
+  struct conn_list *dest = &game.est_connections;
It solves the problem, but is this the correct way to do it?

Andreas Røsdal

diff -Nur -Xfreeciv-cvs-Apr-18/diff_ignore 
freeciv-cvs-Apr-18/client/gui-gtk-2.0/gui_main.c 
freeciv_changed/client/gui-gtk-2.0/gui_main.c
--- freeciv-cvs-Apr-18/client/gui-gtk-2.0/gui_main.c    2003-04-19 
06:57:11.000000000 +0200
+++ freeciv_changed/client/gui-gtk-2.0/gui_main.c       2003-04-19 
19:59:01.000000000 +0200
@@ -105,6 +105,14 @@
 GtkWidget *main_frame_civ_name;
 GtkWidget *main_label_info;
 
+static GtkWidget *avbox, *ahbox, *vbox, *conn_box;
+static GtkListStore *conn_list_model;       
+static GtkWidget *conn_list_view;           
+static GtkCellRenderer *conn_list_renderer;
+static GtkTreeViewColumn *conn_list_column; 
+static GtkTreeIter conn_list_iter;
+static GtkWidget* scroll_panel;
+
 GtkWidget *econ_label[10];
 GtkWidget *bulb_label;
 GtkWidget *sun_label;
@@ -147,6 +155,8 @@
 static void get_net_input(gpointer data, gint fid, GdkInputCondition 
condition);
 static void set_wait_for_writable_socket(struct connection *pc,
                                          bool socket_writable);
+void update_conn_list(void);
+void hide_conn_list(void);
 
 static void print_usage(const char *argv0);
 static void parse_options(int argc, char **argv);
@@ -644,8 +654,7 @@
 **************************************************************************/
 static void setup_widgets(void)
 {
-  GtkWidget *box, *ebox, *hbox, *vbox;
-  GtkWidget *avbox, *ahbox, *align;
+  GtkWidget *box, *ebox, *hbox, *sbox, *align, *conn_label;
   GtkWidget *frame, *table, *table2, *paned, *menubar, *sw, *text;
   GtkStyle *style;
   int i;
@@ -679,7 +688,7 @@
   avbox = detached_widget_fill(ahbox);
 
   align = gtk_alignment_new(0.5, 0.5, 0.0, 0.0);
-  gtk_box_pack_start(GTK_BOX(avbox), align, TRUE, TRUE, 0);
+  gtk_box_pack_start(GTK_BOX(avbox), align, FALSE, FALSE, 0);
 
   overview_canvas = gtk_drawing_area_new();
 
@@ -695,13 +704,44 @@
   g_signal_connect(overview_canvas, "button_press_event",
                   G_CALLBACK(butt_down_overviewcanvas), NULL);
 
+  /* Prepare list of connections in the pregame state. */
+  conn_label = g_object_new(GTK_TYPE_LABEL,
+                      "use-underline", TRUE,
+                      "mnemonic-widget", conn_list_view,
+                      "label", _("_Connected Players:"),
+                      "xalign", 0.0, "yalign", 0.5, NULL);
+  conn_list_model = gtk_list_store_new(1, G_TYPE_STRING); 
+  conn_list_view = gtk_tree_view_new_with_model(
+                         GTK_TREE_MODEL(conn_list_model));
+  gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(conn_list_view), false);
+  
+  /*  Add the player name column.  */
+  conn_list_renderer = gtk_cell_renderer_text_new();
+  conn_list_column = gtk_tree_view_column_new_with_attributes("connections",
+                 conn_list_renderer, "text", 0,  NULL);
+  gtk_tree_view_append_column(GTK_TREE_VIEW(conn_list_view),conn_list_column);
+  g_object_set(conn_list_renderer, "weight", "bold", NULL);
+  gtk_list_store_append(conn_list_model, &conn_list_iter);
+  
+  /* Display the list. */
+  conn_box = gtk_vbox_new(FALSE, 2);
+
+  scroll_panel = gtk_scrolled_window_new(NULL,NULL);
+  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_panel),
+                 GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
+  gtk_box_pack_start(GTK_BOX(conn_box), conn_label, FALSE, FALSE, 0);
+  gtk_container_add(GTK_CONTAINER(conn_box), scroll_panel);
+  gtk_container_add(GTK_CONTAINER(avbox), conn_box);
+  gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scroll_panel),
+                 conn_list_view);
+
   /* The Rest */
 
   ahbox = detached_widget_new();
   gtk_container_add(GTK_CONTAINER(vbox), ahbox);
   avbox = detached_widget_fill(ahbox);
 
-  /* Info on player's civilization */
+  /* Info on player's civilization, when game is running. */
   frame = gtk_frame_new(NULL);
   gtk_box_pack_start(GTK_BOX(avbox), frame, FALSE, FALSE, 0);
 
@@ -891,9 +931,9 @@
 
   /* *** The message window -- this is a detachable widget *** */
 
-  ahbox = detached_widget_new();
-  gtk_paned_pack2(GTK_PANED(paned), ahbox, TRUE, TRUE);
-  avbox = detached_widget_fill(ahbox);
+  sbox = detached_widget_new();
+  gtk_paned_pack2(GTK_PANED(paned), sbox, TRUE, TRUE);
+  avbox = detached_widget_fill(sbox);
 
   sw = gtk_scrolled_window_new(NULL, NULL);
   gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
@@ -942,9 +982,33 @@
     gtk_widget_hide(map_horizontal_scrollbar);
     gtk_widget_hide(map_vertical_scrollbar);
   }
+  gtk_widget_hide(ahbox);  /* Hide info on player's civ. in pregame */
+}
+
+/**************************************************************************
+ Update the list of connections in the pregame state.
+**************************************************************************/
+void update_conn_list(void) 
+{
+  gtk_list_store_clear(conn_list_model);
+  conn_list_iterate(game.est_connections, pconn)
+    gtk_list_store_append(conn_list_model, &conn_list_iter);
+    gtk_list_store_set(conn_list_model, &conn_list_iter, 0, pconn->username, 
-1);
+  conn_list_iterate_end;
+  gtk_widget_hide(ahbox);           /* hide info about civ */
+  gtk_widget_show(conn_box);        /* show connections    */
 }
 
 /**************************************************************************
+  Hide the view for connected players when the game starts.
+**************************************************************************/
+void hide_conn_list(void) 
+{
+  gtk_widget_hide(conn_box);
+  gtk_widget_show(ahbox);
+}
+
+/**************************************************************************
  called from main().
 **************************************************************************/
 void ui_init(void)
@@ -1334,4 +1398,7 @@
 {
   gtk_input_remove(input_id);
   gdk_window_set_cursor(root_window, NULL);
+  conn_list_init(&game.all_connections);
+  conn_list_init(&game.est_connections);
+  conn_list_init(&game.game_connections);
 }
diff -Nur -Xfreeciv-cvs-Apr-18/diff_ignore 
freeciv-cvs-Apr-18/client/gui-gtk-2.0/plrdlg.c 
freeciv_changed/client/gui-gtk-2.0/plrdlg.c
--- freeciv-cvs-Apr-18/client/gui-gtk-2.0/plrdlg.c      2003-04-19 
06:57:11.000000000 +0200
+++ freeciv_changed/client/gui-gtk-2.0/plrdlg.c 2003-04-19 18:49:20.000000000 
+0200
@@ -53,6 +53,9 @@
 static GtkWidget *players_sship_command;
 static GtkListStore *store;
 
+void update_conn_list(void);
+void hide_conn_list(void);
+
 static void create_players_dialog(void);
 static void players_meet_callback(GtkMenuItem *item, gpointer data);
 static void players_war_callback(GtkMenuItem *item, gpointer data);
@@ -526,9 +529,15 @@
 
         build_row(&iter, i);
       }
+    } 
+      update_players_menu();
+    } else {
+    /* update list of connected players in gui_main */
+    if (get_client_state() != CLIENT_GAME_RUNNING_STATE) {
+      update_conn_list();      
+    } else {
+      hide_conn_list();
     }
-
-    update_players_menu();
   }
 }
 

diff -Nur -Xfreeciv-cvs-Apr-18/diff_ignore 
freeciv-cvs-Apr-18/server/connecthand.c freeciv_changed/server/connecthand.c
--- freeciv-cvs-Apr-18/server/connecthand.c     2003-04-13 06:57:19.000000000 
+0200
+++ freeciv_changed/server/connecthand.c        2003-04-19 19:56:08.000000000 
+0200
@@ -50,7 +50,7 @@
 **************************************************************************/
 static void establish_new_connection(struct connection *pconn)
 {
-  struct conn_list *dest = &pconn->self;
+  struct conn_list *dest = &game.est_connections;
   struct player *pplayer;
   struct packet_login_reply packet;
   char hostname[512];

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