Turned a lot of other global objects into Currentons
[supertux.git] / src / supertux / menu / menu_storage.cpp
1 //  SuperTux
2 //  Copyright (C) 2009 Ingo Ruhnke <grumbel@gmail.com>
3 //
4 //  This program is free software: you can redistribute it and/or modify
5 //  it under the terms of the GNU General Public License as published by
6 //  the Free Software Foundation, either version 3 of the License, or
7 //  (at your option) any later version.
8 //
9 //  This program is distributed in the hope that it will be useful,
10 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 //  GNU General Public License for more details.
13 //
14 //  You should have received a copy of the GNU General Public License
15 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 #include "supertux/menu/menu_storage.hpp"
18
19 #include "supertux/globals.hpp"
20 #include "supertux/menu/addon_menu.hpp"
21 #include "supertux/menu/cheat_menu.hpp"
22 #include "supertux/menu/contrib_menu.hpp"
23 #include "supertux/menu/game_menu.hpp"
24 #include "supertux/menu/joystick_menu.hpp"
25 #include "supertux/menu/keyboard_menu.hpp"
26 #include "supertux/menu/language_menu.hpp"
27 #include "supertux/menu/main_menu.hpp"
28 #include "supertux/menu/options_menu.hpp"
29 #include "supertux/menu/profile_menu.hpp"
30 #include "supertux/menu/worldmap_menu.hpp"
31 #include "supertux/menu/worldmap_cheat_menu.hpp"
32
33 MenuStorage* MenuStorage::s_instance = 0;
34
35 MenuStorage&
36 MenuStorage::instance()
37 {
38   assert(s_instance);
39   return *s_instance;
40 }
41
42 MenuStorage::MenuStorage()
43 {
44   assert(!s_instance);
45   s_instance = this;
46 }
47
48 MenuStorage::~MenuStorage()
49 {
50   s_instance = nullptr;
51 }
52
53 std::unique_ptr<Menu>
54 MenuStorage::create(MenuId menu_id)
55 {
56   switch(menu_id)
57   {
58     case MAIN_MENU:
59       return std::unique_ptr<Menu>(new MainMenu);
60
61     case LANGUAGE_MENU:
62       return std::unique_ptr<Menu>(new LanguageMenu);
63
64     case OPTIONS_MENU:
65       return std::unique_ptr<Menu>(new OptionsMenu(true));
66
67     case INGAME_OPTIONS_MENU:
68       return std::unique_ptr<Menu>(new OptionsMenu(false));
69
70     case PROFILE_MENU:
71       return std::unique_ptr<Menu>(new ProfileMenu);
72
73     case KEYBOARD_MENU:
74       return std::unique_ptr<Menu>(new KeyboardMenu(*InputManager::current()));
75
76     case JOYSTICK_MENU:
77       return std::unique_ptr<Menu>(new JoystickMenu(*InputManager::current()));
78
79     case WORLDMAP_MENU:
80       return std::unique_ptr<Menu>(new WorldmapMenu);
81
82     case WORLDMAP_CHEAT_MENU:
83       return std::unique_ptr<Menu>(new WorldmapCheatMenu);
84
85     case GAME_MENU:
86       return std::unique_ptr<Menu>(new GameMenu);
87
88     case CHEAT_MENU:
89       return std::unique_ptr<Menu>(new CheatMenu);
90
91     case CONTRIB_MENU:
92       return std::unique_ptr<Menu>(new ContribMenu);
93
94     case CONTRIB_WORLD_MENU:
95       return 0; //return new ContribWorldMenu();
96
97     case ADDON_MENU:
98       return std::unique_ptr<Menu>(new AddonMenu);
99
100     case NO_MENU:
101       return std::unique_ptr<Menu>();
102
103     default:
104       assert(!"unknown MenuId provided");
105       return std::unique_ptr<Menu>();
106   }
107 }
108
109 /* EOF */