Index: apps/plugins/jpeg/jpeg.c =================================================================== --- apps/plugins/jpeg/jpeg.c (revision 21172) +++ apps/plugins/jpeg/jpeg.c (working copy) @@ -27,7 +27,6 @@ #include "plugin.h" #include -#include #include #include @@ -323,17 +322,16 @@ return false; } +MENUITEM_FUNCTION(grayscale_item, 0, "Greyscale", + set_option_grayscale, NULL, NULL, Icon_NOICON); +MENUITEM_FUNCTION(dithering_item, 0, "Dithering", + set_option_dithering, NULL, NULL, Icon_NOICON); +MAKE_MENU(display_menu, "Display Options", NULL, Icon_NOICON, + &grayscale_item, &dithering_item); + static void display_options(void) { - static const struct menu_item items[] = { - { "Greyscale", set_option_grayscale }, - { "Dithering", set_option_dithering }, - }; - - int m = menu_init(items, ARRAYLEN(items), - NULL, NULL, NULL, NULL); - menu_run(m); - menu_exit(m); + rb->do_menu(&display_menu, NULL, NULL, false); } #endif /* HAVE_LCD_COLOR */ @@ -349,12 +347,11 @@ rb->lcd_set_background(LCD_WHITE); #endif #endif - int m; int result; enum menu_id { - MIID_QUIT = 0, + MIID_RETURN = 0, MIID_TOGGLE_SS_MODE, MIID_CHANGE_SS_MODE, #if PLUGIN_BUFFER_SIZE >= MIN_MEM @@ -363,42 +360,30 @@ #ifdef HAVE_LCD_COLOR MIID_DISPLAY_OPTIONS, #endif - MIID_RETURN, + MIID_QUIT, }; - static const struct menu_item items[] = { - [MIID_QUIT] = - { "Quit", NULL }, - [MIID_TOGGLE_SS_MODE] = - { "Toggle Slideshow Mode", NULL }, - [MIID_CHANGE_SS_MODE] = - { "Change Slideshow Time", NULL }, + MENUITEM_STRINGLIST(menu, "Jpeg Menu", NULL, + "Return", "Toggle Slideshow Mode", + "Change Slideshow Time", #if PLUGIN_BUFFER_SIZE >= MIN_MEM - [MIID_SHOW_PLAYBACK_MENU] = - { "Show Playback Menu", NULL }, + "Show Playback Menu", #endif #ifdef HAVE_LCD_COLOR - [MIID_DISPLAY_OPTIONS] = - { "Display Options", NULL }, + "Display Options", #endif - [MIID_RETURN] = - { "Return", NULL }, - }; + "Quit"); static const struct opt_items slideshow[2] = { { "Disable", -1 }, { "Enable", -1 }, }; - m = menu_init(items, sizeof(items) / sizeof(*items), - NULL, NULL, NULL, NULL); - result=menu_show(m); + result=rb->do_menu(&menu, NULL, NULL, false); switch (result) { - case MIID_QUIT: - menu_exit(m); - return 1; + case MIID_RETURN: break; case MIID_TOGGLE_SS_MODE: rb->set_option("Toggle Slideshow", &slideshow_enabled, INT, @@ -427,7 +412,8 @@ display_options(); break; #endif - case MIID_RETURN: + case MIID_QUIT: + return 1; break; } @@ -456,7 +442,6 @@ rb->lcd_set_background(LCD_BLACK); #endif rb->lcd_clear_display(); - menu_exit(m); return 0; } Index: apps/plugins/viewer.c =================================================================== --- apps/plugins/viewer.c (revision 21172) +++ apps/plugins/viewer.c (working copy) @@ -22,7 +22,6 @@ #include "plugin.h" #include #include "lib/playback_control.h" -#include "lib/oldmenuapi.h" PLUGIN_HEADER @@ -1448,30 +1448,37 @@ &prefs.autoscroll_speed, NULL, 1, 1, 10, NULL); } +MENUITEM_FUNCTION(encoding_item, 0, "Encoding", encoding_setting, + NULL, NULL, Icon_NOICON); +MENUITEM_FUNCTION(word_wrap_item, 0, "Word Wrap", word_wrap_setting, + NULL, NULL, Icon_NOICON); +MENUITEM_FUNCTION(line_mode_item, 0, "Line Mode", line_mode_setting, + NULL, NULL, Icon_NOICON); +MENUITEM_FUNCTION(view_mode_item, 0, "Wide View", view_mode_setting, + NULL, NULL, Icon_NOICON); +#ifdef HAVE_LCD_BITMAP +MENUITEM_FUNCTION(scrollbar_item, 0, "Show Scrollbar", scrollbar_setting, + NULL, NULL, Icon_NOICON); +MENUITEM_FUNCTION(page_mode_item, 0, "Overlap Pages", page_mode_setting, + NULL, NULL, Icon_NOICON); +#endif +MENUITEM_FUNCTION(scroll_mode_item, 0, "Scroll Mode", scroll_mode_setting, + NULL, NULL, Icon_NOICON); +MENUITEM_FUNCTION(autoscroll_speed_item, 0, "Auto-Scroll Speed", + autoscroll_speed_setting, NULL, NULL, Icon_NOICON); +MAKE_MENU(option_menu, "Viewer Options", NULL, Icon_NOICON, + &encoding_item, &word_wrap_item, &line_mode_item, &view_mode_item, +#ifdef HAVE_LCD_BITMAP + &scrollbar_item, &page_mode_item, +#endif + &scroll_mode_item, &autoscroll_speed_item); + static bool viewer_options_menu(void) { - int m; bool result; + result = (rb->do_menu(&option_menu, NULL, NULL, false) == MENU_ATTACHED_USB); - static const struct menu_item items[] = { - {"Encoding", encoding_setting }, - {"Word Wrap", word_wrap_setting }, - {"Line Mode", line_mode_setting }, - {"Wide View", view_mode_setting }, #ifdef HAVE_LCD_BITMAP - {"Show Scrollbar", scrollbar_setting }, - {"Overlap Pages", page_mode_setting }, -#endif - {"Scroll Mode", scroll_mode_setting}, - {"Auto-Scroll Speed", autoscroll_speed_setting }, - }; - m = menu_init(items, sizeof(items) / sizeof(*items), - NULL, NULL, NULL, NULL); - - result = menu_run(m); - menu_exit(m); -#ifdef HAVE_LCD_BITMAP - /* Show-scrollbar mode for current view-width mode */ init_need_scrollbar(); #endif @@ -1480,23 +1487,15 @@ static void viewer_menu(void) { - int m; int result; - static const struct menu_item items[] = { - {"Quit", NULL }, - {"Viewer Options", NULL }, - {"Show Playback Menu", NULL }, - {"Return", NULL }, - }; + MENUITEM_STRINGLIST(menu, "Viewer Menu", NULL, + "Return", "Viewer Options", + "Show Playback Menu", "Quit"); - m = menu_init(items, sizeof(items) / sizeof(*items), NULL, NULL, NULL, NULL); - result=menu_show(m); + result = rb->do_menu(&menu, NULL, NULL, false); switch (result) { - case 0: /* quit */ - menu_exit(m); - viewer_exit(NULL); - done = true; + case 0: /* return */ break; case 1: /* change settings */ done = viewer_options_menu(); @@ -1504,10 +1503,11 @@ case 2: /* playback control */ playback_control(NULL); break; - case 3: /* return */ + case 3: /* quit */ + viewer_exit(NULL); + done = true; break; } - menu_exit(m); viewer_draw(col); } Index: apps/plugins/rockboy/menu.c =================================================================== --- apps/plugins/rockboy/menu.c (revision 21172) +++ apps/plugins/rockboy/menu.c (working copy) @@ -8,7 +8,6 @@ #include "rockmacros.h" #include "mem.h" #include "save.h" -#include "lib/oldmenuapi.h" #include "rtc-gb.h" #include "pcm.h" @@ -85,7 +84,7 @@ */ int do_user_menu(void) { bool done=false; - int m, ret=0; + int selected=0, ret=0; int result; int time = 0; @@ -97,20 +96,15 @@ while (rb->button_get(false) != BUTTON_NONE) rb->yield(); - static const struct menu_item items[] = { - {"Load Game", NULL }, - {"Save Game", NULL }, - {"Options", NULL }, - {"Quit", NULL }, - }; + MENUITEM_STRINGLIST(menu, "Rockboy Menu", NULL, + "Load Game", "Save Game", + "Options", "Quit"); pcm_init(); - m = menu_init(items, sizeof(items) / sizeof(*items), NULL, NULL, NULL, NULL); - while(!done) { - result=menu_show(m); + result = rb->do_menu(&menu, &selected, NULL, false); switch (result) { @@ -133,8 +127,6 @@ } } - menu_exit(m); - rb->lcd_setfont(0); /* Reset the font */ rb->lcd_clear_display(); /* Clear display for screen size changes */ @@ -288,50 +280,65 @@ } } +/* + * slot_get_name + */ +static char *slot_get_name(int selected_item, void * data, + char * buffer, size_t buffer_len) +{ + char (*items)[20] = data; + (void) buffer; + (void) buffer_len; + return items[selected_item]; +} + /* + * list_action_callback + */ +static int list_action_callback(int action, struct gui_synclist *lists) +{ + (void) lists; + if (action == ACTION_STD_OK) + return ACTION_STD_CANCEL; + return action; +} + +/* * do_slot_menu - prompt the user for a load/save memory slot */ static void do_slot_menu(bool is_load) { bool done=false; - - char buf[5][20]; - - int m; + char items[5][20]; int result; int i; - - struct menu_item items[] = { - { buf[0] , NULL }, - { buf[1] , NULL }, - { buf[2] , NULL }, - { buf[3] , NULL }, - { buf[4] , NULL }, - }; - int num_items = sizeof(items) / sizeof(*items); + struct simplelist_info info; /* create menu items */ for (i = 0; i < num_items; i++) - slot_info(buf[i], 20, i); + slot_info(items[i], 20, i); - m = menu_init(items, num_items, NULL, NULL, NULL, NULL); + rb->simplelist_info_init(&info, NULL, num_items, (void *)items); + info.get_name = slot_get_name; + info.action_callback = list_action_callback; while(!done) { - result=menu_show(m); - + if(rb->simplelist_show_list(&info)) + break; + + result = info.selection; if (result= 0 ) done = do_slot(result, is_load); else done = true; } - menu_exit(m); } static void do_opt_menu(void) { bool done=false; - int m; + int selected=0; int result; static const struct opt_items onoff[2] = { @@ -379,63 +386,54 @@ }; #endif - static const struct menu_item items[] = { - { "Max Frameskip", NULL }, - { "Sound" , NULL }, - { "Stats" , NULL }, - { "Set Keys (Buggy)", NULL }, + MENUITEM_STRINGLIST(menu, "Options", NULL, + "Max Frameskip", "Sound", "Stats", "Set Keys (Buggy)", #ifdef HAVE_LCD_COLOR - { "Screen Size" , NULL }, - { "Screen Rotate" , NULL }, - { "Set Palette" , NULL }, + "Screen Size", "Screen Rotate", "Set Palette", #endif - }; + ); - m = menu_init(items, sizeof(items) / sizeof(*items), NULL, NULL, NULL, NULL); - options.dirty=1; /* Assume that the settings have been changed */ while(!done) { - - result=menu_show(m); - + result = rb->do_menu(&menu, &selected, NULL, false); + switch (result) { case 0: /* Frameskip */ - rb->set_option(items[0].desc, &options.maxskip, INT, frameskip, + rb->set_option("Max Frameskip", &options.maxskip, INT, frameskip, sizeof(frameskip)/sizeof(*frameskip), NULL ); break; case 1: /* Sound */ if(options.sound>1) options.sound=1; - rb->set_option(items[1].desc, &options.sound, INT, onoff, 2, NULL ); + rb->set_option("Sound", &options.sound, INT, onoff, 2, NULL ); if(options.sound) sound_dirty(); break; case 2: /* Stats */ - rb->set_option(items[2].desc, &options.showstats, INT, onoff, 2, NULL ); + rb->set_option("Stats", &options.showstats, INT, onoff, 2, NULL ); break; case 3: /* Keys */ setupkeys(); break; #ifdef HAVE_LCD_COLOR case 4: /* Screen Size */ - rb->set_option(items[4].desc, &options.scaling, INT, scaling, + rb->set_option("Screen Size", &options.scaling, INT, scaling, sizeof(scaling)/sizeof(*scaling), NULL ); setvidmode(); break; case 5: /* Screen rotate */ - rb->set_option(items[5].desc, &options.rotate, INT, onoff, 2, NULL ); + rb->set_option("Screen Rotate", &options.rotate, INT, onoff, 2, NULL ); setvidmode(); break; case 6: /* Palette */ - rb->set_option(items[6].desc, &options.pal, INT, palette, 17, NULL ); + rb->set_option("Set Palette", &options.pal, INT, palette, 17, NULL ); set_pal(); break; -#endif +#endif default: done=true; break; } } - menu_exit(m); } Index: apps/plugins/solitaire.c =================================================================== --- apps/plugins/solitaire.c (revision 21172) +++ apps/plugins/solitaire.c (working copy) @@ -24,7 +24,6 @@ #include "lib/configfile.h" #include "button.h" #include "lcd.h" -#include "lib/oldmenuapi.h" #ifdef HAVE_LCD_BITMAP @@ -773,16 +772,11 @@ { TYPE_INT, 0, 1, { .int_p = &sol_disk.draw_type }, "draw_type", NULL } }; -char draw_option_string[32]; +static const struct opt_items drawcards[2] = { + { "Draw Three Cards", -1 }, + { "Draw One Card", -1 }, +}; -static void create_draw_option_string(void) -{ - if (sol.draw_type == 0) - rb->strcpy(draw_option_string, "Draw Three Cards"); - else - rb->strcpy(draw_option_string, "Draw One Card"); -} - void solitaire_init(void); /* menu return codes */ @@ -790,37 +784,22 @@ int solitaire_menu(bool in_game) { - int m; + int selected = 0; int result = -1; - int i = 0; - struct menu_item items[6]; + MENUITEM_STRINGLIST(menu, "Solitaire Menu", NULL, + "Start Game", "Draw Cards Option", + "Help", "Audio Playback", "Quit"); + MENUITEM_STRINGLIST(menu_in_game, "Solitaire Menu", NULL, + "Resume Game", "Restart Game", "Help", + "Audio Playback", "Save and Quit", "Quit"); - if( in_game ) - { - items[i++].desc = "Resume Game"; - items[i++].desc = "Restart Game"; - } - else - { - items[i++].desc = "Start Game"; - items[i++].desc = draw_option_string; - } - items[i++].desc = "Help"; - items[i++].desc = "Audio Playback"; - if( in_game ) - { - items[i++].desc = "Save and Quit"; - } - items[i++].desc = "Quit"; - - create_draw_option_string(); - m = menu_init(items, i, NULL, NULL, NULL, NULL); while (result < 0) { - switch (menu_show(m)) + switch (rb->do_menu(in_game? &menu_in_game: &menu, + &selected, NULL, false)) { - case MENU_SELECTED_EXIT: + default: result = MENU_RESUME; break; @@ -840,8 +819,9 @@ } else { - sol.draw_type = (sol.draw_type + 1) % 2; - create_draw_option_string(); + if (rb->set_option("Draw Cards Option", &sol.draw_type, + INT, drawcards, 2, NULL)) + result = MENU_USB; } break; @@ -866,7 +846,6 @@ break; } } - menu_exit(m); return result; }