1 | // SuperTux |
2 | // Copyright (C) 2006 Matthias Braun <matze@braunis.de> |
3 | // 2014 Ingo Ruhnke <grumbel@gmail.com> |
4 | // |
5 | // This program is free software: you can redistribute it and/or modify |
6 | // it under the terms of the GNU General Public License as published by |
7 | // the Free Software Foundation, either version 3 of the License, or |
8 | // (at your option) any later version. |
9 | // |
10 | // This program is distributed in the hope that it will be useful, |
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | // GNU General Public License for more details. |
14 | // |
15 | // You should have received a copy of the GNU General Public License |
16 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | |
18 | #ifndef HEADER_SUPERTUX_SUPERTUX_SCREEN_MANAGER_HPP |
19 | #define |
20 | |
21 | #include <memory> |
22 | |
23 | #include "squirrel/squirrel_thread_queue.hpp" |
24 | #include "supertux/screen.hpp" |
25 | #include "util/currenton.hpp" |
26 | |
27 | class Compositor; |
28 | class ControllerHUD; |
29 | class DrawingContext; |
30 | class InputManager; |
31 | class ; |
32 | class ; |
33 | class ScreenFade; |
34 | class VideoSystem; |
35 | |
36 | /** |
37 | * Manages, updates and draws all Screens, Controllers, Menus and the Console. |
38 | */ |
39 | class ScreenManager final : public Currenton<ScreenManager> |
40 | { |
41 | public: |
42 | ScreenManager(VideoSystem& video_system, InputManager& input_manager); |
43 | ~ScreenManager(); |
44 | |
45 | void run(); |
46 | void quit(std::unique_ptr<ScreenFade> fade = {}); |
47 | void set_speed(float speed); |
48 | float get_speed() const; |
49 | bool has_pending_fadeout() const; |
50 | |
51 | // push new screen on screen_stack |
52 | void push_screen(std::unique_ptr<Screen> screen, std::unique_ptr<ScreenFade> fade = {}); |
53 | void pop_screen(std::unique_ptr<ScreenFade> fade = {}); |
54 | void set_screen_fade(std::unique_ptr<ScreenFade> fade); |
55 | |
56 | private: |
57 | struct FPS_Stats; |
58 | void draw_fps(DrawingContext& context, FPS_Stats& fps_statistics); |
59 | void draw_player_pos(DrawingContext& context); |
60 | void draw(Compositor& compositor, FPS_Stats& fps_statistics); |
61 | void update_gamelogic(float dt_sec); |
62 | void process_events(); |
63 | void handle_screen_switch(); |
64 | |
65 | private: |
66 | VideoSystem& m_video_system; |
67 | InputManager& m_input_manager; |
68 | std::unique_ptr<MenuStorage> ; |
69 | std::unique_ptr<MenuManager> ; |
70 | std::unique_ptr<ControllerHUD> m_controller_hud; |
71 | |
72 | float m_speed; |
73 | struct Action |
74 | { |
75 | enum Type { PUSH_ACTION, POP_ACTION, QUIT_ACTION }; |
76 | Type type; |
77 | std::unique_ptr<Screen> screen; |
78 | |
79 | Action(Type type_, |
80 | std::unique_ptr<Screen> screen_ = {}) : |
81 | type(type_), |
82 | screen(std::move(screen_)) |
83 | {} |
84 | }; |
85 | |
86 | std::vector<Action> m_actions; |
87 | |
88 | std::unique_ptr<ScreenFade> m_screen_fade; |
89 | std::vector<std::unique_ptr<Screen> > m_screen_stack; |
90 | }; |
91 | |
92 | #endif |
93 | |
94 | /* EOF */ |
95 | |