Index: apps/playlist.c =================================================================== --- apps/playlist.c (Revision 21232) +++ apps/playlist.c (Arbeitskopie) @@ -342,7 +342,7 @@ if (check_rockboxdir()) { cond_talk_ids_fq(LANG_PLAYLIST_CONTROL_ACCESS_ERROR); - splashf(HZ*2, (unsigned char *)"%s (%d)", + splashf(HZ*2, "%s (%d)", str(LANG_PLAYLIST_CONTROL_ACCESS_ERROR), playlist->control_fd); } Index: apps/gui/splash.c =================================================================== --- apps/gui/splash.c (Revision 21232) +++ apps/gui/splash.c (Arbeitskopie) @@ -29,6 +29,7 @@ #include "talk.h" #include "splash.h" #include "viewport.h" +#include "action.h" #ifdef HAVE_LCD_BITMAP @@ -73,7 +74,6 @@ y = h; vsnprintf(splash_buf, sizeof(splash_buf), fmt, ap); - va_end(ap); /* break splash string into display lines, doing proper word wrap */ @@ -205,33 +205,74 @@ screen->set_viewport(NULL); } -void splashf(int ticks, const char *fmt, ...) +static int vasplashf(const int timeout, const char *fmt, va_list ap, + const bool abort) { - va_list ap; int i; - /* If fmt is a lang ID then get the corresponding string (which still might contain % place holders). */ fmt = P2STR((unsigned char *)fmt); + + /* parse and display the text */ FOR_NB_SCREENS(i) + splash_internal(&(screens[i]), fmt, ap); + + /* handle timeout + * if timeout is 0, then return instantly without any yield'ing. + * Otherwise, sleep or ask for button until the timeout wears off, + * that includes yielding + */ + if (timeout) { - va_start(ap, fmt); - splash_internal(&(screens[i]), fmt, ap); - va_end(ap); + if (abort) + return get_action(CONTEXT_STD, timeout); + else + sleep(timeout); } - if (ticks) - sleep(ticks); + + return 0; } -void splash(int ticks, const char *str) +int asplashf(const int timeout, const char* fmt, ...) { + int ret; + va_list ap; + va_start(ap, fmt); + ret = vasplashf(timeout, fmt, ap, true); + va_end(ap); + return ret; +} + +void splashf(const int timeout, const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + vasplashf(timeout, fmt, ap, false); + va_end(ap); +} + #if !defined(SIMULATOR) || CONFIG_CODEC == SWCODEC +static inline void splash_voice_string(const char *str) +{ long id; /* fmt may be a so called virtual pointer. See settings.h. */ if((id = P2ID((const unsigned char*)str)) >= 0) /* If fmt specifies a voicefont ID, and voice menus are enabled, then speak it. */ cond_talk_ids_fq(id); +} +#else +#define splash_voice_string(a) #endif - splashf(ticks, "%s", P2STR((const unsigned char*)str)); + +int asplash(const int timeout, const char *str) +{ + splash_voice_string(str); + return asplashf(timeout, "%s", P2STR((const unsigned char*)str)); } + +void splash(const int timeout, const char *str) +{ + splash_voice_string(str); + splashf(timeout, "%s", P2STR((const unsigned char*)str)); +} Index: apps/gui/splash.h =================================================================== --- apps/gui/splash.h (Revision 21232) +++ apps/gui/splash.h (Arbeitskopie) @@ -22,20 +22,26 @@ #ifndef _GUI_SPLASH_H_ #define _GUI_SPLASH_H_ #include <_ansi.h> -#include "screen_access.h" /* - * Puts a splash message centered on all the screens for a given period - * - ticks : how long the splash is displayed (in rb ticks) + * Puts a formatted splash message centered on all the screens for a given period + * - timeout : how long the splash is displayed (in rb ticks) * - fmt : what to say *printf style */ -extern void splashf(int ticks, const char *fmt, ...) ATTRIBUTE_PRINTF(2, 3); +void splashf(const int timeout, const char *fmt, ...) ATTRIBUTE_PRINTF(2, 3); /* * Puts a splash message centered on all the screens for a given period - * - ticks : how long the splash is displayed (in rb ticks) + * - timout : how long the splash is displayed (in rb ticks) * - str : what to say, if this is a LANG_* string (from ID2P) * it will be voiced */ -extern void splash(int ticks, const char *str); -#endif /* _GUI_ICON_H_ */ +void splash(const int timeout, const char *str); + +/* These variants can be cancelled through a button press; they return the + * action received from the button press. It calls get_action for + * CONTEXT_STD, so return values will be ACTION_STD_* */ +int asplashf(const int timeout, const char* fmt, ...) ATTRIBUTE_PRINTF(2,3); + +int asplash(const int timeout, const char *str); +#endif /* _GUI_SPLASH_H_ */ Index: apps/filetree.c =================================================================== --- apps/filetree.c (Revision 21232) +++ apps/filetree.c (Arbeitskopie) @@ -94,7 +94,7 @@ { if (global_settings.party_mode && audio_status()) { - splash(HZ, ID2P(LANG_PARTY_MODE)); + asplash(HZ, ID2P(LANG_PARTY_MODE)); return false; } @@ -508,7 +508,7 @@ if (!settings_load_config(buf,true)) break; gui_synclist_draw(&tree_lists); - splash(HZ, ID2P(LANG_SETTINGS_LOADED)); + asplash(HZ, ID2P(LANG_SETTINGS_LOADED)); break; case FILE_ATTR_BMARK: @@ -523,7 +523,7 @@ set_file(buf, (char *)global_settings.lang_file, MAX_FILENAME); talk_init(); /* use voice of same language */ - splash(HZ, ID2P(LANG_LANGUAGE_LOADED)); + asplash(HZ, ID2P(LANG_LANGUAGE_LOADED)); } break; @@ -537,7 +537,7 @@ case FILE_ATTR_KBD: splash(0, ID2P(LANG_WAIT)); if (!load_kbd(buf)) - splash(HZ, ID2P(LANG_KEYBOARD_LOADED)); + asplash(HZ, ID2P(LANG_KEYBOARD_LOADED)); set_file(buf, (char *)global_settings.kbd_file, MAX_FILENAME); break; #endif @@ -553,7 +553,7 @@ /* plugin file */ case FILE_ATTR_ROCK: if (global_settings.party_mode && audio_status()) { - splash(HZ, ID2P(LANG_PARTY_MODE)); + asplash(HZ, ID2P(LANG_PARTY_MODE)); break; } @@ -577,7 +577,7 @@ const char* plugin; if (global_settings.party_mode && audio_status()) { - splash(HZ, ID2P(LANG_PARTY_MODE)); + asplash(HZ, ID2P(LANG_PARTY_MODE)); break; } Index: apps/root_menu.c =================================================================== --- apps/root_menu.c (Revision 21232) +++ apps/root_menu.c (Arbeitskopie) @@ -258,7 +258,7 @@ } else { - splash(HZ*2, ID2P(LANG_NOTHING_TO_RESUME)); + asplash(HZ*2, ID2P(LANG_NOTHING_TO_RESUME)); } return ret_val; }