Update keys for cheat menu and console only when items are enabled. Fixes #1062.
[supertux.git] / src / supertux / menu / menu_storage.hpp
index 8ac6bf2..dbd622d 100644 (file)
@@ -1,5 +1,5 @@
 //  SuperTux
-//  Copyright (C) 2009 Ingo Ruhnke <grumbel@gmx.de>
+//  Copyright (C) 2009 Ingo Ruhnke <grumbel@gmail.com>
 //
 //  This program is free software: you can redistribute it and/or modify
 //  it under the terms of the GNU General Public License as published by
@@ -17,6 +17,8 @@
 #ifndef HEADER_SUPERTUX_SUPERTUX_MENU_MENU_STORAGE_HPP
 #define HEADER_SUPERTUX_SUPERTUX_MENU_MENU_STORAGE_HPP
 
+#include <memory>
+
 class JoystickMenu;
 class KeyboardMenu;
 class Menu;
@@ -25,19 +27,35 @@ class ProfileMenu;
 
 class MenuStorage
 {
+private:
+  static MenuStorage* s_instance;
 public:
-  MenuStorage();
+  static MenuStorage& instance();
+
+public:
+  enum MenuId {
+    NO_MENU,
+    MAIN_MENU,
+    OPTIONS_MENU,
+    INGAME_OPTIONS_MENU,
+    PROFILE_MENU,
+    CONTRIB_MENU,
+    CONTRIB_WORLD_MENU,
+    ADDON_MENU,
+    LANGUAGE_MENU,
+    KEYBOARD_MENU,
+    JOYSTICK_MENU,
+    WORLDMAP_MENU,
+    WORLDMAP_CHEAT_MENU,
+    GAME_MENU,
+    CHEAT_MENU
+  };
 
-  static OptionsMenu*  get_options_menu();
-  static ProfileMenu*  get_profile_menu();
-  static KeyboardMenu* get_key_options_menu();
-  static JoystickMenu* get_joystick_options_menu();
+public:
+  MenuStorage();
+  ~MenuStorage();
 
-private:
-  static OptionsMenu*  options_menu;
-  static ProfileMenu*  profile_menu;
-  static KeyboardMenu* key_options_menu;
-  static JoystickMenu* joystick_options_menu;
+  std::unique_ptr<Menu> create(MenuId menu_id);
 
 private:
   MenuStorage(const MenuStorage&);