Author: mir3x
Date: Thu Dec 24 09:39:47 2015
New Revision: 31184

URL: http://svn.gna.org/viewcvs/freeciv?rev=31184&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:
    branches/S2_5/client/gui-qt/citydlg.cpp
    branches/S2_5/client/gui-qt/citydlg.h
    branches/S2_5/client/gui-qt/mapctrl.cpp

Modified: branches/S2_5/client/gui-qt/citydlg.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-qt/citydlg.cpp?rev=31184&r1=31183&r2=31184&view=diff
==============================================================================
--- branches/S2_5/client/gui-qt/citydlg.cpp     (original)
+++ branches/S2_5/client/gui-qt/citydlg.cpp     Thu Dec 24 09:39:47 2015
@@ -3022,10 +3022,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();
@@ -3039,6 +3040,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;
@@ -3143,6 +3145,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: branches/S2_5/client/gui-qt/citydlg.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-qt/citydlg.h?rev=31184&r1=31183&r2=31184&view=diff
==============================================================================
--- branches/S2_5/client/gui-qt/citydlg.h       (original)
+++ branches/S2_5/client/gui-qt/citydlg.h       Thu Dec 24 09:39:47 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: branches/S2_5/client/gui-qt/mapctrl.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-qt/mapctrl.cpp?rev=31184&r1=31183&r2=31184&view=diff
==============================================================================
--- branches/S2_5/client/gui-qt/mapctrl.cpp     (original)
+++ branches/S2_5/client/gui-qt/mapctrl.cpp     Thu Dec 24 09:39:47 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