From: Ingo Ruhnke Date: Mon, 22 Mar 2004 12:00:29 +0000 (+0000) Subject: - added shurtcut function to create menu items X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=a7045d8eeb0e923852128a362c2ca8cf5c76e1ae;p=supertux.git - added shurtcut function to create menu items SVN-Revision: 313 --- diff --git a/src/leveleditor.cpp b/src/leveleditor.cpp index 2350385ce..c7776a3f5 100644 --- a/src/leveleditor.cpp +++ b/src/leveleditor.cpp @@ -489,63 +489,63 @@ int le_init() } menu_init(&leveleditor_menu); - menu_additem(&leveleditor_menu, menu_item_create(MN_LABEL,"Level Editor Menu",0,0)); - menu_additem(&leveleditor_menu, menu_item_create(MN_HL,"",0,0)); - menu_additem(&leveleditor_menu, menu_item_create(MN_ACTION,"Return To Level Editor",0,0)); - menu_additem(&leveleditor_menu, menu_item_create(MN_DEACTIVE,"Level Subset Settings",0,&subset_settings_menu)); - menu_additem(&leveleditor_menu, menu_item_create(MN_GOTO,"Load Level Subset",0,&subset_load_menu)); - menu_additem(&leveleditor_menu, menu_item_create(MN_GOTO,"New Level Subset",0,&subset_new_menu)); - menu_additem(&leveleditor_menu, menu_item_create(MN_HL,"",0,0)); - menu_additem(&leveleditor_menu, menu_item_create(MN_ACTION,"Quit Level Editor",0,0)); + menu_additem(&leveleditor_menu, MN_LABEL,"Level Editor Menu",0,0); + menu_additem(&leveleditor_menu, MN_HL,"",0,0); + menu_additem(&leveleditor_menu, MN_ACTION,"Return To Level Editor",0,0); + menu_additem(&leveleditor_menu, MN_DEACTIVE,"Level Subset Settings",0,&subset_settings_menu); + menu_additem(&leveleditor_menu, MN_GOTO,"Load Level Subset",0,&subset_load_menu); + menu_additem(&leveleditor_menu, MN_GOTO,"New Level Subset",0,&subset_new_menu); + menu_additem(&leveleditor_menu, MN_HL,"",0,0); + menu_additem(&leveleditor_menu, MN_ACTION,"Quit Level Editor",0,0); menu_reset(); menu_set_current(&leveleditor_menu); show_menu = YES; menu_init(&subset_load_menu); - menu_additem(&subset_load_menu,menu_item_create(MN_LABEL,"Load Level Subset",0,0)); - menu_additem(&subset_load_menu,menu_item_create(MN_HL,"",0,0)); + menu_additem(&subset_load_menu,MN_LABEL,"Load Level Subset",0,0); + menu_additem(&subset_load_menu,MN_HL,"",0,0); for(i = 0; i < level_subsets.num_items; ++i) { - menu_additem(&subset_load_menu,menu_item_create(MN_ACTION,level_subsets.item[i],0,0)); + menu_additem(&subset_load_menu,MN_ACTION,level_subsets.item[i],0,0); } - menu_additem(&subset_load_menu,menu_item_create(MN_HL,"",0,0)); - menu_additem(&subset_load_menu,menu_item_create(MN_BACK,"Back",0,0)); + menu_additem(&subset_load_menu,MN_HL,"",0,0); + menu_additem(&subset_load_menu,MN_BACK,"Back",0,0); menu_init(&subset_new_menu); - menu_additem(&subset_new_menu,menu_item_create(MN_LABEL,"New Level Subset",0,0)); - menu_additem(&subset_new_menu,menu_item_create(MN_HL,"",0,0)); - menu_additem(&subset_new_menu,menu_item_create(MN_TEXTFIELD,"Enter Name",0,0)); - menu_additem(&subset_new_menu,menu_item_create(MN_ACTION,"Create",0,0)); - menu_additem(&subset_new_menu,menu_item_create(MN_HL,"",0,0)); - menu_additem(&subset_new_menu,menu_item_create(MN_BACK,"Back",0,0)); + menu_additem(&subset_new_menu,MN_LABEL,"New Level Subset",0,0); + menu_additem(&subset_new_menu,MN_HL,"",0,0); + menu_additem(&subset_new_menu,MN_TEXTFIELD,"Enter Name",0,0); + menu_additem(&subset_new_menu,MN_ACTION,"Create",0,0); + menu_additem(&subset_new_menu,MN_HL,"",0,0); + menu_additem(&subset_new_menu,MN_BACK,"Back",0,0); menu_init(&subset_settings_menu); - menu_additem(&subset_settings_menu,menu_item_create(MN_LABEL,"Level Subset Settings",0,0)); - menu_additem(&subset_settings_menu,menu_item_create(MN_HL,"",0,0)); - menu_additem(&subset_settings_menu,menu_item_create(MN_TEXTFIELD,"Title",0,0)); - menu_additem(&subset_settings_menu,menu_item_create(MN_TEXTFIELD,"Description",0,0)); - menu_additem(&subset_settings_menu,menu_item_create(MN_HL,"",0,0)); - menu_additem(&subset_settings_menu,menu_item_create(MN_ACTION,"Save Changes",0,0)); - menu_additem(&subset_settings_menu,menu_item_create(MN_HL,"",0,0)); - menu_additem(&subset_settings_menu,menu_item_create(MN_BACK,"Back",0,0)); + menu_additem(&subset_settings_menu,MN_LABEL,"Level Subset Settings",0,0); + menu_additem(&subset_settings_menu,MN_HL,"",0,0); + menu_additem(&subset_settings_menu,MN_TEXTFIELD,"Title",0,0); + menu_additem(&subset_settings_menu,MN_TEXTFIELD,"Description",0,0); + menu_additem(&subset_settings_menu,MN_HL,"",0,0); + menu_additem(&subset_settings_menu,MN_ACTION,"Save Changes",0,0); + menu_additem(&subset_settings_menu,MN_HL,"",0,0); + menu_additem(&subset_settings_menu,MN_BACK,"Back",0,0); menu_init(&level_settings_menu); level_settings_menu.arrange_left = YES; - menu_additem(&level_settings_menu,menu_item_create(MN_LABEL,"Level Settings",0,0)); - menu_additem(&level_settings_menu,menu_item_create(MN_HL,"",0,0)); - menu_additem(&level_settings_menu,menu_item_create(MN_TEXTFIELD,"Name ",0,0)); - menu_additem(&level_settings_menu,menu_item_create(MN_STRINGSELECT,"Theme ",0,0)); - menu_additem(&level_settings_menu,menu_item_create(MN_STRINGSELECT,"Song ",0,0)); - menu_additem(&level_settings_menu,menu_item_create(MN_STRINGSELECT,"Bg-Image",0,0)); - menu_additem(&level_settings_menu,menu_item_create(MN_NUMFIELD,"Length ",0,0)); - menu_additem(&level_settings_menu,menu_item_create(MN_NUMFIELD,"Time ",0,0)); - menu_additem(&level_settings_menu,menu_item_create(MN_NUMFIELD,"Gravity",0,0)); - menu_additem(&level_settings_menu,menu_item_create(MN_NUMFIELD,"Red ",0,0)); - menu_additem(&level_settings_menu,menu_item_create(MN_NUMFIELD,"Green ",0,0)); - menu_additem(&level_settings_menu,menu_item_create(MN_NUMFIELD,"Blue ",0,0)); - menu_additem(&level_settings_menu,menu_item_create(MN_HL,"",0,0)); - menu_additem(&level_settings_menu,menu_item_create(MN_ACTION,"Apply Changes",0,0)); + menu_additem(&level_settings_menu,MN_LABEL,"Level Settings",0,0); + menu_additem(&level_settings_menu,MN_HL,"",0,0); + menu_additem(&level_settings_menu,MN_TEXTFIELD,"Name ",0,0); + menu_additem(&level_settings_menu,MN_STRINGSELECT,"Theme ",0,0); + menu_additem(&level_settings_menu,MN_STRINGSELECT,"Song ",0,0); + menu_additem(&level_settings_menu,MN_STRINGSELECT,"Bg-Image",0,0); + menu_additem(&level_settings_menu,MN_NUMFIELD,"Length ",0,0); + menu_additem(&level_settings_menu,MN_NUMFIELD,"Time ",0,0); + menu_additem(&level_settings_menu,MN_NUMFIELD,"Gravity",0,0); + menu_additem(&level_settings_menu,MN_NUMFIELD,"Red ",0,0); + menu_additem(&level_settings_menu,MN_NUMFIELD,"Green ",0,0); + menu_additem(&level_settings_menu,MN_NUMFIELD,"Blue ",0,0); + menu_additem(&level_settings_menu,MN_HL,"",0,0); + menu_additem(&level_settings_menu,MN_ACTION,"Apply Changes",0,0); SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); diff --git a/src/menu.cpp b/src/menu.cpp index f462fb156..a131c50d9 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -557,3 +557,12 @@ void menu_event(SDL_keysym* keysym) #endif*/ } +menu_item_type* +menu_additem(menu_type* pmenu, MenuItemKind kind, char *text, int init_toggle, void* target_menu) +{ + menu_item_type* item = menu_item_create(kind, text, init_toggle, target_menu); + menu_additem(pmenu, item); + return item; +} + +// EOF // diff --git a/src/menu.h b/src/menu.h index 67593f3be..74455c93b 100644 --- a/src/menu.h +++ b/src/menu.h @@ -60,6 +60,7 @@ menu_type; void menu_init (menu_type* pmenu); void menu_free (menu_type* pmenu); void menu_additem(menu_type* pmenu, menu_item_type* pmenu_item); +menu_item_type* menu_additem(menu_type* pmenu, MenuItemKind kind, char *text, int init_toggle, void* target_menu); void menu_action (menu_type* pmenu); int menu_check (menu_type* pmenu); void menu_draw (menu_type* pmenu); diff --git a/src/setup.cpp b/src/setup.cpp index 5e90b15b8..9ca59a37d 100644 --- a/src/setup.cpp +++ b/src/setup.cpp @@ -320,68 +320,68 @@ void st_directory_setup(void) void st_menu(void) { menu_init(&main_menu); - menu_additem(&main_menu,menu_item_create(MN_LABEL,"Main Menu",0,0)); - menu_additem(&main_menu,menu_item_create(MN_HL,"",0,0)); - menu_additem(&main_menu,menu_item_create(MN_ACTION,"Start Game",0,0)); - menu_additem(&main_menu,menu_item_create(MN_GOTO,"Load Game",0,&load_game_menu)); - menu_additem(&main_menu,menu_item_create(MN_GOTO,"Options",0,&options_menu)); - menu_additem(&main_menu,menu_item_create(MN_ACTION,"Level editor",0,0)); - menu_additem(&main_menu,menu_item_create(MN_ACTION,"Credits",0,0)); - menu_additem(&main_menu,menu_item_create(MN_HL,"",0,0)); - menu_additem(&main_menu,menu_item_create(MN_ACTION,"Quit",0,0)); + menu_additem(&main_menu, MN_LABEL,"Main Menu",0,0); + menu_additem(&main_menu, MN_HL,"",0,0); + menu_additem(&main_menu, MN_ACTION,"Start Game",0,0); + menu_additem(&main_menu, MN_GOTO,"Load Game",0,&load_game_menu); + menu_additem(&main_menu, MN_GOTO,"Options",0,&options_menu); + menu_additem(&main_menu, MN_ACTION,"Level editor",0,0); + menu_additem(&main_menu, MN_ACTION,"Credits",0,0); + menu_additem(&main_menu, MN_HL,"",0,0); + menu_additem(&main_menu, MN_ACTION,"Quit",0,0); menu_init(&options_menu); - menu_additem(&options_menu,menu_item_create(MN_LABEL,"Options",0,0)); - menu_additem(&options_menu,menu_item_create(MN_HL,"",0,0)); - menu_additem(&options_menu,menu_item_create(MN_TOGGLE,"Fullscreen",use_fullscreen,0)); + menu_additem(&options_menu, MN_LABEL,"Options",0,0); + menu_additem(&options_menu, MN_HL,"",0,0); + menu_additem(&options_menu, MN_TOGGLE,"Fullscreen",use_fullscreen,0); if(audio_device == YES) { - menu_additem(&options_menu,menu_item_create(MN_TOGGLE,"Sound ",use_sound,0)); - menu_additem(&options_menu,menu_item_create(MN_TOGGLE,"Music ",use_music,0)); + menu_additem(&options_menu, MN_TOGGLE,"Sound ",use_sound,0); + menu_additem(&options_menu, MN_TOGGLE,"Music ",use_music,0); } else { - menu_additem(&options_menu,menu_item_create(MN_DEACTIVE,"Sound ",use_sound,0)); - menu_additem(&options_menu,menu_item_create(MN_DEACTIVE,"Music ",use_music,0)); + menu_additem(&options_menu, MN_DEACTIVE,"Sound ",use_sound,0); + menu_additem(&options_menu, MN_DEACTIVE,"Music ",use_music,0); } - menu_additem(&options_menu,menu_item_create(MN_TOGGLE,"Show FPS ",show_fps,0)); - menu_additem(&options_menu,menu_item_create(MN_HL,"",0,0)); - menu_additem(&options_menu,menu_item_create(MN_BACK,"Back",0,0)); + menu_additem(&options_menu, MN_TOGGLE,"Show FPS ",show_fps,0); + menu_additem(&options_menu, MN_HL,"",0,0); + menu_additem(&options_menu, MN_BACK,"Back",0,0); menu_init(&load_game_menu); - menu_additem(&load_game_menu,menu_item_create(MN_LABEL,"Load Game",0,0)); - menu_additem(&load_game_menu,menu_item_create(MN_HL,"",0,0)); - menu_additem(&load_game_menu,menu_item_create(MN_DEACTIVE,"Slot 1",0,0)); - menu_additem(&load_game_menu,menu_item_create(MN_DEACTIVE,"Slot 2",0,0)); - menu_additem(&load_game_menu,menu_item_create(MN_DEACTIVE,"Slot 3",0,0)); - menu_additem(&load_game_menu,menu_item_create(MN_DEACTIVE,"Slot 4",0,0)); - menu_additem(&load_game_menu,menu_item_create(MN_DEACTIVE,"Slot 5",0,0)); - menu_additem(&load_game_menu,menu_item_create(MN_HL,"",0,0)); - menu_additem(&load_game_menu,menu_item_create(MN_BACK,"Back",0,0)); + menu_additem(&load_game_menu, MN_LABEL,"Load Game",0,0); + menu_additem(&load_game_menu, MN_HL,"",0,0); + menu_additem(&load_game_menu, MN_DEACTIVE,"Slot 1",0,0); + menu_additem(&load_game_menu, MN_DEACTIVE,"Slot 2",0,0); + menu_additem(&load_game_menu, MN_DEACTIVE,"Slot 3",0,0); + menu_additem(&load_game_menu, MN_DEACTIVE,"Slot 4",0,0); + menu_additem(&load_game_menu, MN_DEACTIVE,"Slot 5",0,0); + menu_additem(&load_game_menu, MN_HL,"",0,0); + menu_additem(&load_game_menu, MN_BACK,"Back",0,0); menu_init(&save_game_menu); - menu_additem(&save_game_menu,menu_item_create(MN_LABEL,"Save Game",0,0)); - menu_additem(&save_game_menu,menu_item_create(MN_HL,"",0,0)); - menu_additem(&save_game_menu,menu_item_create(MN_DEACTIVE,"Slot 1",0,0)); - menu_additem(&save_game_menu,menu_item_create(MN_DEACTIVE,"Slot 2",0,0)); - menu_additem(&save_game_menu,menu_item_create(MN_DEACTIVE,"Slot 3",0,0)); - menu_additem(&save_game_menu,menu_item_create(MN_DEACTIVE,"Slot 4",0,0)); - menu_additem(&save_game_menu,menu_item_create(MN_DEACTIVE,"Slot 5",0,0)); - menu_additem(&save_game_menu,menu_item_create(MN_HL,"",0,0)); - menu_additem(&save_game_menu,menu_item_create(MN_BACK,"Back",0,0)); + menu_additem(&save_game_menu, MN_LABEL,"Save Game",0,0); + menu_additem(&save_game_menu, MN_HL,"",0,0); + menu_additem(&save_game_menu, MN_DEACTIVE,"Slot 1",0,0); + menu_additem(&save_game_menu, MN_DEACTIVE,"Slot 2",0,0); + menu_additem(&save_game_menu, MN_DEACTIVE,"Slot 3",0,0); + menu_additem(&save_game_menu, MN_DEACTIVE,"Slot 4",0,0); + menu_additem(&save_game_menu, MN_DEACTIVE,"Slot 5",0,0); + menu_additem(&save_game_menu, MN_HL,"",0,0); + menu_additem(&save_game_menu, MN_BACK,"Back",0,0); menu_init(&game_menu); - menu_additem(&game_menu,menu_item_create(MN_LABEL,"InGame Menu",0,0)); - menu_additem(&game_menu,menu_item_create(MN_HL,"",0,0)); - menu_additem(&game_menu,menu_item_create(MN_ACTION,"Return To Game",0,0)); - menu_additem(&game_menu,menu_item_create(MN_GOTO,"Save Game",0,&save_game_menu)); - menu_additem(&game_menu,menu_item_create(MN_GOTO,"Load Game",0,&load_game_menu)); - menu_additem(&game_menu,menu_item_create(MN_GOTO,"Options",0,&options_menu)); - menu_additem(&game_menu,menu_item_create(MN_HL,"",0,0)); - menu_additem(&game_menu,menu_item_create(MN_ACTION,"Quit Game",0,0)); + menu_additem(&game_menu, MN_LABEL,"InGame Menu",0,0); + menu_additem(&game_menu, MN_HL,"",0,0); + menu_additem(&game_menu, MN_ACTION,"Return To Game",0,0); + menu_additem(&game_menu, MN_GOTO,"Save Game",0,&save_game_menu); + menu_additem(&game_menu, MN_GOTO,"Load Game",0,&load_game_menu); + menu_additem(&game_menu, MN_GOTO,"Options",0,&options_menu); + menu_additem(&game_menu, MN_HL,"",0,0); + menu_additem(&game_menu, MN_ACTION,"Quit Game",0,0); menu_init(&highscore_menu); - menu_additem(&highscore_menu,menu_item_create(MN_TEXTFIELD,"Enter your name:",0,0)); + menu_additem(&highscore_menu, MN_TEXTFIELD,"Enter your name:",0,0); }