Move functions around, make some static, move some around
This commit is contained in:
parent
96068dfa81
commit
7d60a2cc8f
|
@ -35,24 +35,6 @@
|
|||
|
||||
#include "gfx_thumbnail_path.h"
|
||||
|
||||
/* Used fixed size char arrays here, just to avoid
|
||||
* the inconvenience of having to calloc()/free()
|
||||
* each individual entry by hand... */
|
||||
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];
|
||||
};
|
||||
|
||||
/* Resets thumbnail path data
|
||||
* (blanks all internal string containers) */
|
||||
void gfx_thumbnail_path_reset(gfx_thumbnail_path_data_t *path_data)
|
||||
|
@ -91,38 +73,8 @@ gfx_thumbnail_path_data_t *gfx_thumbnail_path_init(void)
|
|||
return path_data;
|
||||
}
|
||||
|
||||
|
||||
/* Utility Functions */
|
||||
|
||||
/* Fetches the thumbnail subdirectory (Named_Snaps,
|
||||
* Named_Titles, Named_Boxarts) corresponding to the
|
||||
* specified 'type index' (1, 2, 3).
|
||||
* Returns true if 'type index' is valid */
|
||||
bool gfx_thumbnail_get_sub_directory(
|
||||
unsigned type_idx, const char **sub_directory)
|
||||
{
|
||||
if (!sub_directory)
|
||||
return false;
|
||||
|
||||
switch (type_idx)
|
||||
{
|
||||
case 1:
|
||||
*sub_directory = "Named_Snaps";
|
||||
return true;
|
||||
case 2:
|
||||
*sub_directory = "Named_Titles";
|
||||
return true;
|
||||
case 3:
|
||||
*sub_directory = "Named_Boxarts";
|
||||
return true;
|
||||
case 0:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Returns currently set thumbnail 'type' (Named_Snaps,
|
||||
* Named_Titles, Named_Boxarts) for specified thumbnail
|
||||
* identifier (right, left) */
|
||||
|
@ -131,71 +83,69 @@ static const char *gfx_thumbnail_get_type(
|
|||
gfx_thumbnail_path_data_t *path_data,
|
||||
enum gfx_thumbnail_id thumbnail_id)
|
||||
{
|
||||
unsigned type = 0;
|
||||
unsigned gfx_thumbnails = settings->uints.gfx_thumbnails;
|
||||
unsigned menu_left_thumbnails = settings->uints.menu_left_thumbnails;
|
||||
const char *val_off = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF);
|
||||
|
||||
if (!path_data)
|
||||
return val_off;
|
||||
|
||||
switch (thumbnail_id)
|
||||
if (path_data)
|
||||
{
|
||||
case GFX_THUMBNAIL_RIGHT:
|
||||
if (path_data->playlist_right_mode != PLAYLIST_THUMBNAIL_MODE_DEFAULT)
|
||||
type = (unsigned)path_data->playlist_right_mode - 1;
|
||||
else
|
||||
type = gfx_thumbnails;
|
||||
break;
|
||||
case GFX_THUMBNAIL_LEFT:
|
||||
if (path_data->playlist_left_mode != PLAYLIST_THUMBNAIL_MODE_DEFAULT)
|
||||
type = (unsigned)path_data->playlist_left_mode - 1;
|
||||
else
|
||||
type = menu_left_thumbnails;
|
||||
break;
|
||||
default:
|
||||
return val_off;
|
||||
unsigned type = 0;
|
||||
unsigned menu_left_thumbnails = settings->uints.menu_left_thumbnails;
|
||||
unsigned gfx_thumbnails = settings->uints.gfx_thumbnails;
|
||||
switch (thumbnail_id)
|
||||
{
|
||||
case GFX_THUMBNAIL_RIGHT:
|
||||
if (path_data->playlist_right_mode != PLAYLIST_THUMBNAIL_MODE_DEFAULT)
|
||||
type = (unsigned)path_data->playlist_right_mode - 1;
|
||||
else
|
||||
type = gfx_thumbnails;
|
||||
break;
|
||||
case GFX_THUMBNAIL_LEFT:
|
||||
if (path_data->playlist_left_mode != PLAYLIST_THUMBNAIL_MODE_DEFAULT)
|
||||
type = (unsigned)path_data->playlist_left_mode - 1;
|
||||
else
|
||||
type = menu_left_thumbnails;
|
||||
break;
|
||||
default:
|
||||
goto end;
|
||||
}
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case 1:
|
||||
return "Named_Snaps";
|
||||
case 2:
|
||||
return "Named_Titles";
|
||||
case 3:
|
||||
return "Named_Boxarts";
|
||||
case 0:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case 1:
|
||||
return "Named_Snaps";
|
||||
case 2:
|
||||
return "Named_Titles";
|
||||
case 3:
|
||||
return "Named_Boxarts";
|
||||
case 0:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return val_off;
|
||||
end:
|
||||
return msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF);
|
||||
}
|
||||
|
||||
/* 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)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
unsigned gfx_thumbnails = settings->uints.gfx_thumbnails;
|
||||
unsigned menu_left_thumbnails = settings->uints.menu_left_thumbnails;
|
||||
|
||||
if (!path_data)
|
||||
return false;
|
||||
|
||||
switch (thumbnail_id)
|
||||
if (path_data)
|
||||
{
|
||||
case GFX_THUMBNAIL_RIGHT:
|
||||
if (path_data->playlist_right_mode != PLAYLIST_THUMBNAIL_MODE_DEFAULT)
|
||||
return path_data->playlist_right_mode != PLAYLIST_THUMBNAIL_MODE_OFF;
|
||||
return gfx_thumbnails != 0;
|
||||
case GFX_THUMBNAIL_LEFT:
|
||||
if (path_data->playlist_left_mode != PLAYLIST_THUMBNAIL_MODE_DEFAULT)
|
||||
return path_data->playlist_left_mode != PLAYLIST_THUMBNAIL_MODE_OFF;
|
||||
return menu_left_thumbnails != 0;
|
||||
default:
|
||||
break;
|
||||
settings_t *settings = config_get_ptr();
|
||||
unsigned gfx_thumbnails = settings->uints.gfx_thumbnails;
|
||||
unsigned menu_left_thumbnails = settings->uints.menu_left_thumbnails;
|
||||
switch (thumbnail_id)
|
||||
{
|
||||
case GFX_THUMBNAIL_RIGHT:
|
||||
if (path_data->playlist_right_mode != PLAYLIST_THUMBNAIL_MODE_DEFAULT)
|
||||
return path_data->playlist_right_mode != PLAYLIST_THUMBNAIL_MODE_OFF;
|
||||
return gfx_thumbnails != 0;
|
||||
case GFX_THUMBNAIL_LEFT:
|
||||
if (path_data->playlist_left_mode != PLAYLIST_THUMBNAIL_MODE_DEFAULT)
|
||||
return path_data->playlist_left_mode != PLAYLIST_THUMBNAIL_MODE_OFF;
|
||||
return menu_left_thumbnails != 0;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -205,7 +155,7 @@ bool gfx_thumbnail_is_enabled(gfx_thumbnail_path_data_t *path_data, enum gfx_thu
|
|||
|
||||
/* Fills content_img field of path_data using existing
|
||||
* content_label field (for internal use only) */
|
||||
static void fill_content_img(gfx_thumbnail_path_data_t *path_data)
|
||||
static void gfx_thumbnail_fill_content_img(gfx_thumbnail_path_data_t *path_data)
|
||||
{
|
||||
char *scrub_char_pointer = NULL;
|
||||
|
||||
|
@ -283,11 +233,11 @@ bool gfx_thumbnail_set_system(gfx_thumbnail_path_data_t *path_data,
|
|||
{
|
||||
/* Check for history/favourites playlists */
|
||||
bool playlist_valid =
|
||||
(string_is_equal(system, "history") &&
|
||||
string_is_equal(playlist_file,
|
||||
FILE_PATH_CONTENT_HISTORY)) ||
|
||||
(string_is_equal(system, "favorites") &&
|
||||
string_is_equal(playlist_file,
|
||||
(string_is_equal(system, "history")
|
||||
&& string_is_equal(playlist_file,
|
||||
FILE_PATH_CONTENT_HISTORY))
|
||||
|| (string_is_equal(system, "favorites")
|
||||
&& string_is_equal(playlist_file,
|
||||
FILE_PATH_CONTENT_FAVORITES));
|
||||
|
||||
if (!playlist_valid)
|
||||
|
@ -348,7 +298,7 @@ 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 */
|
||||
fill_content_img(path_data);
|
||||
gfx_thumbnail_fill_content_img(path_data);
|
||||
|
||||
/* Have to set content path to *something*...
|
||||
* Just use label value (it doesn't matter) */
|
||||
|
@ -502,7 +452,7 @@ bool gfx_thumbnail_set_content_playlist(
|
|||
"", sizeof(path_data->content_label));
|
||||
|
||||
/* Determine content image name */
|
||||
fill_content_img(path_data);
|
||||
gfx_thumbnail_fill_content_img(path_data);
|
||||
|
||||
/* Store playlist index */
|
||||
path_data->playlist_index = idx;
|
||||
|
@ -617,8 +567,8 @@ bool gfx_thumbnail_update_path(
|
|||
* then the current 'path_data->system' string is
|
||||
* meaningless. In this case, we fall back to the
|
||||
* content directory name */
|
||||
if (string_is_equal(path_data->system, "history") ||
|
||||
string_is_equal(path_data->system, "favorites"))
|
||||
if ( string_is_equal(path_data->system, "history")
|
||||
|| string_is_equal(path_data->system, "favorites"))
|
||||
{
|
||||
if (!gfx_thumbnail_get_content_dir(
|
||||
path_data, content_dir, sizeof(content_dir)))
|
||||
|
@ -634,8 +584,8 @@ bool gfx_thumbnail_update_path(
|
|||
|
||||
/* > Special case: thumbnail for imageviewer content
|
||||
* is the image file itself */
|
||||
if (string_is_equal(system_name, "images_history") ||
|
||||
string_is_equal(path_data->content_core_name, "imageviewer"))
|
||||
if ( string_is_equal(system_name, "images_history")
|
||||
|| string_is_equal(path_data->content_core_name, "imageviewer"))
|
||||
{
|
||||
/* imageviewer content is identical for left and right thumbnails */
|
||||
if (path_is_media_type(path_data->content_path) == RARCH_CONTENT_IMAGE)
|
||||
|
@ -673,7 +623,8 @@ bool gfx_thumbnail_update_path(
|
|||
* Returns true if path is valid. */
|
||||
bool gfx_thumbnail_get_path(
|
||||
gfx_thumbnail_path_data_t *path_data,
|
||||
enum gfx_thumbnail_id thumbnail_id, const char **path)
|
||||
enum gfx_thumbnail_id thumbnail_id,
|
||||
const char **path)
|
||||
{
|
||||
char *thumbnail_path = NULL;
|
||||
|
||||
|
@ -720,21 +671,6 @@ bool gfx_thumbnail_get_system(
|
|||
return true;
|
||||
}
|
||||
|
||||
/* Fetches current content path.
|
||||
* Returns true if content path is valid. */
|
||||
bool gfx_thumbnail_get_content_path(
|
||||
gfx_thumbnail_path_data_t *path_data, const char **content_path)
|
||||
{
|
||||
if (!path_data || !content_path)
|
||||
return false;
|
||||
if (string_is_empty(path_data->content_path))
|
||||
return false;
|
||||
|
||||
*content_path = path_data->content_path;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Fetches current thumbnail label.
|
||||
* Returns true if label is valid. */
|
||||
bool gfx_thumbnail_get_label(
|
||||
|
@ -765,21 +701,6 @@ bool gfx_thumbnail_get_core_name(
|
|||
return true;
|
||||
}
|
||||
|
||||
/* Fetches current database name.
|
||||
* Returns true if database name is valid. */
|
||||
bool gfx_thumbnail_get_db_name(
|
||||
gfx_thumbnail_path_data_t *path_data, const char **db_name)
|
||||
{
|
||||
if (!path_data || !db_name)
|
||||
return false;
|
||||
if (string_is_empty(path_data->content_db_name))
|
||||
return false;
|
||||
|
||||
*db_name = path_data->content_db_name;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Fetches current thumbnail image name
|
||||
* (name is the same for all thumbnail types).
|
||||
* Returns true if image name is valid. */
|
||||
|
|
|
@ -50,6 +50,24 @@ enum gfx_thumbnail_id
|
|||
/* Prevent direct access to gfx_thumbnail_path_data_t members */
|
||||
typedef struct gfx_thumbnail_path_data gfx_thumbnail_path_data_t;
|
||||
|
||||
/* Used fixed size char arrays here, just to avoid
|
||||
* the inconvenience of having to calloc()/free()
|
||||
* each individual entry by hand... */
|
||||
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];
|
||||
};
|
||||
|
||||
/* Initialisation */
|
||||
|
||||
/* Creates new thumbnail path data container.
|
||||
|
@ -64,12 +82,6 @@ void gfx_thumbnail_path_reset(gfx_thumbnail_path_data_t *path_data);
|
|||
|
||||
/* Utility Functions */
|
||||
|
||||
/* Fetches the thumbnail subdirectory (Named_Snaps,
|
||||
* Named_Titles, Named_Boxarts) corresponding to the
|
||||
* specified 'type index' (1, 2, 3).
|
||||
* Returns true if 'type index' is valid */
|
||||
bool gfx_thumbnail_get_sub_directory(unsigned type_idx, const char **sub_directory);
|
||||
|
||||
/* 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);
|
||||
|
@ -124,10 +136,6 @@ bool gfx_thumbnail_get_path(gfx_thumbnail_path_data_t *path_data, enum gfx_thumb
|
|||
* Returns true if 'system' is valid. */
|
||||
bool gfx_thumbnail_get_system(gfx_thumbnail_path_data_t *path_data, const char **system);
|
||||
|
||||
/* Fetches current content path.
|
||||
* Returns true if content path is valid. */
|
||||
bool gfx_thumbnail_get_content_path(gfx_thumbnail_path_data_t *path_data, const char **content_path);
|
||||
|
||||
/* Fetches current thumbnail label.
|
||||
* Returns true if label is valid. */
|
||||
bool gfx_thumbnail_get_label(gfx_thumbnail_path_data_t *path_data, const char **label);
|
||||
|
@ -136,10 +144,6 @@ bool gfx_thumbnail_get_label(gfx_thumbnail_path_data_t *path_data, const char **
|
|||
* Returns true if core name is valid. */
|
||||
bool gfx_thumbnail_get_core_name(gfx_thumbnail_path_data_t *path_data, const char **core_name);
|
||||
|
||||
/* Fetches current database name.
|
||||
* Returns true if database name is valid. */
|
||||
bool gfx_thumbnail_get_db_name(gfx_thumbnail_path_data_t *path_data, const char **db_name);
|
||||
|
||||
/* Fetches current thumbnail image name
|
||||
* (name is the same for all thumbnail types).
|
||||
* Returns true if image name is valid. */
|
||||
|
|
|
@ -88,6 +88,45 @@ typedef struct pl_entry_id
|
|||
/* Utility Functions */
|
||||
/*********************/
|
||||
|
||||
/* Fetches the thumbnail subdirectory (Named_Snaps,
|
||||
* Named_Titles, Named_Boxarts) corresponding to the
|
||||
* specified 'type index' (1, 2, 3).
|
||||
* Returns true if 'type index' is valid */
|
||||
static bool gfx_thumbnail_get_sub_directory(
|
||||
unsigned type_idx, const char **sub_directory)
|
||||
{
|
||||
if (!sub_directory)
|
||||
return false;
|
||||
|
||||
switch (type_idx)
|
||||
{
|
||||
case 1:
|
||||
*sub_directory = "Named_Snaps";
|
||||
return true;
|
||||
case 2:
|
||||
*sub_directory = "Named_Titles";
|
||||
return true;
|
||||
case 3:
|
||||
*sub_directory = "Named_Boxarts";
|
||||
return true;
|
||||
case 0:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Fetches current database name.
|
||||
* Returns true if database name is valid. */
|
||||
static void gfx_thumbnail_get_db_name(
|
||||
gfx_thumbnail_path_data_t *path_data, const char **db_name)
|
||||
{
|
||||
if (!string_is_empty(path_data->content_db_name))
|
||||
*db_name = path_data->content_db_name;
|
||||
}
|
||||
|
||||
|
||||
/* Fetches local and remote paths for current thumbnail
|
||||
* of current type */
|
||||
static bool get_thumbnail_paths(
|
||||
|
@ -114,7 +153,7 @@ static bool get_thumbnail_paths(
|
|||
return false;
|
||||
|
||||
/* Extract required strings */
|
||||
gfx_thumbnail_get_system(pl_thumb->thumbnail_path_data, &system);
|
||||
gfx_thumbnail_get_system( pl_thumb->thumbnail_path_data, &system);
|
||||
gfx_thumbnail_get_db_name(pl_thumb->thumbnail_path_data, &db_name);
|
||||
if (!gfx_thumbnail_get_img_name(pl_thumb->thumbnail_path_data, &img_name))
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue