From 8f3280129282706ce86a98d6584c3407aec105bb Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 29 Apr 2017 20:27:40 +0200 Subject: [PATCH] It should now properly show supported roms again when no core info file is found and we have already loaded a core --- menu/cbs/menu_cbs_deferred_push.c | 56 +++++++++++++++++++++++++++---- menu/menu_entries.c | 35 +++++++++++++++++++ menu/menu_entries.h | 4 +++ 3 files changed, 89 insertions(+), 6 deletions(-) diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index 794864d675..fda7c524a7 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -695,13 +695,57 @@ static int general_push(menu_displaylist_info_t *info, } break; case PUSH_DETECT_CORE_LIST: - if (list && !string_is_empty(list->all_ext)) - strlcpy(info->exts, list->all_ext, sizeof(info->exts)); - else if (system_menu->valid_extensions) { - if (!string_is_empty(system_menu->valid_extensions)) - strlcpy(info->exts, system_menu->valid_extensions, - sizeof(info->exts)); + char newstring[PATH_MAX_LENGTH]; + union string_list_elem_attr attr; + struct string_list *str_list2 = string_list_new(); + + newstring[0] = '\0'; + attr.i = 0; + + if (system_menu->valid_extensions) + { + if (!string_is_empty(system_menu->valid_extensions)) + { + unsigned x; + struct string_list *str_list = string_split(system_menu->valid_extensions, "|"); + + for (x = 0; x < str_list->size; x++) + { + const char *elem = str_list->elems[x].data; + string_list_append(str_list2, elem, attr); + } + + string_list_free(str_list); + } + } + + if (menu_entries_current_core_is_no_core()) + { + if (list && !string_is_empty(list->all_ext)) + { + unsigned x; + struct string_list *str_list = string_split(list->all_ext, "|"); + + for (x = 0; x < str_list->size; x++) + { + if (!string_list_find_elem(str_list2, str_list->elems[x].data)) + { + const char *elem = str_list->elems[x].data; + string_list_append(str_list2, elem, attr); + } + } + + string_list_free(str_list); + } + } + + string_list_join_concat(newstring, sizeof(newstring), + str_list2, "|"); + + strlcpy(info->exts, newstring, sizeof(info->exts)); + + string_list_free(str_list2); } break; } diff --git a/menu/menu_entries.c b/menu/menu_entries.c index 82b7d172e2..413e7f745f 100644 --- a/menu/menu_entries.c +++ b/menu/menu_entries.c @@ -258,6 +258,41 @@ int menu_entries_get_title(char *s, size_t len) return 0; } +int menu_entries_get_core_name(char *s, size_t len) +{ + struct retro_system_info *system = NULL; + rarch_system_info_t *info = NULL; + const char *core_name = NULL; + + menu_driver_ctl(RARCH_MENU_CTL_SYSTEM_INFO_GET, + &system); + + core_name = system->library_name; + info = runloop_get_system_info(); + + if (string_is_empty(core_name) && info) + core_name = info->info.library_name; + if (string_is_empty(core_name)) + core_name = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_CORE); + + snprintf(s, len, "%s", core_name); + + return 0; +} + +bool menu_entries_current_core_is_no_core(void) +{ + char corename[255]; + const char *no_core_str = NULL; + + corename[0] = '\0'; + + menu_entries_get_core_name(corename, sizeof(corename)); + + no_core_str = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_CORE); + + return string_is_equal(corename, no_core_str); +} /* Sets 's' to the name of the current core * (shown at the top of the UI). */ diff --git a/menu/menu_entries.h b/menu/menu_entries.h index bb58b5f5b7..1cdbad3bfb 100644 --- a/menu/menu_entries.h +++ b/menu/menu_entries.h @@ -136,8 +136,12 @@ void menu_entries_get(size_t i, void *data_entry); int menu_entries_get_title(char *title, size_t title_len); +bool menu_entries_current_core_is_no_core(void); + int menu_entries_get_core_title(char *title_msg, size_t title_msg_len); +int menu_entries_get_core_name(char *s, size_t len); + file_list_t *menu_entries_get_selection_buf_ptr(size_t idx); file_list_t *menu_entries_get_menu_stack_ptr(size_t idx);