From a5e3e6713e1dd31a1493e5e7886ef72d6d46b563 Mon Sep 17 00:00:00 2001 From: Ingo Ruhnke Date: Fri, 8 Aug 2014 20:14:53 +0200 Subject: [PATCH] Cleaned up some function names in MenuManager --- src/control/keyboard_manager.cpp | 2 +- src/gui/menu.cpp | 14 +++++++------- src/gui/menu_manager.hpp | 10 +++++----- src/supertux/game_session.cpp | 2 +- src/supertux/screen_manager.cpp | 16 ++++++++-------- src/supertux/title_screen.cpp | 2 +- src/worldmap/worldmap.cpp | 2 +- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/control/keyboard_manager.cpp b/src/control/keyboard_manager.cpp index d53ed3981..c6b3b1bec 100644 --- a/src/control/keyboard_manager.cpp +++ b/src/control/keyboard_manager.cpp @@ -76,7 +76,7 @@ KeyboardManager::process_key_event(const SDL_KeyboardEvent& event) // if console is open: send key there process_console_key_event(event); } - else if (MenuManager::instance().current()) + else if (MenuManager::instance().is_active()) { // if menu mode: send key there process_menu_key_event(event); diff --git a/src/gui/menu.cpp b/src/gui/menu.cpp index 240f2fa71..5c0a1dc89 100644 --- a/src/gui/menu.cpp +++ b/src/gui/menu.cpp @@ -69,10 +69,10 @@ Menu::~Menu() { MenuManager::instance().m_all_menus.remove(this); - if (MenuManager::instance().current() == this) + if (MenuManager::instance().m_current == this) MenuManager::instance().m_current = nullptr; - if (MenuManager::instance().get_previous() == this) + if (MenuManager::instance().m_previous == this) MenuManager::instance().m_previous = nullptr; } @@ -630,13 +630,13 @@ Menu::draw(DrawingContext& context) { if (close) { - menu_width = (MenuManager::instance().current()->get_width() * (1.0f - effect_progress)); - menu_height = (MenuManager::instance().current()->get_height() * (1.0f - effect_progress)); + menu_width *= 1.0f - effect_progress; + menu_height *= 1.0f - effect_progress; } - else if (MenuManager::instance().get_previous()) + else if (MenuManager::instance().m_previous) { - menu_width = (menu_width * effect_progress) + (MenuManager::instance().get_previous()->get_width() * (1.0f - effect_progress)); - menu_height = (menu_height * effect_progress) + (MenuManager::instance().get_previous()->get_height() * (1.0f - effect_progress)); + menu_width = (menu_width * effect_progress) + (MenuManager::instance().m_previous->get_width() * (1.0f - effect_progress)); + menu_height = (menu_height * effect_progress) + (MenuManager::instance().m_previous->get_height() * (1.0f - effect_progress)); //std::cout << effect_progress << " " << this << " " << last_menus.back() << std::endl; } else diff --git a/src/gui/menu_manager.hpp b/src/gui/menu_manager.hpp index a390c6f0d..d601ae211 100644 --- a/src/gui/menu_manager.hpp +++ b/src/gui/menu_manager.hpp @@ -52,15 +52,15 @@ public: void recalc_pos(); - Menu* get_previous() + /** Return the current active menu or NULL if none is active */ + Menu* current() const { - return m_previous; + return m_current; } - /** Return the current active menu or NULL if none is active */ - Menu* current() + bool is_active() const { - return m_current; + return m_current != nullptr; } private: diff --git a/src/supertux/game_session.cpp b/src/supertux/game_session.cpp index f6bd71afd..86cc2bc0b 100644 --- a/src/supertux/game_session.cpp +++ b/src/supertux/game_session.cpp @@ -436,7 +436,7 @@ GameSession::update(float elapsed_time) } // Unpause the game if the menu has been closed - if (game_pause && !MenuManager::instance().current()) { + if (game_pause && !MenuManager::instance().is_active()) { g_screen_manager->set_speed(speed_before_pause); game_pause = false; } diff --git a/src/supertux/screen_manager.cpp b/src/supertux/screen_manager.cpp index 49468c21b..4b7661b12 100644 --- a/src/supertux/screen_manager.cpp +++ b/src/supertux/screen_manager.cpp @@ -139,8 +139,8 @@ ScreenManager::draw(DrawingContext& context) static int frame_count = 0; current_screen->draw(context); - if(MenuManager::instance().current() != NULL) - MenuManager::instance().current()->draw(context); + if(m_menu_manager->current() != NULL) + m_menu_manager->current()->draw(context); if(screen_fade.get() != NULL) screen_fade->draw(context); Console::instance->draw(context); @@ -175,8 +175,8 @@ ScreenManager::update_gamelogic(float elapsed_time) scripting::update_debugger(); scripting::TimeScheduler::instance->update(game_time); current_screen->update(elapsed_time); - if (MenuManager::instance().current() != NULL) - MenuManager::instance().current()->update(); + if (m_menu_manager->current() != NULL) + m_menu_manager->current()->update(); if(screen_fade.get() != NULL) screen_fade->update(elapsed_time); Console::instance->update(elapsed_time); @@ -191,8 +191,8 @@ ScreenManager::process_events() { g_input_manager->process_event(event); - if(MenuManager::instance().current() != NULL) - MenuManager::instance().current()->event(event); + if(m_menu_manager->current() != NULL) + m_menu_manager->current()->event(event); switch(event.type) { @@ -206,7 +206,7 @@ ScreenManager::process_events() case SDL_WINDOWEVENT_RESIZED: Renderer::instance()->resize(event.window.data1, event.window.data2); - MenuManager::instance().recalc_pos(); + m_menu_manager->recalc_pos(); break; } break; @@ -220,7 +220,7 @@ ScreenManager::process_events() { g_config->use_fullscreen = !g_config->use_fullscreen; Renderer::instance()->apply_config(); - MenuManager::instance().recalc_pos(); + m_menu_manager->recalc_pos(); } else if (event.key.keysym.sym == SDLK_PRINTSCREEN || event.key.keysym.sym == SDLK_F12) diff --git a/src/supertux/title_screen.cpp b/src/supertux/title_screen.cpp index bea654768..03201fee4 100644 --- a/src/supertux/title_screen.cpp +++ b/src/supertux/title_screen.cpp @@ -167,7 +167,7 @@ TitleScreen::update(float elapsed_time) // reopen menu if user closed it (so that the app doesn't close when user // accidently hit ESC) - if(MenuManager::instance().current() == 0 && g_screen_manager->has_no_pending_fadeout()) + if(!MenuManager::instance().is_active() && g_screen_manager->has_no_pending_fadeout()) { MenuManager::instance().set_current(main_menu.get()); } diff --git a/src/worldmap/worldmap.cpp b/src/worldmap/worldmap.cpp index c21fc0777..01fce1d98 100644 --- a/src/worldmap/worldmap.cpp +++ b/src/worldmap/worldmap.cpp @@ -406,7 +406,7 @@ void WorldMap::on_escape_press() { // Show or hide the menu - if(!MenuManager::instance().current()) { + if(!MenuManager::instance().is_active()) { MenuManager::instance().set_current(worldmap_menu.get()); tux->set_direction(D_NONE); // stop tux movement when menu is called } else { -- 2.11.0