Author: mir3x
Date: Thu Feb  2 20:34:42 2017
New Revision: 34930

URL: http://svn.gna.org/viewcvs/freeciv?rev=34930&view=rev
Log:
Qt client - add movement cost to terrain tooltip

See patch #8099


Modified:
    branches/S3_0/client/gui-qt/hudwidget.cpp
    branches/S3_0/client/gui-qt/mapview.cpp

Modified: branches/S3_0/client/gui-qt/hudwidget.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S3_0/client/gui-qt/hudwidget.cpp?rev=34930&r1=34929&r2=34930&view=diff
==============================================================================
--- branches/S3_0/client/gui-qt/hudwidget.cpp   (original)
+++ branches/S3_0/client/gui-qt/hudwidget.cpp   Thu Feb  2 20:34:42 2017
@@ -1569,8 +1569,10 @@
 ****************************************************************************/
 QString popup_terrain_info(struct tile *ptile)
 {
-  QString ret, t;
+  int movement_cost;
   struct terrain *terr;
+  QString ret, t, move_text;
+  bool has_road;
 
   terr = ptile->terrain;
   ret = QString(_("Terrain: %1\n")).arg(tile_get_info_text(ptile, TRUE, 0));
@@ -1580,7 +1582,27 @@
   if (t != "") {
     ret = ret + QString(_("Infrastructure: %1\n")).arg(t);
   }
-  ret = ret + QString(_("Defense bonus: %1%")).arg(terr->defense_bonus);
+  ret = ret + QString(_("Defense bonus: %1%\n")).arg(terr->defense_bonus);
+  movement_cost = terr->movement_cost;
+
+  extra_type_by_cause_iterate(EC_ROAD, pextra) {
+    struct road_type *proad = extra_road_get(pextra);
+
+    if (tile_has_road(ptile, proad)) {
+      if (proad->move_cost <= movement_cost) {
+        has_road = true;
+        move_text = move_points_text(proad->move_cost, TRUE);
+        movement_cost = proad->move_cost;
+      }
+    }
+  } extra_type_by_cause_iterate_end;
+
+  if (has_road == true) {
+    ret = ret + QString(_("Movement cost: %1")).arg(move_text);
+  } else {
+    ret = ret + QString(_("Movement cost: %1")).arg(movement_cost);
+  }
+
   return ret;
 }
 

Modified: branches/S3_0/client/gui-qt/mapview.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S3_0/client/gui-qt/mapview.cpp?rev=34930&r1=34929&r2=34930&view=diff
==============================================================================
--- branches/S3_0/client/gui-qt/mapview.cpp     (original)
+++ branches/S3_0/client/gui-qt/mapview.cpp     Thu Feb  2 20:34:42 2017
@@ -182,6 +182,7 @@
   timer->start(200);
   resize(0, 0);
   setMouseTracking(true);
+  stored_autocenter = gui_options.auto_center_on_unit;
   setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
 }
 


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

Reply via email to