mirror of
https://github.com/libretro/RetroArch
synced 2025-03-03 22:14:17 +00:00
Show system icons in explore view
This commit is contained in:
parent
84d849f49b
commit
5229b255b5
@ -269,6 +269,32 @@ void fill_pathname_application_special(char *s,
|
||||
#endif
|
||||
}
|
||||
|
||||
break;
|
||||
case APPLICATION_SPECIAL_DIRECTORY_ASSETS_ICONS:
|
||||
{
|
||||
#ifdef HAVE_MENU
|
||||
settings_t *settings = config_get_ptr();
|
||||
const char *menu_ident = settings->arrays.menu_driver;
|
||||
|
||||
if (string_is_equal(menu_ident, "xmb"))
|
||||
{
|
||||
fill_pathname_application_special(s, len, APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_ICONS);
|
||||
}
|
||||
else if (string_is_equal(menu_ident, "glui"))
|
||||
{
|
||||
fill_pathname_application_special(s, len, APPLICATION_SPECIAL_DIRECTORY_ASSETS_MATERIALUI_ICONS);
|
||||
}
|
||||
else if (string_is_equal(menu_ident, "ozone"))
|
||||
{
|
||||
fill_pathname_application_special(s, len, APPLICATION_SPECIAL_DIRECTORY_ASSETS_OZONE_ICONS);
|
||||
}
|
||||
else if (len)
|
||||
{
|
||||
s[0] = '\0';
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
break;
|
||||
case APPLICATION_SPECIAL_DIRECTORY_ASSETS_OZONE:
|
||||
#ifdef HAVE_OZONE
|
||||
@ -288,6 +314,30 @@ void fill_pathname_application_special(char *s,
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case APPLICATION_SPECIAL_DIRECTORY_ASSETS_OZONE_ICONS:
|
||||
#ifdef HAVE_OZONE
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
const char *dir_assets = settings->paths.directory_assets;
|
||||
|
||||
strlcpy(s, dir_assets, len);
|
||||
fill_pathname_slash(s, len);
|
||||
|
||||
/* xmb */
|
||||
strlcat(s, "xmb", len);
|
||||
fill_pathname_slash(s, len);
|
||||
|
||||
/* monochrome */
|
||||
strlcat(s, "monochrome", len);
|
||||
fill_pathname_slash(s, len);
|
||||
|
||||
/* Icons path */
|
||||
strlcat(s, "png", len);
|
||||
fill_pathname_slash(s, len);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
case APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB:
|
||||
#ifdef HAVE_XMB
|
||||
{
|
||||
|
@ -118,7 +118,9 @@ enum application_special_type
|
||||
APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_ICONS,
|
||||
APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_FONT,
|
||||
APPLICATION_SPECIAL_DIRECTORY_ASSETS_OZONE,
|
||||
APPLICATION_SPECIAL_DIRECTORY_ASSETS_OZONE_ICONS,
|
||||
APPLICATION_SPECIAL_DIRECTORY_ASSETS_SOUNDS,
|
||||
APPLICATION_SPECIAL_DIRECTORY_ASSETS_ICONS,
|
||||
APPLICATION_SPECIAL_DIRECTORY_THUMBNAILS_CHEEVOS_BADGES,
|
||||
APPLICATION_SPECIAL_DIRECTORY_THUMBNAILS_DISCORD_AVATARS
|
||||
};
|
||||
|
@ -103,8 +103,6 @@ static void ozone_menu_animation_update_time(
|
||||
|
||||
static void *ozone_init(void **userdata, bool video_is_threaded)
|
||||
{
|
||||
char xmb_path[PATH_MAX_LENGTH];
|
||||
char monochrome_path[PATH_MAX_LENGTH];
|
||||
bool fallback_color_theme = false;
|
||||
unsigned width, height, color_theme = 0;
|
||||
ozone_handle_t *ozone = NULL;
|
||||
@ -281,28 +279,10 @@ static void *ozone_init(void **userdata, bool video_is_threaded)
|
||||
sizeof(ozone->tab_path)
|
||||
);
|
||||
|
||||
/* XMB monochrome */
|
||||
fill_pathname_join(
|
||||
xmb_path,
|
||||
directory_assets,
|
||||
"xmb",
|
||||
sizeof(xmb_path)
|
||||
);
|
||||
|
||||
fill_pathname_join(
|
||||
monochrome_path,
|
||||
xmb_path,
|
||||
"monochrome",
|
||||
sizeof(monochrome_path)
|
||||
);
|
||||
|
||||
/* Icons path */
|
||||
fill_pathname_join(
|
||||
ozone->icons_path,
|
||||
monochrome_path,
|
||||
"png",
|
||||
sizeof(ozone->icons_path)
|
||||
);
|
||||
fill_pathname_application_special(ozone->icons_path,
|
||||
sizeof(ozone->icons_path),
|
||||
APPLICATION_SPECIAL_DIRECTORY_ASSETS_OZONE_ICONS);
|
||||
|
||||
last_use_preferred_system_color_theme = settings->bools.menu_use_preferred_system_color_theme;
|
||||
gfx_animation_set_update_time_cb(ozone_menu_animation_update_time);
|
||||
|
@ -342,6 +342,14 @@ uintptr_t ozone_entries_icon_get_texture(ozone_handle_t *ozone,
|
||||
return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_RESUME];
|
||||
case MENU_ENUM_LABEL_START_VIDEO_PROCESSOR:
|
||||
return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_MOVIE];
|
||||
#ifdef HAVE_LIBRETRODB
|
||||
case MENU_ENUM_LABEL_EXPLORE_ITEM:
|
||||
{
|
||||
uintptr_t icon = menu_explore_get_entry_icon(type);
|
||||
if (icon) return icon;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -2752,6 +2752,14 @@ static uintptr_t xmb_icon_get_id(xmb_handle_t *xmb,
|
||||
return xmb->textures.list[XMB_TEXTURE_RESUME];
|
||||
case MENU_ENUM_LABEL_START_VIDEO_PROCESSOR:
|
||||
return xmb->textures.list[XMB_TEXTURE_MOVIE];
|
||||
#ifdef HAVE_LIBRETRODB
|
||||
case MENU_ENUM_LABEL_EXPLORE_ITEM:
|
||||
{
|
||||
uintptr_t icon = menu_explore_get_entry_icon(type);
|
||||
if (icon) return icon;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -482,6 +482,9 @@ void menu_display_handle_wallpaper_upload(retro_task_t *task,
|
||||
void *user_data, const char *err);
|
||||
|
||||
#if defined(HAVE_LIBRETRODB)
|
||||
uintptr_t menu_explore_get_entry_icon(unsigned type);
|
||||
void menu_explore_context_init(void);
|
||||
void menu_explore_context_deinit(void);
|
||||
void menu_explore_free(void);
|
||||
#endif
|
||||
|
||||
|
@ -58,6 +58,10 @@ enum
|
||||
EXPLORE_BY_SYSTEM,
|
||||
EXPLORE_CAT_COUNT,
|
||||
|
||||
EXPLORE_ICONS_OFF = 0,
|
||||
EXPLORE_ICONS_CONTENT = 1,
|
||||
EXPLORE_ICONS_SYSTEM_CATEGORY = 2,
|
||||
|
||||
EXPLORE_TYPE_ADDITIONALFILTER = FILE_TYPE_RDB, /* database icon */
|
||||
EXPLORE_TYPE_FILTERNULL = MENU_SETTINGS_LAST,
|
||||
EXPLORE_TYPE_SEARCH,
|
||||
@ -110,11 +114,12 @@ typedef struct
|
||||
|
||||
explore_entry_t* entries;
|
||||
playlist_t **playlists;
|
||||
uintptr_t* icons;
|
||||
const char* label_explore_item_str;
|
||||
char title[1024];
|
||||
char find_string[1024];
|
||||
unsigned top_depth;
|
||||
playlist_t *cached_playlist;
|
||||
unsigned show_icons;
|
||||
} explore_state_t;
|
||||
|
||||
static const struct
|
||||
@ -481,6 +486,16 @@ static void explore_add_unique_string(
|
||||
}
|
||||
}
|
||||
|
||||
static void explore_unload_icons(explore_state_t *state)
|
||||
{
|
||||
unsigned i;
|
||||
if (!state)
|
||||
return;
|
||||
for (i = 0; i != EX_BUF_LEN(state->icons); i++)
|
||||
if (state->icons[i])
|
||||
video_driver_texture_unload(&state->icons[i]);
|
||||
}
|
||||
|
||||
static void explore_free(explore_state_t *state)
|
||||
{
|
||||
unsigned i;
|
||||
@ -494,9 +509,58 @@ static void explore_free(explore_state_t *state)
|
||||
for (i = 0; i != EX_BUF_LEN(state->playlists); i++)
|
||||
playlist_free(state->playlists[i]);
|
||||
EX_BUF_FREE(state->playlists);
|
||||
|
||||
explore_unload_icons(state);
|
||||
EX_BUF_FREE(state->icons);
|
||||
|
||||
ex_arena_free(&state->arena);
|
||||
}
|
||||
|
||||
static void explore_load_icons(explore_state_t *state)
|
||||
{
|
||||
char path[PATH_MAX_LENGTH];
|
||||
size_t i, pathlen, system_count;
|
||||
if (!state)
|
||||
return;
|
||||
|
||||
system_count = EX_BUF_LEN(state->by[EXPLORE_BY_SYSTEM]);
|
||||
EX_BUF_RESIZE(state->icons, system_count);
|
||||
|
||||
fill_pathname_application_special(path, sizeof(path),
|
||||
APPLICATION_SPECIAL_DIRECTORY_ASSETS_ICONS);
|
||||
if (string_is_empty(path))
|
||||
return;
|
||||
|
||||
fill_pathname_slash(path, sizeof(path));
|
||||
pathlen = strlen(path);
|
||||
|
||||
for (i = 0; i != system_count; i++)
|
||||
{
|
||||
struct texture_image ti;
|
||||
state->icons[i] = 0;
|
||||
|
||||
strlcpy(path + pathlen,
|
||||
state->by[EXPLORE_BY_SYSTEM][i]->str, sizeof(path) - pathlen);
|
||||
strlcat(path, ".png", sizeof(path));
|
||||
if (!path_is_valid(path))
|
||||
continue;
|
||||
|
||||
ti.width = 0;
|
||||
ti.height = 0;
|
||||
ti.pixels = NULL;
|
||||
ti.supports_rgba = video_driver_supports_rgba();
|
||||
|
||||
if (!image_texture_load(&ti, path))
|
||||
continue;
|
||||
|
||||
if (ti.pixels)
|
||||
video_driver_texture_load(&ti,
|
||||
TEXTURE_FILTER_MIPMAP_LINEAR, &state->icons[i]);
|
||||
|
||||
image_texture_free(&ti);
|
||||
}
|
||||
}
|
||||
|
||||
static explore_state_t *explore_build_list(void)
|
||||
{
|
||||
unsigned i;
|
||||
@ -923,9 +987,9 @@ unsigned menu_displaylist_explore(file_list_t *list)
|
||||
|
||||
if (!explore_state)
|
||||
{
|
||||
menu_explore_free();
|
||||
explore_state = explore_build_list();
|
||||
explore_state->top_depth = (unsigned)menu_stack->size - 1;
|
||||
explore_load_icons(explore_state);
|
||||
}
|
||||
|
||||
if (menu_stack->size > 1)
|
||||
@ -940,6 +1004,7 @@ unsigned menu_displaylist_explore(file_list_t *list)
|
||||
current_type = stack_top[depth].type;
|
||||
current_cat = current_type - EXPLORE_TYPE_FIRSTCATEGORY;
|
||||
previous_cat = stack_top[depth ? depth - 1 : 0].type - EXPLORE_TYPE_FIRSTCATEGORY;
|
||||
explore_state->show_icons = EXPLORE_ICONS_OFF;
|
||||
|
||||
if (depth)
|
||||
{
|
||||
@ -1008,7 +1073,7 @@ unsigned menu_displaylist_explore(file_list_t *list)
|
||||
for (cat = 0; cat < EXPLORE_CAT_COUNT; cat++)
|
||||
{
|
||||
explore_string_t **entries = explore_state->by[cat];
|
||||
int tmplen;
|
||||
size_t tmplen;
|
||||
|
||||
if (!EX_BUF_LEN(entries))
|
||||
continue;
|
||||
@ -1072,6 +1137,9 @@ SKIP_EXPLORE_BY_CATEGORY:;
|
||||
|
||||
explore_append_title(explore_state,
|
||||
msg_hash_to_str(explore_by_info[current_cat].by_enum));
|
||||
|
||||
if (current_cat == EXPLORE_BY_SYSTEM)
|
||||
explore_state->show_icons = EXPLORE_ICONS_SYSTEM_CATEGORY;
|
||||
}
|
||||
else if (
|
||||
previous_cat < EXPLORE_CAT_COUNT
|
||||
@ -1096,6 +1164,9 @@ SKIP_EXPLORE_BY_CATEGORY:;
|
||||
{
|
||||
explore_append_title(explore_state, " - %s",
|
||||
msg_hash_to_str(explore_by_info[current_cat].by_enum));
|
||||
|
||||
if (current_cat == EXPLORE_BY_SYSTEM)
|
||||
explore_state->show_icons = EXPLORE_ICONS_SYSTEM_CATEGORY;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1117,6 +1188,7 @@ SKIP_EXPLORE_BY_CATEGORY:;
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_EXPLORE_ADD_ADDITIONAL_FILTER),
|
||||
EXPLORE_TYPE_ADDITIONALFILTER);
|
||||
explore_menu_add_spacer(list);
|
||||
explore_state->show_icons = EXPLORE_ICONS_CONTENT;
|
||||
}
|
||||
|
||||
for (i = 1; i < depth; i++)
|
||||
@ -1254,6 +1326,44 @@ SKIP_ENTRY:;
|
||||
return list->size;
|
||||
}
|
||||
|
||||
uintptr_t menu_explore_get_entry_icon(unsigned type)
|
||||
{
|
||||
unsigned i;
|
||||
if (!explore_state || !explore_state->show_icons
|
||||
|| type < EXPLORE_TYPE_FIRSTITEM)
|
||||
return 0;
|
||||
|
||||
i = (type - EXPLORE_TYPE_FIRSTITEM);
|
||||
if (explore_state->show_icons == EXPLORE_ICONS_CONTENT)
|
||||
{
|
||||
explore_entry_t* e = &explore_state->entries[i];
|
||||
if (e < EX_BUF_END(explore_state->entries))
|
||||
return explore_state->icons[e->by[EXPLORE_BY_SYSTEM]->idx];
|
||||
}
|
||||
else if (explore_state->show_icons == EXPLORE_ICONS_SYSTEM_CATEGORY)
|
||||
{
|
||||
if (i < EX_BUF_LEN(explore_state->icons))
|
||||
return explore_state->icons[i];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void menu_explore_context_init(void)
|
||||
{
|
||||
if (!explore_state)
|
||||
return;
|
||||
|
||||
explore_load_icons(explore_state);
|
||||
}
|
||||
|
||||
void menu_explore_context_deinit(void)
|
||||
{
|
||||
if (!explore_state)
|
||||
return;
|
||||
|
||||
explore_unload_icons(explore_state);
|
||||
}
|
||||
|
||||
void menu_explore_free(void)
|
||||
{
|
||||
if (!explore_state)
|
||||
|
12
retroarch.c
12
retroarch.c
@ -7488,7 +7488,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data)
|
||||
#ifdef HAVE_NETWORKING
|
||||
core_updater_list_free_cached();
|
||||
#endif
|
||||
#ifdef HAVE_LIBRETRODB
|
||||
#if defined(HAVE_MENU) && defined(HAVE_LIBRETRODB)
|
||||
menu_explore_free();
|
||||
#endif
|
||||
|
||||
@ -34554,8 +34554,14 @@ static void drivers_init(struct rarch_state *p_rarch, int flags)
|
||||
{
|
||||
/* Initialize menu driver */
|
||||
if (flags & DRIVER_MENU_MASK)
|
||||
{
|
||||
if (!menu_driver_init(video_is_threaded))
|
||||
RARCH_ERR("Unable to init menu driver.\n");
|
||||
|
||||
#ifdef HAVE_LIBRETRODB
|
||||
menu_explore_context_init();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/* Initialising the menu driver will also initialise
|
||||
@ -34621,6 +34627,10 @@ static void driver_uninit(struct rarch_state *p_rarch, int flags)
|
||||
#ifdef HAVE_MENU
|
||||
if (flags & DRIVER_MENU_MASK)
|
||||
{
|
||||
#ifdef HAVE_LIBRETRODB
|
||||
menu_explore_context_deinit();
|
||||
#endif
|
||||
|
||||
menu_driver_ctl(RARCH_MENU_CTL_DEINIT, NULL);
|
||||
}
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user