// SuperTux
-// Copyright (C) 2009 Ingo Ruhnke <grumbel@gmx.de>
+// Copyright (C) 2009 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 <vector>
#include <list>
+#include <memory>
+#include "SDL.h"
+
+class DrawingContext;
class Menu;
+class MenuTransition;
-class MenuManager // FIXME: temporary name
+class MenuManager
{
+private:
+ static MenuManager* s_instance;
public:
- static std::vector<Menu*> last_menus;
- static Menu* previous;
- static Menu* current_;
+ static MenuManager& instance();
public:
- /** Pointers to all currently available menus, used to handle repositioning on window resize */
- static std::list<Menu*> all_menus;
+ std::vector<std::unique_ptr<Menu> > m_menu_stack;
+ std::unique_ptr<MenuTransition> m_transition;
+
+ friend class Menu;
public:
- /** Set the current menu, if pmenu is NULL, hide the current menu */
- static void set_current(Menu* pmenu);
+ MenuManager();
+ ~MenuManager();
- static void push_current(Menu* pmenu);
- static void pop_current();
+ void event(const SDL_Event& event);
+ void process_input();
+ void refresh();
- static void recalc_pos();
+ void draw(DrawingContext& context);
+ bool check_menu();
- /** Return the current active menu or NULL if none is active */
- static Menu* current()
+ void set_menu(int id);
+ void set_menu(std::unique_ptr<Menu> menu);
+ void push_menu(int id);
+ void push_menu(std::unique_ptr<Menu> menu);
+ void pop_menu();
+ void clear_menu_stack();
+
+ void on_window_resize();
+ bool is_active() const
{
- return current_;
+ return !m_menu_stack.empty();
}
private:
+ Menu* current() const;
+ void transition(Menu* from, Menu* to);
+
+private:
MenuManager(const MenuManager&);
MenuManager& operator=(const MenuManager&);
};