[Freeciv-Dev] (PR#13144) Show and hide dead players in the players dialo
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: |
[Freeciv-Dev] (PR#13144) Show and hide dead players in the players dialog |
From: |
"Mateusz Stefek" <mstefek@xxxxxxxxx> |
Date: |
Thu, 19 May 2005 12:59:24 -0700 |
Reply-to: |
bugs@xxxxxxxxxxx |
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13144 >
With the attached patch the players dialog can hide or display rows
with dead players.
This was requested by many.
--
mateusz
Pliki binarne orig/client/civclient i freeciv/client/civclient siê ró¿ni±
Tylko w freeciv/client: .cvsignore
Tylko w freeciv/client: .deps
Pliki binarne orig/client/gui-gtk-2.0/libguiclient.a i
freeciv/client/gui-gtk-2.0/libguiclient.a siê ró¿ni±
diff -ur orig/client/gui-gtk-2.0/plrdlg.c freeciv/client/gui-gtk-2.0/plrdlg.c
--- orig/client/gui-gtk-2.0/plrdlg.c 2005-05-18 16:24:55.000000000 +0200
+++ freeciv/client/gui-gtk-2.0/plrdlg.c 2005-05-18 16:19:48.000000000 +0200
@@ -256,6 +256,16 @@
update_views();
}
+/*************************************************************************
+ Called whenever player toggles the 'Show/Dead Players' menu item
+*************************************************************************/
+static void toggle_dead_players(GtkCheckMenuItem* item, gpointer data)
+{
+ player_dlg_show_dead_players =
+ gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item));
+ update_players_dialog();
+}
+
/**************************************************************************
...
**************************************************************************/
@@ -263,9 +273,9 @@
{
int i;
GtkWidget *menu = gtk_menu_new();
-
+ GtkWidget *item;
+
for (i = 1; i < num_player_dlg_columns; i++) {
- GtkWidget *item;
struct player_dlg_column *pcol;
pcol = &player_dlg_columns[i];
@@ -274,6 +284,16 @@
gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
g_signal_connect(item, "toggled", G_CALLBACK(toggle_view), pcol);
}
+
+ item = gtk_separator_menu_item_new();
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
+
+ item = gtk_check_menu_item_new_with_label(Q_("?show:Dead Players"));
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item),
+ player_dlg_show_dead_players);
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
+ g_signal_connect(item, "toggled", G_CALLBACK(toggle_dead_players), NULL);
+
return menu;
}
@@ -578,6 +598,15 @@
-1);
}
+/**************************************************************************
+...
+**************************************************************************/
+static bool player_should_be_shown(int plrno) {
+ return is_valid_player_id(plrno)
+ && (player_dlg_show_dead_players
+ || game.players[plrno].is_alive)
+ && (!is_barbarian(&game.players[plrno]));
+}
/**************************************************************************
...
@@ -605,11 +634,11 @@
/*
* The nation already had a row in the player report. In that
- * case we just update the row.
+ * case we just update the row. If player is dead we remove him
+ * if necessary.
*/
- if (is_valid_player_id(plrno)) {
+ if (player_should_be_shown(plrno)) {
exists[plrno] = TRUE;
-
build_row(&it, plrno);
} else {
gtk_list_store_remove(store, &it);
@@ -620,7 +649,7 @@
players_iterate(pplayer) {
/* skip barbarians */
- if (!is_barbarian(pplayer)) {
+ if (player_should_be_shown(pplayer->player_no)) {
if (!exists[pplayer->player_no]) {
/*
* A nation is not in the player report yet. This happens when
Pliki binarne orig/client/gui-gtk-2.0/plrdlg.o i
freeciv/client/gui-gtk-2.0/plrdlg.o siê ró¿ni±
diff -ur orig/client/options.c freeciv/client/options.c
--- orig/client/options.c 2005-05-11 21:31:37.000000000 +0200
+++ freeciv/client/options.c 2005-05-18 15:53:32.000000000 +0200
@@ -456,12 +456,17 @@
message_options_load(&sf, prefix);
+ /* Players dialog */
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);
}
-
+
+ player_dlg_show_dead_players =
+ secfile_lookup_bool_default(&sf, TRUE, "%s.player_dlg_show_dead_players",
+ prefix);
+
/* 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 */
num = secfile_lookup_int_default(&sf, -1, "cma.number_of_presets");
@@ -568,11 +573,15 @@
city_report_spec_tagname(i));
}
+ /* Players dialog */
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);
}
+
+ secfile_insert_bool(&sf, player_dlg_show_dead_players,
+ "client.player_dlg_show_dead_players");
/* insert global worklists */
for(i = 0; i < MAX_NUM_WORKLISTS; i++){
Pliki binarne orig/client/options.o i freeciv/client/options.o siê ró¿ni±
diff -ur orig/client/plrdlg_common.c freeciv/client/plrdlg_common.c
--- orig/client/plrdlg_common.c 2005-05-05 22:26:13.000000000 +0200
+++ freeciv/client/plrdlg_common.c 2005-05-18 15:50:41.000000000 +0200
@@ -31,6 +31,8 @@
static int frozen_level = 0;
+bool player_dlg_show_dead_players = TRUE;
+
/******************************************************************
Turn off updating of player dialog
*******************************************************************/
diff -ur orig/client/plrdlg_common.h freeciv/client/plrdlg_common.h
--- orig/client/plrdlg_common.h 2004-12-17 10:13:54.000000000 +0100
+++ freeciv/client/plrdlg_common.h 2005-05-18 15:50:16.000000000 +0200
@@ -42,6 +42,8 @@
extern struct player_dlg_column player_dlg_columns[];
extern const int num_player_dlg_columns;
+extern bool player_dlg_show_dead_players;
+
void init_player_dlg_common(void);
int player_dlg_default_sort_column(void);
Pliki binarne orig/client/plrdlg_common.o i freeciv/client/plrdlg_common.o siê
ró¿ni±
- [Freeciv-Dev] (PR#13144) Show and hide dead players in the players dialog,
Mateusz Stefek <=
|
|