Author: jtn
Date: Tue May 12 09:23:01 2015
New Revision: 29054

URL: http://svn.gna.org/viewcvs/freeciv?rev=29054&view=rev
Log:
Allow player observers to view policies dialog.

See gna patch #6077.

Modified:
    trunk/client/gui-gtk-2.0/gamedlgs.c
    trunk/client/gui-gtk-2.0/menu.c
    trunk/client/gui-gtk-3.0/gamedlgs.c
    trunk/client/gui-gtk-3.0/menu.c
    trunk/client/gui-qt/ratesdlg.cpp
    trunk/client/gui-sdl/dialogs.c
    trunk/client/gui-sdl2/dialogs.c
    trunk/client/gui-stub/ratesdlg.c
    trunk/client/gui-xaw/ratesdlg.c
    trunk/client/include/ratesdlg_g.h
    trunk/client/packhand.c
    trunk/client/update_queue.c

Modified: trunk/client/gui-gtk-2.0/gamedlgs.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-2.0/gamedlgs.c?rev=29054&r1=29053&r2=29054&view=diff
==============================================================================
--- trunk/client/gui-gtk-2.0/gamedlgs.c (original)
+++ trunk/client/gui-gtk-2.0/gamedlgs.c Tue May 12 09:23:01 2015
@@ -250,7 +250,7 @@
 {
   struct packet_player_multiplier mul;
 
-  if (response_id == GTK_RESPONSE_OK) {
+  if (response_id == GTK_RESPONSE_OK && can_client_issue_orders()) {
     multipliers_iterate(m) {
       Multiplier_type_id i = multiplier_index(m);
       int value = gtk_range_get_value(GTK_RANGE(multipliers_scale[i]));
@@ -263,6 +263,30 @@
   gtk_widget_destroy(multiplier_dialog_shell);
 }
 
+/**************************************************************************
+  Update multipliers dialog (for player observers)
+**************************************************************************/
+void real_multipliers_dialog_update(void)
+{
+  if (!multiplier_dialog_shell) {
+    return;
+  }
+
+  if (can_client_issue_orders()) {
+    /* We don't want to lose the player's local changes. This dialog
+     * should be the only way the values can change, anyway. */
+    return;
+  }
+
+  multipliers_iterate(pmul) {
+    Multiplier_type_id multiplier = multiplier_index(pmul);
+    int val = client_player()->multipliers[multiplier];
+
+    gtk_range_set_value(GTK_RANGE(multipliers_scale[multiplier]),
+                        mult_to_scale(pmul, val));
+  } multipliers_iterate_end;
+}
+
 /****************************************************************
   Create multipliers dialog
 ****************************************************************/
@@ -272,18 +296,23 @@
   GtkWidget     *label, *scale;
   struct player *pplayer = client_player();
 
-  if (!can_client_issue_orders()) {
-    return NULL;
-  }
-
-  shell = gtk_dialog_new_with_buttons(_("Change policies"),
-                                      NULL,
-                                      0,
-                                      GTK_STOCK_CANCEL,
-                                      GTK_RESPONSE_CANCEL,
-                                      GTK_STOCK_OK,
-                                      GTK_RESPONSE_OK,
-                                      NULL);
+  if (can_client_issue_orders()) {
+    shell = gtk_dialog_new_with_buttons(_("Change policies"),
+                                        NULL,
+                                        0,
+                                        GTK_STOCK_CANCEL,
+                                        GTK_RESPONSE_CANCEL,
+                                        GTK_STOCK_OK,
+                                        GTK_RESPONSE_OK,
+                                        NULL);
+  } else {
+    shell = gtk_dialog_new_with_buttons(_("Policies"),
+                                        NULL,
+                                        0,
+                                        GTK_STOCK_CLOSE,
+                                        GTK_RESPONSE_CLOSE,
+                                        NULL);
+  }
 
   gtk_window_set_position(GTK_WINDOW(shell), GTK_WIN_POS_MOUSE);
   content = gtk_dialog_get_content_area(GTK_DIALOG(shell));
@@ -313,6 +342,8 @@
                      &multipliers_scale[multiplier]);
     gtk_box_pack_start( GTK_BOX( content ), label, TRUE, TRUE, 5 );
     gtk_box_pack_start( GTK_BOX( content ), scale, TRUE, TRUE, 5 );
+    gtk_widget_set_sensitive(multipliers_scale[multiplier],
+                             can_client_issue_orders());
   } multipliers_iterate_end;
 
   g_signal_connect(shell, "destroy",
@@ -331,10 +362,6 @@
 *****************************************************************/
 void popup_multiplier_dialog(void)
 {
-  if (!can_client_issue_orders()) {
-    return;
-  }
-
   if (!multiplier_dialog_shell) {
     multiplier_dialog_shell = create_multiplier_dialog();
   }

Modified: trunk/client/gui-gtk-2.0/menu.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-2.0/menu.c?rev=29054&r1=29053&r2=29054&view=diff
==============================================================================
--- trunk/client/gui-gtk-2.0/menu.c     (original)
+++ trunk/client/gui-gtk-2.0/menu.c     Tue May 12 09:23:01 2015
@@ -1750,8 +1750,6 @@
       /* Civilization menu. */
       {"TAX_RATE", NULL, _("_Tax Rates..."),
        "<Control>t", NULL, G_CALLBACK(tax_rate_callback)},
-      {"POLICIES", NULL, _("Policies..."),
-       "<Shift><Control>p", NULL, G_CALLBACK(multiplier_callback)},
       /* Civilization/Government menu. */
       {"START_REVOLUTION", NULL, _("_Revolution..."),
        "<Shift><Control>r", NULL, G_CALLBACK(government_callback)},
@@ -1788,6 +1786,9 @@
        "F5", NULL, G_CALLBACK(report_economy_callback)},
       {"REPORT_RESEARCH", NULL, _("_Research"),
        "F6", NULL, G_CALLBACK(report_research_callback)},
+
+      {"POLICIES", NULL, _("_Policies..."),
+       "<Shift><Control>p", NULL, G_CALLBACK(multiplier_callback)},
 
       {"REPORT_SPACESHIP", NULL, _("_Spaceship"),
        "F12", NULL, G_CALLBACK(report_spaceship_callback)},
@@ -2601,7 +2602,7 @@
   menus_set_sensitive(playing_group, "TAX_RATE",
                       game.info.changable_tax
                       && can_client_issue_orders());
-  menus_set_sensitive(playing_group, "POLICIES",
+  menus_set_sensitive(player_group, "POLICIES",
                       multiplier_count() > 0);
 
   menus_set_active(safe_group, "SHOW_CITY_OUTLINES", 
options.draw_city_outlines);

Modified: trunk/client/gui-gtk-3.0/gamedlgs.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.0/gamedlgs.c?rev=29054&r1=29053&r2=29054&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.0/gamedlgs.c (original)
+++ trunk/client/gui-gtk-3.0/gamedlgs.c Tue May 12 09:23:01 2015
@@ -248,7 +248,7 @@
 {
   struct packet_player_multiplier mul;
 
-  if (response_id == GTK_RESPONSE_OK) {
+  if (response_id == GTK_RESPONSE_OK && can_client_issue_orders()) {
     multipliers_iterate(m) {
       Multiplier_type_id i = multiplier_index(m);
       int value = gtk_range_get_value(GTK_RANGE(multipliers_scale[i]));
@@ -261,6 +261,30 @@
   gtk_widget_destroy(multiplier_dialog_shell);
 }
 
+/**************************************************************************
+  Update multipliers dialog (for player observers)
+**************************************************************************/
+void real_multipliers_dialog_update(void)
+{
+  if (!multiplier_dialog_shell) {
+    return;
+  }
+
+  if (can_client_issue_orders()) {
+    /* We don't want to lose the player's local changes. This dialog
+     * should be the only way the values can change, anyway. */
+    return;
+  }
+
+  multipliers_iterate(pmul) {
+    Multiplier_type_id multiplier = multiplier_index(pmul);
+    int val = client_player()->multipliers[multiplier];
+
+    gtk_range_set_value(GTK_RANGE(multipliers_scale[multiplier]),
+                        mult_to_scale(pmul, val));
+  } multipliers_iterate_end;
+}
+
 /****************************************************************
   Create multipliers dialog
 ****************************************************************/
@@ -270,18 +294,23 @@
   GtkWidget     *label, *scale;
   struct player *pplayer = client_player();
 
-  if (!can_client_issue_orders()) {
-    return NULL;
-  }
-
-  shell = gtk_dialog_new_with_buttons(_("Change policies"),
-                                      NULL,
-                                      0,
-                                      GTK_STOCK_CANCEL,
-                                      GTK_RESPONSE_CANCEL,
-                                      GTK_STOCK_OK,
-                                      GTK_RESPONSE_OK,
-                                      NULL);
+  if (can_client_issue_orders()) {
+    shell = gtk_dialog_new_with_buttons(_("Change policies"),
+                                        NULL,
+                                        0,
+                                        GTK_STOCK_CANCEL,
+                                        GTK_RESPONSE_CANCEL,
+                                        GTK_STOCK_OK,
+                                        GTK_RESPONSE_OK,
+                                        NULL);
+  } else {
+    shell = gtk_dialog_new_with_buttons(_("Policies"),
+                                        NULL,
+                                        0,
+                                        GTK_STOCK_CLOSE,
+                                        GTK_RESPONSE_CLOSE,
+                                        NULL);
+  }
 
   gtk_window_set_position(GTK_WINDOW(shell), GTK_WIN_POS_MOUSE);
   content = gtk_dialog_get_content_area(GTK_DIALOG(shell));
@@ -312,6 +341,8 @@
                      &multipliers_scale[multiplier]);
     gtk_box_pack_start( GTK_BOX( content ), label, TRUE, TRUE, 5 );
     gtk_box_pack_start( GTK_BOX( content ), scale, TRUE, TRUE, 5 );
+    gtk_widget_set_sensitive(multipliers_scale[multiplier],
+                             can_client_issue_orders());
   } multipliers_iterate_end;
 
   g_signal_connect(shell, "destroy",
@@ -330,10 +361,6 @@
 *****************************************************************/
 void popup_multiplier_dialog(void)
 {
-  if (!can_client_issue_orders()) {
-    return;
-  }
-
   if (!multiplier_dialog_shell) {
     multiplier_dialog_shell = create_multiplier_dialog();
   }

Modified: trunk/client/gui-gtk-3.0/menu.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.0/menu.c?rev=29054&r1=29053&r2=29054&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.0/menu.c     (original)
+++ trunk/client/gui-gtk-3.0/menu.c     Tue May 12 09:23:01 2015
@@ -1751,9 +1751,6 @@
       /* Civilization menu. */
       {"TAX_RATE", NULL, _("_Tax Rates..."),
        "<Control>t", NULL, G_CALLBACK(tax_rate_callback)},
-       /* Civilization/Policies menu */
-      {"POLICIES", NULL, _("_Policies..."),
-       "<Shift><Control>p", NULL, G_CALLBACK(multiplier_callback)},
       /* Civilization/Government menu. */
       {"START_REVOLUTION", NULL, _("_Revolution..."),
        "<Shift><Control>r", NULL, G_CALLBACK(government_callback)},
@@ -1790,6 +1787,10 @@
        "F5", NULL, G_CALLBACK(report_economy_callback)},
       {"REPORT_RESEARCH", NULL, _("_Research"),
        "F6", NULL, G_CALLBACK(report_research_callback)},
+
+       /* Civilization/Policies menu */
+      {"POLICIES", NULL, _("_Policies..."),
+       "<Shift><Control>p", NULL, G_CALLBACK(multiplier_callback)},
 
       {"REPORT_SPACESHIP", NULL, _("_Spaceship"),
        "F12", NULL, G_CALLBACK(report_spaceship_callback)},
@@ -2602,7 +2603,7 @@
   menus_set_sensitive(playing_group, "TAX_RATE",
                       game.info.changable_tax
                       && can_client_issue_orders());
-  menus_set_sensitive(playing_group, "POLICIES",
+  menus_set_sensitive(player_group, "POLICIES",
                       multiplier_count() > 0);
 
   menus_set_active(safe_group, "SHOW_CITY_OUTLINES", 
options.draw_city_outlines);

Modified: trunk/client/gui-qt/ratesdlg.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/ratesdlg.cpp?rev=29054&r1=29053&r2=29054&view=diff
==============================================================================
--- trunk/client/gui-qt/ratesdlg.cpp    (original)
+++ trunk/client/gui-qt/ratesdlg.cpp    Tue May 12 09:23:01 2015
@@ -282,3 +282,11 @@
   tax_rates_dialog* trd = new tax_rates_dialog(gui()->central_wdg);
   trd->show();
 }
+
+/**************************************************************************
+  Update multipliers (policies) dialog.
+**************************************************************************/
+void real_multipliers_dialog_update(void)
+{
+  /* PORTME */
+}

Modified: trunk/client/gui-sdl/dialogs.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-sdl/dialogs.c?rev=29054&r1=29053&r2=29054&view=diff
==============================================================================
--- trunk/client/gui-sdl/dialogs.c      (original)
+++ trunk/client/gui-sdl/dialogs.c      Tue May 12 09:23:01 2015
@@ -68,6 +68,7 @@
 #include "messagewin.h"
 #include "optiondlg.h"
 #include "plrdlg.h"
+#include "ratesdlg.h"
 #include "repodlgs.h"
 #include "sprite.h"
 #include "themespec.h"
@@ -3748,3 +3749,11 @@
   /* Just tell the client common code to handle this. */
   return FALSE;
 }
+
+/****************************************************************
+  Update multipliers (policies) dialog.
+*****************************************************************/
+void real_multipliers_dialog_update(void)
+{ 
+  /* PORTME */
+}

Modified: trunk/client/gui-sdl2/dialogs.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-sdl2/dialogs.c?rev=29054&r1=29053&r2=29054&view=diff
==============================================================================
--- trunk/client/gui-sdl2/dialogs.c     (original)
+++ trunk/client/gui-sdl2/dialogs.c     Tue May 12 09:23:01 2015
@@ -68,6 +68,7 @@
 #include "messagewin.h"
 #include "optiondlg.h"
 #include "plrdlg.h"
+#include "ratesdlg.h"
 #include "repodlgs.h"
 #include "sprite.h"
 #include "themespec.h"
@@ -3731,3 +3732,11 @@
   /* Just tell the client common code to handle this. */
   return FALSE;
 }
+
+/****************************************************************
+  Update multipliers (policies) dialog.
+*****************************************************************/
+void real_multipliers_dialog_update(void)
+{
+  /* PORTME */
+} 

Modified: trunk/client/gui-stub/ratesdlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-stub/ratesdlg.c?rev=29054&r1=29053&r2=29054&view=diff
==============================================================================
--- trunk/client/gui-stub/ratesdlg.c    (original)
+++ trunk/client/gui-stub/ratesdlg.c    Tue May 12 09:23:01 2015
@@ -27,3 +27,11 @@
 {
   /* PORTME */
 }
+
+/**************************************************************************
+  Update multipliers (policies) dialog.
+**************************************************************************/
+void real_multipliers_dialog_update(void)
+{ 
+  /* PORTME */
+}

Modified: trunk/client/gui-xaw/ratesdlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-xaw/ratesdlg.c?rev=29054&r1=29053&r2=29054&view=diff
==============================================================================
--- trunk/client/gui-xaw/ratesdlg.c     (original)
+++ trunk/client/gui-xaw/ratesdlg.c     Tue May 12 09:23:01 2015
@@ -394,3 +394,11 @@
     rates_set_values(rates_tax_value,0, rates_lux_value,0, val,0);
   }
 }
+
+/**************************************************************************
+  Update multipliers (policies) dialog.
+**************************************************************************/
+void real_multipliers_dialog_update(void)
+{ 
+  /* FIXME */
+}

Modified: trunk/client/include/ratesdlg_g.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/include/ratesdlg_g.h?rev=29054&r1=29053&r2=29054&view=diff
==============================================================================
--- trunk/client/include/ratesdlg_g.h   (original)
+++ trunk/client/include/ratesdlg_g.h   Tue May 12 09:23:01 2015
@@ -17,4 +17,9 @@
 
 GUI_FUNC_PROTO(void, popup_rates_dialog, void)
 
+GUI_FUNC_PROTO(void, real_multipliers_dialog_update, void)
+
+/* Actually defined in update_queue.c */
+void multipliers_dialog_update(void);
+
 #endif  /* FC__RATESDLG_G_H */

Modified: trunk/client/packhand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/packhand.c?rev=29054&r1=29053&r2=29054&view=diff
==============================================================================
--- trunk/client/packhand.c     (original)
+++ trunk/client/packhand.c     Tue May 12 09:23:01 2015
@@ -70,6 +70,7 @@
 #include "messagewin_g.h"
 #include "pages_g.h"
 #include "plrdlg_g.h"
+#include "ratesdlg_g.h"
 #include "repodlgs_g.h"
 #include "spaceshipdlg_g.h"
 #include "voteinfo_bar_g.h"
@@ -2181,6 +2182,11 @@
   pplayer->revolution_finishes = pinfo->revolution_finishes;
   pplayer->ai_common.skill_level = pinfo->ai_skill_level;
 
+  multipliers_iterate(pmul) {
+    pplayer->multipliers[multiplier_index(pmul)] =
+      pinfo->multiplier[multiplier_index(pmul)];
+  } multipliers_iterate_end;
+
   /* if the server requests that the client reset, then information about
    * connections to this player are lost. If this is the case, insert the
    * correct conn back into the player->connections list */
@@ -2208,6 +2214,7 @@
     economy_report_dialog_update();
     units_report_dialog_update();
     city_report_dialog_update();
+    multipliers_dialog_update();
     update_info_label();
   }
 
