diff options
Diffstat (limited to 'apps/plugins/puzzles/rockbox.c')
-rw-r--r-- | apps/plugins/puzzles/rockbox.c | 69 |
1 files changed, 40 insertions, 29 deletions
diff --git a/apps/plugins/puzzles/rockbox.c b/apps/plugins/puzzles/rockbox.c index 077d5f8fe2..54d24b065b 100644 --- a/apps/plugins/puzzles/rockbox.c +++ b/apps/plugins/puzzles/rockbox.c | |||
@@ -23,8 +23,8 @@ | |||
23 | 23 | ||
24 | #include "plugin.h" | 24 | #include "plugin.h" |
25 | 25 | ||
26 | #include "puzzles.h" | 26 | #include "src/puzzles.h" |
27 | #include "keymaps.h" | 27 | #include "src/keymaps.h" |
28 | 28 | ||
29 | #ifndef COMBINED | 29 | #ifndef COMBINED |
30 | #include "lib/playback_control.h" | 30 | #include "lib/playback_control.h" |
@@ -315,6 +315,7 @@ static void rb_draw_line(void *handle, int x1, int y1, int x2, int y2, | |||
315 | draw_antialiased_line(x1, y1, x2, y2); | 315 | draw_antialiased_line(x1, y1, x2, y2); |
316 | } | 316 | } |
317 | 317 | ||
318 | #if 0 | ||
318 | /* | 319 | /* |
319 | * draw filled polygon | 320 | * draw filled polygon |
320 | * originally by Sebastian Leonhardt (ulmutul) | 321 | * originally by Sebastian Leonhardt (ulmutul) |
@@ -409,6 +410,7 @@ static void v_fillarea(int count, int *pxy) | |||
409 | fill_poly_line(i, count, pxy); | 410 | fill_poly_line(i, count, pxy); |
410 | } | 411 | } |
411 | } | 412 | } |
413 | #endif | ||
412 | 414 | ||
413 | static void rb_draw_poly(void *handle, int *coords, int npoints, | 415 | static void rb_draw_poly(void *handle, int *coords, int npoints, |
414 | int fillcolor, int outlinecolor) | 416 | int fillcolor, int outlinecolor) |
@@ -916,7 +918,7 @@ static bool config_menu(void) | |||
916 | config_item old; | 918 | config_item old; |
917 | int pos = rb->gui_synclist_get_sel_pos(&list); | 919 | int pos = rb->gui_synclist_get_sel_pos(&list); |
918 | memcpy(&old, config + pos, sizeof(old)); | 920 | memcpy(&old, config + pos, sizeof(old)); |
919 | char *old_str; | 921 | char *old_str = NULL; |
920 | if(old.type == C_STRING) | 922 | if(old.type == C_STRING) |
921 | old_str = dupstr(old.sval); | 923 | old_str = dupstr(old.sval); |
922 | bool freed_str = do_configure_item(config + pos); | 924 | bool freed_str = do_configure_item(config + pos); |
@@ -928,13 +930,13 @@ static bool config_menu(void) | |||
928 | if(freed_str) | 930 | if(freed_str) |
929 | config[pos].sval = old_str; | 931 | config[pos].sval = old_str; |
930 | } | 932 | } |
931 | else if(old.type == C_STRING) | ||
932 | { | ||
933 | /* success, and we duplicated the old string, so free it */ | ||
934 | sfree(old_str); | ||
935 | } | ||
936 | else | 933 | else |
937 | { | 934 | { |
935 | if(old.type == C_STRING) | ||
936 | { | ||
937 | /* success, and we duplicated the old string, so free it */ | ||
938 | sfree(old_str); | ||
939 | } | ||
938 | success = true; | 940 | success = true; |
939 | } | 941 | } |
940 | break; | 942 | break; |
@@ -956,33 +958,29 @@ done: | |||
956 | 958 | ||
957 | const char *preset_formatter(int sel, void *data, char *buf, size_t len) | 959 | const char *preset_formatter(int sel, void *data, char *buf, size_t len) |
958 | { | 960 | { |
959 | char *name; | 961 | struct preset_menu *menu = data; |
960 | game_params *junk; | 962 | rb->snprintf(buf, len, "%s", menu->entries[sel].title); |
961 | midend_fetch_preset(me, sel, &name, &junk); | ||
962 | rb->strlcpy(buf, name, len); | ||
963 | return buf; | 963 | return buf; |
964 | } | 964 | } |
965 | 965 | ||
966 | static bool presets_menu(void) | 966 | /* main worker function */ |
967 | static bool do_preset_menu(struct preset_menu *menu, char *title) | ||
967 | { | 968 | { |
968 | if(!midend_num_presets(me)) | 969 | if(!menu->n_entries) |
969 | { | ||
970 | rb->splash(HZ, "No presets!"); | ||
971 | return false; | 970 | return false; |
972 | } | ||
973 | 971 | ||
974 | /* display a list */ | 972 | /* display a list */ |
975 | struct gui_synclist list; | 973 | struct gui_synclist list; |
976 | 974 | ||
977 | rb->gui_synclist_init(&list, &preset_formatter, NULL, false, 1, NULL); | 975 | rb->gui_synclist_init(&list, &preset_formatter, menu, false, 1, NULL); |
978 | rb->gui_synclist_set_icon_callback(&list, NULL); | 976 | rb->gui_synclist_set_icon_callback(&list, NULL); |
979 | rb->gui_synclist_set_nb_items(&list, midend_num_presets(me)); | 977 | rb->gui_synclist_set_nb_items(&list, menu->n_entries); |
980 | rb->gui_synclist_limit_scroll(&list, false); | 978 | rb->gui_synclist_limit_scroll(&list, false); |
981 | 979 | ||
982 | int current = midend_which_preset(me); | 980 | rb->gui_synclist_select_item(&list, 0); /* we don't start with the current one selected */ |
983 | rb->gui_synclist_select_item(&list, current >= 0 ? current : 0); | ||
984 | 981 | ||
985 | rb->gui_synclist_set_title(&list, "Game Type", NOICON); | 982 | char def[] = "Game Type"; |
983 | rb->gui_synclist_set_title(&list, title ? title : def, NOICON); | ||
986 | while(1) | 984 | while(1) |
987 | { | 985 | { |
988 | rb->gui_synclist_draw(&list); | 986 | rb->gui_synclist_draw(&list); |
@@ -994,11 +992,19 @@ static bool presets_menu(void) | |||
994 | case ACTION_STD_OK: | 992 | case ACTION_STD_OK: |
995 | { | 993 | { |
996 | int sel = rb->gui_synclist_get_sel_pos(&list); | 994 | int sel = rb->gui_synclist_get_sel_pos(&list); |
997 | char *junk; | 995 | struct preset_menu_entry *entry = menu->entries + sel; |
998 | game_params *params; | 996 | if(entry->params) |
999 | midend_fetch_preset(me, sel, &junk, ¶ms); | 997 | { |
1000 | midend_set_params(me, params); | 998 | midend_set_params(me, entry->params); |
1001 | return true; | 999 | return true; |
1000 | } | ||
1001 | else | ||
1002 | { | ||
1003 | /* recurse */ | ||
1004 | if(do_preset_menu(entry->submenu, entry->title)) | ||
1005 | return true; | ||
1006 | } | ||
1007 | break; | ||
1002 | } | 1008 | } |
1003 | case ACTION_STD_PREV: | 1009 | case ACTION_STD_PREV: |
1004 | case ACTION_STD_CANCEL: | 1010 | case ACTION_STD_CANCEL: |
@@ -1009,6 +1015,11 @@ static bool presets_menu(void) | |||
1009 | } | 1015 | } |
1010 | } | 1016 | } |
1011 | 1017 | ||
1018 | static bool presets_menu(void) | ||
1019 | { | ||
1020 | return do_preset_menu(midend_get_presets(me, NULL), NULL); | ||
1021 | } | ||
1022 | |||
1012 | static const struct { | 1023 | static const struct { |
1013 | const char *game, *help; | 1024 | const char *game, *help; |
1014 | } quick_help_text[] = { | 1025 | } quick_help_text[] = { |
@@ -1212,7 +1223,7 @@ static int pausemenu_cb(int action, const struct menu_item_ex *this_item) | |||
1212 | return ACTION_EXIT_MENUITEM; | 1223 | return ACTION_EXIT_MENUITEM; |
1213 | #endif | 1224 | #endif |
1214 | case 9: | 1225 | case 9: |
1215 | if(!midend_num_presets(me)) | 1226 | if(!midend_get_presets(me, NULL)->n_entries) |
1216 | return ACTION_EXIT_MENUITEM; | 1227 | return ACTION_EXIT_MENUITEM; |
1217 | break; | 1228 | break; |
1218 | case 10: | 1229 | case 10: |
@@ -1808,7 +1819,7 @@ static int mainmenu_cb(int action, const struct menu_item_ex *this_item) | |||
1808 | return ACTION_EXIT_MENUITEM; | 1819 | return ACTION_EXIT_MENUITEM; |
1809 | #endif | 1820 | #endif |
1810 | case 5: | 1821 | case 5: |
1811 | if(!midend_num_presets(me)) | 1822 | if(!midend_get_presets(me, NULL)->n_entries) |
1812 | return ACTION_EXIT_MENUITEM; | 1823 | return ACTION_EXIT_MENUITEM; |
1813 | break; | 1824 | break; |
1814 | case 6: | 1825 | case 6: |