diff options
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/puzzles/rockbox.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/apps/plugins/puzzles/rockbox.c b/apps/plugins/puzzles/rockbox.c index f81ed46f6c..43afb62e40 100644 --- a/apps/plugins/puzzles/rockbox.c +++ b/apps/plugins/puzzles/rockbox.c | |||
@@ -964,7 +964,8 @@ const char *preset_formatter(int sel, void *data, char *buf, size_t len) | |||
964 | } | 964 | } |
965 | 965 | ||
966 | /* main worker function */ | 966 | /* main worker function */ |
967 | static bool do_preset_menu(struct preset_menu *menu, char *title) | 967 | /* returns the index of the selected item on success, -1 on failure */ |
968 | static int do_preset_menu(struct preset_menu *menu, char *title, int selected) | ||
968 | { | 969 | { |
969 | if(!menu->n_entries) | 970 | if(!menu->n_entries) |
970 | return false; | 971 | return false; |
@@ -977,9 +978,9 @@ static bool do_preset_menu(struct preset_menu *menu, char *title) | |||
977 | rb->gui_synclist_set_nb_items(&list, menu->n_entries); | 978 | rb->gui_synclist_set_nb_items(&list, menu->n_entries); |
978 | rb->gui_synclist_limit_scroll(&list, false); | 979 | rb->gui_synclist_limit_scroll(&list, false); |
979 | 980 | ||
980 | rb->gui_synclist_select_item(&list, 0); /* we don't start with the current one selected */ | 981 | rb->gui_synclist_select_item(&list, selected); |
981 | 982 | ||
982 | char def[] = "Game Type"; | 983 | static char def[] = "Game Type"; |
983 | rb->gui_synclist_set_title(&list, title ? title : def, NOICON); | 984 | rb->gui_synclist_set_title(&list, title ? title : def, NOICON); |
984 | while(1) | 985 | while(1) |
985 | { | 986 | { |
@@ -996,19 +997,19 @@ static bool do_preset_menu(struct preset_menu *menu, char *title) | |||
996 | if(entry->params) | 997 | if(entry->params) |
997 | { | 998 | { |
998 | midend_set_params(me, entry->params); | 999 | midend_set_params(me, entry->params); |
999 | return true; | 1000 | return sel; |
1000 | } | 1001 | } |
1001 | else | 1002 | else |
1002 | { | 1003 | { |
1003 | /* recurse */ | 1004 | /* recurse */ |
1004 | if(do_preset_menu(entry->submenu, entry->title)) | 1005 | if(do_preset_menu(entry->submenu, entry->title, 0)) /* select first one */ |
1005 | return true; | 1006 | return sel; |
1006 | } | 1007 | } |
1007 | break; | 1008 | break; |
1008 | } | 1009 | } |
1009 | case ACTION_STD_PREV: | 1010 | case ACTION_STD_PREV: |
1010 | case ACTION_STD_CANCEL: | 1011 | case ACTION_STD_CANCEL: |
1011 | return false; | 1012 | return -1; |
1012 | default: | 1013 | default: |
1013 | break; | 1014 | break; |
1014 | } | 1015 | } |
@@ -1017,7 +1018,20 @@ static bool do_preset_menu(struct preset_menu *menu, char *title) | |||
1017 | 1018 | ||
1018 | static bool presets_menu(void) | 1019 | static bool presets_menu(void) |
1019 | { | 1020 | { |
1020 | return do_preset_menu(midend_get_presets(me, NULL), NULL); | 1021 | /* figure out the index of the current preset |
1022 | * if it's in a submenu, give up and default to the first item */ | ||
1023 | struct preset_menu *top = midend_get_presets(me, NULL); | ||
1024 | int sel = 0; | ||
1025 | for(int i = 0; i < top->n_entries; ++i) | ||
1026 | { | ||
1027 | if(top->entries[i].id == midend_which_preset(me)) | ||
1028 | { | ||
1029 | sel = i; | ||
1030 | break; | ||
1031 | } | ||
1032 | } | ||
1033 | |||
1034 | return do_preset_menu(midend_get_presets(me, NULL), NULL, sel) >= 0; | ||
1021 | } | 1035 | } |
1022 | 1036 | ||
1023 | static const struct { | 1037 | static const struct { |