@@ -2230,11 +2237,6 @@
     update_intel_dialog(pplayer);
   }
 
-  multipliers_iterate(pmul) {
-    pplayer->multipliers[multiplier_index(pmul)] =
-        pinfo->multiplier[multiplier_index(pmul)];
-  } multipliers_iterate_end;
-  
   editgui_refresh();
   editgui_notify_object_changed(OBJTYPE_PLAYER, player_number(pplayer),
                                 FALSE);

Modified: trunk/client/update_queue.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/update_queue.c?rev=29054&r1=29053&r2=29054&view=diff
==============================================================================
--- trunk/client/update_queue.c (original)
+++ trunk/client/update_queue.c Tue May 12 09:23:01 2015
@@ -32,6 +32,7 @@
 #include "menu_g.h"
 #include "pages_g.h"
 #include "plrdlg_g.h"
+#include "ratesdlg_g.h"
 #include "repodlgs_g.h"
 
 /* client */
@@ -543,6 +544,12 @@
   }
 }
 
+/****************************************************************************
+  Update multipliers/policy dialog.
+****************************************************************************/
+void multipliers_dialog_update(void) {
+  update_queue_add(UQ_CALLBACK(real_multipliers_dialog_update), NULL);
+}
 
 /****************************************************************************
   Update cities gui.


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to