From 728f18780d7a71b382e4290ccafb52fbc50c5e06 Mon Sep 17 00:00:00 2001 From: mmlosh Date: Wed, 29 Jul 2009 17:29:31 +0000 Subject: [PATCH] Fix for #453 (Menu frame lingers) * moved "Menu::set_current(NULL);" before fadeout, so it closes during it * added main_loop->has_no_pending_fadeout() to avoid reopening main menu during fadeouts. git-svn-id: http://supertux.lethargik.org/svn/supertux/trunk/supertux@5906 837edb03-e0f3-0310-88ca-d4d4e8b29345 --- src/game_session.cpp | 1 - src/levelintro.cpp | 1 - src/mainloop.cpp | 8 +++++++- src/mainloop.hpp | 1 + src/textscroller.cpp | 1 - src/title.cpp | 6 ++++-- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/game_session.cpp b/src/game_session.cpp index 168b33b3e..c0747e83e 100644 --- a/src/game_session.cpp +++ b/src/game_session.cpp @@ -420,7 +420,6 @@ GameSession::process_menu() void GameSession::setup() { - Menu::set_current(NULL); current_ = this; if(currentsector != Sector::current()) { diff --git a/src/levelintro.cpp b/src/levelintro.cpp index 29660bee3..5662a3093 100644 --- a/src/levelintro.cpp +++ b/src/levelintro.cpp @@ -49,7 +49,6 @@ LevelIntro::~LevelIntro() void LevelIntro::setup() { - Menu::set_current(NULL); } void diff --git a/src/mainloop.cpp b/src/mainloop.cpp index f291e2807..0807a5800 100644 --- a/src/mainloop.cpp +++ b/src/mainloop.cpp @@ -115,6 +115,12 @@ MainLoop::get_speed() const return speed; } +bool +MainLoop::has_no_pending_fadeout() const +{ + return screen_fade.get() == NULL || screen_fade->done(); +} + void MainLoop::draw_fps(DrawingContext& context, float fps_fps) { @@ -232,7 +238,7 @@ void MainLoop::handle_screen_switch() { while( (next_screen.get() != NULL || nextpop) && - (screen_fade.get() == NULL || screen_fade->done())) { + has_no_pending_fadeout()) { if(current_screen.get() != NULL) { current_screen->leave(); } diff --git a/src/mainloop.hpp b/src/mainloop.hpp index 6edb42123..46e119af0 100644 --- a/src/mainloop.hpp +++ b/src/mainloop.hpp @@ -42,6 +42,7 @@ public: void quit(ScreenFade* fade = NULL); void set_speed(float speed); float get_speed() const; + bool has_no_pending_fadeout() const; /** * requests that a screenshot be taken after the next frame has been rendered diff --git a/src/textscroller.cpp b/src/textscroller.cpp index 94a74ee64..b46011903 100644 --- a/src/textscroller.cpp +++ b/src/textscroller.cpp @@ -88,7 +88,6 @@ void TextScroller::setup() { sound_manager->play_music(music); - Menu::set_current(NULL); } void diff --git a/src/title.cpp b/src/title.cpp index b6d1f4afd..724d1afb5 100644 --- a/src/title.cpp +++ b/src/title.cpp @@ -422,6 +422,7 @@ TitleScreen::update(float elapsed_time) break; case MNID_CREDITS: + Menu::set_current(NULL); main_loop->push_screen(new TextScroller("credits.txt"), new FadeOut(0.5)); break; @@ -440,9 +441,9 @@ TitleScreen::update(float elapsed_time) } } - // reopen menu of user closed it (so that the app doesn't close when user + // reopen menu if user closed it (so that the app doesn't close when user // accidently hit ESC) - if(Menu::current() == 0) { + if(Menu::current() == 0 && main_loop->has_no_pending_fadeout()) { generate_main_menu(); Menu::set_current(main_menu.get()); } @@ -451,6 +452,7 @@ TitleScreen::update(float elapsed_time) void TitleScreen::start_game() { + Menu::set_current(NULL); std::string basename = current_world->get_basedir(); basename = basename.substr(0, basename.length()-1); std::string worlddirname = FileSystem::basename(basename); -- 2.11.0