From c7d9f2f7e82d6c886ef4302b476c58d61effa2b1 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 4 Jul 2015 18:57:04 +0200 Subject: [PATCH] Show prettified core info display names in Core Updater --- core_info.c | 33 +++++++++++++++++++++++++++++++++ core_info.h | 2 ++ menu/cbs/menu_cbs_get_value.c | 12 ++++++++---- menu/menu_displaylist.c | 21 ++++++++++++++++++++- 4 files changed, 63 insertions(+), 5 deletions(-) diff --git a/core_info.c b/core_info.c index 959da20c7e..1ea7b7eec0 100644 --- a/core_info.c +++ b/core_info.c @@ -377,6 +377,39 @@ bool core_info_list_get_display_name(core_info_list_t *core_info_list, return false; } +bool core_info_get_display_name(const char *path, char *s, size_t len) +{ + size_t i; + char *core_name = NULL; + config_file_t *conf = NULL; + + if (!path_file_exists(path)) + return false; + + conf = config_file_new(path); + + if (!conf) + goto error; + + config_get_string(conf, "corename", + &core_name); + + config_file_free(conf); + + if (!core_name) + goto error; + + if (!conf) + return false; + + strlcpy(s, core_name, len); + + return true; + +error: + return false; +} + bool core_info_list_get_info(core_info_list_t *core_info_list, core_info_t *out_info, const char *path) { diff --git a/core_info.h b/core_info.h index 96366bacc2..f620836cde 100644 --- a/core_info.h +++ b/core_info.h @@ -104,6 +104,8 @@ const char *core_info_list_get_all_extensions(core_info_list_t *list); bool core_info_list_get_display_name(core_info_list_t *list, const char *path, char *buf, size_t size); +bool core_info_get_display_name_from_file(const char *path, char *buf, size_t size); + void core_info_get_name(const char *path, char *s, size_t len); #ifdef __cplusplus diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index e41d84de31..d1268f56e2 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -802,7 +802,7 @@ static void menu_action_setting_disp_set_label_menu_file_filter( path, "(FILTER)", s2, len2); } -static void menu_action_setting_disp_set_label_menu_file_url( +static void menu_action_setting_disp_set_label_menu_file_url_core( file_list_t* list, unsigned *w, unsigned type, unsigned i, const char *label, @@ -811,8 +811,12 @@ static void menu_action_setting_disp_set_label_menu_file_url( const char *path, char *s2, size_t len2) { - menu_action_setting_generic_disp_set_label(w, s, len, - path, "(URL)", s2, len2); + const char *alt = NULL; + strlcpy(s, "(CORE)", len); + menu_list_get_alt_at_offset(list, i, &alt); + *w = strlen(s); + if (alt) + strlcpy(s2, alt, len2); } static void menu_action_setting_disp_set_label_menu_file_rdb( @@ -1066,7 +1070,7 @@ static int menu_cbs_init_bind_get_string_representation_compare_type( break; case MENU_FILE_DOWNLOAD_CORE: cbs->action_get_value = - menu_action_setting_disp_set_label_menu_file_url; + menu_action_setting_disp_set_label_menu_file_url_core; break; case MENU_FILE_RDB: cbs->action_get_value = diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index a11e50c7b6..36b58e1627 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -45,7 +45,7 @@ extern size_t core_len; static void print_buf_lines(file_list_t *list, char *buf, int buf_size, unsigned type) { - int i; + int i, j = 0; char c; char *line_start = buf; @@ -74,6 +74,25 @@ static void print_buf_lines(file_list_t *list, char *buf, int buf_size, menu_list_push(list, line_start, "", type, 0, 0); + if (type == MENU_FILE_DOWNLOAD_CORE) + { + char core_path[PATH_MAX_LENGTH] = {0}; + char display_name[PATH_MAX_LENGTH] = {0}; + settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); + + fill_pathname_join(core_path, settings->libretro_info_path, + line_start, sizeof(core_path)); + + path_remove_extension(core_path); + path_remove_extension(core_path); + strlcat(core_path, ".info", sizeof(core_path)); + + if (core_info_get_display_name( + core_path, display_name, sizeof(display_name))) + menu_list_set_alt_at_offset(list, j, display_name); + } + j++; /* Restore the saved char */ *(buf + i + 1) = c;