#define SUPERTUX_MENU_H
#include <SDL.h>
+#include <vector>
+#include "texture.h"
+#include "timer.h"
+#include "type.h"
+#include "mousecursor.h"
-/* (global) menu variables */
-int menuaction;
-int menuitem;
-int menumenu;
-int show_menu;
-int menu_change;
+/* Kinds of menu items */
+enum MenuItemKind {
+ MN_ACTION,
+ MN_GOTO,
+ MN_TOGGLE,
+ MN_BACK,
+ MN_DEACTIVE,
+ MN_TEXTFIELD,
+ MN_NUMFIELD,
+ MN_CONTROLFIELD,
+ MN_STRINGSELECT,
+ MN_LABEL,
+ MN_HL, /* horizontal line */
+};
-/* Action done on the menu */
-enum {
- MN_UP,
- MN_DOWN,
- MN_HIT
+class Menu;
+
+class MenuItem
+{
+public:
+ MenuItemKind kind;
+ int toggled;
+ char *text;
+ char *input;
+ string_list_type* list;
+ Menu* target_menu;
+
+ 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);
};
-/* Menus */
-enum {
- MENU_MAIN,
- MENU_OPTIONS
+class Menu
+{
+private:
+ // position of the menu (ie. center of the menu, not top/left)
+ int pos_x;
+ int pos_y;
+
+ Menu* last_menu;
+ int width();
+ int height();
+
+public:
+ Timer effect;
+ int arrange_left;
+ int active_item;
+ std::vector<MenuItem> item;
+
+ static void set_current(Menu* pmenu);
+
+ Menu();
+ ~Menu();
+
+ 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);
};
-/* Initialize the menu variables */
-void initmenu(void);
-/* "Calculate" and draw the menu */
-int drawmenu(void);
+/* Action done on the menu */
+enum MenuAction {
+ MENU_ACTION_NONE = -1,
+ MENU_ACTION_UP,
+ MENU_ACTION_DOWN,
+ MENU_ACTION_LEFT,
+ MENU_ACTION_RIGHT,
+ MENU_ACTION_HIT,
+ MENU_ACTION_INPUT,
+ MENU_ACTION_REMOVE
+};
+
+/* (global) menu variables */
+extern MenuAction menuaction;
+extern bool show_menu;
+extern bool menu_change;
-/* Check for a menu event */
-void menu_event(SDLKey key);
+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;
+extern Menu* options_controls_menu;
+extern Menu* highscore_menu;
+extern Menu* load_game_menu;
+extern Menu* save_game_menu;
+extern Menu* current_menu;
+
+/* input implementation variables */
+extern int delete_character;
+extern char mn_input_char;
+
+/* Reset the global menu variables */
+void menu_reset(void);
+
+/* "Calculate" and draw the menu */
+void menu_process_current(void);
#endif /*SUPERTUX_MENU_H*/
+/* Local Variables: */
+/* mode:c++ */
+/* End */