// 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
#ifndef HEADER_SUPERTUX_GUI_MENU_MANAGER_HPP
#define HEADER_SUPERTUX_GUI_MENU_MANAGER_HPP
-#include <vector>
#include <list>
+#include <memory>
+#include <vector>
+
+#include "SDL.h"
+class Dialog;
+class DrawingContext;
class Menu;
+class MenuTransition;
class MenuManager
{
public:
static MenuManager& instance();
-public:
- std::vector<Menu*> m_last_menus;
- std::list<Menu*> m_all_menus;
-
- /** Used only for transition effects */
- Menu* m_previous;
-
- Menu* m_current;
+private:
+ std::unique_ptr<Dialog> m_dialog;
+ bool m_has_next_dialog;
+ std::unique_ptr<Dialog> m_next_dialog;
- friend class Menu;
+ std::vector<std::unique_ptr<Menu> > m_menu_stack;
+ std::unique_ptr<MenuTransition> m_transition;
public:
MenuManager();
~MenuManager();
- /** Set the current menu, if pmenu is NULL, hide the current menu */
- void set_current(Menu* pmenu);
+ void event(const SDL_Event& event);
+ void process_input();
+ void refresh();
- void push_current(Menu* pmenu);
- void pop_current();
+ void draw(DrawingContext& context);
- void recalc_pos();
+ void set_dialog(std::unique_ptr<Dialog> dialog);
- /** Return the current active menu or NULL if none is active */
- Menu* current() const
- {
- return m_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 m_current != nullptr;
+ return !m_menu_stack.empty();
}
private:
+ Menu* current_menu() const;
+ void transition(Menu* from, Menu* to);
+
+private:
MenuManager(const MenuManager&);
MenuManager& operator=(const MenuManager&);
};