--- client/packhand.c 3 Jan 2003 08:58:47 -0000 1.268 +++ client/packhand.c 4 Jan 2003 00:09:30 -0000 @@ -1181,6 +1181,43 @@ /************************************************************************** ... **************************************************************************/ +static bool government_selected = FALSE; +static int government_choice; + +/************************************************************************** +... +**************************************************************************/ +void set_government_choice(int government) +{ + struct packet_player_request packet; + + if (!government_selected) { + send_packet_player_request(&aconnection, &packet, PACKET_PLAYER_REVOLUTION); + government_selected = TRUE; + } + government_choice = government; +} + +/**************************************************************** +... +*****************************************************************/ +static bool government_chosen(void) +{ + if (government_selected) { + struct packet_player_request packet; + + packet.government = government_choice; + send_packet_player_request(&aconnection, &packet, PACKET_PLAYER_GOVERNMENT); + + government_selected = FALSE; + return TRUE; + } + return FALSE; +} + +/************************************************************************** +... +**************************************************************************/ void handle_player_info(struct packet_player_info *pinfo) { int i; @@ -1266,7 +1303,10 @@ (!game.player_ptr->ai.control || ai_popup_windows) && can_client_change_view()) { create_event(-1, -1, E_REVOLT_DONE, _("Game: Revolution finished")); - popup_government_dialog(); + + if (!government_chosen()) { + popup_government_dialog(); + } } update_players_dialog(); --- client/packhand.h 11 Nov 2002 10:00:47 -0000 1.30 +++ client/packhand.h 4 Jan 2003 00:09:30 -0000 @@ -72,4 +72,6 @@ int packet_type, int size, int request_id); void set_reports_thaw_request(int request_id); + +void set_government_choice(int government); #endif /* FC__PACKHAND_H */ --- client/gui-gtk-2.0/menu.c 1 Jan 2003 11:51:33 -0000 1.10 +++ client/gui-gtk-2.0/menu.c 4 Jan 2003 00:09:37 -0000 @@ -24,6 +24,7 @@ #include "astring.h" #include "fcintl.h" #include "log.h" +#include "government.h" #include "map.h" #include "mem.h" #include "support.h" @@ -37,6 +38,7 @@ #include "dialogs.h" #include "finddlg.h" #include "gotodlg.h" +#include "graphics.h" #include "gui_stuff.h" #include "helpdlg.h" #include "mapctrl.h" /* center_on_unit */ @@ -44,6 +46,7 @@ #include "messagewin.h" #include "optiondlg.h" #include "options.h" +#include "packhand.h" #include "plrdlg.h" #include "ratesdlg.h" #include "repodlgs.h" @@ -555,8 +558,6 @@ NULL, 0, "" }, { "/" N_("Game") "/tearoff1", NULL, NULL, 0, "" }, - { "/" N_("Game") "/sep1", NULL, - NULL, 0, "" }, { "/" N_("Game") "/" N_("_Local Options"), NULL, game_menu_callback, MENU_GAME_OPTIONS }, { "/" N_("Game") "/" N_("Messa_ge Options"), NULL, @@ -596,8 +597,13 @@ kingdom_menu_callback, MENU_KINGDOM_WORKLISTS }, { "/" N_("Kingdom") "/sep2", NULL, NULL, 0, "" }, - { "/" N_("Kingdom") "/" N_("_Revolution"), "r", + { "/" N_("_Kingdom") "/" N_("_Government"), NULL, + NULL, 0, "" }, + { "/" N_("Kingdom") "/" N_("_Government") "/" N_("_Revolution"), + "r", kingdom_menu_callback, MENU_KINGDOM_REVOLUTION }, + { "/" N_("_Kingdom") "/" N_("_Government") "/sep1", NULL, + NULL, 0, "" }, /* View menu ... */ { "/" N_("_View"), NULL, NULL, 0, "" }, @@ -957,6 +963,13 @@ gtk_label_set_text_with_mnemonic(GTK_LABEL(GTK_BIN(item)->child), s); } +/**************************************************************** +... +*****************************************************************/ +void government_callback(GtkMenuItem *item, gpointer data) +{ + set_government_choice(GPOINTER_TO_INT(data)); +} /**************************************************************** Note: the menu strings should contain underscores as in the @@ -972,6 +985,53 @@ menus_set_sensitive("
/_Orders", FALSE); } else { struct unit *punit; + + GtkWidget *parent, *item; + const char *path; + + path = translate_menu_path("
/_Kingdom/_Government", 1); + + if((parent=gtk_item_factory_get_widget(item_factory, path))) { + int i; + GList *iter, *iter_next; + + /* remove previous government entries. */ + iter = gtk_container_get_children(GTK_CONTAINER(parent)); + for (iter = g_list_nth(iter, 3); iter; iter = iter_next) { + iter_next = iter->next; + + gtk_container_remove(GTK_CONTAINER(parent), GTK_WIDGET(iter->data)); + } + + /* add new government entries. */ + for (i=0; iname); + + gsprite = get_government(g->index)->sprite; + image = gtk_image_new_from_pixmap(gsprite->pixmap, gsprite->mask); + gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image); + + gtk_widget_show(image); + gtk_widget_show(item); + + g_signal_connect(item, "activate", + G_CALLBACK(government_callback), GINT_TO_POINTER(g->index)); + + if (!can_change_to_government(game.player_ptr, i)) + gtk_widget_set_sensitive(item, FALSE); + + gtk_menu_shell_append(GTK_MENU_SHELL(parent), item); + gtk_widget_show(item); + } + } + } + menus_set_sensitive("
/_Reports", TRUE); menus_set_sensitive("
/_Kingdom", TRUE); menus_set_sensitive("
/_View", TRUE); @@ -981,7 +1041,7 @@ can_client_issue_orders()); menus_set_sensitive("
/_Kingdom/Work_lists", can_client_issue_orders()); - menus_set_sensitive("
/_Kingdom/_Revolution", + menus_set_sensitive("
/_Kingdom/_Government", can_client_issue_orders()); menus_set_sensitive("
/_Reports/S_paceship",