// SuperTux
// Copyright (C) 2006 Matthias Braun <matze@braunis.de>
+// 2014 Ingo Ruhnke <grumbel@gmail.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
#include <cstddef>
#include "scripting/thread_queue.hpp"
+#include "supertux/screen.hpp"
+#include "util/currenton.hpp"
-class Screen;
class Console;
-class ScreenFade;
class DrawingContext;
+class MenuManager;
+class MenuStorage;
+class Screen;
+class ScreenFade;
/**
* Manages, updates and draws all Screens, Controllers, Menus and the Console.
*/
-class ScreenManager
+class ScreenManager : public Currenton<ScreenManager>
{
public:
ScreenManager();
~ScreenManager();
void run(DrawingContext &context);
- void exit_screen(ScreenFade* fade = NULL);
- void quit(ScreenFade* fade = NULL);
+ void quit(std::unique_ptr<ScreenFade> fade = {});
void set_speed(float speed);
float get_speed() const;
- bool has_no_pending_fadeout() const;
+ bool has_pending_fadeout() const;
/**
* requests that a screenshot be taken after the next frame has been rendered
void take_screenshot();
// push new screen on screen_stack
- void push_screen(Screen* screen, ScreenFade* fade = NULL);
- void set_screen_fade(ScreenFade* fade);
+ void push_screen(std::unique_ptr<Screen> screen, std::unique_ptr<ScreenFade> fade = {});
+ void pop_screen(std::unique_ptr<ScreenFade> fade = {});
+ void set_screen_fade(std::unique_ptr<ScreenFade> fade);
/// threads that wait for a screenswitch
- scripting::ThreadQueue waiting_threads;
+ scripting::ThreadQueue m_waiting_threads;
private:
void draw_fps(DrawingContext& context, float fps);
void handle_screen_switch();
private:
- bool running;
- float speed;
- bool nextpop;
- bool nextpush;
+ std::unique_ptr<MenuStorage> m_menu_storage;
+ std::unique_ptr<MenuManager> m_menu_manager;
+
+ float m_speed;
+ struct Action
+ {
+ enum Type { PUSH_ACTION, POP_ACTION, QUIT_ACTION };
+ Type type;
+ std::unique_ptr<Screen> screen;
+
+ Action(Type type_,
+ std::unique_ptr<Screen> screen_ = {}) :
+ type(type_),
+ screen(std::move(screen_))
+ {}
+ };
+
+ std::vector<Action> m_actions;
+
/// measured fps
- float fps;
- std::auto_ptr<Screen> next_screen;
- std::auto_ptr<Screen> current_screen;
- std::auto_ptr<Console> console;
- std::auto_ptr<ScreenFade> screen_fade;
- std::vector<Screen*> screen_stack;
- bool screenshot_requested; /**< true if a screenshot should be taken after the next frame has been rendered */
+ float m_fps;
+ std::unique_ptr<ScreenFade> m_screen_fade;
+ std::vector<std::unique_ptr<Screen> > m_screen_stack;
+ bool m_screenshot_requested; /**< true if a screenshot should be taken after the next frame has been rendered */
};
#endif