From 19074099e21fa15535f611b3d231e55a14818019 Mon Sep 17 00:00:00 2001 From: grumbel Date: Thu, 19 Nov 2009 04:16:02 +0000 Subject: [PATCH] Renamed MenuManager to MenuStorage and MenuManager2 to MenuManager git-svn-id: http://supertux.lethargik.org/svn/supertux/trunk/supertux@6040 837edb03-e0f3-0310-88ca-d4d4e8b29345 --- src/control/joystickkeyboardcontroller.cpp | 2 +- src/gui/menu.cpp | 34 +++++++++++----------- src/gui/menu_manager.cpp | 16 +++++----- src/gui/menu_manager.hpp | 6 ++-- src/supertux/game_session.cpp | 16 +++++----- src/supertux/mainloop.cpp | 16 +++++----- src/supertux/menu/language_menu.cpp | 6 ++-- .../menu/{menu_manager.cpp => menu_storage.cpp} | 14 ++++----- .../menu/{menu_manager.hpp => menu_storage.hpp} | 12 ++++---- src/supertux/menu/options_menu.cpp | 12 ++++---- src/supertux/menu/profile_menu.cpp | 2 +- src/supertux/title_screen.cpp | 26 ++++++++--------- src/worldmap/worldmap.cpp | 16 +++++----- 13 files changed, 89 insertions(+), 89 deletions(-) rename src/supertux/menu/{menu_manager.cpp => menu_storage.cpp} (81%) rename src/supertux/menu/{menu_manager.hpp => menu_storage.hpp} (81%) diff --git a/src/control/joystickkeyboardcontroller.cpp b/src/control/joystickkeyboardcontroller.cpp index 6511a91b0..53a252d1b 100644 --- a/src/control/joystickkeyboardcontroller.cpp +++ b/src/control/joystickkeyboardcontroller.cpp @@ -490,7 +490,7 @@ JoystickKeyboardController::process_key_event(const SDL_Event& event) if (Console::instance->hasFocus()) { // if console is open: send key there process_console_key_event(event); - } else if (MenuManager2::current()) { + } else if (MenuManager::current()) { // if menu mode: send key there process_menu_key_event(event); } else if(key_mapping == keymap.end()) { diff --git a/src/gui/menu.cpp b/src/gui/menu.cpp index a78d9b784..66754c9ff 100644 --- a/src/gui/menu.cpp +++ b/src/gui/menu.cpp @@ -55,7 +55,7 @@ Menu::Menu() : arrow_left(), arrow_right() { - MenuManager2::all_menus.push_back(this); + MenuManager::all_menus.push_back(this); hit_item = -1; menuaction = MENU_ACTION_NONE; @@ -79,7 +79,7 @@ Menu::Menu() : Menu::~Menu() { - MenuManager2::all_menus.remove(this); + MenuManager::all_menus.remove(this); for(std::vector::iterator i = items.begin(); i != items.end(); ++i) @@ -87,11 +87,11 @@ Menu::~Menu() delete *i; } - if (MenuManager2::current_ == this) - MenuManager2::current_ = NULL; + if (MenuManager::current_ == this) + MenuManager::current_ = NULL; - if (MenuManager2::previous == this) - MenuManager2::previous = NULL; + if (MenuManager::previous == this) + MenuManager::previous = NULL; } void @@ -231,7 +231,7 @@ Menu::update() effect_progress = 1.0f; if (close) { - MenuManager2::current_ = 0; + MenuManager::current_ = 0; close = false; } } @@ -347,7 +347,7 @@ Menu::update() switch (items[active_item]->kind) { case MN_GOTO: assert(items[active_item]->target_menu != 0); - MenuManager2::push_current(items[active_item]->target_menu); + MenuManager::push_current(items[active_item]->target_menu); break; case MN_TOGGLE: @@ -379,7 +379,7 @@ Menu::update() break; case MN_BACK: - MenuManager2::pop_current(); + MenuManager::pop_current(); break; default: break; @@ -414,7 +414,7 @@ Menu::update() break; case MENU_ACTION_BACK: - MenuManager2::pop_current(); + MenuManager::pop_current(); break; case MENU_ACTION_NONE: @@ -652,13 +652,13 @@ Menu::draw(DrawingContext& context) { if (close) { - menu_width = (MenuManager2::current_->get_width() * (1.0f - effect_progress)); - menu_height = (MenuManager2::current_->get_height() * (1.0f - effect_progress)); + menu_width = (MenuManager::current_->get_width() * (1.0f - effect_progress)); + menu_height = (MenuManager::current_->get_height() * (1.0f - effect_progress)); } - else if (MenuManager2::previous) + else if (MenuManager::previous) { - menu_width = (menu_width * effect_progress) + (MenuManager2::previous->get_width() * (1.0f - effect_progress)); - menu_height = (menu_height * effect_progress) + (MenuManager2::previous->get_height() * (1.0f - effect_progress)); + menu_width = (menu_width * effect_progress) + (MenuManager::previous->get_width() * (1.0f - effect_progress)); + menu_height = (menu_height * effect_progress) + (MenuManager::previous->get_height() * (1.0f - effect_progress)); //std::cout << effect_progress << " " << this << " " << last_menus.back() << std::endl; } else @@ -762,10 +762,10 @@ Menu::set_toggled(int id, bool toggled) Menu* Menu::get_parent() const { - if (MenuManager2::last_menus.empty()) + if (MenuManager::last_menus.empty()) return 0; else - return MenuManager2::last_menus.back(); + return MenuManager::last_menus.back(); } /* Check for menu event */ diff --git a/src/gui/menu_manager.cpp b/src/gui/menu_manager.cpp index 51326362d..c30471e31 100644 --- a/src/gui/menu_manager.cpp +++ b/src/gui/menu_manager.cpp @@ -21,13 +21,13 @@ #include "supertux/globals.hpp" #include "supertux/timer.hpp" -std::vector MenuManager2::last_menus; -std::list MenuManager2::all_menus; -Menu* MenuManager2::current_ = 0; -Menu* MenuManager2::previous = 0; +std::vector MenuManager::last_menus; +std::list MenuManager::all_menus; +Menu* MenuManager::current_ = 0; +Menu* MenuManager::previous = 0; void -MenuManager2::push_current(Menu* pmenu) +MenuManager::push_current(Menu* pmenu) { previous = current_; @@ -40,7 +40,7 @@ MenuManager2::push_current(Menu* pmenu) } void -MenuManager2::pop_current() +MenuManager::pop_current() { previous = current_; @@ -55,7 +55,7 @@ MenuManager2::pop_current() } void -MenuManager2::set_current(Menu* menu) +MenuManager::set_current(Menu* menu) { if (current_ && current_->close == true) return; @@ -79,7 +79,7 @@ MenuManager2::set_current(Menu* menu) } void -MenuManager2::recalc_pos() +MenuManager::recalc_pos() { if (current_) current_->set_pos(SCREEN_WIDTH/2, SCREEN_HEIGHT/2); diff --git a/src/gui/menu_manager.hpp b/src/gui/menu_manager.hpp index 639f0fc78..be4a875b1 100644 --- a/src/gui/menu_manager.hpp +++ b/src/gui/menu_manager.hpp @@ -22,7 +22,7 @@ class Menu; -class MenuManager2 // FIXME: temporary name +class MenuManager // FIXME: temporary name { public: static std::vector last_menus; @@ -49,8 +49,8 @@ public: } private: - MenuManager2(const MenuManager2&); - MenuManager2& operator=(const MenuManager2&); + MenuManager(const MenuManager&); + MenuManager& operator=(const MenuManager&); }; #endif diff --git a/src/supertux/game_session.cpp b/src/supertux/game_session.cpp index 811b0406a..de0e53921 100644 --- a/src/supertux/game_session.cpp +++ b/src/supertux/game_session.cpp @@ -35,7 +35,7 @@ #include "supertux/levelintro.hpp" #include "supertux/globals.hpp" #include "supertux/mainloop.hpp" -#include "supertux/menu/menu_manager.hpp" +#include "supertux/menu/menu_storage.hpp" #include "supertux/menu/options_menu.hpp" #include "supertux/sector.hpp" #include "util/file_system.hpp" @@ -85,7 +85,7 @@ GameSession::GameSession(const std::string& levelfile_, Statistics* statistics) game_menu->add_label(level->name); game_menu->add_hl(); game_menu->add_entry(MNID_CONTINUE, _("Continue")); - game_menu->add_submenu(_("Options"), MenuManager::get_options_menu()); + game_menu->add_submenu(_("Options"), MenuStorage::get_options_menu()); game_menu->add_hl(); game_menu->add_entry(MNID_ABORTLEVEL, _("Abort Level")); } @@ -153,7 +153,7 @@ GameSession::~GameSession() delete capture_demo_stream; delete playback_demo_stream; delete demo_controller; - MenuManager::free_options_menu(); + MenuStorage::free_options_menu(); } void @@ -248,7 +248,7 @@ GameSession::toggle_pause() if(!game_pause) { speed_before_pause = g_main_loop->get_speed(); g_main_loop->set_speed(0); - MenuManager2::set_current(game_menu.get()); + MenuManager::set_current(game_menu.get()); game_menu->set_active_item(MNID_CONTINUE); game_pause = true; } @@ -393,16 +393,16 @@ GameSession::draw_pause(DrawingContext& context) void GameSession::process_menu() { - Menu* menu = MenuManager2::current(); + Menu* menu = MenuManager::current(); if(menu) { if(menu == game_menu.get()) { switch (game_menu->check()) { case MNID_CONTINUE: - MenuManager2::set_current(0); + MenuManager::set_current(0); toggle_pause(); break; case MNID_ABORTLEVEL: - MenuManager2::set_current(0); + MenuManager::set_current(0); g_main_loop->exit_screen(); break; } @@ -440,7 +440,7 @@ GameSession::update(float elapsed_time) process_menu(); // Unpause the game if the menu has been closed - if (game_pause && !MenuManager2::current()) { + if (game_pause && !MenuManager::current()) { g_main_loop->set_speed(speed_before_pause); game_pause = false; } diff --git a/src/supertux/mainloop.cpp b/src/supertux/mainloop.cpp index fe498700c..2b6ee997f 100644 --- a/src/supertux/mainloop.cpp +++ b/src/supertux/mainloop.cpp @@ -145,8 +145,8 @@ MainLoop::draw(DrawingContext& context) static int frame_count = 0; current_screen->draw(context); - if(MenuManager2::current() != NULL) - MenuManager2::current()->draw(context); + if(MenuManager::current() != NULL) + MenuManager::current()->draw(context); if(screen_fade.get() != NULL) screen_fade->draw(context); Console::instance->draw(context); @@ -181,8 +181,8 @@ MainLoop::update_gamelogic(float elapsed_time) Scripting::update_debugger(); Scripting::TimeScheduler::instance->update(game_time); current_screen->update(elapsed_time); - if (MenuManager2::current() != NULL) - MenuManager2::current()->update(); + if (MenuManager::current() != NULL) + MenuManager::current()->update(); if(screen_fade.get() != NULL) screen_fade->update(elapsed_time); Console::instance->update(elapsed_time); @@ -198,8 +198,8 @@ MainLoop::process_events() { g_main_controller->process_event(event); - if(MenuManager2::current() != NULL) - MenuManager2::current()->event(event); + if(MenuManager::current() != NULL) + MenuManager::current()->event(event); switch(event.type) { @@ -209,7 +209,7 @@ MainLoop::process_events() case SDL_VIDEORESIZE: Renderer::instance()->resize(event.resize.w, event.resize.h); - MenuManager2::recalc_pos(); + MenuManager::recalc_pos(); break; case SDL_KEYDOWN: @@ -221,7 +221,7 @@ MainLoop::process_events() { g_config->use_fullscreen = !g_config->use_fullscreen; init_video(); - MenuManager2::recalc_pos(); + MenuManager::recalc_pos(); } else if (event.key.keysym.sym == SDLK_PRINT || event.key.keysym.sym == SDLK_F12) diff --git a/src/supertux/menu/language_menu.cpp b/src/supertux/menu/language_menu.cpp index a8a316c3d..5e110b08a 100644 --- a/src/supertux/menu/language_menu.cpp +++ b/src/supertux/menu/language_menu.cpp @@ -61,14 +61,14 @@ LanguageMenu::menu_action(MenuItem* item) dictionary_manager.set_language(language); g_config->locale = language.str(); g_config->save(); - MenuManager2::pop_current(); + MenuManager::pop_current(); } else if (item->id == MNID_LANGUAGE_ENGLISH) // english { g_config->locale = "en"; dictionary_manager.set_language(tinygettext::Language::from_name(g_config->locale)); g_config->save(); - MenuManager2::pop_current(); + MenuManager::pop_current(); } else { @@ -82,7 +82,7 @@ LanguageMenu::menu_action(MenuItem* item) g_config->locale = i->str(); dictionary_manager.set_language(*i); g_config->save(); - MenuManager2::pop_current(); + MenuManager::pop_current(); break; } } diff --git a/src/supertux/menu/menu_manager.cpp b/src/supertux/menu/menu_storage.cpp similarity index 81% rename from src/supertux/menu/menu_manager.cpp rename to src/supertux/menu/menu_storage.cpp index 1c9f0bc7c..22a6949f4 100644 --- a/src/supertux/menu/menu_manager.cpp +++ b/src/supertux/menu/menu_storage.cpp @@ -14,37 +14,37 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#include "supertux/menu/menu_manager.hpp" +#include "supertux/menu/menu_storage.hpp" #include "supertux/menu/options_menu.hpp" #include "supertux/menu/profile_menu.hpp" -Menu* MenuManager::options_menu = 0; -Menu* MenuManager::profile_menu = 0; +Menu* MenuStorage::options_menu = 0; +Menu* MenuStorage::profile_menu = 0; Menu* -MenuManager::get_options_menu() +MenuStorage::get_options_menu() { options_menu = new OptionsMenu(); return options_menu; } void -MenuManager::free_options_menu() +MenuStorage::free_options_menu() { delete options_menu; options_menu = 0; } Menu* -MenuManager::get_profile_menu() +MenuStorage::get_profile_menu() { profile_menu = new ProfileMenu(); return profile_menu; } void -MenuManager::free_profile_menu() +MenuStorage::free_profile_menu() { delete profile_menu; profile_menu = 0; diff --git a/src/supertux/menu/menu_manager.hpp b/src/supertux/menu/menu_storage.hpp similarity index 81% rename from src/supertux/menu/menu_manager.hpp rename to src/supertux/menu/menu_storage.hpp index 435421d71..84ff7c954 100644 --- a/src/supertux/menu/menu_manager.hpp +++ b/src/supertux/menu/menu_storage.hpp @@ -14,15 +14,15 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#ifndef HEADER_SUPERTUX_SUPERTUX_MENU_MENU_MANAGER_HPP -#define HEADER_SUPERTUX_SUPERTUX_MENU_MENU_MANAGER_HPP +#ifndef HEADER_SUPERTUX_SUPERTUX_MENU_MENU_STORAGE_HPP +#define HEADER_SUPERTUX_SUPERTUX_MENU_MENU_STORAGE_HPP class Menu; -class MenuManager +class MenuStorage { public: - MenuManager(); + MenuStorage(); static Menu* get_options_menu(); static void free_options_menu(); @@ -35,8 +35,8 @@ private: static Menu* profile_menu; private: - MenuManager(const MenuManager&); - MenuManager& operator=(const MenuManager&); + MenuStorage(const MenuStorage&); + MenuStorage& operator=(const MenuStorage&); }; #endif diff --git a/src/supertux/menu/options_menu.cpp b/src/supertux/menu/options_menu.cpp index 0bceec86d..46c504e49 100644 --- a/src/supertux/menu/options_menu.cpp +++ b/src/supertux/menu/options_menu.cpp @@ -27,7 +27,7 @@ #include "supertux/main.hpp" #include "supertux/menu/profile_menu.hpp" #include "supertux/menu/language_menu.hpp" -#include "supertux/menu/menu_manager.hpp" +#include "supertux/menu/menu_storage.hpp" #include "util/gettext.hpp" #include "video/renderer.hpp" @@ -54,7 +54,7 @@ OptionsMenu::OptionsMenu() : add_submenu(_("Select Language"), language_menu.get()) ->set_help(_("Select a different language to display text in")); - add_submenu(_("Select Profile"), MenuManager::get_profile_menu()) + add_submenu(_("Select Profile"), MenuStorage::get_profile_menu()) ->set_help(_("Select a profile to play with")); add_toggle(MNID_PROFILES, _("Profile on Startup"), g_config->sound_enabled) @@ -177,12 +177,12 @@ OptionsMenu::menu_action(MenuItem* item) g_config->aspect_width = 0; // Magic values g_config->aspect_height = 0; Renderer::instance()->apply_config(); - MenuManager2::recalc_pos(); + MenuManager::recalc_pos(); } else if(sscanf(item->list[item->selected].c_str(), "%d:%d", &g_config->aspect_width, &g_config->aspect_height) == 2) { Renderer::instance()->apply_config(); - MenuManager2::recalc_pos(); + MenuManager::recalc_pos(); } else { @@ -201,7 +201,7 @@ OptionsMenu::menu_action(MenuItem* item) g_config->magnification /= 100.0f; } Renderer::instance()->apply_config(); - MenuManager2::recalc_pos(); + MenuManager::recalc_pos(); break; case MNID_FULLSCREEN_RESOLUTION: @@ -215,7 +215,7 @@ OptionsMenu::menu_action(MenuItem* item) if(g_config->use_fullscreen != is_toggled(MNID_FULLSCREEN)) { g_config->use_fullscreen = !g_config->use_fullscreen; init_video(); // FIXME: Should call apply_config instead - MenuManager2::recalc_pos(); + MenuManager::recalc_pos(); g_config->save(); } break; diff --git a/src/supertux/menu/profile_menu.cpp b/src/supertux/menu/profile_menu.cpp index e25f80fa9..ef2c0c36e 100644 --- a/src/supertux/menu/profile_menu.cpp +++ b/src/supertux/menu/profile_menu.cpp @@ -43,7 +43,7 @@ void ProfileMenu::menu_action(MenuItem* item) { g_config->profile = item->id; - MenuManager2::set_current(0); + MenuManager::set_current(0); } /* diff --git a/src/supertux/title_screen.cpp b/src/supertux/title_screen.cpp index 2e2d84c38..457667235 100644 --- a/src/supertux/title_screen.cpp +++ b/src/supertux/title_screen.cpp @@ -34,7 +34,7 @@ #include "supertux/gameconfig.hpp" #include "supertux/globals.hpp" #include "supertux/mainloop.hpp" -#include "supertux/menu/menu_manager.hpp" +#include "supertux/menu/menu_storage.hpp" #include "supertux/menu/options_menu.hpp" #include "supertux/resources.hpp" #include "supertux/sector.hpp" @@ -183,7 +183,7 @@ TitleScreen::check_levels_contrib_menu() contrib_world_menu->add_hl(); contrib_world_menu->add_back(_("Back")); - MenuManager2::push_current(contrib_world_menu.get()); + MenuManager::push_current(contrib_world_menu.get()); } } @@ -260,7 +260,7 @@ TitleScreen::check_addons_menu() try { AddonManager::get_instance().check_online(); generate_addons_menu(); - MenuManager2::set_current(addons_menu.get()); + MenuManager::set_current(addons_menu.get()); addons_menu->set_active_item(index); } catch (std::runtime_error e) { @@ -341,7 +341,7 @@ TitleScreen::generate_main_menu() main_menu->add_entry(MNID_STARTGAME, _("Start Game")); main_menu->add_entry(MNID_LEVELS_CONTRIB, _("Contrib Levels")); main_menu->add_entry(MNID_ADDONS, _("Add-ons")); - main_menu->add_submenu(_("Options"), MenuManager::get_options_menu()); + main_menu->add_submenu(_("Options"), MenuStorage::get_options_menu()); main_menu->add_entry(MNID_CREDITS, _("Credits")); main_menu->add_entry(MNID_QUITMAINMENU, _("Quit")); } @@ -361,7 +361,7 @@ TitleScreen::setup() sector->activate(sector->player->get_pos()); } - MenuManager2::set_current(main_menu.get()); + MenuManager::set_current(main_menu.get()); } void @@ -369,7 +369,7 @@ TitleScreen::leave() { Sector* sector = titlesession->get_current_sector(); sector->deactivate(); - MenuManager2::set_current(NULL); + MenuManager::set_current(NULL); } void @@ -402,7 +402,7 @@ TitleScreen::update(float elapsed_time) make_tux_jump(); - Menu* menu = MenuManager2::current(); + Menu* menu = MenuManager::current(); if(menu) { if(menu == main_menu.get()) { switch (main_menu->check()) { @@ -419,17 +419,17 @@ TitleScreen::update(float elapsed_time) case MNID_LEVELS_CONTRIB: // Contrib Menu generate_contrib_menu(); - MenuManager2::push_current(contrib_menu.get()); + MenuManager::push_current(contrib_menu.get()); break; case MNID_ADDONS: // Add-ons Menu generate_addons_menu(); - MenuManager2::push_current(addons_menu.get()); + MenuManager::push_current(addons_menu.get()); break; case MNID_CREDITS: - MenuManager2::set_current(NULL); + MenuManager::set_current(NULL); g_main_loop->push_screen(new TextScroller("credits.txt"), new FadeOut(0.5)); break; @@ -450,16 +450,16 @@ TitleScreen::update(float elapsed_time) // reopen menu if user closed it (so that the app doesn't close when user // accidently hit ESC) - if(MenuManager2::current() == 0 && g_main_loop->has_no_pending_fadeout()) { + if(MenuManager::current() == 0 && g_main_loop->has_no_pending_fadeout()) { generate_main_menu(); - MenuManager2::set_current(main_menu.get()); + MenuManager::set_current(main_menu.get()); } } void TitleScreen::start_game() { - MenuManager2::set_current(NULL); + MenuManager::set_current(NULL); std::string basename = current_world->get_basedir(); basename = basename.substr(0, basename.length()-1); std::string worlddirname = FileSystem::basename(basename); diff --git a/src/worldmap/worldmap.cpp b/src/worldmap/worldmap.cpp index 7842676c6..c8fbfd227 100644 --- a/src/worldmap/worldmap.cpp +++ b/src/worldmap/worldmap.cpp @@ -46,7 +46,7 @@ #include "supertux/game_session.hpp" #include "supertux/globals.hpp" #include "supertux/mainloop.hpp" -#include "supertux/menu/menu_manager.hpp" +#include "supertux/menu/menu_storage.hpp" #include "supertux/menu/options_menu.hpp" #include "supertux/player_status.hpp" #include "supertux/resources.hpp" @@ -178,7 +178,7 @@ WorldMap::WorldMap(const std::string& filename, const std::string& force_spawnpo worldmap_menu->add_label(_("Pause")); worldmap_menu->add_hl(); worldmap_menu->add_entry(MNID_RETURNWORLDMAP, _("Continue")); - worldmap_menu->add_submenu(_("Options"), MenuManager::get_options_menu()); + worldmap_menu->add_submenu(_("Options"), MenuStorage::get_options_menu()); worldmap_menu->add_hl(); worldmap_menu->add_entry(MNID_QUITWORLDMAP, _("Quit World")); @@ -441,11 +441,11 @@ void WorldMap::on_escape_press() { // Show or hide the menu - if(!MenuManager2::current()) { - MenuManager2::set_current(worldmap_menu.get()); + if(!MenuManager::current()) { + MenuManager::set_current(worldmap_menu.get()); tux->set_direction(D_NONE); // stop tux movement when menu is called } else { - MenuManager2::set_current(NULL); + MenuManager::set_current(NULL); } } @@ -598,13 +598,13 @@ void WorldMap::update(float delta) { if(!in_level) { - Menu* menu = MenuManager2::current(); + Menu* menu = MenuManager::current(); if(menu != NULL) { if(menu == worldmap_menu.get()) { switch (worldmap_menu->check()) { case MNID_RETURNWORLDMAP: // Return to game - MenuManager2::set_current(0); + MenuManager::set_current(0); break; case MNID_QUITWORLDMAP: // Quit Worldmap g_main_loop->exit_screen(); @@ -938,7 +938,7 @@ void WorldMap::setup() { sound_manager->play_music(music); - MenuManager2::set_current(NULL); + MenuManager::set_current(NULL); current_ = this; load_state(); -- 2.11.0