From 264ce2714ecbdedf92a0f333ea7b89fe9ceedfe1 Mon Sep 17 00:00:00 2001 From: Ingo Ruhnke Date: Fri, 8 Aug 2014 21:20:27 +0200 Subject: [PATCH] Switched from passing pointers around to using numeric MenuIds and a factory class --- src/gui/menu.cpp | 2 +- src/gui/menu.hpp | 2 +- src/gui/menu_item.cpp | 8 ++-- src/gui/menu_item.hpp | 4 +- src/gui/menu_manager.cpp | 35 +++++++++++++++-- src/gui/menu_manager.hpp | 7 +++- src/supertux/game_session.cpp | 15 ++----- src/supertux/game_session.hpp | 2 - src/supertux/menu/contrib_menu.cpp | 7 ++-- src/supertux/menu/contrib_menu.hpp | 1 - src/supertux/menu/game_menu.cpp | 8 ++-- src/supertux/menu/game_menu.hpp | 2 +- src/supertux/menu/main_menu.cpp | 8 ++-- src/supertux/menu/menu_storage.cpp | 78 +++++++++++++++++++++++-------------- src/supertux/menu/menu_storage.hpp | 31 ++++++++++----- src/supertux/menu/options_menu.cpp | 13 +++---- src/supertux/menu/options_menu.hpp | 6 --- src/supertux/menu/worldmap_menu.cpp | 2 +- src/supertux/title_screen.cpp | 17 ++++---- src/supertux/title_screen.hpp | 3 -- src/worldmap/worldmap.cpp | 13 ++----- src/worldmap/worldmap.hpp | 3 -- 22 files changed, 149 insertions(+), 118 deletions(-) diff --git a/src/gui/menu.cpp b/src/gui/menu.cpp index 5c0a1dc89..581414e7f 100644 --- a/src/gui/menu.cpp +++ b/src/gui/menu.cpp @@ -172,7 +172,7 @@ Menu::add_back(const std::string& text) } MenuItem* -Menu::add_submenu(const std::string& text, Menu* submenu, int id) +Menu::add_submenu(const std::string& text, int submenu, int id) { std::unique_ptr item(new MenuItem(MN_GOTO, id)); item->text = text; diff --git a/src/gui/menu.hpp b/src/gui/menu.hpp index 302750684..006eda7bf 100644 --- a/src/gui/menu.hpp +++ b/src/gui/menu.hpp @@ -62,7 +62,7 @@ public: MenuItem* add_toggle(int id, const std::string& text, bool toggled = false); MenuItem* add_inactive(int id, const std::string& text); MenuItem* add_back(const std::string& text); - MenuItem* add_submenu(const std::string& text, Menu* submenu, int id = -1); + MenuItem* add_submenu(const std::string& text, int submenu, int id = -1); MenuItem* add_controlfield(int id, const std::string& text, const std::string& mapping = ""); MenuItem* add_string_select(int id, const std::string& text); diff --git a/src/gui/menu_item.cpp b/src/gui/menu_item.cpp index 02eb90c78..e8554ef7e 100644 --- a/src/gui/menu_item.cpp +++ b/src/gui/menu_item.cpp @@ -16,12 +16,14 @@ #include "gui/menu_item.hpp" +#include + +#include "supertux/menu/menu_storage.hpp" #include "supertux/resources.hpp" #include "supertux/timer.hpp" #include "video/font.hpp" -#include -static const float FLICK_CURSOR_TIME = 0.5f; +static const float FLICK_CURSOR_TIME = 0.5f; MenuItem::MenuItem(MenuItemKind _kind, int _id) : kind(_kind), @@ -37,7 +39,7 @@ MenuItem::MenuItem(MenuItemKind _kind, int _id) : { toggled = false; selected = false; - target_menu = 0; + target_menu = MenuStorage::NO_MENU; } void diff --git a/src/gui/menu_item.hpp b/src/gui/menu_item.hpp index 35fbc37f1..22814129e 100644 --- a/src/gui/menu_item.hpp +++ b/src/gui/menu_item.hpp @@ -42,7 +42,7 @@ class MenuItem { public: static MenuItem* create(MenuItemKind kind, const std::string& text, - int init_toggle, Menu* target_menu, int id, int key); + int init_toggle, int target_menu, int id, int key); public: MenuItem(MenuItemKind kind, int id = -1); @@ -65,7 +65,7 @@ public: std::vector list; // list of values for a STRINGSELECT item size_t selected; // currently selected item - Menu* target_menu; + int target_menu; private: /// keyboard key or joystick button diff --git a/src/gui/menu_manager.cpp b/src/gui/menu_manager.cpp index dd07255e5..77c5a7f44 100644 --- a/src/gui/menu_manager.cpp +++ b/src/gui/menu_manager.cpp @@ -21,6 +21,7 @@ #include "control/input_manager.hpp" #include "gui/menu.hpp" #include "supertux/globals.hpp" +#include "supertux/menu/menu_storage.hpp" #include "supertux/timer.hpp" MenuManager* MenuManager::s_instance = 0; @@ -55,8 +56,29 @@ MenuManager::draw(DrawingContext& context) } } +bool +MenuManager::check_menu() +{ + if (m_current) + { + m_current->check_menu(); + return true; + } + else + { + return false; + } +} + void -MenuManager::push_current(Menu* menu) +MenuManager::push_current(int id) +{ + Menu* menu = MenuStorage::instance().create(static_cast(id)); + push_current_(menu); +} + +void +MenuManager::push_current_(Menu* menu) { m_previous = m_current; @@ -84,12 +106,19 @@ MenuManager::pop_current() } else { - set_current(nullptr); + set_current(MenuStorage::NO_MENU); } } void -MenuManager::set_current(Menu* menu) +MenuManager::set_current(int id) +{ + Menu* menu = MenuStorage::instance().create(static_cast(id)); + set_current_ptr(menu); +} + +void +MenuManager::set_current_ptr(Menu* menu) { if (m_current && m_current->close == true) { diff --git a/src/gui/menu_manager.hpp b/src/gui/menu_manager.hpp index 85a88cabf..e0915ffa3 100644 --- a/src/gui/menu_manager.hpp +++ b/src/gui/menu_manager.hpp @@ -46,11 +46,14 @@ public: ~MenuManager(); void draw(DrawingContext& context); + bool check_menu(); /** Set the current menu, if pmenu is NULL, hide the current menu */ - void set_current(Menu* pmenu); + void set_current_ptr(Menu* menu); + void set_current(int id); - void push_current(Menu* pmenu); + void push_current(int id); + void push_current_(Menu* menu); void pop_current(); void recalc_pos(); diff --git a/src/supertux/game_session.cpp b/src/supertux/game_session.cpp index 86cc2bc0b..11f1f3617 100644 --- a/src/supertux/game_session.cpp +++ b/src/supertux/game_session.cpp @@ -34,7 +34,6 @@ #include "supertux/gameconfig.hpp" #include "supertux/globals.hpp" #include "supertux/levelintro.hpp" -#include "supertux/menu/game_menu.hpp" #include "supertux/menu/menu_storage.hpp" #include "supertux/menu/options_menu.hpp" #include "supertux/player_status.hpp" @@ -66,7 +65,6 @@ GameSession::GameSession(const std::string& levelfile_, PlayerStatus* player_sta capture_file(), playback_demo_stream(0), demo_controller(0), - game_menu(), play_time(0), edit_mode(false), levelintro_shown(false) @@ -80,8 +78,6 @@ GameSession::GameSession(const std::string& levelfile_, PlayerStatus* player_sta if (restart_level() != 0) throw std::runtime_error ("Initializing the level failed."); - - game_menu.reset(new GameMenu(*level)); } int @@ -248,8 +244,7 @@ GameSession::toggle_pause() if(!game_pause) { speed_before_pause = g_screen_manager->get_speed(); g_screen_manager->set_speed(0); - MenuManager::instance().set_current(game_menu.get()); - game_menu->set_active_item(MNID_CONTINUE); + MenuManager::instance().set_current(MenuStorage::GAME_MENU); game_pause = true; } @@ -259,7 +254,7 @@ GameSession::toggle_pause() void GameSession::abort_level() { - MenuManager::instance().set_current(0); + MenuManager::instance().set_current(MenuStorage::NO_MENU); g_screen_manager->exit_screen(); currentsector->player->set_bonus(bonus_at_start); PlayerStatus *currentStatus = get_player_status(); @@ -429,11 +424,7 @@ GameSession::update(float elapsed_time) on_escape_press(); process_events(); - Menu* menu = MenuManager::instance().current(); - if (menu && menu == game_menu.get()) - { - menu->check_menu(); - } + MenuManager::instance().check_menu(); // Unpause the game if the menu has been closed if (game_pause && !MenuManager::instance().is_active()) { diff --git a/src/supertux/game_session.hpp b/src/supertux/game_session.hpp index 87a419272..f2f18f1f3 100644 --- a/src/supertux/game_session.hpp +++ b/src/supertux/game_session.hpp @@ -141,8 +141,6 @@ private: std::istream* playback_demo_stream; CodeController* demo_controller; - std::unique_ptr game_menu; - float play_time; /**< total time in seconds that this session ran interactively */ bool edit_mode; /**< true if GameSession runs in level editor mode */ diff --git a/src/supertux/menu/contrib_menu.cpp b/src/supertux/menu/contrib_menu.cpp index 2139e21fd..913a13650 100644 --- a/src/supertux/menu/contrib_menu.cpp +++ b/src/supertux/menu/contrib_menu.cpp @@ -19,13 +19,12 @@ #include #include "gui/menu_manager.hpp" -#include "supertux/menu/contrib_world_menu.hpp" +#include "supertux/menu/menu_storage.hpp" #include "supertux/title_screen.hpp" #include "supertux/world.hpp" #include "util/gettext.hpp" ContribMenu::ContribMenu() : - m_contrib_world_menu(), m_contrib_worlds() { /** Generating contrib levels list by making use of Level Subset */ @@ -82,8 +81,10 @@ ContribMenu::check_menu() } else { +#ifdef GRUMBEL m_contrib_world_menu.reset(new ContribWorldMenu(*world)); - MenuManager::instance().push_current(m_contrib_world_menu.get()); + MenuManager::instance().push_current(MenuStorage::CONTRIB_WORLD_MENU); +#endif } } } diff --git a/src/supertux/menu/contrib_menu.hpp b/src/supertux/menu/contrib_menu.hpp index aa45b959f..01f872982 100644 --- a/src/supertux/menu/contrib_menu.hpp +++ b/src/supertux/menu/contrib_menu.hpp @@ -25,7 +25,6 @@ class World; class ContribMenu : public Menu { private: - std::unique_ptr m_contrib_world_menu; std::vector > m_contrib_worlds; public: diff --git a/src/supertux/menu/game_menu.cpp b/src/supertux/menu/game_menu.cpp index 13deef988..0fad9d6e1 100644 --- a/src/supertux/menu/game_menu.cpp +++ b/src/supertux/menu/game_menu.cpp @@ -24,12 +24,14 @@ #include "supertux/menu/options_menu.hpp" #include "util/gettext.hpp" -GameMenu::GameMenu(const Level& level) +GameMenu::GameMenu() { - add_label(level.name); + Level* level = GameSession::current()->get_current_level(); + + add_label(level->name); add_hl(); add_entry(MNID_CONTINUE, _("Continue")); - add_submenu(_("Options"), MenuStorage::instance().get_options_menu()); + add_submenu(_("Options"), MenuStorage::OPTIONS_MENU); add_hl(); add_entry(MNID_ABORTLEVEL, _("Abort Level")); } diff --git a/src/supertux/menu/game_menu.hpp b/src/supertux/menu/game_menu.hpp index c325926c6..38124cd42 100644 --- a/src/supertux/menu/game_menu.hpp +++ b/src/supertux/menu/game_menu.hpp @@ -30,7 +30,7 @@ class GameMenu : public Menu { private: public: - GameMenu(const Level& level); + GameMenu(); void check_menu() override; diff --git a/src/supertux/menu/main_menu.cpp b/src/supertux/menu/main_menu.cpp index 21b1fa044..97101c51e 100644 --- a/src/supertux/menu/main_menu.cpp +++ b/src/supertux/menu/main_menu.cpp @@ -40,7 +40,7 @@ MainMenu::MainMenu() : add_entry(MNID_STARTGAME, _("Start Game")); add_entry(MNID_LEVELS_CONTRIB, _("Contrib Levels")); add_entry(MNID_ADDONS, _("Add-ons")); - add_submenu(_("Options"), MenuStorage::instance().get_options_menu()); + add_submenu(_("Options"), MenuStorage::OPTIONS_MENU); add_entry(MNID_CREDITS, _("Credits")); add_entry(MNID_QUITMAINMENU, _("Quit")); } @@ -62,17 +62,17 @@ MainMenu::check_menu() case MNID_LEVELS_CONTRIB: // Contrib Menu m_contrib_menu.reset(new ContribMenu()); - MenuManager::instance().push_current(m_contrib_menu.get()); + MenuManager::instance().push_current(MenuStorage::CONTRIB_MENU); break; case MNID_ADDONS: // Add-ons Menu m_addon_menu.reset(new AddonMenu()); - MenuManager::instance().push_current(m_addon_menu.get()); + MenuManager::instance().push_current(MenuStorage::ADDON_MENU); break; case MNID_CREDITS: - MenuManager::instance().set_current(NULL); + MenuManager::instance().set_current(MenuStorage::NO_MENU); g_screen_manager->push_screen(std::unique_ptr(new TextScroller("credits.txt")), std::unique_ptr(new FadeOut(0.5))); break; diff --git a/src/supertux/menu/menu_storage.cpp b/src/supertux/menu/menu_storage.cpp index 0623f2361..757eeff0a 100644 --- a/src/supertux/menu/menu_storage.cpp +++ b/src/supertux/menu/menu_storage.cpp @@ -16,11 +16,18 @@ #include "supertux/menu/menu_storage.hpp" -#include "supertux/menu/options_menu.hpp" -#include "supertux/menu/profile_menu.hpp" +#include "supertux/globals.hpp" +#include "supertux/menu/addon_menu.hpp" +#include "supertux/menu/contrib_menu.hpp" +#include "supertux/menu/contrib_world_menu.hpp" +#include "supertux/menu/game_menu.hpp" #include "supertux/menu/joystick_menu.hpp" #include "supertux/menu/keyboard_menu.hpp" -#include "supertux/globals.hpp" +#include "supertux/menu/language_menu.hpp" +#include "supertux/menu/main_menu.hpp" +#include "supertux/menu/options_menu.hpp" +#include "supertux/menu/profile_menu.hpp" +#include "supertux/menu/worldmap_menu.hpp" MenuStorage* MenuStorage::s_instance = 0; @@ -42,48 +49,59 @@ MenuStorage::~MenuStorage() s_instance = nullptr; } -OptionsMenu* -MenuStorage::get_options_menu() +Menu* +MenuStorage::create(MenuId menu_id) { - if (!m_options_menu) + switch(menu_id) { - m_options_menu.reset(new OptionsMenu); - } + case MAIN_MENU: + return new MainMenu; - return m_options_menu.get(); -} + case LANGUAGE_MENU: + return new LanguageMenu; -ProfileMenu* -MenuStorage::get_profile_menu() -{ - if (!m_profile_menu) - { - m_profile_menu.reset(new ProfileMenu); - } + case OPTIONS_MENU: + return new OptionsMenu; + + case PROFILE_MENU: + return new ProfileMenu; + + case KEYBOARD_MENU: + return new KeyboardMenu(g_input_manager); - return m_profile_menu.get(); + case JOYSTICK_MENU: + return new JoystickMenu(g_input_manager); + + case WORLDMAP_MENU: + return new WorldmapMenu; + + case GAME_MENU: + return new GameMenu; + + case CONTRIB_MENU: + return new ContribMenu; + + case CONTRIB_WORLD_MENU: + return 0; //return new ContribWorldMenu(); + + case ADDON_MENU: + return new AddonMenu; + + default: + assert(!"unknown MenuId provided"); + } } KeyboardMenu* MenuStorage::get_key_options_menu() { - if (!m_key_options_menu) - { - m_key_options_menu.reset(new KeyboardMenu(g_input_manager)); - } - - return m_key_options_menu.get(); + return new KeyboardMenu(g_input_manager); } JoystickMenu* MenuStorage::get_joystick_options_menu() { - if (!m_joystick_options_menu) - { - m_joystick_options_menu.reset(new JoystickMenu(g_input_manager)); - } - - return m_joystick_options_menu.get(); + return new JoystickMenu(g_input_manager); } /* EOF */ diff --git a/src/supertux/menu/menu_storage.hpp b/src/supertux/menu/menu_storage.hpp index 2314097e5..647af1ad4 100644 --- a/src/supertux/menu/menu_storage.hpp +++ b/src/supertux/menu/menu_storage.hpp @@ -33,19 +33,30 @@ public: static MenuStorage& instance(); public: + enum MenuId { + NO_MENU, + MAIN_MENU, + OPTIONS_MENU, + PROFILE_MENU, + CONTRIB_MENU, + CONTRIB_WORLD_MENU, + ADDON_MENU, + LANGUAGE_MENU, + KEYBOARD_MENU, + JOYSTICK_MENU, + WORLDMAP_MENU, + GAME_MENU + }; + +public: MenuStorage(); ~MenuStorage(); - - OptionsMenu* get_options_menu(); - ProfileMenu* get_profile_menu(); - KeyboardMenu* get_key_options_menu(); + + Menu* create(MenuId menu_id); + + // FIXME JoystickMenu* get_joystick_options_menu(); - -private: - std::unique_ptr m_options_menu; - std::unique_ptr m_profile_menu; - std::unique_ptr m_key_options_menu; - std::unique_ptr m_joystick_options_menu; + KeyboardMenu* get_key_options_menu(); private: MenuStorage(const MenuStorage&); diff --git a/src/supertux/menu/options_menu.cpp b/src/supertux/menu/options_menu.cpp index b40eafc4e..5ea8a672f 100644 --- a/src/supertux/menu/options_menu.cpp +++ b/src/supertux/menu/options_menu.cpp @@ -42,20 +42,17 @@ enum OptionsMenuIDs { MNID_MUSIC }; -OptionsMenu::OptionsMenu() : - language_menu() +OptionsMenu::OptionsMenu() { - language_menu.reset(new LanguageMenu()); - add_label(_("Options")); add_hl(); // Language change should only be possible in the main menu, since elsewhere it might not always work fully // FIXME: Implement me: if (get_parent() == main_menu) - add_submenu(_("Select Language"), language_menu.get()) + add_submenu(_("Select Language"), MenuStorage::LANGUAGE_MENU) ->set_help(_("Select a different language to display text in")); - add_submenu(_("Select Profile"), MenuStorage::instance().get_profile_menu()) + add_submenu(_("Select Profile"), MenuStorage::PROFILE_MENU) ->set_help(_("Select a profile to play with")); add_toggle(MNID_PROFILES, _("Profile on Startup"), g_config->sound_enabled) @@ -192,10 +189,10 @@ OptionsMenu::OptionsMenu() : add_inactive(MNID_MUSIC, _("Music (disabled)")); } - add_submenu(_("Setup Keyboard"), MenuStorage::instance().get_key_options_menu()) + add_submenu(_("Setup Keyboard"), MenuStorage::KEYBOARD_MENU) ->set_help(_("Configure key-action mappings")); - add_submenu(_("Setup Joystick"), MenuStorage::instance().get_joystick_options_menu()) + add_submenu(_("Setup Joystick"), MenuStorage::JOYSTICK_MENU) ->set_help(_("Configure joystick control-action mappings")); add_hl(); add_back(_("Back")); diff --git a/src/supertux/menu/options_menu.hpp b/src/supertux/menu/options_menu.hpp index 8ac34d309..45d1738a6 100644 --- a/src/supertux/menu/options_menu.hpp +++ b/src/supertux/menu/options_menu.hpp @@ -18,11 +18,8 @@ #ifndef HEADER_SUPERTUX_SUPERTUX_OPTIONS_MENU_HPP #define HEADER_SUPERTUX_SUPERTUX_OPTIONS_MENU_HPP - #include "gui/menu.hpp" -class LanguageMenu; - class OptionsMenu : public Menu { public: @@ -31,9 +28,6 @@ public: void menu_action(MenuItem* item); void check_menu(); - -protected: - std::unique_ptr language_menu; }; #endif diff --git a/src/supertux/menu/worldmap_menu.cpp b/src/supertux/menu/worldmap_menu.cpp index c54f0c839..805d0ea62 100644 --- a/src/supertux/menu/worldmap_menu.cpp +++ b/src/supertux/menu/worldmap_menu.cpp @@ -28,7 +28,7 @@ WorldmapMenu::WorldmapMenu() add_label(_("Pause")); add_hl(); add_entry(MNID_RETURNWORLDMAP, _("Continue")); - add_submenu(_("Options"), MenuStorage::instance().get_options_menu()); + add_submenu(_("Options"), MenuStorage::OPTIONS_MENU); add_hl(); add_entry(MNID_QUITWORLDMAP, _("Quit World")); } diff --git a/src/supertux/title_screen.cpp b/src/supertux/title_screen.cpp index 03201fee4..a50c6104b 100644 --- a/src/supertux/title_screen.cpp +++ b/src/supertux/title_screen.cpp @@ -18,6 +18,7 @@ #include "supertux/title_screen.hpp" #include "audio/sound_manager.hpp" +#include "gui/menu.hpp" #include "gui/menu_manager.hpp" #include "lisp/parser.hpp" #include "object/camera.hpp" @@ -25,12 +26,9 @@ #include "supertux/fadeout.hpp" #include "supertux/gameconfig.hpp" #include "supertux/globals.hpp" -#include "supertux/screen_manager.hpp" -#include "supertux/menu/addon_menu.hpp" -#include "supertux/menu/contrib_world_menu.hpp" -#include "supertux/menu/contrib_menu.hpp" -#include "supertux/menu/main_menu.hpp" +#include "supertux/menu/menu_storage.hpp" #include "supertux/resources.hpp" +#include "supertux/screen_manager.hpp" #include "supertux/sector.hpp" #include "supertux/textscroller.hpp" #include "supertux/world.hpp" @@ -43,7 +41,6 @@ #include TitleScreen::TitleScreen(PlayerStatus* player_status) : - main_menu(new MainMenu()), frame(), controller(), titlesession() @@ -125,7 +122,7 @@ TitleScreen::setup() sector->activate(sector->player->get_pos()); } - MenuManager::instance().set_current(main_menu.get()); + MenuManager::instance().set_current(MenuStorage::MAIN_MENU); } void @@ -133,7 +130,7 @@ TitleScreen::leave() { Sector* sector = titlesession->get_current_sector(); sector->deactivate(); - MenuManager::instance().set_current(nullptr); + MenuManager::instance().set_current(MenuStorage::NO_MENU); } void @@ -169,14 +166,14 @@ TitleScreen::update(float elapsed_time) // accidently hit ESC) if(!MenuManager::instance().is_active() && g_screen_manager->has_no_pending_fadeout()) { - MenuManager::instance().set_current(main_menu.get()); + MenuManager::instance().set_current(MenuStorage::MAIN_MENU); } } void TitleScreen::start_game(World* world) { - MenuManager::instance().set_current(NULL); + MenuManager::instance().set_current(MenuStorage::NO_MENU); std::string basename = world->get_basedir(); basename = basename.substr(0, basename.length()-1); diff --git a/src/supertux/title_screen.hpp b/src/supertux/title_screen.hpp index 35a18c83f..a841d52be 100644 --- a/src/supertux/title_screen.hpp +++ b/src/supertux/title_screen.hpp @@ -24,7 +24,6 @@ class AddonMenu; class CodeController; class ContribMenu; class ContribWorldMenu; -class MainMenu; class Menu; class PlayerStatus; class World; @@ -53,10 +52,8 @@ public: private: void make_tux_jump(); - void generate_main_menu(); private: - std::unique_ptr main_menu; SurfacePtr frame; std::unique_ptr controller; std::unique_ptr titlesession; diff --git a/src/worldmap/worldmap.cpp b/src/worldmap/worldmap.cpp index 01fce1d98..ff5d05480 100644 --- a/src/worldmap/worldmap.cpp +++ b/src/worldmap/worldmap.cpp @@ -82,7 +82,6 @@ WorldMap::WorldMap(const std::string& filename, PlayerStatus* player_status, con player_status(player_status), tileset(NULL), free_tileset(false), - worldmap_menu(), camera_offset(), name(), music(), @@ -115,8 +114,6 @@ WorldMap::WorldMap(const std::string& filename, PlayerStatus* player_status, con total_stats.reset(); - worldmap_menu.reset(new WorldmapMenu()); - // create a new squirrel table for the worldmap using namespace scripting; @@ -407,10 +404,10 @@ WorldMap::on_escape_press() { // Show or hide the menu if(!MenuManager::instance().is_active()) { - MenuManager::instance().set_current(worldmap_menu.get()); + MenuManager::instance().set_current(MenuStorage::WORLDMAP_MENU); tux->set_direction(D_NONE); // stop tux movement when menu is called } else { - MenuManager::instance().set_current(NULL); + MenuManager::instance().set_current(MenuStorage::NO_MENU); } } @@ -569,10 +566,8 @@ void WorldMap::update(float delta) { if(!in_level) { - Menu* menu = MenuManager::instance().current(); - if (menu && menu == worldmap_menu.get()) + if (MenuManager::instance().check_menu()) { - menu->check_menu(); return; } @@ -904,7 +899,7 @@ void WorldMap::setup() { sound_manager->play_music(music); - MenuManager::instance().set_current(NULL); + MenuManager::instance().set_current(MenuStorage::NO_MENU); current_ = this; load_state(); diff --git a/src/worldmap/worldmap.hpp b/src/worldmap/worldmap.hpp index 0925edc0f..bb019194f 100644 --- a/src/worldmap/worldmap.hpp +++ b/src/worldmap/worldmap.hpp @@ -38,7 +38,6 @@ #include "worldmap/teleporter.hpp" class Sprite; -class Menu; class GameObject; class TileMap; class PlayerStatus; @@ -85,8 +84,6 @@ private: static WorldMap* current_; - std::unique_ptr worldmap_menu; - Vector camera_offset; std::string name; -- 2.11.0