X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fmenu.h;h=e8baf7018bd4a46903f95e7e47fd844950d17e09;hb=9e082fc66762cb43a25955a971082a0a5aab0840;hp=b0058d4f890f336d3de30ed45824d082511ae4cb;hpb=69ab58f652b9ee0b981d01d79ae74b5371418746;p=supertux.git diff --git a/src/menu.h b/src/menu.h index b0058d4f8..e8baf7018 100644 --- a/src/menu.h +++ b/src/menu.h @@ -14,6 +14,7 @@ #define SUPERTUX_MENU_H #include +#include #include "texture.h" #include "timer.h" #include "type.h" @@ -36,54 +37,59 @@ enum MenuItemKind { 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, const char *text, int init_toggle, Menu* target_menu); +}; class Menu { -friend void menu_event(SDL_Event& event); - private: // position of the menu (ie. center of the menu, not top/left) 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 item; static void set_current(Menu* pmenu); Menu(); ~Menu(); - void additem(menu_item_type* pmenu_item); - void additem(MenuItemKind kind, char *text, int init_toggle, Menu* target_menu); + void additem(MenuItem* pmenu_item); + void additem(MenuItemKind kind, const std::string& text, int init_toggle, Menu* target_menu); void action (); + + /** Remove all entries from the menu */ + void clear(); /** 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); }; @@ -103,11 +109,18 @@ enum MenuAction { extern MenuAction menuaction; extern bool show_menu; extern bool menu_change; -extern texture_type checkbox, checkbox_checked, back, arrow_left, arrow_right; + +extern Surface* checkbox; +extern Surface* checkbox_checked; +extern Surface* back; +extern Surface* arrow_left; +extern Surface* arrow_right; extern Menu* contrib_menu; +extern Menu* contrib_subset_menu; extern Menu* main_menu; extern Menu* game_menu; +extern Menu* worldmap_menu; extern Menu* options_menu; extern Menu* options_controls_menu; extern Menu* highscore_menu; @@ -125,11 +138,8 @@ void menu_reset(void); /* "Calculate" and draw the menu */ void menu_process_current(void); -/* Check for a menu event */ -void menu_event(SDL_Event& event); - #endif /*SUPERTUX_MENU_H*/ /* Local Variables: */ -/* mode:c++ */ -/* End */ +/* mode: c++ */ +/* End: */