<URL: http://bugs.freeciv.org/Ticket/Display.html?id=40234 >

2008/5/8 Madeline Book:
>
>  > [EMAIL PROTECTED] - Wed May 07 21:59:32 2008]:
>  >
>  >  GTK-2
>  >
>  >  Current Start button sensitivity checks against global observer, but
>  > observer attached to player cannot start game either.
>
>  The start button should also not be sensitive for detached
>  connections (not observer and not attached to a player).

 Fixed that one.

 I also found out that "Pick Nation" is sometimes used to create new
player (without nations selection) and sometimes to select nation for
existing player. Now button text changes accordingly.
 Sensitivity of the "Take Player"/"Pick Nation" adjusted fixing two bugs:
 - "Pick Nation" is not sensitive for observers.* (S2_1 only, as in
S2_2 and TRUNK observer seems to have full control over nation
selection...)
 - "Take Player" is always available for detached connections


 *) Similar change is later required for connection menu


 - ML

diff -Nurd -X.diff_ignore freeciv/client/civclient.c freeciv/client/civclient.c
--- freeciv/client/civclient.c  2008-04-08 15:32:21.000000000 +0300
+++ freeciv/client/civclient.c  2008-05-08 11:46:28.000000000 +0300
@@ -741,14 +741,22 @@
 }
 
 /**************************************************************************
-  Returns TRUE if the client can issue orders (such as giving unit
+  Returns TRUE iff the client can control player.
+**************************************************************************/
+bool can_client_control(void)
+{
+  return (NULL != client.conn.playing
+         && !client_is_observer());
+}
+
+/**************************************************************************
+  Returns TRUE iff the client can issue orders (such as giving unit
   commands).  This function should be called each time before allowing the
   user to give an order.
 **************************************************************************/
 bool can_client_issue_orders(void)
 {
-  return (NULL != client.conn.playing
-         && !client_is_observer()
+  return (can_client_control()
          && C_S_RUNNING == client_state());
 }
 
diff -Nurd -X.diff_ignore freeciv/client/civclient.h freeciv/client/civclient.h
--- freeciv/client/civclient.h  2008-03-08 16:33:11.000000000 +0200
+++ freeciv/client/civclient.h  2008-05-08 11:46:28.000000000 +0300
@@ -77,6 +77,7 @@
 void set_seconds_to_turndone(double seconds);
 int get_seconds_to_turndone(void);
 double real_timer_callback(void);
+bool can_client_control(void);
 bool can_client_issue_orders(void);
 bool can_client_change_view(void);
 bool can_meet_with_player(const struct player *pplayer);
diff -Nurd -X.diff_ignore freeciv/client/gui-gtk-2.0/gui_main.c 
freeciv/client/gui-gtk-2.0/gui_main.c
--- freeciv/client/gui-gtk-2.0/gui_main.c       2008-03-08 16:32:57.000000000 
+0200
+++ freeciv/client/gui-gtk-2.0/gui_main.c       2008-05-08 12:01:23.000000000 
+0300
@@ -1586,14 +1586,25 @@
   } else {
     gtk_stockbutton_set_label(ready_button, _("_Start"));
   }
-  gtk_widget_set_sensitive(ready_button, (NULL != client.conn.playing));
 
-  gtk_stockbutton_set_label(nation_button, _("Pick _Nation"));
-  if (NULL == client.conn.playing) {
+  /* Sensitive only if client can control player */
+  gtk_widget_set_sensitive(ready_button, can_client_control());
+
+  if (!client.conn.playing) {
+    /* Nation button will attach to player */
+    gtk_stockbutton_set_label(nation_button, _("_Take Player"));
+    gtk_widget_set_sensitive(nation_button, TRUE);
+  } else {
+    /* Nation button will go to Nation selection */
+    gtk_stockbutton_set_label(nation_button, _("Pick _Nation"));
+
+    /* Sensitive iff client can select nation.
+     * FIXME: Observer can always select nations? */
     gtk_widget_set_sensitive(nation_button, game.info.is_new_game);
+                             /* && can_client_control()); */
   }
 
-  if (NULL != client.conn.playing || !client.conn.observer) {
+  if (!client_is_observer()) {
     gtk_stockbutton_set_label(take_button, _("_Observe"));
   } else {
     gtk_stockbutton_set_label(take_button, _("Do not _observe"));
diff -Nurd -X.diff_ignore freeciv/client/gui-gtk-2.0/gui_main.c 
freeciv/client/gui-gtk-2.0/gui_main.c
--- freeciv/client/gui-gtk-2.0/gui_main.c       2008-01-15 04:04:31.000000000 
+0200
+++ freeciv/client/gui-gtk-2.0/gui_main.c       2008-05-08 11:58:49.000000000 
+0300
@@ -1511,11 +1511,19 @@
   } else {
     gtk_stockbutton_set_label(ready_button, _("_Start"));
   }
-  gtk_widget_set_sensitive(ready_button, (game.player_ptr != NULL));
 
-  gtk_stockbutton_set_label(nation_button, _("Pick _Nation"));
-  if (!aconnection.player) {
-    gtk_widget_set_sensitive(nation_button, game.info.is_new_game);
+  /* Observers and detached connections cannot start game. */
+  gtk_widget_set_sensitive(ready_button,
+                           (!aconnection.observer && game.player_ptr));
+
+  if (!game.player_ptr) {
+    gtk_stockbutton_set_label(nation_button, _("_Take Player"));
+    gtk_widget_set_sensitive(nation_button, TRUE);
+  } else {
+    gtk_stockbutton_set_label(nation_button, _("Pick _Nation"));
+    /* Sensitive iff client can select nation. */
+    gtk_widget_set_sensitive(nation_button,
+                             game.info.is_new_game && !aconnection.observer);
   }
 
   if (aconnection.player || !aconnection.observer) {
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to