mirror of
https://github.com/libretro/RetroArch
synced 2025-03-29 22:20:21 +00:00
Cleanups
This commit is contained in:
parent
ba492e9614
commit
d15de21da5
@ -35,46 +35,23 @@
|
||||
|
||||
#include "gfx_thumbnail_path.h"
|
||||
|
||||
/* Resets thumbnail path data
|
||||
* (blanks all internal string containers) */
|
||||
void gfx_thumbnail_path_reset(gfx_thumbnail_path_data_t *path_data)
|
||||
/* Fills content_img field of path_data using existing
|
||||
* content_label field (for internal use only) */
|
||||
static void gfx_thumbnail_fill_content_img(char *s, size_t len, const char *src)
|
||||
{
|
||||
if (!path_data)
|
||||
return;
|
||||
|
||||
path_data->system[0] = '\0';
|
||||
path_data->content_path[0] = '\0';
|
||||
path_data->content_label[0] = '\0';
|
||||
path_data->content_core_name[0] = '\0';
|
||||
path_data->content_db_name[0] = '\0';
|
||||
path_data->content_img[0] = '\0';
|
||||
path_data->right_path[0] = '\0';
|
||||
path_data->left_path[0] = '\0';
|
||||
|
||||
path_data->playlist_right_mode = PLAYLIST_THUMBNAIL_MODE_DEFAULT;
|
||||
path_data->playlist_left_mode = PLAYLIST_THUMBNAIL_MODE_DEFAULT;
|
||||
char *scrub_char_ptr = NULL;
|
||||
/* Copy source label string */
|
||||
strlcpy(s, src, len);
|
||||
/* Scrub characters that are not cross-platform and/or violate the
|
||||
* No-Intro filename standard:
|
||||
* http://datomatic.no-intro.org/stuff/The%20Official%20No-Intro%20Convention%20(20071030).zip
|
||||
* Replace these characters in the entry name with underscores */
|
||||
while ((scrub_char_ptr = strpbrk(s, "&*/:`\"<>?\\|")))
|
||||
*scrub_char_ptr = '_';
|
||||
/* Add PNG extension */
|
||||
strlcat(s, ".png", len);
|
||||
}
|
||||
|
||||
/* Initialisation */
|
||||
|
||||
/* Creates new thumbnail path data container.
|
||||
* Returns handle to new gfx_thumbnail_path_data_t object.
|
||||
* on success, otherwise NULL.
|
||||
* Note: Returned object must be free()d */
|
||||
gfx_thumbnail_path_data_t *gfx_thumbnail_path_init(void)
|
||||
{
|
||||
gfx_thumbnail_path_data_t *path_data = (gfx_thumbnail_path_data_t*)
|
||||
malloc(sizeof(*path_data));
|
||||
if (!path_data)
|
||||
return NULL;
|
||||
|
||||
gfx_thumbnail_path_reset(path_data);
|
||||
|
||||
return path_data;
|
||||
}
|
||||
|
||||
/* Utility Functions */
|
||||
|
||||
/* Returns currently set thumbnail 'type' (Named_Snaps,
|
||||
* Named_Titles, Named_Boxarts) for specified thumbnail
|
||||
* identifier (right, left) */
|
||||
@ -124,6 +101,46 @@ end:
|
||||
return msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF);
|
||||
}
|
||||
|
||||
/* Resets thumbnail path data
|
||||
* (blanks all internal string containers) */
|
||||
void gfx_thumbnail_path_reset(gfx_thumbnail_path_data_t *path_data)
|
||||
{
|
||||
if (!path_data)
|
||||
return;
|
||||
|
||||
path_data->system[0] = '\0';
|
||||
path_data->content_path[0] = '\0';
|
||||
path_data->content_label[0] = '\0';
|
||||
path_data->content_core_name[0] = '\0';
|
||||
path_data->content_db_name[0] = '\0';
|
||||
path_data->content_img[0] = '\0';
|
||||
path_data->right_path[0] = '\0';
|
||||
path_data->left_path[0] = '\0';
|
||||
|
||||
path_data->playlist_right_mode = PLAYLIST_THUMBNAIL_MODE_DEFAULT;
|
||||
path_data->playlist_left_mode = PLAYLIST_THUMBNAIL_MODE_DEFAULT;
|
||||
}
|
||||
|
||||
/* Initialisation */
|
||||
|
||||
/* Creates new thumbnail path data container.
|
||||
* Returns handle to new gfx_thumbnail_path_data_t object.
|
||||
* on success, otherwise NULL.
|
||||
* Note: Returned object must be free()d */
|
||||
gfx_thumbnail_path_data_t *gfx_thumbnail_path_init(void)
|
||||
{
|
||||
gfx_thumbnail_path_data_t *path_data = (gfx_thumbnail_path_data_t*)
|
||||
malloc(sizeof(*path_data));
|
||||
if (!path_data)
|
||||
return NULL;
|
||||
|
||||
gfx_thumbnail_path_reset(path_data);
|
||||
|
||||
return path_data;
|
||||
}
|
||||
|
||||
/* Utility Functions */
|
||||
|
||||
/* Returns true if specified thumbnail is enabled
|
||||
* (i.e. if 'type' is not equal to MENU_ENUM_LABEL_VALUE_OFF) */
|
||||
bool gfx_thumbnail_is_enabled(gfx_thumbnail_path_data_t *path_data, enum gfx_thumbnail_id thumbnail_id)
|
||||
@ -153,28 +170,6 @@ bool gfx_thumbnail_is_enabled(gfx_thumbnail_path_data_t *path_data, enum gfx_thu
|
||||
|
||||
/* Setters */
|
||||
|
||||
/* Fills content_img field of path_data using existing
|
||||
* content_label field (for internal use only) */
|
||||
static void gfx_thumbnail_fill_content_img(gfx_thumbnail_path_data_t *path_data)
|
||||
{
|
||||
char *scrub_char_pointer = NULL;
|
||||
|
||||
/* Copy source label string */
|
||||
strlcpy(path_data->content_img,
|
||||
path_data->content_label, sizeof(path_data->content_img));
|
||||
|
||||
/* Scrub characters that are not cross-platform and/or violate the
|
||||
* No-Intro filename standard:
|
||||
* http://datomatic.no-intro.org/stuff/The%20Official%20No-Intro%20Convention%20(20071030).zip
|
||||
* Replace these characters in the entry name with underscores */
|
||||
while ((scrub_char_pointer =
|
||||
strpbrk(path_data->content_img, "&*/:`\"<>?\\|")))
|
||||
*scrub_char_pointer = '_';
|
||||
|
||||
/* Add PNG extension */
|
||||
strlcat(path_data->content_img, ".png", sizeof(path_data->content_img));
|
||||
}
|
||||
|
||||
/* Sets current 'system' (default database name).
|
||||
* Returns true if 'system' is valid.
|
||||
* If playlist is provided, extracts system-specific
|
||||
@ -298,7 +293,8 @@ bool gfx_thumbnail_set_content(gfx_thumbnail_path_data_t *path_data, const char
|
||||
strlcpy(path_data->content_label, label, sizeof(path_data->content_label));
|
||||
|
||||
/* Determine content image name */
|
||||
gfx_thumbnail_fill_content_img(path_data);
|
||||
gfx_thumbnail_fill_content_img(path_data->content_img,
|
||||
sizeof(path_data->content_img), path_data->content_label);
|
||||
|
||||
/* Have to set content path to *something*...
|
||||
* Just use label value (it doesn't matter) */
|
||||
@ -452,7 +448,8 @@ bool gfx_thumbnail_set_content_playlist(
|
||||
"", sizeof(path_data->content_label));
|
||||
|
||||
/* Determine content image name */
|
||||
gfx_thumbnail_fill_content_img(path_data);
|
||||
gfx_thumbnail_fill_content_img(path_data->content_img,
|
||||
sizeof(path_data->content_img), path_data->content_label);
|
||||
|
||||
/* Store playlist index */
|
||||
path_data->playlist_index = idx;
|
||||
@ -742,10 +739,3 @@ bool gfx_thumbnail_get_content_dir(
|
||||
|
||||
return !string_is_empty(content_dir);
|
||||
}
|
||||
|
||||
/* Fetches current playlist index. */
|
||||
size_t gfx_thumbnail_get_playlist_index(
|
||||
gfx_thumbnail_path_data_t *path_data)
|
||||
{
|
||||
return (path_data) ? path_data->playlist_index : 0;
|
||||
}
|
||||
|
@ -58,14 +58,14 @@ struct gfx_thumbnail_path_data
|
||||
enum playlist_thumbnail_mode playlist_right_mode;
|
||||
enum playlist_thumbnail_mode playlist_left_mode;
|
||||
size_t playlist_index;
|
||||
char system[PATH_MAX_LENGTH];
|
||||
char content_path[PATH_MAX_LENGTH];
|
||||
char content_label[PATH_MAX_LENGTH];
|
||||
char content_core_name[PATH_MAX_LENGTH];
|
||||
char content_db_name[PATH_MAX_LENGTH];
|
||||
char content_img[PATH_MAX_LENGTH];
|
||||
char right_path[PATH_MAX_LENGTH];
|
||||
char left_path[PATH_MAX_LENGTH];
|
||||
char content_core_name[256];
|
||||
char system[256];
|
||||
char content_db_name[256];
|
||||
};
|
||||
|
||||
/* Initialisation */
|
||||
@ -153,9 +153,6 @@ bool gfx_thumbnail_get_img_name(gfx_thumbnail_path_data_t *path_data, const char
|
||||
* Returns true if content directory is valid. */
|
||||
bool gfx_thumbnail_get_content_dir(gfx_thumbnail_path_data_t *path_data, char *content_dir, size_t len);
|
||||
|
||||
/* Fetches current playlist index. */
|
||||
size_t gfx_thumbnail_get_playlist_index(gfx_thumbnail_path_data_t *path_data);
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
||||
#endif
|
||||
|
@ -10177,7 +10177,9 @@ static void ozone_render(void *data,
|
||||
|
||||
/* Explore list needs cached selection index */
|
||||
if (ozone->flags & OZONE_FLAG_IS_EXPLORE_LIST)
|
||||
selection = gfx_thumbnail_get_playlist_index(menu_st->thumbnail_path_data);
|
||||
selection = menu_st->thumbnail_path_data
|
||||
? menu_st->thumbnail_path_data->playlist_index
|
||||
: 0;
|
||||
|
||||
switch (ozone->thumbnails.pending)
|
||||
{
|
||||
|
@ -6778,7 +6778,9 @@ static void rgui_load_current_thumbnails(rgui_t *rgui, struct menu_state *menu_s
|
||||
|
||||
/* Explore list needs cached selection index */
|
||||
if (rgui->flags & RGUI_FLAG_IS_EXPLORE_LIST)
|
||||
selection = gfx_thumbnail_get_playlist_index(menu_st->thumbnail_path_data);
|
||||
selection = menu_st->thumbnail_path_data
|
||||
? menu_st->thumbnail_path_data->playlist_index
|
||||
: 0;
|
||||
|
||||
if (gfx_thumbnail_get_system(menu_st->thumbnail_path_data, &system))
|
||||
task_push_pl_entry_thumbnail_download(system,
|
||||
|
@ -4930,7 +4930,9 @@ static void xmb_render(void *data,
|
||||
|
||||
/* Explore list needs cached selection index */
|
||||
if (xmb->is_explore_list)
|
||||
selection = gfx_thumbnail_get_playlist_index(menu_st->thumbnail_path_data);
|
||||
selection = menu_st->thumbnail_path_data
|
||||
? menu_st->thumbnail_path_data->playlist_index
|
||||
: 0;
|
||||
|
||||
switch (xmb->thumbnails.pending)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user