Author: mir3x
Date: Thu Dec 24 09:40:03 2015
New Revision: 31186

URL: http://svn.gna.org/viewcvs/freeciv?rev=31186&view=rev
Log:
Added two shorcuts on mapview: 
ctrl + left click on own city -> change production 
ctrl + shift + left click on own city -> change production and buy it instantly.

See patch #6704


Modified:
    trunk/client/gui-qt/citydlg.cpp
    trunk/client/gui-qt/citydlg.h
    trunk/client/gui-qt/mapctrl.cpp

Modified: trunk/client/gui-qt/citydlg.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/citydlg.cpp?rev=31186&r1=31185&r2=31186&view=diff
==============================================================================
--- trunk/client/gui-qt/citydlg.cpp     (original)
+++ trunk/client/gui-qt/citydlg.cpp     Thu Dec 24 09:40:03 2015
@@ -3027,10 +3027,11 @@
   show_units - if to show units
   when - where to insert
   curr - current index to insert
-****************************************************************************/
-production_widget::production_widget(QWidget *parent, struct city *pcity, 
+  buy - buy if possible
+****************************************************************************/
+production_widget::production_widget(QWidget *parent, struct city *pcity,
                                      bool future, int when, int curr,
-                                     bool show_units): QTableView()
+                                     bool show_units, bool buy): QTableView()
 {
   QPoint pos, sh;
   int desk_width = QApplication::desktop()->width();
@@ -3044,6 +3045,7 @@
   curr_selection = curr;
   sh_units = show_units;
   pw_city = pcity;
+  buy_it = buy;
   when_change = when;
   list_model = new city_production_model(pw_city, future, show_units, this);
   sh = list_model->sh;
@@ -3148,6 +3150,9 @@
     switch (when_change) {
     case 0: /*Change current tech*/
       city_change_production(pw_city, *target);
+      if (buy_it) {
+        city_buy_production(pw_city);
+      }
       break;
     case 1:                 /* Change current (selected on list)*/
       if (curr_selection < 0 || curr_selection > worklist_length(&queue)) {

Modified: trunk/client/gui-qt/citydlg.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/citydlg.h?rev=31186&r1=31185&r2=31186&view=diff
==============================================================================
--- trunk/client/gui-qt/citydlg.h       (original)
+++ trunk/client/gui-qt/citydlg.h       Thu Dec 24 09:40:03 2015
@@ -269,7 +269,7 @@
 
 public:
   production_widget(QWidget *parent, struct city *pcity, bool future,
-                    int when, int curr, bool show_units);
+                    int when, int curr, bool show_units, bool buy = false);
   ~production_widget();
 
 public slots:
@@ -284,6 +284,7 @@
   int when_change;
   int curr_selection;
   bool sh_units;
+  bool buy_it;
   fc_tooltip *fc_tt;
 };
 

Modified: trunk/client/gui-qt/mapctrl.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/mapctrl.cpp?rev=31186&r1=31185&r2=31186&view=diff
==============================================================================
--- trunk/client/gui-qt/mapctrl.cpp     (original)
+++ trunk/client/gui-qt/mapctrl.cpp     Thu Dec 24 09:40:03 2015
@@ -35,6 +35,7 @@
 
 // gui-qt
 #include "fc_client.h"
+#include "citydlg.h"
 #include "qtg_cxxside.h"
 
 
@@ -185,6 +186,7 @@
   bool ctrl;
   bool shft;
   QPoint pos;
+  production_widget *pw;
 
   alt = false;
   ctrl = false;
@@ -223,10 +225,20 @@
     }
   }
 
+  if (pcity && pcity->owner != client_player()) {
+    pcity = nullptr;
+  }
+
   /* Left Button */
   if (event->button() == Qt::LeftButton) {
-    /* <SHIFT> + <CONTROL> + LMB : Adjust workers. */
-    if (shft && ctrl) {
+    if (ctrl && shft && pcity) {
+      pw = new production_widget(this, pcity, false, 0, 0, true, true);
+      pw->show();
+    } else if (ctrl && pcity) {
+      pw = new production_widget(this, pcity, false, 0, 0, true);
+      pw->show();
+      /* <SHIFT> + <CONTROL> + LMB : Adjust workers. */
+    } else if (shft && ctrl) {
       adjust_workers_button_pressed(event->pos().x(), event->pos().y());
       /* <CONTROL> + LMB : Quickselect a sea unit. */
     } else if (ctrl) {


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

Reply via email to