From: Ricardo Cruz Date: Wed, 28 Jul 2004 16:04:25 +0000 (+0000) Subject: New field: (passive-message "blabla") . This will show blabla in a passive way. ie... X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=88e294c0a6de9fbd4fabc07ccb1d82fa6b476992;p=supertux.git New field: (passive-message "blabla") . This will show blabla in a passive way. ie. when a player passed throught it, it will be shown for almost 3 seconds. As I said in my previous commit to 0_1_1_branch that �When you go from a message to another, you might notice that only a random of those will be displayed, not necessarly the last one. Will be fixed.�. Also, if you use (map-message "blabla"), a message flag will be shown in that field. SVN-Revision: 1654 --- diff --git a/src/worldmap.cpp b/src/worldmap.cpp index 68ad20bf0..67a2fadf3 100644 --- a/src/worldmap.cpp +++ b/src/worldmap.cpp @@ -37,6 +37,8 @@ #include "app/gettext.h" #include "misc.h" +#define DISPLAY_MAP_MESSAGE_TIME 2600 + Menu* worldmap_menu = 0; namespace WorldMapNS { @@ -294,7 +296,12 @@ Tux::action(float delta) { // We reached the next tile, so we check what to do now offset -= 32; - if (worldmap->at(tile_pos)->stop || worldmap->at_special_tile()) + 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); + + if (worldmap->at(tile_pos)->stop || (special_tile && + !special_tile->passive_message)) { stop(); } @@ -388,9 +395,9 @@ WorldMap::WorldMap() start_x = 4; start_y = 5; - level_sprite = new Surface(datadir + "/images/worldmap/levelmarker.png", true); leveldot_green = new Surface(datadir + "/images/worldmap/leveldot_green.png", true); leveldot_red = new Surface(datadir + "/images/worldmap/leveldot_red.png", true); + messagedot = new Surface(datadir + "/images/worldmap/messagedot.png", true); enter_level = false; @@ -403,9 +410,9 @@ WorldMap::~WorldMap() delete tux; delete tile_manager; - delete level_sprite; delete leveldot_green; delete leveldot_red; + delete messagedot; } void @@ -459,6 +466,11 @@ WorldMap::load_map() special_tile.west = true; reader.read_string("extro-filename", special_tile.extro_filename); + reader.read_string("passive-message", special_tile.display_map_message); + 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); @@ -901,6 +913,10 @@ WorldMap::draw(DrawingContext& context, const Vector& offset) for(SpecialTiles::iterator i = special_tiles.begin(); i != special_tiles.end(); ++i) { + if (!i->display_map_message.empty() && !i->passive_message) + context.draw_surface(messagedot, + Vector(i->x*32 + offset.x, i->y*32 + offset.y), LAYER_TILES+1); + if(i->level_name.empty()) continue; @@ -968,7 +984,7 @@ WorldMap::draw_status(DrawingContext& context) LAYER_FOREGROUND1); } - /* Display a message in the map, if any as been selected */ + /* Display an in-map message in the map, if any as been selected */ 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), @@ -977,6 +993,18 @@ 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; + } + } } void diff --git a/src/worldmap.h b/src/worldmap.h index 3e03400ef..5b4607a65 100644 --- a/src/worldmap.h +++ b/src/worldmap.h @@ -121,9 +121,9 @@ private: bool quit; - Surface* level_sprite; Surface* leveldot_green; Surface* leveldot_red; + Surface* messagedot; std::string name; std::string music; @@ -160,6 +160,8 @@ public: /** Message to show in the Map */ std::string display_map_message; + Timer display_map_message_timer; + bool passive_message; /** Go to this world */ std::string next_worldmap;