mirror of
https://github.com/libretro/RetroArch
synced 2025-02-06 09:40:06 +00:00
Merge pull request #325 from libretro/libretrodesc
Resolve libretro core names in RGUI.
This commit is contained in:
commit
425c4a19ab
@ -189,6 +189,7 @@ void shader_manager_get_str(struct gfx_shader *shader,
|
|||||||
struct rgui_file
|
struct rgui_file
|
||||||
{
|
{
|
||||||
char *path;
|
char *path;
|
||||||
|
char *alt;
|
||||||
unsigned type;
|
unsigned type;
|
||||||
size_t directory_ptr;
|
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].path = strdup(path);
|
||||||
|
list->list[list->size].alt = NULL;
|
||||||
list->list[list->size].type = type;
|
list->list[list->size].type = type;
|
||||||
list->list[list->size].directory_ptr = directory_ptr;
|
list->list[list->size].directory_ptr = directory_ptr;
|
||||||
list->size++;
|
list->size++;
|
||||||
@ -234,10 +236,27 @@ void rgui_list_free(rgui_list_t *list)
|
|||||||
void rgui_list_clear(rgui_list_t *list)
|
void rgui_list_clear(rgui_list_t *list)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < list->size; i++)
|
for (size_t i = 0; i < list->size; i++)
|
||||||
|
{
|
||||||
free(list->list[i].path);
|
free(list->list[i].path);
|
||||||
|
free(list->list[i].alt);
|
||||||
|
}
|
||||||
list->size = 0;
|
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,
|
void rgui_list_get_at_offset(const rgui_list_t *list, size_t index,
|
||||||
const char **path, unsigned *file_type)
|
const char **path, unsigned *file_type)
|
||||||
{
|
{
|
||||||
|
@ -201,6 +201,32 @@ static int rgui_core_setting_toggle(unsigned setting, rgui_action_t action)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
if (type != RGUI_FILE_PLAIN)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
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)))
|
||||||
|
rgui_list_set_alt_at_offset(list, i, display_name);
|
||||||
|
config_file_free(conf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int rgui_settings_toggle_setting(rgui_handle_t *rgui, unsigned setting, rgui_action_t action, unsigned menu_type)
|
static int rgui_settings_toggle_setting(rgui_handle_t *rgui, unsigned setting, rgui_action_t action, unsigned menu_type)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SHADER_MANAGER
|
#ifdef HAVE_SHADER_MANAGER
|
||||||
@ -1389,6 +1415,9 @@ static int rgui_iterate(void *data, unsigned action)
|
|||||||
else
|
else
|
||||||
rgui_directory_parse(rgui, dir, menu_type, rgui->selection_buf);
|
rgui_directory_parse(rgui, dir, menu_type, rgui->selection_buf);
|
||||||
|
|
||||||
|
if (menu_type == RGUI_SETTINGS_CORE)
|
||||||
|
rgui_resolve_libretro_names(rgui->selection_buf, dir);
|
||||||
|
|
||||||
// Before a refresh, we could have deleted a file on disk, causing
|
// 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.
|
// 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)
|
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);
|
shader_manager_get_str(&rgui->shader, type_str, sizeof(type_str), type);
|
||||||
}
|
}
|
||||||
else
|
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
|
#endif
|
||||||
if (menu_type == RGUI_SETTINGS_CORE ||
|
if (menu_type == RGUI_SETTINGS_CORE ||
|
||||||
menu_type == RGUI_SETTINGS_CONFIG ||
|
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,
|
void rgui_list_get_at_offset(const rgui_list_t *list, size_t index,
|
||||||
const char **path, unsigned *type);
|
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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user