mirror of
https://github.com/libretro/RetroArch
synced 2025-02-07 21:39:54 +00:00
Resolve libretro core names in RGUI.
This commit is contained in:
parent
9e67406c40
commit
a53680a57e
@ -189,6 +189,7 @@ void shader_manager_get_str(struct gfx_shader *shader,
|
||||
struct rgui_file
|
||||
{
|
||||
char *path;
|
||||
char *alt;
|
||||
unsigned type;
|
||||
size_t directory_ptr;
|
||||
};
|
||||
@ -209,6 +210,7 @@ void rgui_list_push(void *userdata,
|
||||
}
|
||||
|
||||
list->list[list->size].path = strdup(path);
|
||||
list->list[list->size].alt = NULL;
|
||||
list->list[list->size].type = type;
|
||||
list->list[list->size].directory_ptr = directory_ptr;
|
||||
list->size++;
|
||||
@ -234,10 +236,27 @@ void rgui_list_free(rgui_list_t *list)
|
||||
void rgui_list_clear(rgui_list_t *list)
|
||||
{
|
||||
for (size_t i = 0; i < list->size; i++)
|
||||
{
|
||||
free(list->list[i].path);
|
||||
free(list->list[i].alt);
|
||||
}
|
||||
list->size = 0;
|
||||
}
|
||||
|
||||
void rgui_list_set_alt_at_offset(rgui_list_t *list, size_t index,
|
||||
const char *alt)
|
||||
{
|
||||
free(list->list[index].alt);
|
||||
list->list[index].alt = strdup(alt);
|
||||
}
|
||||
|
||||
void rgui_list_get_alt_at_offset(const rgui_list_t *list, size_t index,
|
||||
const char **alt)
|
||||
{
|
||||
if (alt)
|
||||
*alt = list->list[index].alt ? list->list[index].alt : list->list[index].path;
|
||||
}
|
||||
|
||||
void rgui_list_get_at_offset(const rgui_list_t *list, size_t index,
|
||||
const char **path, unsigned *file_type)
|
||||
{
|
||||
|
@ -200,6 +200,37 @@ static int rgui_core_setting_toggle(unsigned setting, rgui_action_t action)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef HAVE_DYNAMIC
|
||||
static void rgui_resolve_libretro_names(rgui_list_t *list, const char *dir)
|
||||
{
|
||||
for (size_t i = 0; i < list->size; i++)
|
||||
{
|
||||
const char *path;
|
||||
unsigned type = 0;
|
||||
rgui_list_get_at_offset(list, i, &path, &type);
|
||||
|
||||
char core_path[PATH_MAX];
|
||||
fill_pathname_join(core_path, dir, path, sizeof(core_path));
|
||||
|
||||
if (type != RGUI_FILE_PLAIN)
|
||||
continue;
|
||||
|
||||
// TODO: If we standardize on .info files later, we could use them here perhaps.
|
||||
|
||||
struct retro_system_info info = {0};
|
||||
// Have to employ some heuristics on which cores to load.
|
||||
// Loading arbitrary libraries is dangerous (some libs can crash in global constructors ...)
|
||||
if (strstr(path, "retro") && libretro_get_system_info(core_path, &info, NULL))
|
||||
{
|
||||
char desc[256];
|
||||
snprintf(desc, sizeof(desc), "%s %s", info.library_name, info.library_version);
|
||||
libretro_free_system_info(&info);
|
||||
rgui_list_set_alt_at_offset(rgui->selection_buf, i, desc);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static int rgui_settings_toggle_setting(rgui_handle_t *rgui, unsigned setting, rgui_action_t action, unsigned menu_type)
|
||||
{
|
||||
#ifdef HAVE_SHADER_MANAGER
|
||||
@ -1314,6 +1345,11 @@ static int rgui_iterate(void *data, unsigned action)
|
||||
else
|
||||
rgui_directory_parse(rgui, dir, menu_type, rgui->selection_buf);
|
||||
|
||||
#ifdef HAVE_DYNAMIC
|
||||
if (menu_type == RGUI_SETTINGS_CORE)
|
||||
rgui_resolve_libretro_names(rgui->selection_buf, dir);
|
||||
#endif
|
||||
|
||||
// Before a refresh, we could have deleted a file on disk, causing
|
||||
// selection_ptr to suddendly be out of range. Ensure it doesn't overflow.
|
||||
if (rgui->selection_ptr >= rgui->selection_buf->size && rgui->selection_buf->size)
|
||||
|
@ -359,6 +359,25 @@ static void render_text(rgui_handle_t *rgui)
|
||||
shader_manager_get_str(&rgui->shader, type_str, sizeof(type_str), type);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#ifdef HAVE_DYNAMIC
|
||||
// Pretty-print libretro cores from menu.
|
||||
if (menu_type == RGUI_SETTINGS_CORE)
|
||||
{
|
||||
if (type == RGUI_FILE_PLAIN)
|
||||
{
|
||||
strlcpy(type_str, "(CORE)", sizeof(type_str));
|
||||
rgui_list_get_alt_at_offset(rgui->selection_buf, i, &path);
|
||||
w = 6;
|
||||
}
|
||||
else
|
||||
{
|
||||
strlcpy(type_str, "(DIR)", sizeof(type_str));
|
||||
type = RGUI_FILE_DIRECTORY;
|
||||
w = 5;
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (menu_type == RGUI_SETTINGS_CORE ||
|
||||
menu_type == RGUI_SETTINGS_CONFIG ||
|
||||
|
@ -43,6 +43,11 @@ void rgui_list_get_last(const rgui_list_t *list,
|
||||
void rgui_list_get_at_offset(const rgui_list_t *list, size_t index,
|
||||
const char **path, unsigned *type);
|
||||
|
||||
void rgui_list_set_alt_at_offset(rgui_list_t *list, size_t index,
|
||||
const char *alt);
|
||||
void rgui_list_get_alt_at_offset(const rgui_list_t *list, size_t index,
|
||||
const char **alt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user