Support loading backdrops from anywhere in the filesystem. Fixes FS#12041

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29700 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Frank Gevaerts 2011-04-10 13:25:47 +00:00
parent b66239b436
commit d09f97880a
4 changed files with 10 additions and 23 deletions

View file

@ -113,10 +113,7 @@ bool skin_backdrops_preload(void)
if (screen == SCREEN_MAIN && global_settings.backdrop_file[0] &&
global_settings.backdrop_file[0] != '-' && filename[0] == '-')
{
char* temp = filename+2; /* slightly hacky to get a buffer */
size_t size = sizeof(backdrops[i].name) - 2;
snprintf(temp, size, BACKDROP_DIR "/%s.bmp", global_settings.backdrop_file);
filename = temp;
filename = global_settings.backdrop_file;
}
if (*filename && *filename != '-')
{
@ -156,7 +153,6 @@ void skin_backdrop_unload(int backdrop_id)
void skin_backdrop_load_setting(void)
{
int i;
char filename[MAX_PATH];
for(i=0;i<SKINNABLE_SCREENS_COUNT*NB_SCREENS;i++)
{
if (backdrops[i].name[0] == '-' && backdrops[i].screen == SCREEN_MAIN)
@ -166,11 +162,11 @@ void skin_backdrop_load_setting(void)
{
if (!backdrops[i].buffer)
backdrops[i].buffer = (char*)skin_buffer_alloc(LCD_BACKDROP_BYTES);
snprintf(filename, sizeof filename, BACKDROP_DIR "/%s.bmp",
global_settings.backdrop_file);
bool loaded = backdrops[i].buffer &&
screens[SCREEN_MAIN].backdrop_load(filename,
backdrops[i].buffer);
screens[SCREEN_MAIN].backdrop_load(
global_settings.backdrop_file,
backdrops[i].buffer);
backdrops[i].name[2] = loaded ? '.' : '\0';
return;
}

View file

@ -1017,18 +1017,9 @@ MENUITEM_FUNCTION(add_to_faves_item, MENU_FUNC_USEPARAM, ID2P(LANG_ADD_TO_FAVES)
#if LCD_DEPTH > 1
static bool set_backdrop(void)
{
/* load the image
if(sb_set_backdrop(SCREEN_MAIN, selected_file)) {
splash(HZ, str(LANG_BACKDROP_LOADED));
set_file(selected_file, (char *)global_settings.backdrop_file,
MAX_FILENAME);
return true;
} else {
splash(HZ, str(LANG_BACKDROP_FAILED));
return false;
}*/
set_file(selected_file, (char *)global_settings.backdrop_file,
MAX_FILENAME);
strlcpy(global_settings.backdrop_file, selected_file,
sizeof(global_settings.backdrop_file));
settings_save();
skin_backdrop_load_setting();
return true;
}

View file

@ -588,7 +588,7 @@ struct user_settings
#endif /* HAVE_TAGCACHE */
#if LCD_DEPTH > 1
unsigned char backdrop_file[MAX_FILENAME+1]; /* backdrop bitmap file */
unsigned char backdrop_file[MAX_PATHNAME+1]; /* backdrop bitmap file */
#endif
#ifdef HAVE_LCD_COLOR

View file

@ -1587,7 +1587,7 @@ const struct settings_list settings[] = {
TEXT_SETTING(0,lang_file,"lang","",LANG_DIR "/",".lng"),
#if LCD_DEPTH > 1
TEXT_SETTING(F_THEMESETTING,backdrop_file,"backdrop",
DEFAULT_BACKDROP, BACKDROP_DIR "/", ".bmp"),
DEFAULT_BACKDROP, NULL, NULL),
#endif
#ifdef HAVE_LCD_BITMAP
TEXT_SETTING(0,kbd_file,"kbd","-",ROCKBOX_DIR "/",".kbd"),