Move patch to another directory
[supertux.git] / src / gui / menu_manager.hpp
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 #ifndef HEADER_SUPERTUX_GUI_MENU_MANAGER_HPP
18 #define HEADER_SUPERTUX_GUI_MENU_MANAGER_HPP
19
20 #include <list>
21 #include <memory>
22 #include <vector>
23
24 #include "SDL.h"
25
26 class Dialog;
27 class DrawingContext;
28 class Menu;
29 class MenuTransition;
30
31 class MenuManager
32 {
33 private:
34   static MenuManager* s_instance;
35 public:
36   static MenuManager& instance();
37
38 private:
39   std::unique_ptr<Dialog> m_dialog;
40   bool m_has_next_dialog;
41   std::unique_ptr<Dialog> m_next_dialog;
42
43   std::vector<std::unique_ptr<Menu> > m_menu_stack;
44   std::unique_ptr<MenuTransition> m_transition;
45
46 public:
47   MenuManager();
48   ~MenuManager();
49
50   void event(const SDL_Event& event);
51   void process_input();
52   void refresh();
53
54   void draw(DrawingContext& context);
55
56   void set_dialog(std::unique_ptr<Dialog> dialog);
57
58   void set_menu(int id);
59   void set_menu(std::unique_ptr<Menu> menu);
60   void push_menu(int id);
61   void push_menu(std::unique_ptr<Menu> menu);
62   void pop_menu();
63   void clear_menu_stack();
64
65   void on_window_resize();
66   bool is_active() const
67   {
68     return !m_menu_stack.empty();
69   }
70
71 private:
72   Menu* current_menu() const;
73   void transition(Menu* from, Menu* to);
74
75 private:
76   MenuManager(const MenuManager&);
77   MenuManager& operator=(const MenuManager&);
78 };
79
80 #endif
81
82 /* EOF */