diff --git a/config.def.h b/config.def.h index fed662e391..91b079f808 100644 --- a/config.def.h +++ b/config.def.h @@ -578,12 +578,15 @@ /* Ozone colour theme: 1 == Basic Black */ #define DEFAULT_OZONE_COLOR_THEME 1 #define DEFAULT_OZONE_COLLAPSE_SIDEBAR false -#define DEFAULT_OZONE_TRUNCATE_PLAYLIST_NAME true -#define DEFAULT_OZONE_SORT_AFTER_TRUNCATE_PLAYLIST_NAME true #define DEFAULT_OZONE_SCROLL_CONTENT_METADATA false #define DEFAULT_OZONE_THUMBNAIL_SCALE_FACTOR 1.0f #endif +#if defined(HAVE_OZONE) || defined(HAVE_XMB) +#define DEFAULT_OZONE_TRUNCATE_PLAYLIST_NAME true +#define DEFAULT_OZONE_SORT_AFTER_TRUNCATE_PLAYLIST_NAME false +#endif + #define DEFAULT_SETTINGS_SHOW_DRIVERS true #define DEFAULT_SETTINGS_SHOW_VIDEO true diff --git a/configuration.c b/configuration.c index eb06600553..af3fc8f43c 100644 --- a/configuration.c +++ b/configuration.c @@ -2034,9 +2034,11 @@ true, DEFAULT_VIBRATE_ON_KEYPRESS, false); #ifdef HAVE_OZONE SETTING_BOOL("ozone_collapse_sidebar", &settings->bools.ozone_collapse_sidebar, true, DEFAULT_OZONE_COLLAPSE_SIDEBAR, false); - SETTING_BOOL("ozone_truncate_playlist_name", &settings->bools.ozone_truncate_playlist_name, true, DEFAULT_OZONE_TRUNCATE_PLAYLIST_NAME, false); - SETTING_BOOL("ozone_sort_after_truncate_playlist_name", &settings->bools.ozone_sort_after_truncate_playlist_name, true, DEFAULT_OZONE_SORT_AFTER_TRUNCATE_PLAYLIST_NAME, false); SETTING_BOOL("ozone_scroll_content_metadata",&settings->bools.ozone_scroll_content_metadata, true, DEFAULT_OZONE_SCROLL_CONTENT_METADATA, false); +#endif +#if defined(HAVE_OZONE) || defined(HAVE_XMB) + SETTING_BOOL("ozone_truncate_playlist_name", &settings->bools.ozone_truncate_playlist_name, true, DEFAULT_OZONE_TRUNCATE_PLAYLIST_NAME, false); + SETTING_BOOL("ozone_sort_after_truncate_playlist_name", &settings->bools.ozone_sort_after_truncate_playlist_name, true, DEFAULT_OZONE_SORT_AFTER_TRUNCATE_PLAYLIST_NAME, false); #endif SETTING_BOOL("log_to_file", &settings->bools.log_to_file, true, DEFAULT_LOG_TO_FILE, false); SETTING_OVERRIDE(RARCH_OVERRIDE_SETTING_LOG_TO_FILE); diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index 47cafa3fa7..f63587c48d 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -777,11 +777,13 @@ DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_thumbnails_rgui, MENU_ DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_left_thumbnails_ozone, MENU_ENUM_SUBLABEL_LEFT_THUMBNAILS_OZONE) DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_ozone_menu_color_theme, MENU_ENUM_SUBLABEL_OZONE_MENU_COLOR_THEME) DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_ozone_collapse_sidebar, MENU_ENUM_SUBLABEL_OZONE_COLLAPSE_SIDEBAR) -DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_ozone_truncate_playlist_name, MENU_ENUM_SUBLABEL_OZONE_TRUNCATE_PLAYLIST_NAME) -DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_ozone_sort_after_truncate_playlist_name, MENU_ENUM_SUBLABEL_OZONE_SORT_AFTER_TRUNCATE_PLAYLIST_NAME) DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_ozone_scroll_content_metadata, MENU_ENUM_SUBLABEL_OZONE_SCROLL_CONTENT_METADATA) DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_ozone_thumbnail_scale_factor, MENU_ENUM_SUBLABEL_OZONE_THUMBNAIL_SCALE_FACTOR) #endif +#if defined(HAVE_OZONE) || defined(HAVE_XMB) +DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_ozone_truncate_playlist_name, MENU_ENUM_SUBLABEL_OZONE_TRUNCATE_PLAYLIST_NAME) +DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_ozone_sort_after_truncate_playlist_name, MENU_ENUM_SUBLABEL_OZONE_SORT_AFTER_TRUNCATE_PLAYLIST_NAME) +#endif DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_menu_thumbnail_upscale_threshold, MENU_ENUM_SUBLABEL_MENU_THUMBNAIL_UPSCALE_THRESHOLD) DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_timedate_enable, MENU_ENUM_SUBLABEL_TIMEDATE_ENABLE) DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_timedate_style, MENU_ENUM_SUBLABEL_TIMEDATE_STYLE) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 548059b870..dfa2448abc 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -267,6 +267,7 @@ enum xmb_pending_thumbnail_type typedef struct { char *fullpath; + char *console_name; uintptr_t icon; uintptr_t content_icon; float alpha; @@ -396,6 +397,7 @@ typedef struct xmb_handle uint8_t tabs[XMB_SYSTEM_TAB_MAX_LENGTH]; char title_name[255]; + char title_name_alt[255]; /* Cached texts showing current entry index / current list size */ char entry_index_str[32]; @@ -565,10 +567,11 @@ static xmb_node_t *xmb_alloc_node(void) if (!node) return NULL; - node->alpha = node->label_alpha = 0; - node->zoom = node->x = node->y = 0; - node->icon = node->content_icon = 0; - node->fullpath = NULL; + node->alpha = node->label_alpha = 0; + node->zoom = node->x = node->y = 0; + node->icon = node->content_icon = 0; + node->fullpath = NULL; + node->console_name = NULL; return node; } @@ -618,8 +621,9 @@ static xmb_node_t *xmb_copy_node(const xmb_node_t *old_node) if (!new_node) return NULL; - *new_node = *old_node; - new_node->fullpath = old_node->fullpath ? strdup(old_node->fullpath) : NULL; + *new_node = *old_node; + new_node->fullpath = old_node->fullpath ? strdup(old_node->fullpath) : NULL; + new_node->console_name = old_node->console_name ? strdup(old_node->console_name) : NULL; return new_node; } @@ -1100,11 +1104,6 @@ static char* xmb_path_dynamic_wallpaper(xmb_handle_t *xmb) const char *dir_dynamic_wallpapers = settings->paths.directory_dynamic_wallpapers; unsigned depth = (unsigned)xmb_list_get_size(xmb, MENU_LIST_PLAIN); - /* Do not update wallpaper in "Load Content" playlists */ - if ((xmb->categories_selection_ptr == 0 && depth > 4) || - (xmb->categories_selection_ptr > xmb->system_tab_end && depth > 1)) - return strdup(xmb->bg_file_path); - if (tmp) { len = fill_pathname_join_special( @@ -1114,12 +1113,17 @@ static char* xmb_path_dynamic_wallpaper(xmb_handle_t *xmb) sizeof(path)); free(tmp); } - + path[len ] = '.'; path[len+1] = 'p'; path[len+2] = 'n'; path[len+3] = 'g'; path[len+4] = '\0'; + + /* Do not update wallpaper in "Load Content" playlists */ + if ((xmb->categories_selection_ptr == 0 && depth > 4) || + (xmb->categories_selection_ptr > xmb->system_tab_end && depth > 1)) + return strdup(xmb->bg_file_path); if (!path_is_valid(path)) fill_pathname_application_special(path, sizeof(path), @@ -1980,18 +1984,29 @@ static void xmb_list_switch_new(xmb_handle_t *xmb, static void xmb_set_title(xmb_handle_t *xmb) { + xmb->title_name_alt[0] = '\0'; + if (xmb->categories_selection_ptr <= xmb->system_tab_end || (xmb->is_quick_menu && !menu_is_running_quick_menu()) || xmb->depth > 1) menu_entries_get_title(xmb->title_name, sizeof(xmb->title_name)); else { + xmb_node_t *node = (xmb_node_t*)file_list_get_userdata_at_offset( + &xmb->horizontal_list, + xmb->categories_selection_ptr - (xmb->system_tab_end + 1)); const char *path = xmb->horizontal_list.list[ xmb->categories_selection_ptr - (xmb->system_tab_end + 1)].path; if (!path) return; + /* Set alternative title when available */ + if (node && node->console_name) + strlcpy(xmb->title_name_alt, + node->console_name, + sizeof(xmb->title_name_alt)); + fill_pathname_base( xmb->title_name, path, sizeof(xmb->title_name)); path_remove_extension(xmb->title_name); @@ -2237,9 +2252,11 @@ static void xmb_context_destroy_horizontal_list(xmb_handle_t *xmb) static void xmb_init_horizontal_list(xmb_handle_t *xmb) { menu_displaylist_info_t info; - settings_t *settings = config_get_ptr(); - const char *dir_playlist = settings->paths.directory_playlist; - bool menu_content_show_playlists = settings->bools.menu_content_show_playlists; + settings_t *settings = config_get_ptr(); + const char *dir_playlist = settings->paths.directory_playlist; + bool menu_content_show_playlists = settings->bools.menu_content_show_playlists; + bool ozone_truncate_playlist_name = settings->bools.ozone_truncate_playlist_name; + bool ozone_sort_after_truncate = settings->bools.ozone_sort_after_truncate_playlist_name; menu_displaylist_info_init(&info); @@ -2253,15 +2270,75 @@ static void xmb_init_horizontal_list(xmb_handle_t *xmb) if (menu_content_show_playlists && !string_is_empty(info.path)) { + size_t i; + if (menu_displaylist_ctl( DISPLAYLIST_DATABASE_PLAYLISTS_HORIZONTAL, &info, settings)) { - size_t i; for (i = 0; i < xmb->horizontal_list.size; i++) xmb_node_allocate_userdata(xmb, (unsigned)i); menu_displaylist_process(&info); } + + /* Loop through list and set console names */ + for (i = 0; i < xmb->horizontal_list.size; i++) + { + char playlist_file_noext[255]; + char *console_name = NULL; + const char *playlist_file = xmb->horizontal_list.list[i].path; + + if (!playlist_file) + { + file_list_set_alt_at_offset(&xmb->horizontal_list, i, NULL); + continue; + } + + /* Remove extension */ + fill_pathname_base(playlist_file_noext, + playlist_file, sizeof(playlist_file_noext)); + path_remove_extension(playlist_file_noext); + + console_name = playlist_file_noext; + + /* Truncate playlist names, if required + * > Format: "Vendor - Console" + Remove everything before the hyphen + and the subsequent space */ + if (ozone_truncate_playlist_name) + { + bool hyphen_found = false; + + for (;;) + { + /* Check for "- " */ + if (*console_name == '\0') + break; + else if (*console_name == '-' && *(console_name + 1) == ' ') + { + hyphen_found = true; + break; + } + + console_name++; + } + + if (hyphen_found) + console_name += 2; + else + console_name = playlist_file_noext; + } + + /* Assign console name to list */ + file_list_set_alt_at_offset(&xmb->horizontal_list, i, console_name); + } + + /* If playlist names were truncated and option is + * enabled, re-sort list by console name */ + if (ozone_truncate_playlist_name && + ozone_sort_after_truncate && + (xmb->horizontal_list.size > 0)) + file_list_sort_on_alt(&xmb->horizontal_list); } menu_displaylist_info_free(&info); @@ -2339,6 +2416,7 @@ static void xmb_context_reset_horizontal_list( char sysname[PATH_MAX_LENGTH]; char texturepath[PATH_MAX_LENGTH]; char content_texturepath[PATH_MAX_LENGTH]; + const char *console_name = NULL; /* Add current node to playlist database name map */ RHMAP_SET_STR(xmb->playlist_db_node_map, path, node); @@ -2408,8 +2486,7 @@ static void xmb_context_reset_horizontal_list( fill_pathname_join_special(content_texturepath, iconpath, sysname, sizeof(content_texturepath)); - /* If the content icon doesn't exist return default-content */ - + /* If the content icon doesn't exist, return default-content */ if (!path_is_valid(content_texturepath)) fill_pathname_join_delim(content_texturepath, icons_path_default, FILE_PATH_CONTENT_BASENAME, '-', sizeof(content_texturepath)); @@ -2425,6 +2502,22 @@ static void xmb_context_reset_horizontal_list( image_texture_free(&ti); } + + /* Console name */ + console_name = xmb->horizontal_list.list[i].alt + ? xmb->horizontal_list.list[i].alt + : xmb->horizontal_list.list[i].path; + + if (node->console_name) + free(node->console_name); + + /* Note: console_name will *always* be valid here, + * but provide a fallback to prevent NULL pointer + * dereferencing in case of unknown errors... */ + if (console_name) + node->console_name = strdup(console_name); + else + node->console_name = strdup(path); } else if (string_ends_with_size(xmb->horizontal_list.list[i].label, ".lvw", strlen(xmb->horizontal_list.list[i].label), STRLEN_CONST(".lvw"))) @@ -5401,8 +5494,10 @@ static void xmb_frame(void *data, video_frame_info_t *video_info) selection = menu_navigation_get_selection(); + /* Use alternative title if available */ strlcpy(title_truncated, - xmb->title_name, sizeof(title_truncated)); + !string_is_empty(xmb->title_name_alt) ? xmb->title_name_alt : xmb->title_name, + sizeof(title_truncated)); if (!menu_xmb_vertical_fade_factor && selection > 1) { diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 66f976941b..9df5e22d57 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -6162,6 +6162,7 @@ unsigned menu_displaylist_build_list( { bool playlist_show_sublabels = settings->bools.playlist_show_sublabels; bool history_list_enable = settings->bools.history_list_enable; + bool truncate_playlist = settings->bools.ozone_truncate_playlist_name; menu_displaylist_build_info_selective_t build_list[] = { {MENU_ENUM_LABEL_HISTORY_LIST_ENABLE, PARSE_ONLY_BOOL, true}, {MENU_ENUM_LABEL_CONTENT_HISTORY_SIZE, PARSE_ONLY_UINT, false}, @@ -6180,7 +6181,7 @@ unsigned menu_displaylist_build_list( {MENU_ENUM_LABEL_PLAYLIST_FUZZY_ARCHIVE_MATCH, PARSE_ONLY_BOOL, true}, {MENU_ENUM_LABEL_SCAN_WITHOUT_CORE_MATCH, PARSE_ONLY_BOOL, true}, {MENU_ENUM_LABEL_OZONE_TRUNCATE_PLAYLIST_NAME, PARSE_ONLY_BOOL, true}, - {MENU_ENUM_LABEL_OZONE_SORT_AFTER_TRUNCATE_PLAYLIST_NAME, PARSE_ONLY_BOOL, true}, + {MENU_ENUM_LABEL_OZONE_SORT_AFTER_TRUNCATE_PLAYLIST_NAME, PARSE_ONLY_BOOL, false}, {MENU_ENUM_LABEL_CONTENT_RUNTIME_LOG, PARSE_ONLY_BOOL, true}, {MENU_ENUM_LABEL_CONTENT_RUNTIME_LOG_AGGREGATE, PARSE_ONLY_BOOL, true}, {MENU_ENUM_LABEL_PLAYLIST_PORTABLE_PATHS, PARSE_ONLY_BOOL, true}, @@ -6199,6 +6200,10 @@ unsigned menu_displaylist_build_list( if (history_list_enable) build_list[i].checked = true; break; + case MENU_ENUM_LABEL_OZONE_SORT_AFTER_TRUNCATE_PLAYLIST_NAME: + if (truncate_playlist) + build_list[i].checked = true; + break; default: break; } @@ -10222,6 +10227,7 @@ unsigned menu_displaylist_build_list( bool menu_materialui_icons_enable = settings->bools.menu_materialui_icons_enable; bool menu_materialui_show_nav_bar = settings->bools.menu_materialui_show_nav_bar; bool menu_use_preferred_system_color_theme = settings->bools.menu_use_preferred_system_color_theme; + bool truncate_playlist = settings->bools.ozone_truncate_playlist_name; unsigned menu_rgui_color_theme = settings->uints.menu_rgui_color_theme; unsigned menu_rgui_particle_effect = settings->uints.menu_rgui_particle_effect; unsigned menu_screensaver_timeout = settings->uints.menu_screensaver_timeout; @@ -10267,7 +10273,7 @@ unsigned menu_displaylist_build_list( {MENU_ENUM_LABEL_XMB_MENU_COLOR_THEME, PARSE_ONLY_UINT, true}, {MENU_ENUM_LABEL_OZONE_COLLAPSE_SIDEBAR, PARSE_ONLY_BOOL, true}, {MENU_ENUM_LABEL_OZONE_TRUNCATE_PLAYLIST_NAME, PARSE_ONLY_BOOL, true}, - {MENU_ENUM_LABEL_OZONE_SORT_AFTER_TRUNCATE_PLAYLIST_NAME, PARSE_ONLY_BOOL, true}, + {MENU_ENUM_LABEL_OZONE_SORT_AFTER_TRUNCATE_PLAYLIST_NAME, PARSE_ONLY_BOOL, false}, {MENU_ENUM_LABEL_MATERIALUI_ICONS_ENABLE, PARSE_ONLY_BOOL, true}, {MENU_ENUM_LABEL_MATERIALUI_PLAYLIST_ICONS_ENABLE, PARSE_ONLY_BOOL, false}, {MENU_ENUM_LABEL_MATERIALUI_LANDSCAPE_LAYOUT_OPTIMIZATION, PARSE_ONLY_UINT, true}, @@ -10339,6 +10345,10 @@ unsigned menu_displaylist_build_list( if (!menu_use_preferred_system_color_theme) build_list[i].checked = true; break; + case MENU_ENUM_LABEL_OZONE_SORT_AFTER_TRUNCATE_PLAYLIST_NAME: + if (truncate_playlist) + build_list[i].checked = true; + break; default: break; } diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 47f2b41e4d..109a492fd9 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -19523,8 +19523,9 @@ static bool setting_append_list( SD_FLAG_NONE ); -#ifdef HAVE_OZONE - if (string_is_equal(settings->arrays.menu_driver, "ozone")) +#if defined(HAVE_OZONE) || defined(HAVE_XMB) + if (string_is_equal(settings->arrays.menu_driver, "ozone") || + string_is_equal(settings->arrays.menu_driver, "xmb")) { CONFIG_BOOL( list, list_info, @@ -19540,6 +19541,9 @@ static bool setting_append_list( general_write_handler, general_read_handler, SD_FLAG_NONE); + (*list)[list_info->index - 1].action_ok = setting_bool_action_left_with_refresh; + (*list)[list_info->index - 1].action_left = setting_bool_action_left_with_refresh; + (*list)[list_info->index - 1].action_right = setting_bool_action_right_with_refresh; CONFIG_BOOL( list, list_info,