[Freeciv-Dev] Re: (PR#3736) Pregame player list
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Mike Kaufman wrote:
>On Sun, Apr 20, 2003 at 12:34:53AM -0700, andrearo@xxxxxxxxxxxx wrote:
>
>
>> {
>> 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);
>> }
>>
>>
>
>this shouldn't be here. It does appear that client_init() does not get
>called yet. Either don't update the list (and don't require the use of the
>conn lists) until handle_conn_info gets called (the best solution) or make
>these inits near the top of civclient.c,
>
The reason I used those functions was that the conn_lists are not
cleared when a client connects to a server in pregame, then disconnects
and connects to the same server in pregame state. However, I think
client_remove_all_cli_conn() can be used there instead. Right?
Is there anything else that could be changed? It would be nice to have
a teamname column as well..
Andreas Røsdal
diff -Nur -Xfreeciv-cvs-Apr-18/diff_ignore
freeciv-cvs-Apr-18/client/civclient.c freeciv-changed/client/civclient.c
--- freeciv-cvs-Apr-18/client/civclient.c 2003-04-21 22:43:54.000000000
+0200
+++ freeciv-changed/client/civclient.c 2003-04-21 22:40:58.000000000 +0200
@@ -99,7 +99,6 @@
*/
bool turn_done_sent = FALSE;
-static void client_remove_all_cli_conn(void);
/**************************************************************************
...
@@ -710,6 +709,7 @@
}
}
update_turn_done_button_state();
+ update_conn_list_model();
}
@@ -739,7 +739,7 @@
Remove (and free) all connections from all connection lists in client.
Assumes game.all_connections is properly maintained with all connections.
**************************************************************************/
-static void client_remove_all_cli_conn(void)
+void client_remove_all_cli_conn(void)
{
while (conn_list_size(&game.all_connections) > 0) {
struct connection *pconn = conn_list_get(&game.all_connections, 0);
diff -Nur -Xfreeciv-cvs-Apr-18/diff_ignore
freeciv-cvs-Apr-18/client/civclient.h freeciv-changed/client/civclient.h
--- freeciv-cvs-Apr-18/client/civclient.h 2003-04-21 22:43:54.000000000
+0200
+++ freeciv-changed/client/civclient.h 2003-04-21 22:08:30.000000000 +0200
@@ -38,6 +38,7 @@
enum client_states get_client_state(void);
void client_remove_cli_conn(struct connection *pconn);
+void client_remove_all_cli_conn(void);
extern char sound_plugin_name[512];
extern char sound_set_name[512];
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-21
22:43:54.000000000 +0200
+++ freeciv-changed/client/gui-gtk-2.0/gui_main.c 2003-04-21
22:40:29.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;
@@ -644,8 +652,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 +686,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 +702,43 @@
g_signal_connect(overview_canvas, "button_press_event",
G_CALLBACK(butt_down_overviewcanvas), NULL);
+ /* Prepare list of Connected Users in the pregame state. */
+ 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 column with username to Connected Users List. */
+ 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);
+ conn_label = g_object_new(GTK_TYPE_LABEL,
+ "use-underline", TRUE,
+ "mnemonic-widget", conn_list_view,
+ "label", _("_Connected Users:"),
+ "xalign", 0.0, "yalign", 0.5, NULL);
+ 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 +928,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,6 +979,27 @@
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 list-model for Connected Users in the pregame state.
+**************************************************************************/
+void update_conn_list_model(void)
+{
+ if (get_client_state() != CLIENT_GAME_RUNNING_STATE) {
+ 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);
+ gtk_widget_show(conn_box);
+ } else {
+ gtk_widget_hide(conn_box);
+ gtk_widget_show(ahbox);
+ }
}
/**************************************************************************
@@ -1334,4 +1392,6 @@
{
gtk_input_remove(input_id);
gdk_window_set_cursor(root_window, NULL);
+ client_remove_all_cli_conn();
+ update_conn_list_model();
}
diff -Nur -Xfreeciv-cvs-Apr-18/diff_ignore
freeciv-cvs-Apr-18/client/include/gui_main_g.h
freeciv-changed/client/include/gui_main_g.h
--- freeciv-cvs-Apr-18/client/include/gui_main_g.h 2003-04-21
22:43:54.000000000 +0200
+++ freeciv-changed/client/include/gui_main_g.h 2003-04-21 22:08:30.000000000
+0200
@@ -22,6 +22,7 @@
void sound_bell(void);
void add_net_input(int);
void remove_net_input(void);
+void update_conn_list_model(void);
void set_unit_icon(int idx, struct unit *punit);
void set_unit_icons_more_arrow(bool onoff);
diff -Nur -Xfreeciv-cvs-Apr-18/diff_ignore freeciv-cvs-Apr-18/client/packhand.c
freeciv-changed/client/packhand.c
--- freeciv-cvs-Apr-18/client/packhand.c 2003-04-21 22:43:54.000000000
+0200
+++ freeciv-changed/client/packhand.c 2003-04-21 22:38:39.000000000 +0200
@@ -1445,6 +1445,7 @@
sz_strlcpy(pconn->capability, pinfo->capability);
}
update_players_dialog();
+ update_conn_list_model();
}
/*************************************************************************
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-21 22:43:54.000000000
+0200
+++ freeciv-changed/server/connecthand.c 2003-04-21 22:08:30.000000000
+0200
@@ -64,9 +64,10 @@
/* "establish" the connection */
pconn->established = TRUE;
- conn_list_insert_back(&game.est_connections, pconn);
send_conn_info(dest, &game.est_connections);
-
+ conn_list_insert_back(&game.est_connections, pconn);
+ send_conn_info(&game.est_connections, dest);
+
/* introduce the server to the connection */
if (my_gethostname(hostname, sizeof(hostname)) == 0) {
notify_conn(dest, _("Welcome to the %s Server running at %s port %d."),
- [Freeciv-Dev] (PR#3736) Pregame player list, Vasco Alexandre da Silva Costa, 2003/04/18
- Message not available
- [Freeciv-Dev] Re: (PR#3736) Pregame player list, andrearo@xxxxxxxxxxxx, 2003/04/19
- Message not available
- [Freeciv-Dev] Re: (PR#3736) Pregame player list, Mike Kaufman, 2003/04/19
- Message not available
- [Freeciv-Dev] Re: (PR#3736) Pregame player list, andrearo@xxxxxxxxxxxx, 2003/04/20
- Message not available
- [Freeciv-Dev] Re: (PR#3736) Pregame player list, Mike Kaufman, 2003/04/21
- Message not available
- [Freeciv-Dev] Re: (PR#3736) Pregame player list,
andrearo@xxxxxxxxxxxx <=
- Message not available
- [Freeciv-Dev] Re: (PR#3736) Pregame player list, Mike Kaufman, 2003/04/21
- Message not available
- [Freeciv-Dev] Re: (PR#3736) Pregame player list, andrearo@xxxxxxxxxxxx, 2003/04/24
|
|