From: Ricardo Cruz Date: Wed, 28 Jul 2004 20:41:59 +0000 (+0000) Subject: Improved passive messages code. Fixed bug of showing a previous passive message when... X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=331ddd57535dd0e1aa5bb9595e8b22a5e8c59629;p=supertux.git Improved passive messages code. Fixed bug of showing a previous passive message when a new one should be being displayed now. 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 --- diff --git a/src/worldmap.cpp b/src/worldmap.cpp index 58cfbbc01..ad7fa4728 100644 --- a/src/worldmap.cpp +++ b/src/worldmap.cpp @@ -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 diff --git a/src/worldmap.h b/src/worldmap.h index 5b4607a65..10b86d7fb 100644 --- a/src/worldmap.h +++ b/src/worldmap.h @@ -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;