Add menu wallpaper setting

This commit is contained in:
twinaphex 2015-01-17 18:15:22 +01:00
parent 0c8eec085c
commit 5f23cda6cb
8 changed files with 93 additions and 10 deletions

View File

@ -191,6 +191,7 @@ struct settings
bool pause_libretro; bool pause_libretro;
bool mouse_enable; bool mouse_enable;
bool timedate_enable; bool timedate_enable;
char wallpaper[PATH_MAX_LENGTH];
struct struct
{ {

View File

@ -270,6 +270,18 @@ void rmenu_set_texture(void *data)
} }
} }
static void rmenu_wallpaper_set_defaults(char *menu_bg, size_t sizeof_menu_bg)
{
fill_pathname_join(menu_bg, g_settings.assets_directory,
"rmenu", sizeof_menu_bg);
#ifdef _XBOX1
fill_pathname_join(menu_bg, menu_bg, "sd", sizeof_menu_bg);
#else
fill_pathname_join(menu_bg, menu_bg, "hd", sizeof_menu_bg);
#endif
fill_pathname_join(menu_bg, menu_bg, "main_menu.png", sizeof_menu_bg);
}
static void rmenu_context_reset(void *data) static void rmenu_context_reset(void *data)
{ {
char menu_bg[PATH_MAX_LENGTH]; char menu_bg[PATH_MAX_LENGTH];
@ -278,14 +290,10 @@ static void rmenu_context_reset(void *data)
if (!menu) if (!menu)
return; return;
fill_pathname_join(menu_bg, g_settings.assets_directory, if (*g_settings.menu.wallpaper)
"rmenu", sizeof(menu_bg)); strlcpy(menu_bg, g_settings.menu.wallpaper, sizeof(menu_bg));
#ifdef _XBOX1 else
fill_pathname_join(menu_bg, menu_bg, "sd", sizeof(menu_bg)); rmenu_set_default_wallpaper(menu_bg, sizeof(menu_bg));
#else
fill_pathname_join(menu_bg, menu_bg, "hd", sizeof(menu_bg));
#endif
fill_pathname_join(menu_bg, menu_bg, "main_menu.png", sizeof(menu_bg));
if (path_file_exists(menu_bg)) if (path_file_exists(menu_bg))
texture_image_load(menu_texture, menu_bg); texture_image_load(menu_texture, menu_bg);

View File

@ -1232,8 +1232,12 @@ static void xmb_context_reset(void *data)
xmb_font_init_first(&gl->font_driver, &xmb->font, gl, fontpath, xmb->font_size); xmb_font_init_first(&gl->font_driver, &xmb->font, gl, fontpath, xmb->font_size);
fill_pathname_join(xmb->textures[XMB_TEXTURE_BG].path, iconpath, if (*g_settings.menu.wallpaper)
"bg.png", sizeof(xmb->textures[XMB_TEXTURE_BG].path)); strlcpy(xmb->textures[XMB_TEXTURE_BG].path, g_settings.menu.wallpaper,
sizeof(xmb->textures[XMB_TEXTURE_BG].path));
else
fill_pathname_join(xmb->textures[XMB_TEXTURE_BG].path, iconpath,
"bg.png", sizeof(xmb->textures[XMB_TEXTURE_BG].path));
fill_pathname_join(xmb->textures[XMB_TEXTURE_SETTINGS].path, iconpath, fill_pathname_join(xmb->textures[XMB_TEXTURE_SETTINGS].path, iconpath,
"settings.png", sizeof(xmb->textures[XMB_TEXTURE_SETTINGS].path)); "settings.png", sizeof(xmb->textures[XMB_TEXTURE_SETTINGS].path));
fill_pathname_join(xmb->textures[XMB_TEXTURE_SETTING].path, iconpath, fill_pathname_join(xmb->textures[XMB_TEXTURE_SETTING].path, iconpath,

View File

@ -74,6 +74,7 @@ typedef enum
MENU_FILE_USE_DIRECTORY, MENU_FILE_USE_DIRECTORY,
MENU_FILE_CARCHIVE, MENU_FILE_CARCHIVE,
MENU_FILE_IN_CARCHIVE, MENU_FILE_IN_CARCHIVE,
MENU_FILE_IMAGE,
MENU_SETTINGS, MENU_SETTINGS,
MENU_SETTING_DRIVER, MENU_SETTING_DRIVER,
MENU_SETTING_ACTION, MENU_SETTING_ACTION,

View File

@ -354,6 +354,34 @@ static int action_ok_cheat_file_load(const char *path,
return 0; return 0;
} }
static int action_ok_menu_wallpaper_load(const char *path,
const char *label, unsigned type, size_t idx)
{
const char *menu_label = NULL;
const char *menu_path = NULL;
rarch_setting_t *setting = NULL;
char wallpaper_path[PATH_MAX_LENGTH];
if (!driver.menu)
return -1;
menu_list_get_last_stack(driver.menu->menu_list, &menu_path, &menu_label,
NULL);
setting = (rarch_setting_t*)
setting_data_find_setting(driver.menu->list_settings, menu_label);
if (!setting)
return -1;
fill_pathname_join(wallpaper_path, menu_path, path, sizeof(wallpaper_path));
strlcpy(g_settings.menu.wallpaper, wallpaper_path, sizeof(g_settings.menu.wallpaper));
menu_list_pop_stack_by_needle(driver.menu->menu_list, setting->name);
return 0;
}
static int action_ok_shader_preset_load(const char *path, static int action_ok_shader_preset_load(const char *path,
const char *label, unsigned type, size_t idx) const char *label, unsigned type, size_t idx)
{ {
@ -2316,6 +2344,21 @@ static int deferred_push_video_filter(void *data, void *userdata,
return 0; return 0;
} }
static int deferred_push_images(void *data, void *userdata,
const char *path, const char *label, unsigned type)
{
file_list_t *list = (file_list_t*)data;
file_list_t *menu_list = (file_list_t*)userdata;
if (!list || !menu_list)
return -1;
menu_entries_parse_list(list, menu_list, path, label,
type, MENU_FILE_IMAGE, "png", NULL);
return 0;
}
static int deferred_push_audio_dsp_plugin(void *data, void *userdata, static int deferred_push_audio_dsp_plugin(void *data, void *userdata,
const char *path, const char *label, unsigned type) const char *path, const char *label, unsigned type)
{ {
@ -2496,6 +2539,9 @@ static int menu_entries_cbs_init_bind_ok_first(menu_file_list_cbs_t *cbs,
case MENU_FILE_SHADER: case MENU_FILE_SHADER:
cbs->action_ok = action_ok_shader_pass_load; cbs->action_ok = action_ok_shader_pass_load;
break; break;
case MENU_FILE_IMAGE:
cbs->action_ok = action_ok_menu_wallpaper_load;
break;
case MENU_FILE_USE_DIRECTORY: case MENU_FILE_USE_DIRECTORY:
cbs->action_ok = action_ok_path_use_directory; cbs->action_ok = action_ok_path_use_directory;
break; break;
@ -2750,6 +2796,7 @@ static void menu_entries_cbs_init_bind_toggle(menu_file_list_cbs_t *cbs,
case MENU_FILE_CARCHIVE: case MENU_FILE_CARCHIVE:
case MENU_FILE_CORE: case MENU_FILE_CORE:
case MENU_FILE_SHADER: case MENU_FILE_SHADER:
case MENU_FILE_IMAGE:
case MENU_FILE_OVERLAY: case MENU_FILE_OVERLAY:
case MENU_FILE_VIDEOFILTER: case MENU_FILE_VIDEOFILTER:
case MENU_FILE_AUDIOFILTER: case MENU_FILE_AUDIOFILTER:
@ -2823,6 +2870,8 @@ static void menu_entries_cbs_init_bind_deferred_push(menu_file_list_cbs_t *cbs,
cbs->action_deferred_push = deferred_push_video_shader_pass; cbs->action_deferred_push = deferred_push_video_shader_pass;
else if (!strcmp(label, "video_filter")) else if (!strcmp(label, "video_filter"))
cbs->action_deferred_push = deferred_push_video_filter; cbs->action_deferred_push = deferred_push_video_filter;
else if (!strcmp(label, "menu_wallpaper"))
cbs->action_deferred_push = deferred_push_images;
else if (!strcmp(label, "audio_dsp_plugin")) else if (!strcmp(label, "audio_dsp_plugin"))
cbs->action_deferred_push = deferred_push_audio_dsp_plugin; cbs->action_deferred_push = deferred_push_audio_dsp_plugin;
else if (!strcmp(label, "input_overlay")) else if (!strcmp(label, "input_overlay"))

View File

@ -573,6 +573,9 @@
# Shows current date and/or time inside menu. # Shows current date and/or time inside menu.
# menu_timedate_enable = true # menu_timedate_enable = true
# Path to a .png image to set as menu wallpaper.
# menu_wallpaper =
# Wrap-around toe beginning and/or end if boundary of list reached horizontally # Wrap-around toe beginning and/or end if boundary of list reached horizontally
# menu_navigation_wraparound_horizontal_enable = false # menu_navigation_wraparound_horizontal_enable = false

View File

@ -510,6 +510,7 @@ static void config_set_defaults(void)
g_settings.menu.pause_libretro = true; g_settings.menu.pause_libretro = true;
g_settings.menu.mouse_enable = false; g_settings.menu.mouse_enable = false;
g_settings.menu.timedate_enable = true; g_settings.menu.timedate_enable = true;
*g_settings.menu.wallpaper = '\0';
g_settings.menu.navigation.wraparound.horizontal_enable = true; g_settings.menu.navigation.wraparound.horizontal_enable = true;
g_settings.menu.navigation.wraparound.vertical_enable = true; g_settings.menu.navigation.wraparound.vertical_enable = true;
g_settings.menu.navigation.browser.filter.supported_extensions_enable = true; g_settings.menu.navigation.browser.filter.supported_extensions_enable = true;
@ -1105,6 +1106,9 @@ static bool config_load_file(const char *path, bool set_defaults)
CONFIG_GET_BOOL(menu.navigation.wraparound.horizontal_enable, "menu_navigation_wraparound_horizontal_enable"); CONFIG_GET_BOOL(menu.navigation.wraparound.horizontal_enable, "menu_navigation_wraparound_horizontal_enable");
CONFIG_GET_BOOL(menu.navigation.wraparound.vertical_enable, "menu_navigation_wraparound_vertical_enable"); CONFIG_GET_BOOL(menu.navigation.wraparound.vertical_enable, "menu_navigation_wraparound_vertical_enable");
CONFIG_GET_BOOL(menu.navigation.browser.filter.supported_extensions_enable, "menu_navigation_browser_filter_supported_extensions_enable"); CONFIG_GET_BOOL(menu.navigation.browser.filter.supported_extensions_enable, "menu_navigation_browser_filter_supported_extensions_enable");
CONFIG_GET_PATH(menu.wallpaper, "menu_wallpaper");
if (!strcmp(g_settings.menu.wallpaper, "default"))
*g_settings.menu.wallpaper = '\0';
#endif #endif
CONFIG_GET_INT(video.hard_sync_frames, "video_hard_sync_frames"); CONFIG_GET_INT(video.hard_sync_frames, "video_hard_sync_frames");
@ -1819,6 +1823,7 @@ bool config_save_file(const char *path)
config_set_bool(conf,"menu_pause_libretro", g_settings.menu.pause_libretro); config_set_bool(conf,"menu_pause_libretro", g_settings.menu.pause_libretro);
config_set_bool(conf,"menu_mouse_enable", g_settings.menu.mouse_enable); config_set_bool(conf,"menu_mouse_enable", g_settings.menu.mouse_enable);
config_set_bool(conf,"menu_timedate_enable", g_settings.menu.timedate_enable); config_set_bool(conf,"menu_timedate_enable", g_settings.menu.timedate_enable);
config_set_path(conf, "menu_wallpaper", g_settings.menu.wallpaper);
#endif #endif
config_set_bool(conf, "video_vsync", g_settings.video.vsync); config_set_bool(conf, "video_vsync", g_settings.video.vsync);
config_set_bool(conf, "video_hard_sync", g_settings.video.hard_sync); config_set_bool(conf, "video_hard_sync", g_settings.video.hard_sync);

View File

@ -5223,6 +5223,18 @@ static bool setting_data_append_list_menu_options(
START_GROUP(group_info, "Menu Options"); START_GROUP(group_info, "Menu Options");
START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info); START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info);
CONFIG_PATH(
g_settings.menu.wallpaper,
"menu_wallpaper",
"Menu Wallpaper",
"",
group_info.name,
subgroup_info.name,
general_write_handler,
general_read_handler);
settings_list_current_add_values(list, list_info, "png");
settings_data_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_EMPTY);
CONFIG_BOOL( CONFIG_BOOL(
g_settings.menu_show_start_screen, g_settings.menu_show_start_screen,
"rgui_show_start_screen", "rgui_show_start_screen",