2 // Copyright (C) 2006 Matthias Braun <matze@braunis.de>
3 // 2014 Ingo Ruhnke <grumbel@gmail.com>
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.
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.
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/>.
18 #ifndef HEADER_SUPERTUX_SUPERTUX_MAINLOOP_HPP
19 #define HEADER_SUPERTUX_SUPERTUX_MAINLOOP_HPP
24 #include "scripting/thread_queue.hpp"
25 #include "supertux/screen.hpp"
35 * Manages, updates and draws all Screens, Controllers, Menus and the Console.
43 void run(DrawingContext &context);
44 void quit(std::unique_ptr<ScreenFade> fade = {});
45 void set_speed(float speed);
46 float get_speed() const;
47 bool has_pending_fadeout() const;
50 * requests that a screenshot be taken after the next frame has been rendered
52 void take_screenshot();
54 // push new screen on screen_stack
55 void push_screen(std::unique_ptr<Screen> screen, std::unique_ptr<ScreenFade> fade = {});
56 void pop_screen(std::unique_ptr<ScreenFade> fade = {});
57 void set_screen_fade(std::unique_ptr<ScreenFade> fade);
59 /// threads that wait for a screenswitch
60 scripting::ThreadQueue m_waiting_threads;
63 void draw_fps(DrawingContext& context, float fps);
64 void draw(DrawingContext& context);
65 void update_gamelogic(float elapsed_time);
66 void process_events();
67 void handle_screen_switch();
70 std::unique_ptr<MenuStorage> m_menu_storage;
71 std::unique_ptr<MenuManager> m_menu_manager;
76 enum Type { PUSH_ACTION, POP_ACTION, QUIT_ACTION };
78 std::unique_ptr<Screen> screen;
81 std::unique_ptr<Screen> screen_ = {}) :
83 screen(std::move(screen_))
87 std::vector<Action> m_actions;
91 std::unique_ptr<ScreenFade> m_screen_fade;
92 std::vector<std::unique_ptr<Screen> > m_screen_stack;
93 bool m_screenshot_requested; /**< true if a screenshot should be taken after the next frame has been rendered */