Author: mir3x
Date: Fri Dec  2 09:22:03 2016
New Revision: 34669

URL: http://svn.gna.org/viewcvs/freeciv?rev=34669&view=rev
Log:
Qt client - added menu entry to load any tileset for current game

See patch #8037


Modified:
    branches/S2_6/client/gui-qt/dialogs.cpp
    branches/S2_6/client/gui-qt/menu.cpp
    branches/S2_6/client/gui-qt/menu.h

Modified: branches/S2_6/client/gui-qt/dialogs.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/dialogs.cpp?rev=34669&r1=34668&r2=34669&view=diff
==============================================================================
--- branches/S2_6/client/gui-qt/dialogs.cpp     (original)
+++ branches/S2_6/client/gui-qt/dialogs.cpp     Fri Dec  2 09:22:03 2016
@@ -2701,12 +2701,11 @@
 
   fc_snprintf(buf, sizeof(buf),
               _("Tileset problem, it's probably incompatible with the"
-                " ruleset:\n%s\nProgram will now exit."), msg);
+                " ruleset:\n%s"), msg);
   ask.setText(buf);
   ask.setStandardButtons(QMessageBox::Ok);
   ask.setWindowTitle(_("Tileset error"));
   ask.exec();
-  gui()->quit();
 
 }
 

Modified: branches/S2_6/client/gui-qt/menu.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/menu.cpp?rev=34669&r1=34668&r2=34669&view=diff
==============================================================================
--- branches/S2_6/client/gui-qt/menu.cpp        (original)
+++ branches/S2_6/client/gui-qt/menu.cpp        Fri Dec  2 09:22:03 2016
@@ -808,6 +808,8 @@
   connect(act, SIGNAL(triggered()), this, SLOT(messages_options()));
   act = menu->addAction(_("Shortcuts"));
   connect(act, SIGNAL(triggered()), this, SLOT(shortcut_options()));
+  act = menu->addAction(_("Load another tileset"));
+  connect(act, SIGNAL(triggered()), this, SLOT(tileset_custom_load()));
   act = menu->addAction(_("Save Options Now"));
   act->setIcon(style()->standardIcon(QStyle::SP_DialogSaveButton));
   connect(act, SIGNAL(triggered()), this, SLOT(save_options_now()));
@@ -2877,6 +2879,55 @@
 }
 
 /****************************************************************
+  Shows rulesets to load
+*****************************************************************/
+void mr_menu::tileset_custom_load()
+{
+  QDialog *dialog = new QDialog(this);
+  QLabel *label;
+  QPushButton *but;
+  QVBoxLayout *layout;
+  const struct strvec *tlset_list;
+  const struct option *poption;
+  QStringList sl;
+  QString s;
+
+  sl << "default_tileset_overhead_name" << "default_tileset_iso_name"
+     << "default_tileset_hex_name" << "default_tileset_isohex_name";
+  layout = new QVBoxLayout;
+  dialog->setWindowTitle(_("Available tilesets"));
+  label = new QLabel;
+  label->setText(_("Some tilesets might be not compatible with current"
+                   " map topology!"));
+  layout->addWidget(label);
+
+  foreach (s, sl) {
+    poption = optset_option_by_name(client_optset, s.toLocal8Bit().data());
+    tlset_list = get_tileset_list(poption);
+    strvec_iterate(tlset_list, value) {
+      but = new QPushButton(value);
+      connect(but, SIGNAL(clicked()), this, SLOT(load_new_tileset()));
+      layout->addWidget(but);
+    } strvec_iterate_end;
+  }
+  dialog->setSizeGripEnabled(true);
+  dialog->setLayout(layout);
+  dialog->show();
+}
+
+/****************************************************************
+  Slot for loading new tileset
+*****************************************************************/
+void mr_menu::load_new_tileset()
+{
+  QPushButton *but;
+
+  but = qobject_cast<QPushButton *>(sender());
+  tilespec_reread(but->text().toLocal8Bit().data(), true);
+  but->parentWidget()->close();
+}
+
+/****************************************************************
   Action "Calculate trade routes"
 *****************************************************************/
 void mr_menu::calc_trade_routes()

Modified: branches/S2_6/client/gui-qt/menu.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/menu.h?rev=34669&r1=34668&r2=34669&view=diff
==============================================================================
--- branches/S2_6/client/gui-qt/menu.h  (original)
+++ branches/S2_6/client/gui-qt/menu.h  Fri Dec  2 09:22:03 2016
@@ -285,6 +285,8 @@
   void save_game();
   void save_game_as();
   void save_image();
+  void tileset_custom_load();
+  void load_new_tileset();
   void back_to_menu();
   void quit_game();
 


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

Reply via email to