4 // Copyright (C) 2004 Tobias Glaesser <tobi.web@gmx.de>
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #ifndef SUPERTUX_MENU_H
21 #define SUPERTUX_MENU_H
28 #include "mousecursor.h"
54 enum WorldMapMenuIDs {
60 enum LevelEditorMainMenuIDs {
61 MNID_RETURNLEVELEDITOR,
66 enum LevelEditorSubsetSettingsIDs {
72 enum LevelEditorSubsetNewIDs {
77 enum LevelEditorSettingsMenuIDs {
94 bool confirm_dialog(char *text);
96 /* Kinds of menu items */
108 MN_HL, /* horizontal line */
120 int *int_p; // used for setting keys (can be used for more stuff...)
122 string_list_type* list;
125 void change_text (const char *text);
126 void change_input(const char *text);
128 static MenuItem* create(MenuItemKind kind, const char *text, int init_toggle, Menu* target_menu, int id, int* int_p);
130 std::string get_input_with_symbol(bool active_item); // returns the text with an input symbol
132 bool input_flickering;
133 Timer input_flickering_timer;
139 static std::vector<Menu*> last_menus;
140 static Menu* current_;
142 static void push_current(Menu* pmenu);
143 static void pop_current();
146 /** Set the current menu, if pmenu is NULL, hide the current menu */
147 static void set_current(Menu* pmenu);
149 /** Return the current active menu or NULL if none is active */
150 static Menu* current() { return current_; }
153 /* Action done on the menu */
155 MENU_ACTION_NONE = -1,
165 /** Number of the item that got 'hit' (ie. pressed) in the last
166 event()/action() call, -1 if none */
169 // position of the menu (ie. center of the menu, not top/left)
173 /** input event for the menu (up, down, left, right, etc.) */
174 MenuAction menuaction;
176 /* input implementation variables */
177 int delete_character;
185 std::vector<MenuItem> item;
190 void additem(MenuItem* pmenu_item);
191 void additem(MenuItemKind kind, const std::string& text, int init_toggle, Menu* target_menu, int id = -1, int *int_p = NULL);
195 /** Remove all entries from the menu */
198 /** Return the index of the menu item that was 'hit' (ie. the user
199 clicked on it) in the last event() call */
202 MenuItem& get_item(int index) { return item[index]; }
203 MenuItem& get_item_by_id(int id);
205 int get_active_item_id();
207 bool isToggled(int id);
209 void Menu::get_controlfield_key_into_input(MenuItem *item);
212 void draw_item(int index, int menu_width, int menu_height);
213 void set_pos(int x, int y, float rw = 0, float rh = 0);
215 /** translate a SDL_Event into a menu_action */
216 void event(SDL_Event& event);
218 int get_width() const;
219 int get_height() const;
221 bool is_toggled(int id) const;
224 extern Surface* checkbox;
225 extern Surface* checkbox_checked;
226 extern Surface* back;
227 extern Surface* arrow_left;
228 extern Surface* arrow_right;
230 extern Menu* contrib_menu;
231 extern Menu* contrib_subset_menu;
232 extern Menu* main_menu;
233 extern Menu* game_menu;
234 extern Menu* worldmap_menu;
235 extern Menu* options_menu;
236 extern Menu* options_keys_menu;
237 extern Menu* options_joystick_menu;
238 extern Menu* highscore_menu;
239 extern Menu* load_game_menu;
240 extern Menu* save_game_menu;
242 #endif /*SUPERTUX_MENU_H*/
244 /* Local Variables: */