Improved passive messages code. Fixed bug of showing a previous passive message when...
authorRicardo Cruz <rick2@aeiou.pt>
Wed, 28 Jul 2004 20:41:59 +0000 (20:41 +0000)
committerRicardo Cruz <rick2@aeiou.pt>
Wed, 28 Jul 2004 20:41:59 +0000 (20:41 +0000)
A bug still to fix is that when going from a passive message to a map one, both will be displayed. Anyway, first we need to test if this all code of passive/map messages is working.

SVN-Revision: 1659

src/worldmap.cpp
src/worldmap.h

index 58cfbbc..ad7fa47 100644 (file)
@@ -37,7 +37,7 @@
 #include "app/gettext.h"
 #include "misc.h"
 
-#define DISPLAY_MAP_MESSAGE_TIME 2600
+#define DISPLAY_MAP_MESSAGE_TIME 2800
 
 Menu* worldmap_menu  = 0;
 
@@ -298,7 +298,10 @@ Tux::action(float delta)
 
           WorldMap::SpecialTile* special_tile = worldmap->at_special_tile();
           if(special_tile && special_tile->passive_message)
-            special_tile->display_map_message_timer.start(DISPLAY_MAP_MESSAGE_TIME);
+            {
+            worldmap->passive_message = special_tile->display_map_message;
+            worldmap->passive_message_timer.start(DISPLAY_MAP_MESSAGE_TIME);
+            }
 
           if (worldmap->at(tile_pos)->stop || (special_tile && 
               !special_tile->passive_message))
@@ -470,7 +473,6 @@ WorldMap::load_map()
                       special_tile.passive_message = false;
                       if(!special_tile.display_map_message.empty())
                         special_tile.passive_message = true;
-                      special_tile.display_map_message_timer.init(true);
                       reader.read_string("map-message", special_tile.display_map_message);
                       reader.read_string("next-world", special_tile.next_worldmap);
                       reader.read_string("level", special_tile.level_name, true);
@@ -537,7 +539,7 @@ void WorldMap::get_level_title(SpecialTile& special_tile)
   LispReader* reader = LispReader::load(datadir + "/levels/" + special_tile.level_name, "supertux-level");
   if(!reader)
     {
-    std::cerr << "Error: Could not open special_tile file. Ignoring...\n";
+    std::cerr << "Error: Could not open level file. Ignoring...\n";
     return;
     }
 
@@ -995,18 +997,11 @@ WorldMap::draw_status(DrawingContext& context)
             }
         }
     }
-  for(SpecialTiles::iterator i = special_tiles.begin(); i != special_tiles.end(); ++i)
-    {
-    /* Display a passive message in the map, if any as been selected */
-    if(i->display_map_message_timer.check())
-      {
-      if(!i->display_map_message.empty())
-        context.draw_text_center(gold_text, i->display_map_message, 
-                Vector(0, screen->h - white_text->get_height() - 60),
-                LAYER_FOREGROUND1);
-      break;
-      }
-    }
+  /* Display a passive message in the map, if needed */
+  if(passive_message_timer.check())
+    context.draw_text_center(gold_text, passive_message, 
+            Vector(0, screen->h - white_text->get_height() - 60),
+            LAYER_FOREGROUND1);
 }
 
 void
index 5b4607a..10b86d7 100644 (file)
@@ -160,7 +160,6 @@ public:
 
     /** Message to show in the Map */
     std::string display_map_message;
-    Timer display_map_message_timer;
     bool passive_message;
 
     /** Go to this world */
@@ -179,6 +178,10 @@ public:
     bool west;
   };
 
+  /** Variables to deal with the passive map messages */
+  Timer passive_message_timer;
+  std::string passive_message;
+
 private:
   std::string map_filename;