Worldmap stats report level target time
authorLMH <lmh.0013@gmail.com>
Sat, 7 Sep 2013 01:06:39 +0000 (15:06 -1000)
committerTobias Markus <tobbi@mozilla-uk.org>
Sat, 26 Oct 2013 16:45:21 +0000 (18:45 +0200)
src/supertux/statistics.cpp
src/supertux/statistics.hpp
src/worldmap/worldmap.cpp

index 975880a..22dbace 100644 (file)
@@ -95,7 +95,7 @@ Statistics::unserialize_from_squirrel(HSQUIRRELVM vm)
 }
 
 void
-Statistics::draw_worldmap_info(DrawingContext& context)
+Statistics::draw_worldmap_info(DrawingContext& context, float target_time)
 {
   // skip draw if level was never played
   if (coins == nv_coins) return;
@@ -121,7 +121,7 @@ Statistics::draw_worldmap_info(DrawingContext& context)
   std::string caption_buf;
   std::string stat_buf;
   float posy = WMAP_INFO_TOP_Y2;
-  for (int stat_no = 0; stat_no < 4; stat_no++) {
+  for (int stat_no = 0; stat_no < 5; stat_no++) {
     switch (stat_no)
     {
       case 0:
@@ -133,13 +133,21 @@ Statistics::draw_worldmap_info(DrawingContext& context)
         stat_buf = frags_to_string(badguys, total_badguys);
         break;
       case 2:
-        caption_buf = _("Min time needed:");
-        stat_buf = time_to_string(time);
-        break;
-      case 3:
         caption_buf = _("Max secrets found:");
         stat_buf = secrets_to_string(secrets, total_secrets);
         break;
+      case 3:
+        caption_buf = _("Best time completed:");
+        stat_buf = time_to_string(time);
+        break;
+      case 4:
+        if(target_time){ // display target time only if defined for level
+          caption_buf = _("Level target time:");
+          stat_buf = time_to_string(target_time);
+        } else {
+          caption_buf = "";
+          stat_buf = "";
+        }
       default:
         log_debug << "Invalid stat requested to be drawn" << std::endl;
         break;
index e11c39d..37a7710 100644 (file)
@@ -58,7 +58,7 @@ public:
    */
   void unserialize_from_squirrel(HSQUIRRELVM vm);
 
-  void draw_worldmap_info(DrawingContext& context); /**< draw worldmap stat HUD */
+  void draw_worldmap_info(DrawingContext& context, float target_time); /**< draw worldmap stat HUD */
   void draw_endseq_panel(DrawingContext& context, Statistics* best_stats, SurfacePtr backdrop); /**< draw panel shown during level's end sequence */
 
   void zero(); /**< Set stats to zero */
index 31d631c..09bb8b5 100644 (file)
@@ -858,7 +858,8 @@ WorldMap::draw_status(DrawingContext& context)
           }
         */
 
-        level->statistics.draw_worldmap_info(context);
+        get_level_target_time(*level);
+        level->statistics.draw_worldmap_info(context, level->target_time);
         break;
       }
     }