18 #ifndef HEADER_SUPERTUX_GUI_MENU_MANAGER_HPP 19 #define HEADER_SUPERTUX_GUI_MENU_MANAGER_HPP 21 #include "util/currenton.hpp" 26 #include "control/controller.hpp" 27 #include "gui/menu_action.hpp" 28 #include "gui/menu_transition.hpp" 29 #include "math/rectf.hpp" 40 static const float s_menu_repeat_initial;
41 static const float s_menu_repeat_rate;
49 std::unique_ptr<T> current =
nullptr;
50 std::unique_ptr<T> next =
nullptr;
51 bool has_next =
false;
55 std::vector<std::unique_ptr<Menu> > m_menu_stack;
56 std::unique_ptr<MenuTransition> m_transition;
58 float m_menu_repeat_time;
60 SettableItem<Dialog> m_dialog;
61 SettableItem<Notification> m_notification;
67 void event(
const SDL_Event& event);
68 void process_input(
const Controller& controller);
73 void set_dialog(std::unique_ptr<Dialog> dialog);
74 void set_notification(std::unique_ptr<Notification> notification);
76 void set_menu(
int id,
bool skip_transition =
false);
77 void set_menu(std::unique_ptr<Menu> menu,
bool skip_transition =
false);
78 void push_menu(
int id,
bool skip_transition =
false);
79 void push_menu(std::unique_ptr<Menu> menu,
bool skip_transition =
false);
80 void pop_menu(
bool skip_transition =
false);
81 void clear_menu_stack(
bool skip_transition =
false);
83 void on_window_resize();
85 bool is_active()
const;
86 bool has_dialog()
const;
88 Menu* current_menu()
const;
89 Menu* previous_menu()
const;
92 void check_input_action(Control control, MenuAction action,
93 const Controller& controller, MenuAction& result);
96 Rectf to_rect(T& menu)
98 return Rectf(menu.get_center_pos().x - menu.get_width() / 2,
99 menu.get_center_pos().y - menu.get_height() / 2,
100 menu.get_center_pos().x + menu.get_width() / 2,
101 menu.get_center_pos().y + menu.get_height() / 2);
104 template<
typename S,
typename T>
105 Rectf to_transition_rect(S* from, T* to)
108 return to_rect(*from);
110 return Rectf(to->get_center_pos(),
Sizef(0, 0));
113 template<
typename S,
typename T>
114 void transition(S* from, T* to)
119 m_transition->start(to_transition_rect(from, to),
120 to_transition_rect(to, from));
Definition: dialog.hpp:32
Definition: controller.hpp:57
Definition: notification.hpp:28
A 'Currenton' allows access to the currently active instance of a class via the static current() func...
Definition: currenton.hpp:30
This class provides functions for drawing things on screen.
Definition: drawing_context.hpp:42