diff --git a/general.h b/general.h index 19b2e6009c..d98dd2565e 100644 --- a/general.h +++ b/general.h @@ -191,6 +191,7 @@ struct settings bool pause_libretro; bool mouse_enable; bool timedate_enable; + char wallpaper[PATH_MAX_LENGTH]; struct { diff --git a/menu/drivers_display/rmenu.c b/menu/drivers_display/rmenu.c index 1019a2d4f8..c89fbebe09 100644 --- a/menu/drivers_display/rmenu.c +++ b/menu/drivers_display/rmenu.c @@ -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) { char menu_bg[PATH_MAX_LENGTH]; @@ -278,14 +290,10 @@ static void rmenu_context_reset(void *data) if (!menu) return; - 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)); + if (*g_settings.menu.wallpaper) + strlcpy(menu_bg, g_settings.menu.wallpaper, sizeof(menu_bg)); + else + rmenu_set_default_wallpaper(menu_bg, sizeof(menu_bg)); if (path_file_exists(menu_bg)) texture_image_load(menu_texture, menu_bg); diff --git a/menu/drivers_display/xmb.c b/menu/drivers_display/xmb.c index 5f555c79b1..9083f33e28 100644 --- a/menu/drivers_display/xmb.c +++ b/menu/drivers_display/xmb.c @@ -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); - fill_pathname_join(xmb->textures[XMB_TEXTURE_BG].path, iconpath, - "bg.png", sizeof(xmb->textures[XMB_TEXTURE_BG].path)); + if (*g_settings.menu.wallpaper) + 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, "settings.png", sizeof(xmb->textures[XMB_TEXTURE_SETTINGS].path)); fill_pathname_join(xmb->textures[XMB_TEXTURE_SETTING].path, iconpath, diff --git a/menu/menu.h b/menu/menu.h index 874225ab9b..7a887869d1 100644 --- a/menu/menu.h +++ b/menu/menu.h @@ -74,6 +74,7 @@ typedef enum MENU_FILE_USE_DIRECTORY, MENU_FILE_CARCHIVE, MENU_FILE_IN_CARCHIVE, + MENU_FILE_IMAGE, MENU_SETTINGS, MENU_SETTING_DRIVER, MENU_SETTING_ACTION, diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index 74dd60c0c7..8b379fb871 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -354,6 +354,34 @@ static int action_ok_cheat_file_load(const char *path, 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, const char *label, unsigned type, size_t idx) { @@ -2316,6 +2344,21 @@ static int deferred_push_video_filter(void *data, void *userdata, 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, 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: cbs->action_ok = action_ok_shader_pass_load; break; + case MENU_FILE_IMAGE: + cbs->action_ok = action_ok_menu_wallpaper_load; + break; case MENU_FILE_USE_DIRECTORY: cbs->action_ok = action_ok_path_use_directory; 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_CORE: case MENU_FILE_SHADER: + case MENU_FILE_IMAGE: case MENU_FILE_OVERLAY: case MENU_FILE_VIDEOFILTER: 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; else if (!strcmp(label, "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")) cbs->action_deferred_push = deferred_push_audio_dsp_plugin; else if (!strcmp(label, "input_overlay")) diff --git a/retroarch.cfg b/retroarch.cfg index d22cfede3d..d1290addb1 100644 --- a/retroarch.cfg +++ b/retroarch.cfg @@ -573,6 +573,9 @@ # Shows current date and/or time inside menu. # 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 # menu_navigation_wraparound_horizontal_enable = false diff --git a/settings.c b/settings.c index 0392d16440..74ffe30001 100644 --- a/settings.c +++ b/settings.c @@ -510,6 +510,7 @@ static void config_set_defaults(void) g_settings.menu.pause_libretro = true; g_settings.menu.mouse_enable = false; g_settings.menu.timedate_enable = true; + *g_settings.menu.wallpaper = '\0'; g_settings.menu.navigation.wraparound.horizontal_enable = true; g_settings.menu.navigation.wraparound.vertical_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.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_PATH(menu.wallpaper, "menu_wallpaper"); + if (!strcmp(g_settings.menu.wallpaper, "default")) + *g_settings.menu.wallpaper = '\0'; #endif 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_mouse_enable", g_settings.menu.mouse_enable); config_set_bool(conf,"menu_timedate_enable", g_settings.menu.timedate_enable); + config_set_path(conf, "menu_wallpaper", g_settings.menu.wallpaper); #endif config_set_bool(conf, "video_vsync", g_settings.video.vsync); config_set_bool(conf, "video_hard_sync", g_settings.video.hard_sync); diff --git a/settings_data.c b/settings_data.c index 9533b07056..807ceb1112 100644 --- a/settings_data.c +++ b/settings_data.c @@ -5223,6 +5223,18 @@ static bool setting_data_append_list_menu_options( START_GROUP(group_info, "Menu Options"); 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( g_settings.menu_show_start_screen, "rgui_show_start_screen",