Author: mir3x
Date: Fri Nov 18 09:13:32 2016
New Revision: 34553

URL: http://svn.gna.org/viewcvs/freeciv?rev=34553&view=rev
Log:
Qt client - use mouse wheel up over sidebar icons to cycle via cities

See patch #7999


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

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=34553&r1=34552&r2=34553&view=diff
==============================================================================
--- branches/S2_6/client/gui-qt/menu.cpp        (original)
+++ branches/S2_6/client/gui-qt/menu.cpp        Fri Nov 18 09:13:32 2016
@@ -63,6 +63,9 @@
 static bool tradecity_rand(const trade_city *t1, const trade_city *t2);
 static void enable_interface(bool enable);
 extern int last_center_enemy;
+extern int last_center_capital;
+extern int last_center_player_city;
+extern int last_center_enemy_city;
 /**************************************************************************
   New turn callback
 **************************************************************************/
@@ -71,6 +74,9 @@
   gui()->rallies.run();
   real_menus_update();
   last_center_enemy = 0;
+  last_center_capital = 0;
+  last_center_player_city = 0;
+  last_center_enemy_city = 0;
 }
 
 /**************************************************************************

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=34553&r1=34552&r2=34553&view=diff
==============================================================================
--- branches/S2_6/client/gui-qt/pages.cpp       (original)
+++ branches/S2_6/client/gui-qt/pages.cpp       Fri Nov 18 09:13:32 2016
@@ -57,7 +57,13 @@
 const char *get_info_label_text(bool);
 }
 
+int last_center_capital = 0;
+int last_center_player_city = 0;
+int last_center_enemy_city = 0;
 extern void popup_shortcuts_dialog();
+static void center_next_enemy_city();
+static void center_next_player_city();
+static void center_next_player_capital();
 static struct server_scan *meta_scan, *lan_scan;
 static bool holding_srv_list_mutex = false;
 static enum connection_state connection_status;
@@ -702,8 +708,12 @@
   sw_cities = new fc_sidewidget(fc_icons::instance()->get_pixmap("cities"),
                                 _("Cities"), "CTS",
                                 city_report_dialog_popup);
+  sw_cities->set_wheel_up(center_next_enemy_city);
+  sw_cities->set_wheel_down(center_next_player_city);
   sw_diplo = new fc_sidewidget(fc_icons::instance()->get_pixmap("nations"),
                                _("Nations"), "PLR", popup_players_dialog);
+  sw_diplo->set_wheel_up(center_next_player_capital);
+  sw_diplo->set_wheel_down(key_center_capital);
   sw_science = new fc_sidewidget(fc_icons::instance()->get_pixmap("research"),
                                  _("Research"), "SCI",
                                  science_report_dialog_popup);
@@ -2075,6 +2085,120 @@
   sw_indicators->set_tooltip(QString(get_info_label_text_popup()));
 }
 
+/****************************************************************************
+  Centers next enemy city on view
+****************************************************************************/
+void center_next_enemy_city()
+{
+  bool center_next = false;
+  bool first_tile = false;
+  int first_id;
+  struct tile *ptile = nullptr;
+
+  players_iterate(pplayer) {
+    if (pplayer != client_player()) {
+      city_list_iterate(pplayer->cities, pcity) {
+        if (first_tile == false) {
+          first_tile = true;
+          ptile = pcity->tile;
+          first_id = pcity->id;
+        }
+        if ((last_center_enemy_city == 0) || center_next == true) {
+          last_center_enemy_city = pcity->id;
+          center_tile_mapcanvas(pcity->tile);
+          return;
+        }
+        if (pcity->id == last_center_enemy_city) {
+          center_next = true;
+        }
+      } city_list_iterate_end;
+    }
+  } players_iterate_end;
+
+  if (ptile != nullptr) {
+    center_tile_mapcanvas(ptile);
+    last_center_enemy_city = first_id;
+  }
+}
+
+/****************************************************************************
+  Centers next player city on view
+****************************************************************************/
+void center_next_player_city()
+{
+  bool center_next = false;
+  bool first_tile = false;
+  int first_id;
+  struct tile *ptile = nullptr;
+
+  players_iterate(pplayer) {
+    if (pplayer == client_player()) {
+      city_list_iterate(pplayer->cities, pcity) {
+        if (first_tile == false) {
+          first_tile = true;
+          ptile = pcity->tile;
+          first_id = pcity->id;
+        }
+        if ((last_center_player_city == 0) || center_next == true) {
+          last_center_player_city = pcity->id;
+          center_tile_mapcanvas(pcity->tile);
+          return;
+        }
+        if (pcity->id == last_center_player_city) {
+          center_next = true;
+        }
+      } city_list_iterate_end;
+    }
+  } players_iterate_end;
+
+  if (ptile != nullptr) {
+    center_tile_mapcanvas(ptile);
+    last_center_player_city = first_id;
+  }
+}
+
+/****************************************************************************
+  Centers next enemy capital
+****************************************************************************/
+void center_next_player_capital()
+{
+  struct city *capital;
+  bool center_next = false;
+  bool first_tile = false;
+  int first_id;
+  struct tile *ptile = nullptr;
+
+  players_iterate(pplayer) {
+    if (pplayer != client_player()) {
+      capital = player_capital(pplayer);
+      if (capital == nullptr) {
+        continue;
+      }
+        if (first_tile == false) {
+          first_tile = true;
+          ptile = capital->tile;
+          first_id = capital->id;
+        }
+        if ((last_center_player_city == 0) || center_next == true) {
+          last_center_player_city = capital->id;
+          center_tile_mapcanvas(capital->tile);
+          put_cross_overlay_tile(capital->tile);
+          return;
+        }
+        if (capital->id == last_center_player_city) {
+          center_next = true;
+        }
+    }
+  } players_iterate_end;
+
+  if (ptile != nullptr) {
+    center_tile_mapcanvas(ptile);
+    put_cross_overlay_tile(ptile);
+    last_center_player_city = first_id;
+  }
+
+}
+
 /***************************************************************************
   Update postion 
 ***************************************************************************/


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

Reply via email to