Author: mir3x
Date: Mon Nov 23 18:06:03 2015
New Revision: 30745

URL: http://svn.gna.org/viewcvs/freeciv?rev=30745&view=rev
Log:
Made all buttons in pregame page sensitive. 
Reported by Marko Lindqvist <cazfi>

See bug #24071


Modified:
    branches/S2_5/client/gui-qt/connectdlg.cpp
    branches/S2_5/client/gui-qt/fc_client.cpp
    branches/S2_5/client/gui-qt/fc_client.h
    branches/S2_5/client/gui-qt/pages.cpp

Modified: branches/S2_5/client/gui-qt/connectdlg.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-qt/connectdlg.cpp?rev=30745&r1=30744&r2=30745&view=diff
==============================================================================
--- branches/S2_5/client/gui-qt/connectdlg.cpp  (original)
+++ branches/S2_5/client/gui-qt/connectdlg.cpp  Mon Nov 23 18:06:03 2015
@@ -23,6 +23,9 @@
 #include "support.h"
 
 #include "connectdlg_g.h"
+
+/* common */
+#include "game.h"
 
 /* client */
 #include "chatline_common.h"   /* for append_output_window */
@@ -70,8 +73,15 @@
  server.
 **************************************************************************/
 void handle_game_load(bool load_successful, const char *filename)
-{ 
-  /* PORTME */
+{
+  if (load_successful) {
+    set_client_page(PAGE_START);
+
+    if (game.info.is_new_game) {
+      /* It's pregame. Create a player and connect to him */
+      send_chat("/take -");
+    }
+  }
 }
 
 

Modified: branches/S2_5/client/gui-qt/fc_client.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-qt/fc_client.cpp?rev=30745&r1=30744&r2=30745&view=diff
==============================================================================
--- branches/S2_5/client/gui-qt/fc_client.cpp   (original)
+++ branches/S2_5/client/gui-qt/fc_client.cpp   Mon Nov 23 18:06:03 2015
@@ -464,10 +464,14 @@
 void fc_client::slot_pregame_observe()
 {
   if (client_is_observer() || client_is_global_observer()) {
-    send_chat("/take -");
+    if (game.info.is_new_game) {
+      send_chat("/take -");
+    } else {
+      send_chat("/detach");
+    }
     obs_button->setText(_("Don't Observe"));
   } else {
-    send_chat("/obs");
+    send_chat("/observe");
     obs_button->setText(_("Observe"));
   }
 }

Modified: branches/S2_5/client/gui-qt/fc_client.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-qt/fc_client.h?rev=30745&r1=30744&r2=30745&view=diff
==============================================================================
--- branches/S2_5/client/gui-qt/fc_client.h     (original)
+++ branches/S2_5/client/gui-qt/fc_client.h     Mon Nov 23 18:06:03 2015
@@ -276,7 +276,7 @@
   void create_cursors(void);
   void update_scenarios_page(void);
   void set_connection_state(enum connection_state state);
-  void update_obs_button();
+  void update_buttons();
   void init();
 
   enum client_pages page;

Modified: branches/S2_5/client/gui-qt/pages.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-qt/pages.cpp?rev=30745&r1=30744&r2=30745&view=diff
==============================================================================
--- branches/S2_5/client/gui-qt/pages.cpp       (original)
+++ branches/S2_5/client/gui-qt/pages.cpp       Mon Nov 23 18:06:03 2015
@@ -936,7 +936,6 @@
     client_start_server();
   }
   send_chat_printf("/load %s", current_file.toLocal8Bit().data());
-  send_chat("/take -");
   switch_page(PAGE_START);
 }
 
@@ -1402,19 +1401,65 @@
   start_players_tree->header()->setResizeMode(QHeaderView::ResizeToContents);
 #endif
   start_players_tree->expandAll();
-  update_obs_button();
+  update_buttons();
 }
 
 /***************************************************************************
   Updates observe button in case user started observing manually
 ***************************************************************************/
-void fc_client::update_obs_button()
-{
+void fc_client::update_buttons()
+{
+  bool sensitive;
+  QString text;
+  QLayoutItem *li;
+  QPushButton *pb;
+
+  /* Observe button */
   if (client_is_observer() || client_is_global_observer()) {
     obs_button->setText(_("Don't Observe"));
   } else {
     obs_button->setText(_("Observe"));
   }
+
+  /* Ready button */
+  if (can_client_control()) {
+    sensitive = true;
+    if (client_player()->is_ready) {
+      text = _("Not ready");
+    } else {
+      int num_unready = 0;
+
+      players_iterate(pplayer) {
+        if (!pplayer->ai_controlled && !pplayer->is_ready) {
+          num_unready++;
+        }
+      } players_iterate_end;
+
+      if (num_unready > 1) {
+        text = _("Ready");
+      } else {
+        /* We are the last unready player so clicking here will
+         * immediately start the game. */
+        text = ("Start");
+      }
+    }
+  } else {
+    text = _("Start");
+    sensitive = false;
+  }
+  li = pages_layout[PAGE_START]->itemAtPosition(5, 7);
+  pb = qobject_cast<QPushButton *>(li->widget());
+  pb->setEnabled(sensitive);
+  pb->setText(text);
+
+  /* Nation button */
+  sensitive = game.info.is_new_game && !client_is_observer();
+  li = pages_layout[PAGE_START]->itemAtPosition(5, 5);
+  pb = qobject_cast<QPushButton *>(li->widget());
+  pb->setEnabled(sensitive);
+
+  sensitive = game.info.is_new_game;
+  pr_options->setEnabled(sensitive);
 }
 
 /***************************************************************************


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

Reply via email to