4a88618c2e4b962a66b7b7e91b42eb3e5309e325
[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/contrib_menu.hpp"
22 #include "supertux/menu/game_menu.hpp"
23 #include "supertux/menu/joystick_menu.hpp"
24 #include "supertux/menu/keyboard_menu.hpp"
25 #include "supertux/menu/language_menu.hpp"
26 #include "supertux/menu/main_menu.hpp"
27 #include "supertux/menu/options_menu.hpp"
28 #include "supertux/menu/profile_menu.hpp"
29 #include "supertux/menu/worldmap_menu.hpp"
30
31 MenuStorage* MenuStorage::s_instance = 0;
32
33 MenuStorage&
34 MenuStorage::instance()
35 {
36   assert(s_instance);
37   return *s_instance;
38 }
39
40 MenuStorage::MenuStorage()
41 {
42   assert(!s_instance);
43   s_instance = this;
44 }
45
46 MenuStorage::~MenuStorage()
47 {
48   s_instance = nullptr;
49 }
50
51 std::unique_ptr<Menu>
52 MenuStorage::create(MenuId menu_id)
53 {
54   switch(menu_id)
55   {
56     case MAIN_MENU:
57       return std::unique_ptr<Menu>(new MainMenu);
58
59     case LANGUAGE_MENU:
60       return std::unique_ptr<Menu>(new LanguageMenu);
61
62     case OPTIONS_MENU:
63       return std::unique_ptr<Menu>(new OptionsMenu(true));
64
65     case INGAME_OPTIONS_MENU:
66       return std::unique_ptr<Menu>(new OptionsMenu(false));
67
68     case PROFILE_MENU:
69       return std::unique_ptr<Menu>(new ProfileMenu);
70
71     case KEYBOARD_MENU:
72       return std::unique_ptr<Menu>(new KeyboardMenu(g_input_manager));
73
74     case JOYSTICK_MENU:
75       return std::unique_ptr<Menu>(new JoystickMenu(g_input_manager));
76
77     case WORLDMAP_MENU:
78       return std::unique_ptr<Menu>(new WorldmapMenu);
79
80     case GAME_MENU:
81       return std::unique_ptr<Menu>(new GameMenu);
82
83     case CONTRIB_MENU:
84       return std::unique_ptr<Menu>(new ContribMenu);
85
86     case CONTRIB_WORLD_MENU:
87       return 0; //return new ContribWorldMenu();
88
89     case ADDON_MENU:
90       return std::unique_ptr<Menu>(new AddonMenu);
91
92     case NO_MENU:
93       return std::unique_ptr<Menu>();
94
95     default:
96       assert(!"unknown MenuId provided");
97   }
98 }
99
100 /* EOF */