Author: mir3x
Date: Fri Nov 11 10:28:57 2016
New Revision: 34483

URL: http://svn.gna.org/viewcvs/freeciv?rev=34483&view=rev
Log:
Qt client - add terrain tooltip to unit label

See patch #7968


Modified:
    trunk/client/gui-qt/hudwidget.cpp

Modified: trunk/client/gui-qt/hudwidget.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/hudwidget.cpp?rev=34483&r1=34482&r2=34483&view=diff
==============================================================================
--- trunk/client/gui-qt/hudwidget.cpp   (original)
+++ trunk/client/gui-qt/hudwidget.cpp   Fri Nov 11 10:28:57 2016
@@ -44,6 +44,8 @@
 #include "fonts.h"
 #include "qtg_cxxside.h"
 #include "sprite.h"
+
+static QString popup_terrain_info(struct tile *ptile);
 
 /***************************************************************************
   Returns true if player has any unit of unit_type
@@ -555,7 +557,7 @@
   pix = QPixmap::fromImage(img);
   tile_label.setPixmap(pix);
   unit_label.setToolTip(popup_info_text(punit->tile));
-  tile_label.setToolTip(popup_info_text(punit->tile));
+  tile_label.setToolTip(popup_terrain_info(punit->tile));
   wwidth = wwidth + pix.width();
   qtg_canvas_free(tile_pixmap);
   qtg_canvas_free(unit_pixmap);
@@ -1344,3 +1346,23 @@
   }
   return false;
 }
+
+/****************************************************************************
+  Tooltip text for terrain information
+****************************************************************************/
+QString popup_terrain_info(struct tile *ptile)
+{
+  QString ret, t;
+  struct terrain *terr;
+
+  terr = ptile->terrain;
+  ret = QString(_("Terrain: %1\n")).arg(tile_get_info_text(ptile, TRUE, 0));
+  ret = ret + QString(_("Food/Prod/Trade: %1\n"))
+              .arg(get_tile_output_text(ptile));
+  t = get_infrastructure_text(ptile->extras);
+  if (t != '\0') {
+    ret = ret + QString(_("Infrastructure: %1\n")).arg(t);
+  }
+  ret = ret + QString(_("Defence bonus: %1%")).arg(terr->defense_bonus);
+  return ret;
+}


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

Reply via email to