From: Ryan Flegel Date: Wed, 18 Jun 2008 05:08:20 +0000 (+0000) Subject: Menu now shrinks when closed instead of disappearing X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=13c4ea0cbf0bdbadc268f49b3cbc797e4f7a746d;p=supertux.git Menu now shrinks when closed instead of disappearing SVN-Revision: 5584 --- diff --git a/src/game_session.cpp b/src/game_session.cpp index ecf7f9275..84893569f 100644 --- a/src/game_session.cpp +++ b/src/game_session.cpp @@ -378,9 +378,14 @@ void GameSession::process_events() { // end of pause mode? + // XXX this looks like a fail-safe to unpause the game if there's no menu + // XXX having it enabled causes some unexpected problems + // XXX hopefully disabling it won't... + /* if(!Menu::current() && game_pause) { game_pause = false; } + */ // playback a demo? if(playback_demo_stream != 0) { diff --git a/src/gui/menu.cpp b/src/gui/menu.cpp index 6d6c2f6a8..b7873b6c0 100644 --- a/src/gui/menu.cpp +++ b/src/gui/menu.cpp @@ -142,23 +142,30 @@ Menu::pop_current() current_->effect_progress = 0.0f; last_menus.pop_back(); } else { - current_ = 0; + set_current(NULL); } } void Menu::set_current(Menu* menu) { + //last_menus.clear(); + if (current_ && current_->close == true) + return; + previous = current_; - last_menus.clear(); + if (menu) { + menu->effect_start_time = real_time; + menu->effect_progress = 0.0f; + current_ = menu; + } + else if (current_) { + current_->effect_start_time = real_time; + current_->effect_progress = 0.0f; + current_->close = true; + } - if (menu) - { - menu->effect_start_time = real_time; - menu->effect_progress = 0.0f; - } - current_ = menu; // just to be sure... main_controller->reset(); } @@ -243,6 +250,7 @@ Menu::~Menu() } Menu::Menu() + : close(false) { all_menus.push_back(this); @@ -401,7 +409,13 @@ Menu::update() if(effect_progress >= 1.0f) { effect_progress = 1.0f; - } else if (effect_progress <= 0.0f) { + + if (close) { + current_ = 0; + close = false; + } + } + else if (effect_progress <= 0.0f) { effect_progress = 0.0f; } @@ -813,7 +827,12 @@ Menu::draw(DrawingContext& context) if (effect_progress != 1.0f) { - if (Menu::previous) + if (close) + { + menu_width = (current_->get_width() * (1.0f - effect_progress)); + menu_height = (current_->get_height() * (1.0f - effect_progress)); + } + else if (Menu::previous) { menu_width = (menu_width * effect_progress) + (Menu::previous->get_width() * (1.0f - effect_progress)); menu_height = (menu_height * effect_progress) + (Menu::previous->get_height() * (1.0f - effect_progress)); diff --git a/src/gui/menu.hpp b/src/gui/menu.hpp index cdb33252f..60d48dd6d 100644 --- a/src/gui/menu.hpp +++ b/src/gui/menu.hpp @@ -146,6 +146,8 @@ private: char mn_input_char; float menu_repeat_time; + bool close; + public: static Font* default_font; static Font* active_font;