From da1931ad9fb227c710b7e155192268715fb37d48 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 31 Oct 2015 17:44:42 +0100 Subject: [PATCH] First working implementation of playlist associations --- core_info.c | 6 +++--- core_info.h | 3 +++ menu/cbs/menu_cbs_ok.c | 27 ++++++++++++++++++++++++--- retroarch.c | 7 ++----- retroarch.h | 3 +-- 5 files changed, 33 insertions(+), 13 deletions(-) diff --git a/core_info.c b/core_info.c index 5637bd7d953e..24bf4a438bf0 100644 --- a/core_info.c +++ b/core_info.c @@ -538,7 +538,7 @@ void core_info_list_get_supported_cores(core_info_list_t *core_info_list, *num_infos = supported; } -static core_info_t *find_core_info(core_info_list_t *list, +core_info_t *core_info_find(core_info_list_t *list, const char *core) { size_t i; @@ -579,7 +579,7 @@ void core_info_list_update_missing_firmware(core_info_list_t *core_info_list, if (!core_info_list || !core) return; - if (!(info = find_core_info(core_info_list, core))) + if (!(info = core_info_find(core_info_list, core))) return; for (i = 0; i < info->firmware_count; i++) @@ -607,7 +607,7 @@ void core_info_list_get_missing_firmware(core_info_list_t *core_info_list, *firmware = NULL; *num_firmware = 0; - if (!(info = find_core_info(core_info_list, core))) + if (!(info = core_info_find(core_info_list, core))) return; *firmware = info->firmware; diff --git a/core_info.h b/core_info.h index d76c2c8ba1a5..86337fa307b2 100644 --- a/core_info.h +++ b/core_info.h @@ -101,6 +101,9 @@ bool core_info_list_get_info(core_info_list_t *list, const char *core_info_list_get_all_extensions(void); +core_info_t *core_info_find(core_info_list_t *list, + const char *core); + bool core_info_list_get_display_name(core_info_list_t *list, const char *path, char *buf, size_t size); diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 1d07e633862d..c7c066e66647 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -466,7 +466,6 @@ static int action_ok_playlist_entry(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { size_t selection; - char new_core_path[PATH_MAX_LENGTH]; uint32_t core_name_hash, core_path_hash; const char *entry_path = NULL; const char *entry_label = NULL; @@ -526,11 +525,33 @@ static int action_ok_playlist_entry(const char *path, (core_name_hash == MENU_VALUE_DETECT) ) { - if (!menu_playlist_find_associated_core(menu->db_playlist_file, new_core_path, sizeof(new_core_path))) + char new_core_path[PATH_MAX_LENGTH]; + core_info_t *core_info = NULL; + global_t *global = global_get_ptr(); + const char *path_base = path_basename(menu->db_playlist_file); + bool found_associated_core = menu_playlist_find_associated_core( + path_base, new_core_path, sizeof(new_core_path)); + + if (!(core_info = core_info_find(global->core_info.list, new_core_path))) + found_associated_core = false; + + if (found_associated_core) + { + char new_display_name[PATH_MAX_LENGTH]; + + strlcpy(new_display_name, core_info->display_name, sizeof(new_display_name)); + content_playlist_update(menu->playlist, selection_ptr, + menu->playlist->entries[selection_ptr].path, menu->playlist->entries[selection_ptr].label, + new_core_path , new_display_name, + menu->playlist->entries[selection_ptr].crc32, + menu->playlist->entries[selection_ptr].db_name); + content_playlist_write_file(menu->playlist); + } + else return action_ok_file_load_with_detect_core(entry_path, label, type, selection_ptr, entry_idx); } - rarch_playlist_load_content(playlist, new_core_path, selection_ptr); + rarch_playlist_load_content(playlist, selection_ptr); if (is_history) { diff --git a/retroarch.c b/retroarch.c index 103afe8d19b5..90c6d4d2d24f 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1491,10 +1491,10 @@ void rarch_main_deinit(void) * * Initializes core and loads content based on playlist entry. **/ -void rarch_playlist_load_content(void *data, const char *core_path, unsigned idx) +void rarch_playlist_load_content(void *data, unsigned idx) { unsigned i; - char new_core_path[PATH_MAX_LENGTH]; + const char *core_path = NULL; const char *path = NULL; char *path_check = NULL; char *path_tolower = NULL; @@ -1508,9 +1508,6 @@ void rarch_playlist_load_content(void *data, const char *core_path, unsigned idx if (!playlist) return; - if (!core_path) - core_path = new_core_path; - content_playlist_get_index(playlist, idx, &path, NULL, &core_path, NULL, NULL, NULL); diff --git a/retroarch.h b/retroarch.h index 1a75e01789f5..5fa9a679b701 100644 --- a/retroarch.h +++ b/retroarch.h @@ -165,12 +165,11 @@ void rarch_main_deinit(void); /** * rarch_playlist_load_content: * @playlist : Playlist handle. - * @path : Path to associated core (optional). * @idx : Index in playlist. * * Initializes core and loads content based on playlist entry. **/ -void rarch_playlist_load_content(void *data, const char *core_path, unsigned index); +void rarch_playlist_load_content(void *data, unsigned index); /** * rarch_defer_core: