17 #ifndef HEADER_SUPERTUX_GUI_MENU_HPP 18 #define HEADER_SUPERTUX_GUI_MENU_HPP 24 #include "gui/menu_action.hpp" 25 #include "math/vector.hpp" 26 #include "video/color.hpp" 27 #include "video/drawing_context.hpp" 61 virtual void menu_action(
MenuItem& item) = 0;
70 virtual void on_window_resize();
74 virtual void event(
const SDL_Event& event);
75 virtual void process_action(
const MenuAction& action);
78 ItemLabel& add_label(
const std::string& text);
79 ItemAction& add_entry(
int id,
const std::string& text);
80 ItemAction& add_entry(
const std::string& text,
const std::function<
void()>& callback);
81 ItemToggle& add_toggle(
int id,
const std::string& text,
bool* toggled,
bool center_text =
false);
82 ItemToggle& add_toggle(
int id,
const std::string& text,
83 const std::function<
bool()>& get_func,
84 const std::function<
void(
bool)>& set_func,
85 bool center_text =
false);
86 ItemInactive& add_inactive(
const std::string& text,
bool default_color =
false);
87 ItemBack& add_back(
const std::string& text,
int id = -1);
88 ItemGoTo& add_submenu(
const std::string& text,
int submenu,
int id = -1);
89 ItemControlField& add_controlfield(
int id,
const std::string& text,
const std::string& mapping =
"");
90 ItemStringSelect& add_string_select(
int id,
const std::string& text,
int* selected,
const std::vector<std::string>& strings);
91 ItemStringSelect& add_string_select(
int id,
const std::string& text,
int default_item,
const std::vector<std::string>& strings);
92 ItemTextField& add_textfield(
const std::string& text, std::string* input,
int id = -1);
93 ItemScript& add_script(
const std::string& text, std::string* script,
int id = -1);
95 ItemIntField& add_intfield(
const std::string& text,
int* input,
int id = -1,
bool positive =
false);
96 ItemFloatField& add_floatfield(
const std::string& text,
float* input,
int id = -1,
bool positive =
false);
97 ItemAction& add_file(
const std::string& text, std::string* input,
const std::vector<std::string>& extensions,
98 const std::string& basedir,
bool path_relative_to_basedir,
99 const std::function<
void (
MenuItem&)>& item_processor = {},
int id = -1);
101 ItemColor& add_color(
const std::string& text,
Color* color,
int id = -1);
104 bool is_linear =
false);
106 ItemPaths& add_path_settings(
const std::string& text,
PathObject& target,
const std::string& path_ref);
107 ItemStringArray& add_string_array(
const std::string& text, std::vector<std::string>& items,
int id = -1);
108 ItemImages& add_images(
const std::string& image_path,
int max_image_width = 0,
int max_image_height = 0,
int id = -1);
109 ItemImages& add_images(
const std::vector<std::string>& image_paths,
int max_image_width = 0,
int max_image_height = 0,
int id = -1);
110 ItemList& add_list(
const std::string& text,
const std::vector<std::string>& items, std::string* value_ptr,
int id = -1);
111 ItemHorizontalMenu& add_horizontalmenu(
int id,
float height,
float min_item_width = -1.f);
116 MenuItem& get_item(
int index) {
return *(m_items[index]); }
119 const MenuItem& get_item_by_id(
int id)
const;
121 int get_active_item_id()
const;
122 void set_active_item(
int id);
124 Vector get_center_pos()
const {
return m_pos; }
125 void set_center_pos(
float x,
float y);
127 float get_width()
const;
128 float get_height()
const;
134 MenuItem& add_item(std::unique_ptr<MenuItem> menu_item);
135 MenuItem& add_item(std::unique_ptr<MenuItem> menu_item,
int pos_);
136 template<
typename T,
typename... Args>
137 T& add_item(Args&&... args)
139 auto item = std::make_unique<T>(std::forward<Args>(args)...);
140 auto item_ptr = item.get();
141 add_item(std::move(item));
144 void delete_item(
int pos_);
152 void check_controlfield_change_event(
const SDL_Event& event);
160 int m_delete_character;
161 char m_mn_input_char;
164 float m_menu_help_height;
167 std::vector<std::unique_ptr<MenuItem> > m_items;
177 Menu& operator=(
const Menu&) =
delete;
Definition: item_stringselect.hpp:24
Definition: item_script.hpp:22
Definition: item_floatfield.hpp:23
Definition: item_colorchannel.hpp:26
Definition: item_toggle.hpp:24
Definition: item_string_array.hpp:23
Definition: item_label.hpp:22
Definition: item_colordisplay.hpp:24
Definition: item_colorchannel.hpp:69
Definition: item_script_line.hpp:23
Definition: item_textfield.hpp:23
Definition: item_paths.hpp:24
Definition: item_images.hpp:23
Definition: item_color.hpp:24
Definition: item_controlfield.hpp:22
Definition: item_inactive.hpp:24
Definition: item_action.hpp:22
Definition: item_back.hpp:22
Definition: item_intfield.hpp:23
A base class for all objects that contain, or make use of a path.
Definition: path_object.hpp:36
Definition: item_list.hpp:25
Definition: item_goto.hpp:22
This class provides functions for drawing things on screen.
Definition: drawing_context.hpp:42
Definition: item_hl.hpp:22