Author: mir3x
Date: Sun Jul 24 20:16:33 2016
New Revision: 33319

URL: http://svn.gna.org/viewcvs/freeciv?rev=33319&view=rev
Log:
Qt client - new layout for pregame options.
Patch by Louis Moureaux <louis94>

See patch #7489


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

Modified: branches/S2_6/client/gui-qt/fc_client.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/fc_client.cpp?rev=33319&r1=33318&r2=33319&view=diff
==============================================================================
--- branches/S2_6/client/gui-qt/fc_client.cpp   (original)
+++ branches/S2_6/client/gui-qt/fc_client.cpp   Sun Jul 24 20:16:33 2016
@@ -914,14 +914,20 @@
 void pregame_options::init()
 {
   QFormLayout *layout;
+  QHBoxLayout *hbox = nullptr;
   QPushButton *but;
   int level;
 
   layout = new QFormLayout(this);
+  nation = new QPushButton(this);
   max_players = new QSpinBox(this);
   ailevel = new QComboBox(this);
   cruleset = new QComboBox(this);
   max_players->setRange(1, MAX_NUM_PLAYERS);
+
+  // Text and icon set by update_buttons()
+  connect(nation, &QPushButton::clicked,
+          this, &pregame_options::pick_nation);
 
   for (level = 0; level < AI_LEVEL_COUNT; level++) {
     if (is_settable_ai_level(static_cast<ai_level>(level))) {
@@ -946,11 +952,17 @@
                    SLOT(popup_server_options()));
 
   layout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
-  layout->addRow(_("Number of Players (including AI):"), max_players);
-  layout->addRow(_("AI Skill Level:"), ailevel);
-  layout->addRow(_("Ruleset"), cruleset);
+  layout->addRow(_("Nation:"), nation);
+  layout->addRow(_("Rules:"), cruleset);
+
+  hbox = new QHBoxLayout();
+  hbox->addWidget(max_players);
+  hbox->addWidget(ailevel);
+  layout->addRow(_("Players:"), hbox);
   layout->addWidget(but);
   setLayout(layout);
+
+  update_buttons();
 }
 
 /****************************************************************************
@@ -987,6 +999,30 @@
 }
 
 /****************************************************************************
+  Updates the buttons whenever the game state has changed
+****************************************************************************/
+void pregame_options::update_buttons()
+{
+  struct sprite *psprite = nullptr;
+  QPixmap *pixmap = nullptr;
+  const struct player *pplayer = client_player();
+
+  // Update the "Select Nation" button
+  if (pplayer != nullptr) {
+    if (pplayer->nation != nullptr) {
+      nation->setText(nation_adjective_for_player(pplayer));
+      psprite = get_nation_shield_sprite(tileset, pplayer->nation);
+      pixmap = psprite->pm;
+      nation->setIconSize(pixmap->size());
+      nation->setIcon(QIcon(*pixmap));
+    } else {
+      nation->setText(_("Random"));
+      nation->setIcon(fc_icons::instance()->get_icon("flush-random"));
+    }
+  }
+}
+
+/****************************************************************************
   Slot for changing aifill value
 ****************************************************************************/
 void pregame_options::max_players_change(int i)
@@ -1018,6 +1054,14 @@
 }
 
 /****************************************************************************
+  Slot for picking a nation
+****************************************************************************/
+void pregame_options::pick_nation()
+{
+  popup_races_dialog(client_player());
+}
+
+/****************************************************************************
   Popups client options
 ****************************************************************************/
 void pregame_options::popup_server_options()

Modified: branches/S2_6/client/gui-qt/fc_client.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/fc_client.h?rev=33319&r1=33318&r2=33319&view=diff
==============================================================================
--- branches/S2_6/client/gui-qt/fc_client.h     (original)
+++ branches/S2_6/client/gui-qt/fc_client.h     Sun Jul 24 20:16:33 2016
@@ -336,6 +336,7 @@
   Q_OBJECT
   QComboBox *ailevel;
   QComboBox *cruleset;
+  QPushButton *nation;
   QSpinBox *max_players;
 public:
   pregame_options() {};
@@ -343,10 +344,12 @@
 
   void set_rulesets(int num_rulesets, char **rulesets);
   void set_aifill(int aifill);
+  void update_buttons();
 private slots:
   void max_players_change(int i);
   void ailevel_change(int i);
   void ruleset_change(int i);
+  void pick_nation();
 public slots:
   void popup_server_options();
 };

Modified: branches/S2_6/client/gui-qt/pages.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/pages.cpp?rev=33319&r1=33318&r2=33319&view=diff
==============================================================================
--- branches/S2_6/client/gui-qt/pages.cpp       (original)
+++ branches/S2_6/client/gui-qt/pages.cpp       Sun Jul 24 20:16:33 2016
@@ -1500,6 +1500,8 @@
 
   sensitive = game.info.is_new_game;
   pr_options->setEnabled(sensitive);
+
+  gui()->pr_options->update_buttons();
 }
 
 /***************************************************************************


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

Reply via email to