Index: apps/plugins/credits.c =================================================================== --- apps/plugins/credits.c (revision 14416) +++ apps/plugins/credits.c (working copy) @@ -21,7 +21,9 @@ PLUGIN_HEADER -void roll_credits(void); +int roll_credits(void); +enum plugin_status roll_credits_interactive(int pos); +char * get_credits(int selected_item, void * data, char *buffer); const char* const credits[] = { #include "credits.raw" /* generated list of names from docs/CREDITS */ }; @@ -31,6 +33,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) { int j = 0; + int pos = 0; int btn; (void)parameter; @@ -53,18 +56,19 @@ goto end_of_proc; } - roll_credits(); + pos = roll_credits(); end_of_proc: /* Turn on backlight timeout (revert to settings) */ backlight_use_settings(rb); /* backlight control in lib/helper.c */ - return PLUGIN_OK; + /* Show the interactive credits */ + return roll_credits_interactive(pos); } #ifdef HAVE_LCD_CHARCELLS -void roll_credits(void) +int roll_credits(void) { int numnames = sizeof(credits)/sizeof(char*); int curr_name = 0; @@ -108,7 +112,7 @@ /* abort on keypress */ if (rb->button_get_w_tmo(HZ/8) & BUTTON_REL) - return; + return name; if (++curr_index >= curr_len) { @@ -120,11 +124,12 @@ curr_line ^= 1; } } + return curr_name; } #else -void roll_credits(void) +int roll_credits(void) { #if (CONFIG_KEYPAD == RECORDER_PAD) #define PAUSE_TIME 1.2 @@ -200,7 +205,7 @@ /* exit on keypress */ btn = rb->button_get_w_tmo(HZ/ANIM_SPEED); if (btn != BUTTON_NONE && !(btn & BUTTON_REL)) - return; + return i; } } j+=i; @@ -208,7 +213,7 @@ /* pause for a bit if needed */ btn = rb->button_get_w_tmo(HZ*PAUSE_TIME); /* exit on keypress */ if (btn != BUTTON_NONE && !(btn & BUTTON_REL)) - return; + return j; /* now begin looping the in-out animation */ while(j < numnames) @@ -236,7 +241,7 @@ /* exit on keypress */ btn = rb->button_get_w_tmo(HZ/ANIM_SPEED); if (btn != BUTTON_NONE && !(btn & BUTTON_REL)) - return; + return j+i; namepos += offset_dummy; offset_dummy++; @@ -263,7 +268,7 @@ /* exit on keypress */ btn = rb->button_get_w_tmo(HZ/ANIM_SPEED); if (btn != BUTTON_NONE && !(btn & BUTTON_REL)) - return; + return j+i+1; } namepos = name_targetpos; @@ -274,12 +279,12 @@ btn = rb->button_get_w_tmo(HZ*PAUSE_TIME); /* exit on keypress */ if (btn != BUTTON_NONE && !(btn & BUTTON_REL)) - return; + return j; } btn = rb->button_get_w_tmo(HZ*2.5); /* exit on keypress */ if (btn != BUTTON_NONE && !(btn & BUTTON_REL)) - return; + return 0; offset_dummy = 1; @@ -293,6 +298,61 @@ rb->lcd_putsxy(credits_pos, 0, elapsednames); rb->lcd_update(); } + + return 0; } #endif + +enum plugin_status roll_credits_interactive(int pos) +{ + struct gui_synclist credits_lists; + enum plugin_status status = PLUGIN_OK; + bool quit = false; + int btn, nbitems; + + rb->lcd_clear_display(); + rb->lcd_update(); + + /* Make sure position is bounded */ + pos = ((pos %= (nbitems = sizeof(credits)/sizeof(char*))) > 0 )? pos : 0; + + /* Create a synclist with the credits information */ + rb->gui_synclist_init(&credits_lists, &get_credits, NULL, false, 1); + rb->gui_synclist_set_title(&credits_lists, "Credits", NOICON); + rb->gui_synclist_set_icon_callback(&credits_lists, NULL); + rb->gui_synclist_set_nb_items(&credits_lists, nbitems); + rb->gui_synclist_limit_scroll(&credits_lists, true); + rb->gui_synclist_select_item(&credits_lists, pos); + rb->gui_synclist_draw(&credits_lists); + + /* Iterate through the synclist */ + while(!quit) + { + btn = rb->get_action(CONTEXT_LIST,TIMEOUT_BLOCK); + if (rb->gui_synclist_do_button(&credits_lists,btn,LIST_WRAP_ON)) + continue; + switch(btn) + { + case ACTION_STD_CANCEL: + quit = true; + break; + default: + if (rb->default_event_handler(btn) == SYS_USB_CONNECTED) + { + status = PLUGIN_USB_CONNECTED; + break; + } + } + } + + return status; +} + +char * get_credits(int selected_item, void* data, char *buffer) +{ + (void)data; + + rb->strcpy(buffer,credits[selected_item]); + return buffer; +}