diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/menu.c | 202 | ||||
-rw-r--r-- | apps/menu.h | 20 | ||||
-rw-r--r-- | apps/plugin.c | 10 | ||||
-rw-r--r-- | apps/plugin.h | 18 | ||||
-rw-r--r-- | apps/plugins/clock.c | 49 | ||||
-rw-r--r-- | apps/plugins/doom/rockdoom.c | 25 | ||||
-rw-r--r-- | apps/plugins/fireworks.c | 7 | ||||
-rw-r--r-- | apps/plugins/jpeg.c | 15 | ||||
-rw-r--r-- | apps/plugins/lib/SOURCES | 1 | ||||
-rw-r--r-- | apps/plugins/lib/oldmenuapi.c | 241 | ||||
-rw-r--r-- | apps/plugins/lib/oldmenuapi.h | 56 | ||||
-rw-r--r-- | apps/plugins/mpegplayer/mpeg_settings.c | 7 | ||||
-rw-r--r-- | apps/plugins/pacbox/pacbox.c | 7 | ||||
-rw-r--r-- | apps/plugins/random_folder_advance_config.c | 21 | ||||
-rw-r--r-- | apps/plugins/rockboy/menu.c | 19 | ||||
-rw-r--r-- | apps/plugins/solitaire.c | 7 | ||||
-rw-r--r-- | apps/plugins/sudoku/sudoku.c | 15 | ||||
-rw-r--r-- | apps/plugins/test_disk.c | 7 | ||||
-rw-r--r-- | apps/plugins/test_sampr.c | 7 | ||||
-rw-r--r-- | apps/plugins/text_editor.c | 13 | ||||
-rw-r--r-- | apps/plugins/viewer.c | 15 | ||||
-rw-r--r-- | apps/plugins/zxbox/spmain.c | 25 |
22 files changed, 438 insertions, 349 deletions
diff --git a/apps/menu.c b/apps/menu.c index 000206182d..04ccaf4366 100644 --- a/apps/menu.c +++ b/apps/menu.c | |||
@@ -57,21 +57,8 @@ | |||
57 | #include "list.h" | 57 | #include "list.h" |
58 | #include "statusbar.h" | 58 | #include "statusbar.h" |
59 | #include "buttonbar.h" | 59 | #include "buttonbar.h" |
60 | /* needed for the old menu system */ | ||
61 | struct menu { | ||
62 | struct menu_item* items; | ||
63 | char *title; | ||
64 | int count; | ||
65 | int (*callback)(int, int); | ||
66 | int current_selection; | ||
67 | }; | ||
68 | #define MAX_MENUS 6 | ||
69 | static struct menu menus[MAX_MENUS]; | ||
70 | static bool inuse[MAX_MENUS] = { false }; | ||
71 | static void init_oldmenu(const struct menu_item_ex *menu, | ||
72 | struct gui_synclist *lists, int selected, bool callback); | ||
73 | static void menu_talk_selected(int m); | ||
74 | 60 | ||
61 | #define MAX_MENUS 8 | ||
75 | /* used to allow for dynamic menus */ | 62 | /* used to allow for dynamic menus */ |
76 | #define MAX_MENU_SUBITEMS 64 | 63 | #define MAX_MENU_SUBITEMS 64 |
77 | static struct menu_item_ex *current_submenus_menu; | 64 | static struct menu_item_ex *current_submenus_menu; |
@@ -182,11 +169,6 @@ static void init_menu_lists(const struct menu_item_ex *menu, | |||
182 | int icon; | 169 | int icon; |
183 | current_subitems_count = 0; | 170 | current_subitems_count = 0; |
184 | 171 | ||
185 | if (type == MT_OLD_MENU) | ||
186 | { | ||
187 | init_oldmenu(menu, lists, selected, callback); | ||
188 | return; | ||
189 | } | ||
190 | if (type == MT_RETURN_ID) | 172 | if (type == MT_RETURN_ID) |
191 | get_menu_callback(menu, &menu_callback); | 173 | get_menu_callback(menu, &menu_callback); |
192 | 174 | ||
@@ -244,13 +226,6 @@ static void talk_menu_item(const struct menu_item_ex *menu, | |||
244 | 226 | ||
245 | if (global_settings.talk_menu) | 227 | if (global_settings.talk_menu) |
246 | { | 228 | { |
247 | if ((menu->flags&MENU_TYPE_MASK) == MT_OLD_MENU) | ||
248 | { | ||
249 | menus[menu->value].current_selection = | ||
250 | gui_synclist_get_sel_pos(lists); | ||
251 | menu_talk_selected(menu->value); | ||
252 | return; | ||
253 | } | ||
254 | sel = get_menu_selection(gui_synclist_get_sel_pos(lists),menu); | 229 | sel = get_menu_selection(gui_synclist_get_sel_pos(lists),menu); |
255 | if ((menu->flags&MENU_TYPE_MASK) == MT_MENU) | 230 | if ((menu->flags&MENU_TYPE_MASK) == MT_MENU) |
256 | { | 231 | { |
@@ -480,8 +455,6 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected) | |||
480 | } | 455 | } |
481 | else if (action == ACTION_STD_MENU) | 456 | else if (action == ACTION_STD_MENU) |
482 | { | 457 | { |
483 | if ((menu->flags&MENU_TYPE_MASK) == MT_OLD_MENU) | ||
484 | return MENU_SELECTED_EXIT; | ||
485 | if (menu != &root_menu_) | 458 | if (menu != &root_menu_) |
486 | ret = GO_TO_ROOT; | 459 | ret = GO_TO_ROOT; |
487 | else | 460 | else |
@@ -521,13 +494,6 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected) | |||
521 | gui_buttonbar_unset(&buttonbar); | 494 | gui_buttonbar_unset(&buttonbar); |
522 | gui_buttonbar_draw(&buttonbar); | 495 | gui_buttonbar_draw(&buttonbar); |
523 | #endif | 496 | #endif |
524 | if ((menu->flags&MENU_TYPE_MASK) == MT_OLD_MENU) | ||
525 | { | ||
526 | selected = gui_synclist_get_sel_pos(&lists); | ||
527 | menus[menu->value].current_selection = selected; | ||
528 | action_signalscreenchange(); | ||
529 | return selected; | ||
530 | } | ||
531 | selected = get_menu_selection(gui_synclist_get_sel_pos(&lists), menu); | 497 | selected = get_menu_selection(gui_synclist_get_sel_pos(&lists), menu); |
532 | temp = menu->submenus[selected]; | 498 | temp = menu->submenus[selected]; |
533 | if (in_stringlist) | 499 | if (in_stringlist) |
@@ -643,169 +609,3 @@ int main_menu(void) | |||
643 | return do_menu(NULL, 0) == MENU_ATTACHED_USB; | 609 | return do_menu(NULL, 0) == MENU_ATTACHED_USB; |
644 | } | 610 | } |
645 | 611 | ||
646 | /* wrappers for the old menu system to work with the new system */ | ||
647 | |||
648 | |||
649 | static int menu_find_free(void) | ||
650 | { | ||
651 | int i; | ||
652 | /* Tries to find an unused slot to put the new menu */ | ||
653 | for ( i=0; i<MAX_MENUS; i++ ) { | ||
654 | if ( !inuse[i] ) { | ||
655 | inuse[i] = true; | ||
656 | break; | ||
657 | } | ||
658 | } | ||
659 | if ( i == MAX_MENUS ) { | ||
660 | DEBUGF("Out of menus!\n"); | ||
661 | return -1; | ||
662 | } | ||
663 | return(i); | ||
664 | } | ||
665 | |||
666 | int menu_init(const struct menu_item* mitems, int count, int (*callback)(int, int), | ||
667 | const char *button1, const char *button2, const char *button3) | ||
668 | { | ||
669 | int menu=menu_find_free(); | ||
670 | if(menu==-1)/* Out of menus */ | ||
671 | return -1; | ||
672 | menus[menu].items = (struct menu_item*)mitems; /* de-const */ | ||
673 | menus[menu].count = count; | ||
674 | menus[menu].callback = callback; | ||
675 | menus[menu].current_selection = 0; | ||
676 | if ((button2 == NULL) && (button3 == NULL)) | ||
677 | menus[menu].title = (char*)button1; | ||
678 | else menus[menu].title = NULL; | ||
679 | return menu; | ||
680 | } | ||
681 | |||
682 | void menu_exit(int m) | ||
683 | { | ||
684 | inuse[m] = false; | ||
685 | } | ||
686 | |||
687 | |||
688 | |||
689 | static int oldmenuwrapper_callback(int action, | ||
690 | const struct menu_item_ex *this_item) | ||
691 | { | ||
692 | if (menus[this_item->value].callback) | ||
693 | { | ||
694 | int val = menus[this_item->value].callback(action, this_item->value); | ||
695 | switch (val) | ||
696 | { | ||
697 | case MENU_SELECTED_EXIT: | ||
698 | return ACTION_EXIT_MENUITEM; | ||
699 | } | ||
700 | return val; | ||
701 | } | ||
702 | return action; | ||
703 | } | ||
704 | |||
705 | static char* oldmenuwrapper_getname(int selected_item, | ||
706 | void * data, char *buffer) | ||
707 | { | ||
708 | (void)buffer; | ||
709 | unsigned char* desc = menus[(intptr_t)data].items[selected_item].desc; | ||
710 | return P2STR(desc); | ||
711 | } | ||
712 | |||
713 | #ifdef HAVE_LCD_BITMAP | ||
714 | static int oldmenu_get_icon(int selected_item, void * data) | ||
715 | { | ||
716 | (void)data; (void)selected_item; | ||
717 | return Icon_Menu_functioncall; | ||
718 | } | ||
719 | #endif | ||
720 | |||
721 | static void init_oldmenu(const struct menu_item_ex *menu, | ||
722 | struct gui_synclist *lists, int selected, bool callback) | ||
723 | { | ||
724 | (void)callback; | ||
725 | gui_synclist_init(lists, oldmenuwrapper_getname, | ||
726 | (void*)(intptr_t)menu->value, false, 1); | ||
727 | gui_synclist_set_nb_items(lists, MENU_GET_COUNT(menu->flags)); | ||
728 | gui_synclist_limit_scroll(lists, true); | ||
729 | #ifdef HAVE_LCD_BITMAP | ||
730 | gui_synclist_set_title(lists, menus[menu->value].title, | ||
731 | Icon_Submenu_Entered); | ||
732 | gui_synclist_set_icon_callback(lists, oldmenu_get_icon); | ||
733 | #endif | ||
734 | gui_synclist_select_item(lists, selected); | ||
735 | } | ||
736 | |||
737 | static void menu_talk_selected(int m) | ||
738 | { | ||
739 | int selected = menus[m].current_selection; | ||
740 | int voice_id = P2ID(menus[m].items[selected].desc); | ||
741 | if (voice_id >= 0) /* valid ID given? */ | ||
742 | talk_id(voice_id, false); /* say it */ | ||
743 | } | ||
744 | |||
745 | int menu_show(int m) | ||
746 | { | ||
747 | int value; | ||
748 | struct menu_item_ex menu; | ||
749 | struct menu_get_name_and_icon menu_info = | ||
750 | { | ||
751 | oldmenuwrapper_callback, | ||
752 | oldmenuwrapper_getname, | ||
753 | (void*)(intptr_t)m, Icon_Submenu | ||
754 | }; | ||
755 | |||
756 | menu.flags = (MENU_TYPE_MASK&MT_OLD_MENU) | MENU_DYNAMIC_DESC | | ||
757 | MENU_ITEM_COUNT(menus[m].count); | ||
758 | menu.value = m; | ||
759 | menu.menu_get_name_and_icon = &menu_info; | ||
760 | value = do_menu(&menu, &menus[m].current_selection); | ||
761 | switch (value) | ||
762 | { | ||
763 | case MENU_ATTACHED_USB: | ||
764 | case GO_TO_ROOT: | ||
765 | return MENU_ATTACHED_USB; | ||
766 | case GO_TO_PREVIOUS: | ||
767 | return MENU_SELECTED_EXIT; | ||
768 | default: | ||
769 | if (value >= 0) | ||
770 | return menus[m].current_selection; | ||
771 | else return value; | ||
772 | } | ||
773 | } | ||
774 | |||
775 | |||
776 | bool menu_run(int m) | ||
777 | { | ||
778 | int selected; | ||
779 | while (1) { | ||
780 | switch (selected=menu_show(m)) | ||
781 | { | ||
782 | case MENU_SELECTED_EXIT: | ||
783 | return false; | ||
784 | |||
785 | case MENU_ATTACHED_USB: | ||
786 | return true; | ||
787 | |||
788 | default: | ||
789 | { | ||
790 | if (selected >= 0 && selected < menus[m].count) | ||
791 | { | ||
792 | if (menus[m].items[selected].function && | ||
793 | menus[m].items[selected].function()) | ||
794 | return true; | ||
795 | } | ||
796 | gui_syncstatusbar_draw(&statusbars, true); | ||
797 | } | ||
798 | } | ||
799 | } | ||
800 | return false; | ||
801 | } | ||
802 | |||
803 | /* | ||
804 | * Property function - return the "count" of menu items in "menu" | ||
805 | */ | ||
806 | |||
807 | int menu_count(int menu) | ||
808 | { | ||
809 | return menus[menu].count; | ||
810 | } | ||
811 | |||
diff --git a/apps/menu.h b/apps/menu.h index 7e08ef5aac..7b26bbc90c 100644 --- a/apps/menu.h +++ b/apps/menu.h | |||
@@ -35,8 +35,6 @@ enum menu_item_type { | |||
35 | MT_FUNCTION_CALL, /* call a function from the menus */ | 35 | MT_FUNCTION_CALL, /* call a function from the menus */ |
36 | MT_RETURN_ID, /* returns the position of the selected item (starting at 0)*/ | 36 | MT_RETURN_ID, /* returns the position of the selected item (starting at 0)*/ |
37 | MT_RETURN_VALUE, /* returns a value associated with an item */ | 37 | MT_RETURN_VALUE, /* returns a value associated with an item */ |
38 | MT_OLD_MENU, /* used so we can wrap the old menu api | ||
39 | around the new api. Noone else should use this */ | ||
40 | }; | 38 | }; |
41 | #define MENU_TYPE_MASK 0xF /* MT_* type */ | 39 | #define MENU_TYPE_MASK 0xF /* MT_* type */ |
42 | 40 | ||
@@ -192,22 +190,4 @@ bool do_setting_from_menu(const struct menu_item_ex *temp); | |||
192 | { (void*)name##_},{.callback_and_desc = & name##__}}; | 190 | { (void*)name##_},{.callback_and_desc = & name##__}}; |
193 | 191 | ||
194 | 192 | ||
195 | /* OLD API - This is only here for plugin compatability now, will be dropped ASAP */ | ||
196 | struct menu_item { | ||
197 | unsigned char *desc; /* string or ID */ | ||
198 | bool (*function) (void); /* return true if USB was connected */ | ||
199 | }; | ||
200 | |||
201 | /* if button2 == button3 == NULL, button1 is the menu title */ | ||
202 | int menu_init(const struct menu_item* mitems, int count, | ||
203 | int (*callback)(int, int), | ||
204 | const char *button1, const char *button2, const char *button3); | ||
205 | void menu_exit(int menu); | ||
206 | |||
207 | /* Returns MENU_* define from root_menu.h, or number of selected menu item*/ | ||
208 | int menu_show(int m); | ||
209 | |||
210 | bool menu_run(int menu); | ||
211 | int menu_count(int menu); | ||
212 | |||
213 | #endif /* End __MENU_H__ */ | 193 | #endif /* End __MENU_H__ */ |
diff --git a/apps/plugin.c b/apps/plugin.c index 1478805e2c..379c154bad 100644 --- a/apps/plugin.c +++ b/apps/plugin.c | |||
@@ -397,12 +397,10 @@ static const struct plugin_api rockbox_api = { | |||
397 | 397 | ||
398 | /* menu */ | 398 | /* menu */ |
399 | do_menu, | 399 | do_menu, |
400 | /* OLD API - dont use unless you have to */ | 400 | /* statusbars */ |
401 | menu_init, | 401 | &statusbars, |
402 | menu_exit, | 402 | gui_syncstatusbar_draw, |
403 | menu_show, | 403 | /* options */ |
404 | menu_run, | ||
405 | menu_count, | ||
406 | set_option, | 404 | set_option, |
407 | set_int, | 405 | set_int, |
408 | set_bool, | 406 | set_bool, |
diff --git a/apps/plugin.h b/apps/plugin.h index e04b0e20d5..08d320ed57 100644 --- a/apps/plugin.h +++ b/apps/plugin.h | |||
@@ -74,6 +74,7 @@ | |||
74 | #ifdef HAVE_LCD_BITMAP | 74 | #ifdef HAVE_LCD_BITMAP |
75 | #include "scrollbar.h" | 75 | #include "scrollbar.h" |
76 | #endif | 76 | #endif |
77 | #include "statusbar.h" | ||
77 | #include "menu.h" | 78 | #include "menu.h" |
78 | #include "rbunicode.h" | 79 | #include "rbunicode.h" |
79 | #include "list.h" | 80 | #include "list.h" |
@@ -113,12 +114,12 @@ | |||
113 | #define PLUGIN_MAGIC 0x526F634B /* RocK */ | 114 | #define PLUGIN_MAGIC 0x526F634B /* RocK */ |
114 | 115 | ||
115 | /* increase this every time the api struct changes */ | 116 | /* increase this every time the api struct changes */ |
116 | #define PLUGIN_API_VERSION 55 | 117 | #define PLUGIN_API_VERSION 56 |
117 | 118 | ||
118 | /* update this to latest version if a change to the api struct breaks | 119 | /* update this to latest version if a change to the api struct breaks |
119 | backwards compatibility (and please take the opportunity to sort in any | 120 | backwards compatibility (and please take the opportunity to sort in any |
120 | new function which are "waiting" at the end of the function table) */ | 121 | new function which are "waiting" at the end of the function table) */ |
121 | #define PLUGIN_MIN_API_VERSION 54 | 122 | #define PLUGIN_MIN_API_VERSION 56 |
122 | 123 | ||
123 | /* plugin return codes */ | 124 | /* plugin return codes */ |
124 | enum plugin_status { | 125 | enum plugin_status { |
@@ -495,15 +496,12 @@ struct plugin_api { | |||
495 | 496 | ||
496 | /* menu */ | 497 | /* menu */ |
497 | int (*do_menu)(const struct menu_item_ex *menu, int *start_selected); | 498 | int (*do_menu)(const struct menu_item_ex *menu, int *start_selected); |
498 | /* OLD API - dont use unless you have to */ | ||
499 | int (*menu_init)(const struct menu_item* mitems, int count, | ||
500 | int (*callback)(int, int), | ||
501 | const char *button1, const char *button2, const char *button3); | ||
502 | void (*menu_exit)(int menu); | ||
503 | int (*menu_show)(int m); | ||
504 | bool (*menu_run)(int menu); | ||
505 | int (*menu_count)(int menu); | ||
506 | 499 | ||
500 | /* scroll bar */ | ||
501 | struct gui_syncstatusbar *statusbars; | ||
502 | void (*gui_syncstatusbar_draw)(struct gui_syncstatusbar * bars, bool force_redraw); | ||
503 | |||
504 | /* options */ | ||
507 | bool (*set_option)(const char* string, void* variable, | 505 | bool (*set_option)(const char* string, void* variable, |
508 | enum optiontype type, const struct opt_items* options, | 506 | enum optiontype type, const struct opt_items* options, |
509 | int numoptions, void (*function)(int)); | 507 | int numoptions, void (*function)(int)); |
diff --git a/apps/plugins/clock.c b/apps/plugins/clock.c index 59b98247b8..3c70759da6 100644 --- a/apps/plugins/clock.c +++ b/apps/plugins/clock.c | |||
@@ -92,6 +92,7 @@ Original release, featuring analog/digital modes and a few options. | |||
92 | #include "time.h" | 92 | #include "time.h" |
93 | #include "checkbox.h" | 93 | #include "checkbox.h" |
94 | #include "xlcd.h" | 94 | #include "xlcd.h" |
95 | #include "oldmenuapi.h" | ||
95 | 96 | ||
96 | PLUGIN_HEADER | 97 | PLUGIN_HEADER |
97 | 98 | ||
@@ -1177,12 +1178,12 @@ void analog_settings_menu(void) | |||
1177 | rb->lcd_set_foreground(LCD_BLACK); | 1178 | rb->lcd_set_foreground(LCD_BLACK); |
1178 | #endif | 1179 | #endif |
1179 | 1180 | ||
1180 | m = rb->menu_init(analog_items, sizeof(analog_items) / sizeof(*analog_items), | 1181 | m = menu_init(rb, analog_items, sizeof(analog_items) / sizeof(*analog_items), |
1181 | NULL, NULL, NULL, NULL); | 1182 | NULL, NULL, NULL, NULL); |
1182 | 1183 | ||
1183 | while(!done) | 1184 | while(!done) |
1184 | { | 1185 | { |
1185 | result = rb->menu_show(m); | 1186 | result = menu_show(m); |
1186 | 1187 | ||
1187 | switch(result) | 1188 | switch(result) |
1188 | { | 1189 | { |
@@ -1204,7 +1205,7 @@ void analog_settings_menu(void) | |||
1204 | break; | 1205 | break; |
1205 | } | 1206 | } |
1206 | 1207 | ||
1207 | rb->menu_exit(m); | 1208 | menu_exit(m); |
1208 | } | 1209 | } |
1209 | } | 1210 | } |
1210 | 1211 | ||
@@ -1222,12 +1223,12 @@ void digital_settings_menu(void) | |||
1222 | rb->lcd_set_foreground(LCD_BLACK); | 1223 | rb->lcd_set_foreground(LCD_BLACK); |
1223 | #endif | 1224 | #endif |
1224 | 1225 | ||
1225 | m = rb->menu_init(digital_items, sizeof(digital_items) / sizeof(*digital_items), | 1226 | m = menu_init(rb, digital_items, sizeof(digital_items) / sizeof(*digital_items), |
1226 | NULL, NULL, NULL, NULL); | 1227 | NULL, NULL, NULL, NULL); |
1227 | 1228 | ||
1228 | while(!done) | 1229 | while(!done) |
1229 | { | 1230 | { |
1230 | result = rb->menu_show(m); | 1231 | result = menu_show(m); |
1231 | 1232 | ||
1232 | switch(result) | 1233 | switch(result) |
1233 | { | 1234 | { |
@@ -1253,7 +1254,7 @@ void digital_settings_menu(void) | |||
1253 | break; | 1254 | break; |
1254 | } | 1255 | } |
1255 | 1256 | ||
1256 | rb->menu_exit(m); | 1257 | menu_exit(m); |
1257 | } | 1258 | } |
1258 | } | 1259 | } |
1259 | 1260 | ||
@@ -1271,12 +1272,12 @@ void fullscreen_settings_menu(void) | |||
1271 | rb->lcd_set_foreground(LCD_BLACK); | 1272 | rb->lcd_set_foreground(LCD_BLACK); |
1272 | #endif | 1273 | #endif |
1273 | 1274 | ||
1274 | m = rb->menu_init(fullscreen_items, sizeof(fullscreen_items) / sizeof(*fullscreen_items), | 1275 | m = menu_init(rb, fullscreen_items, sizeof(fullscreen_items) / sizeof(*fullscreen_items), |
1275 | NULL, NULL, NULL, NULL); | 1276 | NULL, NULL, NULL, NULL); |
1276 | 1277 | ||
1277 | while(!done) | 1278 | while(!done) |
1278 | { | 1279 | { |
1279 | result = rb->menu_show(m); | 1280 | result = menu_show(m); |
1280 | 1281 | ||
1281 | switch(result) | 1282 | switch(result) |
1282 | { | 1283 | { |
@@ -1294,7 +1295,7 @@ void fullscreen_settings_menu(void) | |||
1294 | break; | 1295 | break; |
1295 | } | 1296 | } |
1296 | 1297 | ||
1297 | rb->menu_exit(m); | 1298 | menu_exit(m); |
1298 | } | 1299 | } |
1299 | } | 1300 | } |
1300 | 1301 | ||
@@ -1312,12 +1313,12 @@ void binary_settings_menu(void) | |||
1312 | rb->lcd_set_foreground(LCD_BLACK); | 1313 | rb->lcd_set_foreground(LCD_BLACK); |
1313 | #endif | 1314 | #endif |
1314 | 1315 | ||
1315 | m = rb->menu_init(binary_items, sizeof(binary_items) / sizeof(*binary_items), | 1316 | m = menu_init(rb,binary_items, sizeof(binary_items) / sizeof(*binary_items), |
1316 | NULL, NULL, NULL, NULL); | 1317 | NULL, NULL, NULL, NULL); |
1317 | 1318 | ||
1318 | while(!done) | 1319 | while(!done) |
1319 | { | 1320 | { |
1320 | result = rb->menu_show(m); | 1321 | result = menu_show(m); |
1321 | 1322 | ||
1322 | switch(result) | 1323 | switch(result) |
1323 | { | 1324 | { |
@@ -1331,7 +1332,7 @@ void binary_settings_menu(void) | |||
1331 | break; | 1332 | break; |
1332 | } | 1333 | } |
1333 | 1334 | ||
1334 | rb->menu_exit(m); | 1335 | menu_exit(m); |
1335 | } | 1336 | } |
1336 | } | 1337 | } |
1337 | 1338 | ||
@@ -1349,12 +1350,12 @@ void plain_settings_menu(void) | |||
1349 | rb->lcd_set_foreground(LCD_BLACK); | 1350 | rb->lcd_set_foreground(LCD_BLACK); |
1350 | #endif | 1351 | #endif |
1351 | 1352 | ||
1352 | m = rb->menu_init(plain_items, sizeof(plain_items) / sizeof(*plain_items), | 1353 | m = menu_init(rb,plain_items, sizeof(plain_items) / sizeof(*plain_items), |
1353 | NULL, NULL, NULL, NULL); | 1354 | NULL, NULL, NULL, NULL); |
1354 | 1355 | ||
1355 | while(!done) | 1356 | while(!done) |
1356 | { | 1357 | { |
1357 | result = rb->menu_show(m); | 1358 | result = menu_show(m); |
1358 | 1359 | ||
1359 | switch(result) | 1360 | switch(result) |
1360 | { | 1361 | { |
@@ -1380,7 +1381,7 @@ void plain_settings_menu(void) | |||
1380 | break; | 1381 | break; |
1381 | } | 1382 | } |
1382 | 1383 | ||
1383 | rb->menu_exit(m); | 1384 | menu_exit(m); |
1384 | } | 1385 | } |
1385 | } | 1386 | } |
1386 | 1387 | ||
@@ -1434,12 +1435,12 @@ void general_settings(void) | |||
1434 | 1435 | ||
1435 | set_standard_colors(); | 1436 | set_standard_colors(); |
1436 | 1437 | ||
1437 | m = rb->menu_init(general_settings_items, sizeof(general_settings_items) / sizeof(*general_settings_items), | 1438 | m = menu_init(rb,general_settings_items, sizeof(general_settings_items) / sizeof(*general_settings_items), |
1438 | NULL, NULL, NULL, NULL); | 1439 | NULL, NULL, NULL, NULL); |
1439 | 1440 | ||
1440 | while(!done) | 1441 | while(!done) |
1441 | { | 1442 | { |
1442 | result = rb->menu_show(m); | 1443 | result = menu_show(m); |
1443 | 1444 | ||
1444 | switch(result) | 1445 | switch(result) |
1445 | { | 1446 | { |
@@ -1481,7 +1482,7 @@ void general_settings(void) | |||
1481 | break; | 1482 | break; |
1482 | } | 1483 | } |
1483 | 1484 | ||
1484 | rb->menu_exit(m); | 1485 | menu_exit(m); |
1485 | } | 1486 | } |
1486 | 1487 | ||
1487 | set_digital_colors(); | 1488 | set_digital_colors(); |
@@ -1700,12 +1701,12 @@ void mode_selector(void) | |||
1700 | 1701 | ||
1701 | set_standard_colors(); | 1702 | set_standard_colors(); |
1702 | 1703 | ||
1703 | m = rb->menu_init(mode_selector_items, sizeof(mode_selector_items) / sizeof(*mode_selector_items), | 1704 | m = menu_init(rb,mode_selector_items, sizeof(mode_selector_items) / sizeof(*mode_selector_items), |
1704 | NULL, NULL, NULL, NULL); | 1705 | NULL, NULL, NULL, NULL); |
1705 | 1706 | ||
1706 | while(!done) | 1707 | while(!done) |
1707 | { | 1708 | { |
1708 | result = rb->menu_show(m); | 1709 | result = menu_show(m); |
1709 | 1710 | ||
1710 | /* check for this, so if the user exits the menu without | 1711 | /* check for this, so if the user exits the menu without |
1711 | * making a selection, it won't change to some weird value. */ | 1712 | * making a selection, it won't change to some weird value. */ |
@@ -1714,7 +1715,7 @@ void mode_selector(void) | |||
1714 | 1715 | ||
1715 | done = true; | 1716 | done = true; |
1716 | 1717 | ||
1717 | rb->menu_exit(m); | 1718 | menu_exit(m); |
1718 | } | 1719 | } |
1719 | 1720 | ||
1720 | set_digital_colors(); | 1721 | set_digital_colors(); |
@@ -1830,12 +1831,12 @@ void main_menu(void) | |||
1830 | 1831 | ||
1831 | set_standard_colors(); | 1832 | set_standard_colors(); |
1832 | 1833 | ||
1833 | m = rb->menu_init(main_menu_items, sizeof(main_menu_items) / sizeof(*main_menu_items), | 1834 | m = menu_init(rb,main_menu_items, sizeof(main_menu_items) / sizeof(*main_menu_items), |
1834 | NULL, NULL, NULL, NULL); | 1835 | NULL, NULL, NULL, NULL); |
1835 | 1836 | ||
1836 | while(!done) | 1837 | while(!done) |
1837 | { | 1838 | { |
1838 | result = rb->menu_show(m); | 1839 | result = menu_show(m); |
1839 | 1840 | ||
1840 | switch(result) | 1841 | switch(result) |
1841 | { | 1842 | { |
@@ -1866,7 +1867,7 @@ void main_menu(void) | |||
1866 | break; | 1867 | break; |
1867 | } | 1868 | } |
1868 | 1869 | ||
1869 | rb->menu_exit(m); | 1870 | menu_exit(m); |
1870 | } | 1871 | } |
1871 | 1872 | ||
1872 | rb->lcd_setfont(FONT_SYSFIXED); | 1873 | rb->lcd_setfont(FONT_SYSFIXED); |
diff --git a/apps/plugins/doom/rockdoom.c b/apps/plugins/doom/rockdoom.c index 1081324974..82daadb24e 100644 --- a/apps/plugins/doom/rockdoom.c +++ b/apps/plugins/doom/rockdoom.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include "i_system.h" | 37 | #include "i_system.h" |
38 | #include "hu_stuff.h" | 38 | #include "hu_stuff.h" |
39 | #include "st_stuff.h" | 39 | #include "st_stuff.h" |
40 | #include "lib/oldmenuapi.h" | ||
40 | 41 | ||
41 | PLUGIN_HEADER | 42 | PLUGIN_HEADER |
42 | PLUGIN_IRAM_DECLARE | 43 | PLUGIN_IRAM_DECLARE |
@@ -490,12 +491,12 @@ int Oset_keys() | |||
490 | { "Game Automap", NULL }, | 491 | { "Game Automap", NULL }, |
491 | }; | 492 | }; |
492 | 493 | ||
493 | m = rb->menu_init(items, sizeof(items) / sizeof(*items), | 494 | m = menu_init(rb, items, sizeof(items) / sizeof(*items), |
494 | NULL, NULL, NULL, NULL); | 495 | NULL, NULL, NULL, NULL); |
495 | 496 | ||
496 | while(!menuquit) | 497 | while(!menuquit) |
497 | { | 498 | { |
498 | result=rb->menu_show(m); | 499 | result=menu_show(m); |
499 | if(result<0) | 500 | if(result<0) |
500 | menuquit=1; | 501 | menuquit=1; |
501 | else | 502 | else |
@@ -506,7 +507,7 @@ int Oset_keys() | |||
506 | } | 507 | } |
507 | } | 508 | } |
508 | 509 | ||
509 | rb->menu_exit(m); | 510 | menu_exit(m); |
510 | 511 | ||
511 | return (1); | 512 | return (1); |
512 | } | 513 | } |
@@ -554,12 +555,12 @@ static bool Doptions() | |||
554 | #endif | 555 | #endif |
555 | }; | 556 | }; |
556 | 557 | ||
557 | m = rb->menu_init(items, sizeof(items) / sizeof(*items), | 558 | m = menu_init(rb, items, sizeof(items) / sizeof(*items), |
558 | NULL, NULL, NULL, NULL); | 559 | NULL, NULL, NULL, NULL); |
559 | 560 | ||
560 | while(!menuquit) | 561 | while(!menuquit) |
561 | { | 562 | { |
562 | result=rb->menu_show(m); | 563 | result=menu_show(m); |
563 | if(result==0) | 564 | if(result==0) |
564 | Oset_keys(); | 565 | Oset_keys(); |
565 | else if (result > 0) | 566 | else if (result > 0) |
@@ -568,7 +569,7 @@ static bool Doptions() | |||
568 | menuquit=1; | 569 | menuquit=1; |
569 | } | 570 | } |
570 | 571 | ||
571 | rb->menu_exit(m); | 572 | menu_exit(m); |
572 | 573 | ||
573 | return (1); | 574 | return (1); |
574 | } | 575 | } |
@@ -577,10 +578,10 @@ int menuchoice(struct menu_item *menu, int items) | |||
577 | { | 578 | { |
578 | int m, result; | 579 | int m, result; |
579 | 580 | ||
580 | m = rb->menu_init(menu, items,NULL, NULL, NULL, NULL); | 581 | m = menu_init(rb, menu, items,NULL, NULL, NULL, NULL); |
581 | 582 | ||
582 | result= rb->menu_show(m); | 583 | result= menu_show(m); |
583 | rb->menu_exit(m); | 584 | menu_exit(m); |
584 | if(result<items && result>=0) | 585 | if(result<items && result>=0) |
585 | return result; | 586 | return result; |
586 | return 0; | 587 | return 0; |
@@ -627,12 +628,12 @@ int doom_menu() | |||
627 | while (rb->button_get(false) != BUTTON_NONE) | 628 | while (rb->button_get(false) != BUTTON_NONE) |
628 | rb->yield(); | 629 | rb->yield(); |
629 | 630 | ||
630 | m = rb->menu_init(items, sizeof(items) / sizeof(*items), | 631 | m = menu_init(rb, items, sizeof(items) / sizeof(*items), |
631 | NULL, NULL, NULL, NULL); | 632 | NULL, NULL, NULL, NULL); |
632 | 633 | ||
633 | while(!menuquit) | 634 | while(!menuquit) |
634 | { | 635 | { |
635 | result=rb->menu_show(m); | 636 | result=menu_show(m); |
636 | switch (result) { | 637 | switch (result) { |
637 | case 0: /* Game picker */ | 638 | case 0: /* Game picker */ |
638 | rb->set_option("Game WAD", &gamever, INT, names, status, NULL ); | 639 | rb->set_option("Game WAD", &gamever, INT, names, status, NULL ); |
@@ -664,7 +665,7 @@ int doom_menu() | |||
664 | } | 665 | } |
665 | } | 666 | } |
666 | 667 | ||
667 | rb->menu_exit(m); | 668 | menu_exit(m); |
668 | 669 | ||
669 | return (gamever); | 670 | return (gamever); |
670 | } | 671 | } |
diff --git a/apps/plugins/fireworks.c b/apps/plugins/fireworks.c index f564b68b85..08d4e00d68 100644 --- a/apps/plugins/fireworks.c +++ b/apps/plugins/fireworks.c | |||
@@ -17,6 +17,7 @@ | |||
17 | * | 17 | * |
18 | ****************************************************************************/ | 18 | ****************************************************************************/ |
19 | #include "plugin.h" | 19 | #include "plugin.h" |
20 | #include "oldmenuapi.h" | ||
20 | 21 | ||
21 | PLUGIN_HEADER | 22 | PLUGIN_HEADER |
22 | 23 | ||
@@ -303,14 +304,14 @@ void fireworks_menu(void) | |||
303 | rb->lcd_clear_display(); | 304 | rb->lcd_clear_display(); |
304 | rb->lcd_update(); | 305 | rb->lcd_update(); |
305 | 306 | ||
306 | m = rb->menu_init(items, sizeof(items) / sizeof(*items), | 307 | m = menu_init(rb, items, sizeof(items) / sizeof(*items), |
307 | NULL, NULL, NULL, NULL); | 308 | NULL, NULL, NULL, NULL); |
308 | 309 | ||
309 | rb->button_clear_queue(); | 310 | rb->button_clear_queue(); |
310 | 311 | ||
311 | while(!menu_quit) | 312 | while(!menu_quit) |
312 | { | 313 | { |
313 | result = rb->menu_show(m); | 314 | result = menu_show(m); |
314 | 315 | ||
315 | switch(result) | 316 | switch(result) |
316 | { | 317 | { |
@@ -360,7 +361,7 @@ void fireworks_menu(void) | |||
360 | } | 361 | } |
361 | } | 362 | } |
362 | 363 | ||
363 | rb->menu_exit(m); | 364 | menu_exit(m); |
364 | } | 365 | } |
365 | 366 | ||
366 | /* this is the plugin entry point */ | 367 | /* this is the plugin entry point */ |
diff --git a/apps/plugins/jpeg.c b/apps/plugins/jpeg.c index f04d704b2e..55eade1228 100644 --- a/apps/plugins/jpeg.c +++ b/apps/plugins/jpeg.c | |||
@@ -26,6 +26,7 @@ | |||
26 | 26 | ||
27 | #include "plugin.h" | 27 | #include "plugin.h" |
28 | #include "playback_control.h" | 28 | #include "playback_control.h" |
29 | #include "oldmenuapi.h" | ||
29 | 30 | ||
30 | #ifdef HAVE_LCD_BITMAP | 31 | #ifdef HAVE_LCD_BITMAP |
31 | #include "gray.h" | 32 | #include "gray.h" |
@@ -2415,10 +2416,10 @@ static void display_options(void) | |||
2415 | { "Dithering", set_option_dithering }, | 2416 | { "Dithering", set_option_dithering }, |
2416 | }; | 2417 | }; |
2417 | 2418 | ||
2418 | int m = rb->menu_init(items, ARRAYLEN(items), | 2419 | int m = menu_init(rb, items, ARRAYLEN(items), |
2419 | NULL, NULL, NULL, NULL); | 2420 | NULL, NULL, NULL, NULL); |
2420 | rb->menu_run(m); | 2421 | menu_run(m); |
2421 | rb->menu_exit(m); | 2422 | menu_exit(m); |
2422 | } | 2423 | } |
2423 | #endif /* HAVE_LCD_COLOR */ | 2424 | #endif /* HAVE_LCD_COLOR */ |
2424 | 2425 | ||
@@ -2490,14 +2491,14 @@ int show_menu(void) /* return 1 to quit */ | |||
2490 | { "20 seconds", -1 }, | 2491 | { "20 seconds", -1 }, |
2491 | }; | 2492 | }; |
2492 | 2493 | ||
2493 | m = rb->menu_init(items, sizeof(items) / sizeof(*items), | 2494 | m = menu_init(rb, items, sizeof(items) / sizeof(*items), |
2494 | NULL, NULL, NULL, NULL); | 2495 | NULL, NULL, NULL, NULL); |
2495 | result=rb->menu_show(m); | 2496 | result=menu_show(m); |
2496 | 2497 | ||
2497 | switch (result) | 2498 | switch (result) |
2498 | { | 2499 | { |
2499 | case MIID_QUIT: | 2500 | case MIID_QUIT: |
2500 | rb->menu_exit(m); | 2501 | menu_exit(m); |
2501 | return 1; | 2502 | return 1; |
2502 | break; | 2503 | break; |
2503 | case MIID_TOGGLE_SS_MODE: | 2504 | case MIID_TOGGLE_SS_MODE: |
@@ -2561,7 +2562,7 @@ int show_menu(void) /* return 1 to quit */ | |||
2561 | rb->lcd_set_background(LCD_BLACK); | 2562 | rb->lcd_set_background(LCD_BLACK); |
2562 | #endif | 2563 | #endif |
2563 | rb->lcd_clear_display(); | 2564 | rb->lcd_clear_display(); |
2564 | rb->menu_exit(m); | 2565 | menu_exit(m); |
2565 | return 0; | 2566 | return 0; |
2566 | } | 2567 | } |
2567 | /* interactively scroll around the image */ | 2568 | /* interactively scroll around the image */ |
diff --git a/apps/plugins/lib/SOURCES b/apps/plugins/lib/SOURCES index adb3d68260..03a990acda 100644 --- a/apps/plugins/lib/SOURCES +++ b/apps/plugins/lib/SOURCES | |||
@@ -1,3 +1,4 @@ | |||
1 | oldmenuapi.c | ||
1 | configfile.c | 2 | configfile.c |
2 | fixedpoint.c | 3 | fixedpoint.c |
3 | playback_control.c | 4 | playback_control.c |
diff --git a/apps/plugins/lib/oldmenuapi.c b/apps/plugins/lib/oldmenuapi.c new file mode 100644 index 0000000000..e804a64d62 --- /dev/null +++ b/apps/plugins/lib/oldmenuapi.c | |||
@@ -0,0 +1,241 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 Robert E. Hak | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | /* | ||
20 | 2005 Kevin Ferrare : | ||
21 | - Multi screen support | ||
22 | - Rewrote/removed a lot of code now useless with the new gui API | ||
23 | */ | ||
24 | #include <stdbool.h> | ||
25 | #include <stdlib.h> | ||
26 | |||
27 | #include "plugin.h" | ||
28 | #include "oldmenuapi.h" | ||
29 | |||
30 | struct plugin_api *rb = NULL; | ||
31 | |||
32 | struct menu { | ||
33 | struct menu_item* items; | ||
34 | int (*callback)(int, int); | ||
35 | struct gui_synclist synclist; | ||
36 | }; | ||
37 | |||
38 | #define MAX_MENUS 6 | ||
39 | |||
40 | static struct menu menus[MAX_MENUS]; | ||
41 | static bool inuse[MAX_MENUS] = { false }; | ||
42 | |||
43 | static char * menu_get_itemname(int selected_item, void * data, char *buffer) | ||
44 | { | ||
45 | struct menu *local_menus=(struct menu *)data; | ||
46 | (void)buffer; | ||
47 | return(local_menus->items[selected_item].desc); | ||
48 | } | ||
49 | |||
50 | static int menu_find_free(void) | ||
51 | { | ||
52 | int i; | ||
53 | /* Tries to find an unused slot to put the new menu */ | ||
54 | for ( i=0; i<MAX_MENUS; i++ ) { | ||
55 | if ( !inuse[i] ) { | ||
56 | inuse[i] = true; | ||
57 | break; | ||
58 | } | ||
59 | } | ||
60 | if ( i == MAX_MENUS ) { | ||
61 | DEBUGF("Out of menus!\n"); | ||
62 | return -1; | ||
63 | } | ||
64 | return(i); | ||
65 | } | ||
66 | |||
67 | int menu_init(struct plugin_api *api, const struct menu_item* mitems, | ||
68 | int count, int (*callback)(int, int), | ||
69 | const char *button1, const char *button2, const char *button3) | ||
70 | { | ||
71 | int menu=menu_find_free(); | ||
72 | rb = api; | ||
73 | if(menu==-1)/* Out of menus */ | ||
74 | return -1; | ||
75 | menus[menu].items = (struct menu_item*)mitems; /* de-const */ | ||
76 | rb->gui_synclist_init(&(menus[menu].synclist), | ||
77 | &menu_get_itemname, &menus[menu], false, 1); | ||
78 | rb->gui_synclist_set_icon_callback(&(menus[menu].synclist), NULL); | ||
79 | rb->gui_synclist_set_nb_items(&(menus[menu].synclist), count); | ||
80 | menus[menu].callback = callback; | ||
81 | (void)button1; | ||
82 | (void)button2; | ||
83 | (void)button3; | ||
84 | return menu; | ||
85 | } | ||
86 | |||
87 | void menu_exit(int m) | ||
88 | { | ||
89 | inuse[m] = false; | ||
90 | } | ||
91 | |||
92 | int menu_show(int m) | ||
93 | { | ||
94 | bool exit = false; | ||
95 | int key; | ||
96 | |||
97 | rb->gui_synclist_draw(&(menus[m].synclist)); | ||
98 | rb->action_signalscreenchange(); | ||
99 | rb->gui_syncstatusbar_draw(rb->statusbars, true); | ||
100 | while (!exit) { | ||
101 | key = rb->get_action(CONTEXT_MAINMENU,HZ/2); | ||
102 | /* | ||
103 | * "short-circuit" the default keypresses by running the | ||
104 | * callback function | ||
105 | * The callback may return a new key value, often this will be | ||
106 | * BUTTON_NONE or the same key value, but it's perfectly legal | ||
107 | * to "simulate" key presses by returning another value. | ||
108 | */ | ||
109 | if( menus[m].callback != NULL ) | ||
110 | key = menus[m].callback(key, m); | ||
111 | rb->gui_synclist_do_button(&(menus[m].synclist), key,LIST_WRAP_UNLESS_HELD); | ||
112 | switch( key ) { | ||
113 | case ACTION_STD_OK: | ||
114 | rb->action_signalscreenchange(); | ||
115 | return rb->gui_synclist_get_sel_pos(&(menus[m].synclist)); | ||
116 | |||
117 | |||
118 | case ACTION_STD_CANCEL: | ||
119 | case ACTION_STD_MENU: | ||
120 | exit = true; | ||
121 | break; | ||
122 | |||
123 | default: | ||
124 | if(rb->default_event_handler(key) == SYS_USB_CONNECTED) | ||
125 | return MENU_ATTACHED_USB; | ||
126 | break; | ||
127 | } | ||
128 | rb->gui_syncstatusbar_draw(rb->statusbars, false); | ||
129 | } | ||
130 | rb->action_signalscreenchange(); | ||
131 | return MENU_SELECTED_EXIT; | ||
132 | } | ||
133 | |||
134 | |||
135 | bool menu_run(int m) | ||
136 | { | ||
137 | int selected; | ||
138 | while (1) { | ||
139 | switch (selected=menu_show(m)) | ||
140 | { | ||
141 | case MENU_SELECTED_EXIT: | ||
142 | return false; | ||
143 | |||
144 | case MENU_ATTACHED_USB: | ||
145 | return true; | ||
146 | |||
147 | default: | ||
148 | { | ||
149 | if (menus[m].items[selected].function && | ||
150 | menus[m].items[selected].function()) | ||
151 | return true; | ||
152 | rb->gui_syncstatusbar_draw(rb->statusbars, true); | ||
153 | } | ||
154 | } | ||
155 | } | ||
156 | return false; | ||
157 | } | ||
158 | |||
159 | /* | ||
160 | * Property function - return the current cursor for "menu" | ||
161 | */ | ||
162 | |||
163 | int menu_cursor(int menu) | ||
164 | { | ||
165 | return rb->gui_synclist_get_sel_pos(&(menus[menu].synclist)); | ||
166 | } | ||
167 | |||
168 | /* | ||
169 | * Property function - return the "menu" description at "position" | ||
170 | */ | ||
171 | |||
172 | char* menu_description(int menu, int position) | ||
173 | { | ||
174 | return menus[menu].items[position].desc; | ||
175 | } | ||
176 | |||
177 | /* | ||
178 | * Delete the element "position" from the menu items in "menu" | ||
179 | */ | ||
180 | |||
181 | void menu_delete(int menu, int position) | ||
182 | { | ||
183 | int i; | ||
184 | int nb_items=rb->gui_synclist_get_nb_items(&(menus[menu].synclist)); | ||
185 | /* copy the menu item from the one below */ | ||
186 | for( i = position; i < nb_items - 1; i++) | ||
187 | menus[menu].items[i] = menus[menu].items[i + 1]; | ||
188 | |||
189 | rb->gui_synclist_del_item(&(menus[menu].synclist)); | ||
190 | } | ||
191 | |||
192 | void menu_insert(int menu, int position, char *desc, bool (*function) (void)) | ||
193 | { | ||
194 | int i; | ||
195 | int nb_items=rb->gui_synclist_get_nb_items(&(menus[menu].synclist)); | ||
196 | if(position < 0) | ||
197 | position = nb_items; | ||
198 | |||
199 | /* Move the items below one position forward */ | ||
200 | for( i = nb_items; i > position; i--) | ||
201 | menus[menu].items[i] = menus[menu].items[i - 1]; | ||
202 | |||
203 | /* Update the current item */ | ||
204 | menus[menu].items[position].desc = (unsigned char *)desc; | ||
205 | menus[menu].items[position].function = function; | ||
206 | rb->gui_synclist_add_item(&(menus[menu].synclist)); | ||
207 | } | ||
208 | |||
209 | /* | ||
210 | * Property function - return the "count" of menu items in "menu" | ||
211 | */ | ||
212 | |||
213 | int menu_count(int menu) | ||
214 | { | ||
215 | return rb->gui_synclist_get_nb_items(&(menus[menu].synclist)); | ||
216 | } | ||
217 | |||
218 | /* | ||
219 | * Allows to set the cursor position. Doesn't redraw by itself. | ||
220 | */ | ||
221 | |||
222 | void menu_set_cursor(int menu, int position) | ||
223 | { | ||
224 | rb->gui_synclist_select_item(&(menus[menu].synclist), position); | ||
225 | } | ||
226 | #if 0 | ||
227 | void menu_talk_selected(int m) | ||
228 | { | ||
229 | if(rb->global_settings->talk_menu) | ||
230 | { | ||
231 | int selected=rb->gui_synclist_get_sel_pos(&(menus[m].synclist)); | ||
232 | int voice_id = P2ID(menus[m].items[selected].desc); | ||
233 | if (voice_id >= 0) /* valid ID given? */ | ||
234 | talk_id(voice_id, false); /* say it */ | ||
235 | } | ||
236 | } | ||
237 | #endif | ||
238 | void menu_draw(int m) | ||
239 | { | ||
240 | rb->gui_synclist_draw(&(menus[m].synclist)); | ||
241 | } | ||
diff --git a/apps/plugins/lib/oldmenuapi.h b/apps/plugins/lib/oldmenuapi.h new file mode 100644 index 0000000000..34f6226d59 --- /dev/null +++ b/apps/plugins/lib/oldmenuapi.h | |||
@@ -0,0 +1,56 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 Robert E. Hak | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | |||
21 | /* This API is for existing plugins and shouldn't be used by new ones. | ||
22 | This provides a simpler menu system for plugins, but does not allow for | ||
23 | translatable or talkable strings in the menus. */ | ||
24 | #ifndef __OLDMENUAPI_H__ | ||
25 | #define __OLDMENUAPI_H__ | ||
26 | |||
27 | #include <stdbool.h> | ||
28 | |||
29 | struct menu_item { | ||
30 | unsigned char *desc; /* string or ID */ | ||
31 | bool (*function) (void); /* return true if USB was connected */ | ||
32 | }; | ||
33 | |||
34 | int menu_init(struct plugin_api *api, const struct menu_item* mitems, | ||
35 | int count, int (*callback)(int, int), | ||
36 | const char *button1, const char *button2, const char *button3); | ||
37 | void menu_exit(int menu); | ||
38 | |||
39 | void put_cursorxy(int x, int y, bool on); | ||
40 | |||
41 | /* Returns below define, or number of selected menu item*/ | ||
42 | int menu_show(int m); | ||
43 | |||
44 | bool menu_run(int menu); | ||
45 | int menu_cursor(int menu); | ||
46 | char* menu_description(int menu, int position); | ||
47 | void menu_delete(int menu, int position); | ||
48 | int menu_count(int menu); | ||
49 | bool menu_moveup(int menu); | ||
50 | bool menu_movedown(int menu); | ||
51 | void menu_draw(int menu); | ||
52 | void menu_insert(int menu, int position, char *desc, bool (*function) (void)); | ||
53 | void menu_set_cursor(int menu, int position); | ||
54 | void menu_talk_selected(int m); | ||
55 | |||
56 | #endif /* End __OLDMENUAPI_H__ */ | ||
diff --git a/apps/plugins/mpegplayer/mpeg_settings.c b/apps/plugins/mpegplayer/mpeg_settings.c index c692edf861..964bad08bd 100644 --- a/apps/plugins/mpegplayer/mpeg_settings.c +++ b/apps/plugins/mpegplayer/mpeg_settings.c | |||
@@ -1,5 +1,6 @@ | |||
1 | #include "plugin.h" | 1 | #include "plugin.h" |
2 | #include "lib/configfile.h" | 2 | #include "lib/configfile.h" |
3 | #include "lib/oldmenuapi.h" | ||
3 | 4 | ||
4 | #include "mpeg_settings.h" | 5 | #include "mpeg_settings.h" |
5 | 6 | ||
@@ -41,13 +42,13 @@ bool mpeg_menu(void) | |||
41 | { "Quit mpegplayer", NULL }, | 42 | { "Quit mpegplayer", NULL }, |
42 | }; | 43 | }; |
43 | 44 | ||
44 | m = rb->menu_init(items, sizeof(items) / sizeof(*items), | 45 | m = menu_init(rb, items, sizeof(items) / sizeof(*items), |
45 | NULL, NULL, NULL, NULL); | 46 | NULL, NULL, NULL, NULL); |
46 | 47 | ||
47 | rb->button_clear_queue(); | 48 | rb->button_clear_queue(); |
48 | 49 | ||
49 | while (!menu_quit) { | 50 | while (!menu_quit) { |
50 | result=rb->menu_show(m); | 51 | result=menu_show(m); |
51 | 52 | ||
52 | switch(result) | 53 | switch(result) |
53 | { | 54 | { |
@@ -71,7 +72,7 @@ bool mpeg_menu(void) | |||
71 | } | 72 | } |
72 | } | 73 | } |
73 | 74 | ||
74 | rb->menu_exit(m); | 75 | menu_exit(m); |
75 | 76 | ||
76 | rb->lcd_clear_display(); | 77 | rb->lcd_clear_display(); |
77 | rb->lcd_update(); | 78 | rb->lcd_update(); |
diff --git a/apps/plugins/pacbox/pacbox.c b/apps/plugins/pacbox/pacbox.c index 3a56430106..712c3aff77 100644 --- a/apps/plugins/pacbox/pacbox.c +++ b/apps/plugins/pacbox/pacbox.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include "pacbox.h" | 27 | #include "pacbox.h" |
28 | #include "pacbox_lcd.h" | 28 | #include "pacbox_lcd.h" |
29 | #include "lib/configfile.h" | 29 | #include "lib/configfile.h" |
30 | #include "lib/oldmenuapi.h" | ||
30 | 31 | ||
31 | PLUGIN_HEADER | 32 | PLUGIN_HEADER |
32 | PLUGIN_IRAM_DECLARE | 33 | PLUGIN_IRAM_DECLARE |
@@ -178,13 +179,13 @@ static bool pacbox_menu(void) | |||
178 | { "Quit", NULL }, | 179 | { "Quit", NULL }, |
179 | }; | 180 | }; |
180 | 181 | ||
181 | m = rb->menu_init(items, sizeof(items) / sizeof(*items), | 182 | m = menu_init(rb, items, sizeof(items) / sizeof(*items), |
182 | NULL, NULL, NULL, NULL); | 183 | NULL, NULL, NULL, NULL); |
183 | 184 | ||
184 | rb->button_clear_queue(); | 185 | rb->button_clear_queue(); |
185 | 186 | ||
186 | while (!menu_quit) { | 187 | while (!menu_quit) { |
187 | result=rb->menu_show(m); | 188 | result=menu_show(m); |
188 | 189 | ||
189 | switch(result) | 190 | switch(result) |
190 | { | 191 | { |
@@ -238,7 +239,7 @@ static bool pacbox_menu(void) | |||
238 | } | 239 | } |
239 | } | 240 | } |
240 | 241 | ||
241 | rb->menu_exit(m); | 242 | menu_exit(m); |
242 | 243 | ||
243 | if (need_restart) { | 244 | if (need_restart) { |
244 | init_PacmanMachine(settings_to_dip(settings)); | 245 | init_PacmanMachine(settings_to_dip(settings)); |
diff --git a/apps/plugins/random_folder_advance_config.c b/apps/plugins/random_folder_advance_config.c index 7f498f7532..abe7bfdfbf 100644 --- a/apps/plugins/random_folder_advance_config.c +++ b/apps/plugins/random_folder_advance_config.c | |||
@@ -17,6 +17,7 @@ | |||
17 | * | 17 | * |
18 | ****************************************************************************/ | 18 | ****************************************************************************/ |
19 | #include "plugin.h" | 19 | #include "plugin.h" |
20 | #include "oldmenuapi.h" | ||
20 | 21 | ||
21 | PLUGIN_HEADER | 22 | PLUGIN_HEADER |
22 | 23 | ||
@@ -194,10 +195,10 @@ void edit_list(void) | |||
194 | { "Remove Folder", NULL }, | 195 | { "Remove Folder", NULL }, |
195 | { "Remove Folder Tree", NULL }, | 196 | { "Remove Folder Tree", NULL }, |
196 | }; | 197 | }; |
197 | m = rb->menu_init(items, sizeof(items) / sizeof(*items), | 198 | m = menu_init(rb, items, sizeof(items) / sizeof(*items), |
198 | NULL, NULL, NULL, NULL); | 199 | NULL, NULL, NULL, NULL); |
199 | 200 | ||
200 | switch (rb->menu_show(m)) | 201 | switch (menu_show(m)) |
201 | { | 202 | { |
202 | case 0: | 203 | case 0: |
203 | list->folder[selection][0] = ' '; | 204 | list->folder[selection][0] = ' '; |
@@ -219,7 +220,7 @@ void edit_list(void) | |||
219 | } | 220 | } |
220 | break; | 221 | break; |
221 | } | 222 | } |
222 | rb->menu_exit(m); | 223 | menu_exit(m); |
223 | } | 224 | } |
224 | break; | 225 | break; |
225 | case ACTION_STD_CANCEL: | 226 | case ACTION_STD_CANCEL: |
@@ -229,10 +230,10 @@ void edit_list(void) | |||
229 | { "Save and Exit", NULL }, | 230 | { "Save and Exit", NULL }, |
230 | { "Ignore Changes and Exit", NULL }, | 231 | { "Ignore Changes and Exit", NULL }, |
231 | }; | 232 | }; |
232 | m = rb->menu_init(items, sizeof(items) / sizeof(*items), | 233 | m = menu_init(rb, items, sizeof(items) / sizeof(*items), |
233 | NULL, NULL, NULL, NULL); | 234 | NULL, NULL, NULL, NULL); |
234 | 235 | ||
235 | switch (rb->menu_show(m)) | 236 | switch (menu_show(m)) |
236 | { | 237 | { |
237 | case 0: | 238 | case 0: |
238 | exit = true; | 239 | exit = true; |
@@ -259,7 +260,7 @@ void edit_list(void) | |||
259 | case 1: | 260 | case 1: |
260 | exit = true; | 261 | exit = true; |
261 | } | 262 | } |
262 | rb->menu_exit(m); | 263 | menu_exit(m); |
263 | } | 264 | } |
264 | break; | 265 | break; |
265 | } | 266 | } |
@@ -273,10 +274,10 @@ int main_menu(void) | |||
273 | { "Edit Folder List", NULL }, | 274 | { "Edit Folder List", NULL }, |
274 | { "Quit", NULL }, | 275 | { "Quit", NULL }, |
275 | }; | 276 | }; |
276 | m = rb->menu_init(items, sizeof(items) / sizeof(*items), | 277 | m = menu_init(rb, items, sizeof(items) / sizeof(*items), |
277 | NULL, NULL, NULL, NULL); | 278 | NULL, NULL, NULL, NULL); |
278 | 279 | ||
279 | switch (rb->menu_show(m)) | 280 | switch (menu_show(m)) |
280 | { | 281 | { |
281 | case 0: /* generate */ | 282 | case 0: /* generate */ |
282 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | 283 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ |
@@ -305,10 +306,10 @@ int main_menu(void) | |||
305 | rb->backlight_on(); | 306 | rb->backlight_on(); |
306 | break; | 307 | break; |
307 | case 2: | 308 | case 2: |
308 | rb->menu_exit(m); | 309 | menu_exit(m); |
309 | return 1; | 310 | return 1; |
310 | } | 311 | } |
311 | rb->menu_exit(m); | 312 | menu_exit(m); |
312 | return 0; | 313 | return 0; |
313 | } | 314 | } |
314 | 315 | ||
diff --git a/apps/plugins/rockboy/menu.c b/apps/plugins/rockboy/menu.c index a3d64d60d0..ca15cba7b9 100644 --- a/apps/plugins/rockboy/menu.c +++ b/apps/plugins/rockboy/menu.c | |||
@@ -7,6 +7,7 @@ | |||
7 | #include "button.h" | 7 | #include "button.h" |
8 | #include "rockmacros.h" | 8 | #include "rockmacros.h" |
9 | #include "mem.h" | 9 | #include "mem.h" |
10 | #include "lib/oldmenuapi.h" | ||
10 | 11 | ||
11 | #if (CONFIG_KEYPAD == IPOD_4G_PAD) | 12 | #if (CONFIG_KEYPAD == IPOD_4G_PAD) |
12 | #define MENU_BUTTON_UP BUTTON_SCROLL_BACK | 13 | #define MENU_BUTTON_UP BUTTON_SCROLL_BACK |
@@ -101,11 +102,11 @@ int do_user_menu(void) { | |||
101 | 102 | ||
102 | pcm_init(); | 103 | pcm_init(); |
103 | 104 | ||
104 | m = rb->menu_init(items, sizeof(items) / sizeof(*items), NULL, NULL, NULL, NULL); | 105 | m = menu_init(rb,items, sizeof(items) / sizeof(*items), NULL, NULL, NULL, NULL); |
105 | 106 | ||
106 | while(!done) | 107 | while(!done) |
107 | { | 108 | { |
108 | result=rb->menu_show(m); | 109 | result=menu_show(m); |
109 | 110 | ||
110 | switch (result) | 111 | switch (result) |
111 | { | 112 | { |
@@ -128,7 +129,7 @@ int do_user_menu(void) { | |||
128 | } | 129 | } |
129 | } | 130 | } |
130 | 131 | ||
131 | rb->menu_exit(m); | 132 | menu_exit(m); |
132 | 133 | ||
133 | rb->lcd_setfont(0); /* Reset the font */ | 134 | rb->lcd_setfont(0); /* Reset the font */ |
134 | rb->lcd_clear_display(); /* Clear display for screen size changes */ | 135 | rb->lcd_clear_display(); /* Clear display for screen size changes */ |
@@ -303,18 +304,18 @@ static void do_slot_menu(bool is_load) { | |||
303 | for (i = 0; i < num_items; i++) | 304 | for (i = 0; i < num_items; i++) |
304 | slot_info(buf[i], 20, i); | 305 | slot_info(buf[i], 20, i); |
305 | 306 | ||
306 | m = rb->menu_init(items, num_items, NULL, NULL, NULL, NULL); | 307 | m = menu_init(rb,items, num_items, NULL, NULL, NULL, NULL); |
307 | 308 | ||
308 | while(!done) | 309 | while(!done) |
309 | { | 310 | { |
310 | result=rb->menu_show(m); | 311 | result=menu_show(m); |
311 | 312 | ||
312 | if (result<num_items && result >= 0 ) | 313 | if (result<num_items && result >= 0 ) |
313 | done = do_slot(result, is_load); | 314 | done = do_slot(result, is_load); |
314 | else | 315 | else |
315 | done = true; | 316 | done = true; |
316 | } | 317 | } |
317 | rb->menu_exit(m); | 318 | menu_exit(m); |
318 | } | 319 | } |
319 | 320 | ||
320 | static void do_opt_menu(void) | 321 | static void do_opt_menu(void) |
@@ -374,12 +375,12 @@ static void do_opt_menu(void) | |||
374 | #endif | 375 | #endif |
375 | }; | 376 | }; |
376 | 377 | ||
377 | m = rb->menu_init(items, sizeof(items) / sizeof(*items), NULL, NULL, NULL, NULL); | 378 | m = menu_init(rb,items, sizeof(items) / sizeof(*items), NULL, NULL, NULL, NULL); |
378 | 379 | ||
379 | while(!done) | 380 | while(!done) |
380 | { | 381 | { |
381 | 382 | ||
382 | result=rb->menu_show(m); | 383 | result=menu_show(m); |
383 | 384 | ||
384 | switch (result) | 385 | switch (result) |
385 | { | 386 | { |
@@ -414,5 +415,5 @@ static void do_opt_menu(void) | |||
414 | break; | 415 | break; |
415 | } | 416 | } |
416 | } | 417 | } |
417 | rb->menu_exit(m); | 418 | menu_exit(m); |
418 | } | 419 | } |
diff --git a/apps/plugins/solitaire.c b/apps/plugins/solitaire.c index a73e2c02ed..85d4efd3a9 100644 --- a/apps/plugins/solitaire.c +++ b/apps/plugins/solitaire.c | |||
@@ -36,6 +36,7 @@ use F3 to put card on top of the remains' stack on one of the 4 final stacks | |||
36 | #include "configfile.h" | 36 | #include "configfile.h" |
37 | #include "button.h" | 37 | #include "button.h" |
38 | #include "lcd.h" | 38 | #include "lcd.h" |
39 | #include "oldmenuapi.h" | ||
39 | 40 | ||
40 | #ifdef HAVE_LCD_BITMAP | 41 | #ifdef HAVE_LCD_BITMAP |
41 | 42 | ||
@@ -612,10 +613,10 @@ int solitaire_menu(bool in_game) | |||
612 | 613 | ||
613 | create_draw_option_string(); | 614 | create_draw_option_string(); |
614 | create_unhide_option_string(); | 615 | create_unhide_option_string(); |
615 | m = rb->menu_init(items, i, NULL, NULL, NULL, NULL); | 616 | m = menu_init(rb, items, i, NULL, NULL, NULL, NULL); |
616 | while (result < 0) | 617 | while (result < 0) |
617 | { | 618 | { |
618 | switch (rb->menu_show(m)) | 619 | switch (menu_show(m)) |
619 | { | 620 | { |
620 | case MENU_SELECTED_EXIT: | 621 | case MENU_SELECTED_EXIT: |
621 | result = MENU_RESUME; | 622 | result = MENU_RESUME; |
@@ -662,7 +663,7 @@ int solitaire_menu(bool in_game) | |||
662 | break; | 663 | break; |
663 | } | 664 | } |
664 | } | 665 | } |
665 | rb->menu_exit(m); | 666 | menu_exit(m); |
666 | rb->lcd_setmargins(0, 0); | 667 | rb->lcd_setmargins(0, 0); |
667 | return result; | 668 | return result; |
668 | } | 669 | } |
diff --git a/apps/plugins/sudoku/sudoku.c b/apps/plugins/sudoku/sudoku.c index 59adb77fa9..fcf1566d65 100644 --- a/apps/plugins/sudoku/sudoku.c +++ b/apps/plugins/sudoku/sudoku.c | |||
@@ -57,6 +57,7 @@ Example ".ss" file, and one with a saved state: | |||
57 | */ | 57 | */ |
58 | 58 | ||
59 | #include "plugin.h" | 59 | #include "plugin.h" |
60 | #include "lib/oldmenuapi.h" | ||
60 | 61 | ||
61 | #ifdef HAVE_LCD_BITMAP | 62 | #ifdef HAVE_LCD_BITMAP |
62 | 63 | ||
@@ -1007,10 +1008,10 @@ bool sudoku_menu(struct sudoku_state_t* state) | |||
1007 | { "Quit", NULL }, | 1008 | { "Quit", NULL }, |
1008 | }; | 1009 | }; |
1009 | 1010 | ||
1010 | m = rb->menu_init(items, sizeof(items) / sizeof(*items), | 1011 | m = menu_init(rb,items, sizeof(items) / sizeof(*items), |
1011 | NULL, NULL, NULL, NULL); | 1012 | NULL, NULL, NULL, NULL); |
1012 | 1013 | ||
1013 | result=rb->menu_show(m); | 1014 | result=menu_show(m); |
1014 | 1015 | ||
1015 | switch (result) { | 1016 | switch (result) { |
1016 | case 0: /* Audio playback */ | 1017 | case 0: /* Audio playback */ |
@@ -1044,7 +1045,7 @@ bool sudoku_menu(struct sudoku_state_t* state) | |||
1044 | 1045 | ||
1045 | case 7: /* Quit */ | 1046 | case 7: /* Quit */ |
1046 | save_sudoku(state); | 1047 | save_sudoku(state); |
1047 | rb->menu_exit(m); | 1048 | menu_exit(m); |
1048 | return true; | 1049 | return true; |
1049 | break; | 1050 | break; |
1050 | 1051 | ||
@@ -1052,7 +1053,7 @@ bool sudoku_menu(struct sudoku_state_t* state) | |||
1052 | break; | 1053 | break; |
1053 | } | 1054 | } |
1054 | 1055 | ||
1055 | rb->menu_exit(m); | 1056 | menu_exit(m); |
1056 | 1057 | ||
1057 | return (result==MENU_ATTACHED_USB); | 1058 | return (result==MENU_ATTACHED_USB); |
1058 | } | 1059 | } |
@@ -1068,10 +1069,10 @@ int sudoku_edit_menu(struct sudoku_state_t* state) | |||
1068 | { "Quit", NULL }, | 1069 | { "Quit", NULL }, |
1069 | }; | 1070 | }; |
1070 | 1071 | ||
1071 | m = rb->menu_init(items, sizeof(items) / sizeof(*items), | 1072 | m = menu_init(rb,items, sizeof(items) / sizeof(*items), |
1072 | NULL, NULL, NULL, NULL); | 1073 | NULL, NULL, NULL, NULL); |
1073 | 1074 | ||
1074 | result=rb->menu_show(m); | 1075 | result=menu_show(m); |
1075 | 1076 | ||
1076 | switch (result) { | 1077 | switch (result) { |
1077 | case 0: /* Save new game */ | 1078 | case 0: /* Save new game */ |
@@ -1090,7 +1091,7 @@ int sudoku_edit_menu(struct sudoku_state_t* state) | |||
1090 | break; | 1091 | break; |
1091 | } | 1092 | } |
1092 | 1093 | ||
1093 | rb->menu_exit(m); | 1094 | menu_exit(m); |
1094 | 1095 | ||
1095 | return result; | 1096 | return result; |
1096 | } | 1097 | } |
diff --git a/apps/plugins/test_disk.c b/apps/plugins/test_disk.c index cda1d614c0..c46774d8a0 100644 --- a/apps/plugins/test_disk.c +++ b/apps/plugins/test_disk.c | |||
@@ -18,6 +18,7 @@ | |||
18 | ****************************************************************************/ | 18 | ****************************************************************************/ |
19 | 19 | ||
20 | #include "plugin.h" | 20 | #include "plugin.h" |
21 | #include "oldmenuapi.h" | ||
21 | 22 | ||
22 | PLUGIN_HEADER | 23 | PLUGIN_HEADER |
23 | 24 | ||
@@ -314,10 +315,10 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
314 | if (rb->global_settings->backlight_timeout > 0) | 315 | if (rb->global_settings->backlight_timeout > 0) |
315 | rb->backlight_set_timeout(1); /* keep the light on */ | 316 | rb->backlight_set_timeout(1); /* keep the light on */ |
316 | 317 | ||
317 | m = rb->menu_init(items, sizeof(items) / sizeof(*items), NULL, | 318 | m = menu_init(rb, items, sizeof(items) / sizeof(*items), NULL, |
318 | NULL, NULL, NULL); | 319 | NULL, NULL, NULL); |
319 | rb->menu_run(m); | 320 | menu_run(m); |
320 | rb->menu_exit(m); | 321 | menu_exit(m); |
321 | 322 | ||
322 | /* restore normal backlight setting */ | 323 | /* restore normal backlight setting */ |
323 | rb->backlight_set_timeout(rb->global_settings->backlight_timeout); | 324 | rb->backlight_set_timeout(rb->global_settings->backlight_timeout); |
diff --git a/apps/plugins/test_sampr.c b/apps/plugins/test_sampr.c index 891e68ffda..253c592eaa 100644 --- a/apps/plugins/test_sampr.c +++ b/apps/plugins/test_sampr.c | |||
@@ -17,6 +17,7 @@ | |||
17 | * | 17 | * |
18 | ****************************************************************************/ | 18 | ****************************************************************************/ |
19 | #include "plugin.h" | 19 | #include "plugin.h" |
20 | #include "oldmenuapi.h" | ||
20 | 21 | ||
21 | PLUGIN_HEADER | 22 | PLUGIN_HEADER |
22 | 23 | ||
@@ -271,12 +272,12 @@ enum plugin_status plugin_start(struct plugin_api *api, void *parameter) | |||
271 | talk_menu = rb->global_settings->talk_menu; | 272 | talk_menu = rb->global_settings->talk_menu; |
272 | rb->global_settings->talk_menu = false; | 273 | rb->global_settings->talk_menu = false; |
273 | 274 | ||
274 | m = rb->menu_init(items, ARRAYLEN(items), | 275 | m = menu_init(rb, items, ARRAYLEN(items), |
275 | NULL, NULL, NULL, NULL); | 276 | NULL, NULL, NULL, NULL); |
276 | 277 | ||
277 | while (!exit) | 278 | while (!exit) |
278 | { | 279 | { |
279 | int result = rb->menu_show(m); | 280 | int result = menu_show(m); |
280 | 281 | ||
281 | switch (result) | 282 | switch (result) |
282 | { | 283 | { |
@@ -292,7 +293,7 @@ enum plugin_status plugin_start(struct plugin_api *api, void *parameter) | |||
292 | } | 293 | } |
293 | } | 294 | } |
294 | 295 | ||
295 | rb->menu_exit(m); | 296 | menu_exit(m); |
296 | 297 | ||
297 | rb->global_settings->talk_menu = talk_menu; | 298 | rb->global_settings->talk_menu = talk_menu; |
298 | 299 | ||
diff --git a/apps/plugins/text_editor.c b/apps/plugins/text_editor.c index d95bdb9b81..523cbad30c 100644 --- a/apps/plugins/text_editor.c +++ b/apps/plugins/text_editor.c | |||
@@ -18,6 +18,7 @@ | |||
18 | ****************************************************************************/ | 18 | ****************************************************************************/ |
19 | #include "plugin.h" | 19 | #include "plugin.h" |
20 | #include "action.h" | 20 | #include "action.h" |
21 | #include "oldmenuapi.h" | ||
21 | 22 | ||
22 | #if PLUGIN_BUFFER_SIZE > 0x45000 | 23 | #if PLUGIN_BUFFER_SIZE > 0x45000 |
23 | #define MAX_CHARS 0x40000 /* 128 kiB */ | 24 | #define MAX_CHARS 0x40000 /* 128 kiB */ |
@@ -228,10 +229,10 @@ int do_item_menu(int cur_sel, char* copy_buffer) | |||
228 | { "", NULL }, | 229 | { "", NULL }, |
229 | { "Save", NULL }, | 230 | { "Save", NULL }, |
230 | }; | 231 | }; |
231 | m = rb->menu_init(items, sizeof(items) / sizeof(*items), | 232 | m = menu_init(rb, items, sizeof(items) / sizeof(*items), |
232 | NULL, NULL, NULL, NULL); | 233 | NULL, NULL, NULL, NULL); |
233 | 234 | ||
234 | switch (rb->menu_show(m)) | 235 | switch (menu_show(m)) |
235 | { | 236 | { |
236 | case 0: /* cut */ | 237 | case 0: /* cut */ |
237 | rb->strcpy(copy_buffer,&buffer[do_action(ACTION_GET,0,cur_sel)]); | 238 | rb->strcpy(copy_buffer,&buffer[do_action(ACTION_GET,0,cur_sel)]); |
@@ -279,7 +280,7 @@ int do_item_menu(int cur_sel, char* copy_buffer) | |||
279 | ret = MENU_RET_NO_UPDATE; | 280 | ret = MENU_RET_NO_UPDATE; |
280 | break; | 281 | break; |
281 | } | 282 | } |
282 | rb->menu_exit(m); | 283 | menu_exit(m); |
283 | return ret; | 284 | return ret; |
284 | } | 285 | } |
285 | /* this is the plugin entry point */ | 286 | /* this is the plugin entry point */ |
@@ -409,10 +410,10 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
409 | { "Ignore Changes and Exit", NULL }, | 410 | { "Ignore Changes and Exit", NULL }, |
410 | }; | 411 | }; |
411 | 412 | ||
412 | m = rb->menu_init(items, sizeof(items) / sizeof(*items), | 413 | m = menu_init(rb, items, sizeof(items) / sizeof(*items), |
413 | NULL, NULL, NULL, NULL); | 414 | NULL, NULL, NULL, NULL); |
414 | 415 | ||
415 | result=rb->menu_show(m); | 416 | result=menu_show(m); |
416 | 417 | ||
417 | switch (result) | 418 | switch (result) |
418 | { | 419 | { |
@@ -435,7 +436,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
435 | exit=1; | 436 | exit=1; |
436 | break; | 437 | break; |
437 | } | 438 | } |
438 | rb->menu_exit(m); | 439 | menu_exit(m); |
439 | } | 440 | } |
440 | else exit=1; | 441 | else exit=1; |
441 | break; | 442 | break; |
diff --git a/apps/plugins/viewer.c b/apps/plugins/viewer.c index 07392d49c3..d3f74e6514 100644 --- a/apps/plugins/viewer.c +++ b/apps/plugins/viewer.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include "plugin.h" | 20 | #include "plugin.h" |
21 | #include <ctype.h> | 21 | #include <ctype.h> |
22 | #include "playback_control.h" | 22 | #include "playback_control.h" |
23 | #include "oldmenuapi.h" | ||
23 | 24 | ||
24 | PLUGIN_HEADER | 25 | PLUGIN_HEADER |
25 | 26 | ||
@@ -1283,11 +1284,11 @@ static bool viewer_options_menu(void) | |||
1283 | {"Scroll Mode", scroll_mode_setting}, | 1284 | {"Scroll Mode", scroll_mode_setting}, |
1284 | {"Auto-Scroll Speed", autoscroll_speed_setting }, | 1285 | {"Auto-Scroll Speed", autoscroll_speed_setting }, |
1285 | }; | 1286 | }; |
1286 | m = rb->menu_init(items, sizeof(items) / sizeof(*items), | 1287 | m = menu_init(rb, items, sizeof(items) / sizeof(*items), |
1287 | NULL, NULL, NULL, NULL); | 1288 | NULL, NULL, NULL, NULL); |
1288 | 1289 | ||
1289 | result = rb->menu_run(m); | 1290 | result = menu_run(m); |
1290 | rb->menu_exit(m); | 1291 | menu_exit(m); |
1291 | #ifdef HAVE_LCD_BITMAP | 1292 | #ifdef HAVE_LCD_BITMAP |
1292 | rb->lcd_setmargins(0,0); | 1293 | rb->lcd_setmargins(0,0); |
1293 | 1294 | ||
@@ -1310,13 +1311,13 @@ static void viewer_menu(void) | |||
1310 | {"Return", NULL }, | 1311 | {"Return", NULL }, |
1311 | }; | 1312 | }; |
1312 | 1313 | ||
1313 | m = rb->menu_init(items, sizeof(items) / sizeof(*items), NULL, NULL, NULL, NULL); | 1314 | m = menu_init(rb, items, sizeof(items) / sizeof(*items), NULL, NULL, NULL, NULL); |
1314 | result=rb->menu_show(m); | 1315 | result=menu_show(m); |
1315 | switch (result) | 1316 | switch (result) |
1316 | { | 1317 | { |
1317 | case 0: /* quit */ | 1318 | case 0: /* quit */ |
1318 | rb->splash(1, "Saving Settings"); | 1319 | rb->splash(1, "Saving Settings"); |
1319 | rb->menu_exit(m); | 1320 | menu_exit(m); |
1320 | viewer_exit(NULL); | 1321 | viewer_exit(NULL); |
1321 | done = true; | 1322 | done = true; |
1322 | break; | 1323 | break; |
@@ -1329,7 +1330,7 @@ static void viewer_menu(void) | |||
1329 | case 3: /* return */ | 1330 | case 3: /* return */ |
1330 | break; | 1331 | break; |
1331 | } | 1332 | } |
1332 | rb->menu_exit(m); | 1333 | menu_exit(m); |
1333 | #ifdef HAVE_LCD_BITMAP | 1334 | #ifdef HAVE_LCD_BITMAP |
1334 | rb->lcd_setmargins(0,0); | 1335 | rb->lcd_setmargins(0,0); |
1335 | #endif | 1336 | #endif |
diff --git a/apps/plugins/zxbox/spmain.c b/apps/plugins/zxbox/spmain.c index 036e28a240..b153b4191f 100644 --- a/apps/plugins/zxbox/spmain.c +++ b/apps/plugins/zxbox/spmain.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include "misc.h" | 20 | #include "misc.h" |
21 | #include "zxconfig.h" | 21 | #include "zxconfig.h" |
22 | #include "lib/configfile.h" | 22 | #include "lib/configfile.h" |
23 | #include "lib/oldmenuapi.h" | ||
23 | 24 | ||
24 | #include "spperif.h" | 25 | #include "spperif.h" |
25 | #include "z80.h" | 26 | #include "z80.h" |
@@ -142,13 +143,13 @@ static void set_keys(void){ | |||
142 | { "Map Fire/Jump key", NULL }, | 143 | { "Map Fire/Jump key", NULL }, |
143 | }; | 144 | }; |
144 | 145 | ||
145 | m = rb->menu_init(items, sizeof(items) / sizeof(*items), | 146 | m = menu_init(rb,items, sizeof(items) / sizeof(*items), |
146 | NULL, NULL, NULL, NULL); | 147 | NULL, NULL, NULL, NULL); |
147 | 148 | ||
148 | rb->button_clear_queue(); | 149 | rb->button_clear_queue(); |
149 | 150 | ||
150 | while (!menu_quit) { | 151 | while (!menu_quit) { |
151 | result=rb->menu_show(m); | 152 | result=menu_show(m); |
152 | 153 | ||
153 | switch(result) | 154 | switch(result) |
154 | { | 155 | { |
@@ -188,7 +189,7 @@ static void set_keys(void){ | |||
188 | } | 189 | } |
189 | } | 190 | } |
190 | 191 | ||
191 | rb->menu_exit(m); | 192 | menu_exit(m); |
192 | } | 193 | } |
193 | 194 | ||
194 | /* select predefined keymap */ | 195 | /* select predefined keymap */ |
@@ -202,13 +203,13 @@ static void select_keymap(void){ | |||
202 | { "7658S", NULL }, | 203 | { "7658S", NULL }, |
203 | }; | 204 | }; |
204 | 205 | ||
205 | m = rb->menu_init(items, sizeof(items) / sizeof(*items), | 206 | m = menu_init(rb,items, sizeof(items) / sizeof(*items), |
206 | NULL, NULL, NULL, NULL); | 207 | NULL, NULL, NULL, NULL); |
207 | 208 | ||
208 | rb->button_clear_queue(); | 209 | rb->button_clear_queue(); |
209 | 210 | ||
210 | while (!menu_quit) { | 211 | while (!menu_quit) { |
211 | result=rb->menu_show(m); | 212 | result=menu_show(m); |
212 | 213 | ||
213 | switch(result) | 214 | switch(result) |
214 | { | 215 | { |
@@ -230,7 +231,7 @@ static void select_keymap(void){ | |||
230 | } | 231 | } |
231 | } | 232 | } |
232 | 233 | ||
233 | rb->menu_exit(m); | 234 | menu_exit(m); |
234 | } | 235 | } |
235 | 236 | ||
236 | /* options menu */ | 237 | /* options menu */ |
@@ -267,13 +268,13 @@ static void options_menu(void){ | |||
267 | }; | 268 | }; |
268 | 269 | ||
269 | 270 | ||
270 | m = rb->menu_init(items, sizeof(items) / sizeof(*items), | 271 | m = menu_init(rb,items, sizeof(items) / sizeof(*items), |
271 | NULL, NULL, NULL, NULL); | 272 | NULL, NULL, NULL, NULL); |
272 | 273 | ||
273 | rb->button_clear_queue(); | 274 | rb->button_clear_queue(); |
274 | 275 | ||
275 | while (!menu_quit) { | 276 | while (!menu_quit) { |
276 | result=rb->menu_show(m); | 277 | result=menu_show(m); |
277 | 278 | ||
278 | switch(result) | 279 | switch(result) |
279 | { | 280 | { |
@@ -336,7 +337,7 @@ static void options_menu(void){ | |||
336 | } | 337 | } |
337 | } | 338 | } |
338 | 339 | ||
339 | rb->menu_exit(m); | 340 | menu_exit(m); |
340 | } | 341 | } |
341 | 342 | ||
342 | /* menu */ | 343 | /* menu */ |
@@ -361,13 +362,13 @@ static bool zxbox_menu(void) | |||
361 | { "Quit", NULL }, | 362 | { "Quit", NULL }, |
362 | }; | 363 | }; |
363 | 364 | ||
364 | m = rb->menu_init(items, sizeof(items) / sizeof(*items), | 365 | m = menu_init(rb,items, sizeof(items) / sizeof(*items), |
365 | NULL, NULL, NULL, NULL); | 366 | NULL, NULL, NULL, NULL); |
366 | 367 | ||
367 | rb->button_clear_queue(); | 368 | rb->button_clear_queue(); |
368 | 369 | ||
369 | while (!menu_quit) { | 370 | while (!menu_quit) { |
370 | result=rb->menu_show(m); | 371 | result=menu_show(m); |
371 | 372 | ||
372 | switch(result) | 373 | switch(result) |
373 | { | 374 | { |
@@ -411,7 +412,7 @@ static bool zxbox_menu(void) | |||
411 | } | 412 | } |
412 | } | 413 | } |
413 | 414 | ||
414 | rb->menu_exit(m); | 415 | menu_exit(m); |
415 | #if defined(HAVE_ADJUSTABLE_CPU_FREQ) | 416 | #if defined(HAVE_ADJUSTABLE_CPU_FREQ) |
416 | rb->cpu_boost(true); | 417 | rb->cpu_boost(true); |
417 | #endif | 418 | #endif |