X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fsupertux%2Flevelintro.cpp;h=f4b77acbfd2149f022133e6cc3eec0100d5a2ea8;hb=a351cbfc2a547e3407cf78fbcc93e585cac486d4;hp=8216995762907b4e294de10136425880d4a5f07a;hpb=ce804ee356a732b967f5db8183fc70be27ca8ecc;p=supertux.git diff --git a/src/supertux/levelintro.cpp b/src/supertux/levelintro.cpp index 821699576..f4b77acbf 100644 --- a/src/supertux/levelintro.cpp +++ b/src/supertux/levelintro.cpp @@ -16,26 +16,29 @@ #include "supertux/levelintro.hpp" -#include "control/joystickkeyboardcontroller.hpp" +#include "control/input_manager.hpp" #include "math/random_generator.hpp" #include "sprite/sprite_manager.hpp" #include "supertux/fadeout.hpp" #include "supertux/globals.hpp" -#include "supertux/mainloop.hpp" +#include "supertux/screen_manager.hpp" #include "supertux/resources.hpp" #include "util/gettext.hpp" -LevelIntro::LevelIntro(const Level* level, const Statistics* best_level_statistics) : - level(level), - best_level_statistics(best_level_statistics), +#include +#include + +LevelIntro::LevelIntro(const Level* level_, const Statistics* best_level_statistics_) : + level(level_), + best_level_statistics(best_level_statistics_), player_sprite(), - player_sprite_py(0), + player_sprite_py(0), player_sprite_vy(0), player_sprite_jump_timer() { - player_sprite = sprite_manager->create("images/creatures/tux/tux.sprite"); + player_sprite = SpriteManager::current()->create("images/creatures/tux/tux.sprite"); player_sprite->set_action("small-walk-right"); - player_sprite_jump_timer.start(systemRandom.randf(5,10)); + player_sprite_jump_timer.start(graphicsRandom.randf(5,10)); } LevelIntro::~LevelIntro() @@ -50,13 +53,15 @@ LevelIntro::setup() void LevelIntro::update(float elapsed_time) { + Controller *controller = InputManager::current()->get_controller(); // Check if it's time to exit the screen - if(g_main_controller->pressed(Controller::JUMP) - || g_main_controller->pressed(Controller::ACTION) - || g_main_controller->pressed(Controller::MENU_SELECT) - || g_main_controller->pressed(Controller::PAUSE_MENU)) { - g_main_loop->exit_screen(new FadeOut(0.1)); + if(controller->pressed(Controller::JUMP) + || controller->pressed(Controller::ACTION) + || controller->pressed(Controller::MENU_SELECT) + || controller->pressed(Controller::START) + || controller->pressed(Controller::ESCAPE)) { + ScreenManager::current()->pop_screen(std::unique_ptr(new FadeOut(0.1))); } player_sprite_py += player_sprite_vy * elapsed_time; @@ -67,9 +72,9 @@ LevelIntro::update(float elapsed_time) } if (player_sprite_jump_timer.check()) { player_sprite_vy = -300; - player_sprite_jump_timer.start(systemRandom.randf(2,3)); + player_sprite_jump_timer.start(graphicsRandom.randf(2,3)); } - + } void @@ -87,7 +92,7 @@ LevelIntro::draw(DrawingContext& context) std::string author = level->get_author(); if ((author != "") && (author != "SuperTux Team")) { - std::string author_text = std::string(_("contributed by ")) + author; + std::string author_text = str(boost::format(_("contributed by %s")) % author); context.draw_center_text(Resources::small_font, author_text, Vector(0, py), LAYER_FOREGROUND1, LevelIntro::author_color); py += static_cast(Resources::small_font->get_height()); } @@ -112,7 +117,14 @@ LevelIntro::draw(DrawingContext& context) context.draw_center_text(Resources::normal_font, ss.str(), Vector(0, py), LAYER_FOREGROUND1, LevelIntro::stat_color); py += static_cast(Resources::normal_font->get_height()); } - + + { + std::stringstream ss; + ss << _("Badguys killed") << ": " << Statistics::frags_to_string((best_level_statistics && (best_level_statistics->coins >= 0)) ? best_level_statistics->badguys : 0, stats.total_badguys); + context.draw_center_text(Resources::normal_font, ss.str(), Vector(0, py), LAYER_FOREGROUND1,LevelIntro::stat_color); + py += static_cast(Resources::normal_font->get_height()); + } + { std::stringstream ss; ss << _("Secrets") << ": " << Statistics::secrets_to_string((best_level_statistics && (best_level_statistics->coins >= 0)) ? best_level_statistics->secrets : 0, stats.total_secrets); @@ -122,7 +134,14 @@ LevelIntro::draw(DrawingContext& context) { std::stringstream ss; - ss << _("Time") << ": " << Statistics::time_to_string((best_level_statistics && (best_level_statistics->coins >= 0)) ? best_level_statistics->time : 0); + ss << _("Best time") << ": " << Statistics::time_to_string((best_level_statistics && (best_level_statistics->coins >= 0)) ? best_level_statistics->time : 0); + context.draw_center_text(Resources::normal_font, ss.str(), Vector(0, py), LAYER_FOREGROUND1,LevelIntro::stat_color); + py += static_cast(Resources::normal_font->get_height()); + } + + if(level->target_time){ + std::stringstream ss; + ss << _("Level target time") << ": " << Statistics::time_to_string(level->target_time); context.draw_center_text(Resources::normal_font, ss.str(), Vector(0, py), LAYER_FOREGROUND1,LevelIntro::stat_color); py += static_cast(Resources::normal_font->get_height()); }