mirror of
https://github.com/libretro/RetroArch
synced 2025-02-10 03:39:56 +00:00
Add core_info_list_get_display_name.
Avoids duped code in RGUI.
This commit is contained in:
parent
34ce65d9c4
commit
c813e787cb
17
core_info.c
17
core_info.c
@ -49,6 +49,8 @@ core_info_list_t *core_info_list_new(const char *modules_path)
|
||||
{
|
||||
char info_path[PATH_MAX];
|
||||
core_info[i].path = strdup(contents->elems[i].data);
|
||||
if (!core_info[i].path)
|
||||
break;
|
||||
|
||||
#if defined(IOS) || defined(HAVE_BB10) || defined(__QNX__)
|
||||
// Libs are deployed with a suffix (*_ios.dylib, *_qnx.so, etc).
|
||||
@ -131,6 +133,21 @@ void core_info_list_free(core_info_list_t *core_info_list)
|
||||
free(core_info_list);
|
||||
}
|
||||
|
||||
bool core_info_list_get_display_name(core_info_list_t *core_info_list, const char *path, char *buf, size_t size)
|
||||
{
|
||||
for (size_t i = 0; i < core_info_list->count; i++)
|
||||
{
|
||||
const core_info_t *info = &core_info_list->list[i];
|
||||
if (!strcmp(info->path, path) && info->display_name)
|
||||
{
|
||||
strlcpy(buf, info->display_name, size);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool core_info_does_support_any_file(const core_info_t *core, const struct string_list *list)
|
||||
{
|
||||
if (!list || !core || !core->supported_extensions_list)
|
||||
|
@ -50,6 +50,8 @@ void core_info_list_get_supported_cores(core_info_list_t *core_info_list, const
|
||||
|
||||
const char *core_info_list_get_all_extensions(core_info_list_t *core_info_list);
|
||||
|
||||
bool core_info_list_get_display_name(core_info_list_t *core_info_list, const char *path, char *buf, size_t size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -213,17 +213,12 @@ static void rgui_resolve_libretro_names(rgui_list_t *list, const char *dir)
|
||||
|
||||
char core_path[PATH_MAX];
|
||||
fill_pathname_join(core_path, dir, path, sizeof(core_path));
|
||||
char info_path[PATH_MAX];
|
||||
fill_pathname(info_path, core_path, ".info", sizeof(info_path));
|
||||
|
||||
config_file_t *conf = config_file_new(info_path);
|
||||
if (!conf)
|
||||
continue;
|
||||
|
||||
char display_name[256];
|
||||
if (config_get_array(conf, "display_name", display_name, sizeof(display_name)))
|
||||
if (rgui->core_info &&
|
||||
core_info_list_get_display_name(rgui->core_info,
|
||||
core_path, display_name, sizeof(display_name)))
|
||||
rgui_list_set_alt_at_offset(list, i, display_name);
|
||||
config_file_free(conf);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user