#define SUPERTUX_MENU_H
#include <SDL.h>
+#include <vector>
#include "texture.h"
#include "timer.h"
#include "type.h"
+#include "mousecursor.h"
/* Kinds of menu items */
enum MenuItemKind {
MN_DEACTIVE,
MN_TEXTFIELD,
MN_NUMFIELD,
+ MN_CONTROLFIELD,
MN_STRINGSELECT,
MN_LABEL,
- MN_HL /* horizontal line */
+ MN_HL, /* horizontal line */
};
class Menu;
-struct menu_item_type
- {
- MenuItemKind kind;
- int toggled;
- char *text;
- char *input;
- string_list_type* list;
- Menu* target_menu;
-};
+class MenuItem
+{
+public:
+ MenuItemKind kind;
+ int toggled;
+ char *text;
+ char *input;
+ string_list_type* list;
+ Menu* target_menu;
-menu_item_type* menu_item_create(MenuItemKind kind, char *text, int init_toggle, Menu* target_menu);
-void menu_item_change_text (menu_item_type* pmenu_item, const char *text);
-void menu_item_change_input(menu_item_type* pmenu_item, const char *text);
+ void change_text (const char *text);
+ void change_input(const char *text);
+
+ static MenuItem* create(MenuItemKind kind, char *text, int init_toggle, Menu* target_menu);
+};
class Menu
{
int pos_x;
int pos_y;
- int num_items;
Menu* last_menu;
-
+ int width();
+ int height();
+
public:
- timer_type effect;
+ Timer effect;
int arrange_left;
int active_item;
- menu_item_type *item;
+ std::vector<MenuItem> item;
static void set_current(Menu* pmenu);
Menu();
~Menu();
- void additem(menu_item_type* pmenu_item);
+ void additem(MenuItem* pmenu_item);
void additem(MenuItemKind kind, char *text, int init_toggle, Menu* target_menu);
void action ();
+
+ /** Check, if the value of the active menu item has changed. */
int check ();
void draw ();
void draw_item(int index, int menu_width, int menu_height);
+ void set_pos(int x, int y, float rw = 0, float rh = 0);
+
+ /* Check for a menu event */
+ void event(SDL_Event& event);
};
extern MenuAction menuaction;
extern bool show_menu;
extern bool menu_change;
-extern texture_type checkbox, checkbox_checked, back, arrow_left, arrow_right;
+extern texture_type checkbox;
+extern texture_type checkbox_checked;
+extern texture_type back;
+extern texture_type arrow_left;
+extern texture_type arrow_right;
+
+extern Menu* contrib_menu;
extern Menu* main_menu;
extern Menu* game_menu;
extern Menu* options_menu;
/* "Calculate" and draw the menu */
void menu_process_current(void);
-/* Check for a menu event */
-void menu_event(SDL_keysym* keysym);
-
#endif /*SUPERTUX_MENU_H*/
/* Local Variables: */