X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fmenu.h;h=4ac921dd8c87e2e7f2142a3a3f97f837614a8373;hb=157cef71aeb9ae25b7bb90f37dda11bc09329d11;hp=33c8b24686b618ab0e38e47d4af7c9cba34cb0fa;hpb=bce77ebd5f818899777a216a309e5b1c5ac1c373;p=supertux.git diff --git a/src/menu.h b/src/menu.h index 33c8b2468..4ac921dd8 100644 --- a/src/menu.h +++ b/src/menu.h @@ -27,6 +27,74 @@ #include "type.h" #include "mousecursor.h" +/* IDs for menus */ + +enum MainMenuIDs { + MNID_STARTGAME, + MNID_CONTRIB, + MNID_OPTIONMENU, + MNID_LEVELEDITOR, + MNID_CREDITS, + MNID_QUITMAINMENU + }; + +enum OptionsMenuIDs { + MNID_OPENGL, + MNID_FULLSCREEN, + MNID_SOUND, + MNID_MUSIC, + MNID_SHOWFPS + }; + +enum GameMenuIDs { + MNID_CONTINUE, + MNID_ABORTLEVEL + }; + +enum WorldMapMenuIDs { + MNID_RETURNWORLDMAP, + MNID_QUITWORLDMAP + }; + +enum LevelEditorMainMenuIDs { + MNID_RETURNLEVELEDITOR, + MNID_SUBSETSETTINGS, + MNID_QUITLEVELEDITOR + }; + +enum LevelEditorSubsetSettingsIDs { + MNID_SUBSETTITLE, + MNID_SUBSETDESCRIPTION, + MNID_SUBSETSAVECHANGES + }; + +enum LevelEditorSubsetNewIDs { + MNID_SUBSETNAME, + MNID_CREATESUBSET +}; + +enum LevelEditorSettingsMenuIDs { + MNID_NAME, + MNID_AUTHOR, + MNID_SONG, + MNID_BGIMG, + MNID_PARTICLE, + MNID_LENGTH, + MNID_HEIGHT, + MNID_TIME, + MNID_GRAVITY, + MNID_BGSPEED, + MNID_TopRed, + MNID_TopGreen, + MNID_TopBlue, + MNID_BottomRed, + MNID_BottomGreen, + MNID_BottomBlue, + MNID_APPLY + }; + +bool confirm_dialog(std::string text); + /* Kinds of menu items */ enum MenuItemKind { MN_ACTION, @@ -36,7 +104,8 @@ enum MenuItemKind { MN_DEACTIVE, MN_TEXTFIELD, MN_NUMFIELD, - MN_CONTROLFIELD, + MN_CONTROLFIELD_KB, + MN_CONTROLFIELD_JS, MN_STRINGSELECT, MN_LABEL, MN_HL, /* horizontal line */ @@ -52,15 +121,19 @@ public: char *text; char *input; int *int_p; // used for setting keys (can be used for more stuff...) + int id; // item id string_list_type* list; Menu* target_menu; 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, int* int_p); + static MenuItem* create(MenuItemKind kind, const char *text, int init_toggle, Menu* target_menu, int id, int* int_p); - void set_controlfield_key(SDLKey key, char ch[]); + std::string get_input_with_symbol(bool active_item); // returns the text with an input symbol +private: + bool input_flickering; + Timer input_flickering_timer; }; class Menu @@ -99,7 +172,6 @@ private: // position of the menu (ie. center of the menu, not top/left) int pos_x; int pos_y; - bool has_backitem; /** input event for the menu (up, down, left, right, etc.) */ MenuAction menuaction; @@ -107,6 +179,7 @@ private: /* input implementation variables */ int delete_character; char mn_input_char; + Timer joystick_timer; public: Timer effect; @@ -119,7 +192,7 @@ public: ~Menu(); void additem(MenuItem* pmenu_item); - void additem(MenuItemKind kind, const std::string& text, int init_toggle, Menu* target_menu, int *int_p = NULL); + void additem(MenuItemKind kind, const std::string& text, int init_toggle, Menu* target_menu, int id = -1, int *int_p = NULL); void action (); @@ -131,6 +204,14 @@ public: int check (); MenuItem& get_item(int index) { return item[index]; } + MenuItem& get_item_by_id(int id); + + int get_active_item_id(); + + bool isToggled(int id); + + void Menu::get_controlfield_key_into_input(MenuItem *item); + void Menu::get_controlfield_js_into_input(MenuItem *item); void draw (); void draw_item(int index, int menu_width, int menu_height); @@ -141,6 +222,8 @@ public: int get_width() const; int get_height() const; + + bool is_toggled(int id) const; }; extern Surface* checkbox; @@ -155,7 +238,8 @@ extern Menu* main_menu; extern Menu* game_menu; extern Menu* worldmap_menu; extern Menu* options_menu; -extern Menu* options_controls_menu; +extern Menu* options_keys_menu; +extern Menu* options_joystick_menu; extern Menu* highscore_menu; extern Menu* load_game_menu; extern Menu* save_game_menu;