Flexible thumbnail improvements. (#16082)

- Move flag logic to task_push_pl_entry_thumbnail_download - this
enables individual "download thumbnails" entry to be also flexible
- Add a message when this download has been tried enough times
(i.e. 3)
- Optimize cases when full or short name is the same as standard
name, skip queries if so (both download and local file)
This commit is contained in:
zoltanvb 2024-01-07 16:57:39 +01:00 committed by GitHub
parent 398ace33cc
commit 1e58df4f51
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 47 additions and 12 deletions

View file

@ -292,7 +292,7 @@ void gfx_thumbnail_request(
const char *system = NULL;
const char *img_name = NULL;
static char last_img_name[PATH_MAX_LENGTH] = {0};
enum playlist_thumbnail_name_flags next_flag;
enum playlist_thumbnail_name_flags curr_flag;
if (!playlist)
goto end;
@ -321,15 +321,15 @@ void gfx_thumbnail_request(
if (!gfx_thumbnail_get_system(path_data, &system))
goto end;
/* Apply flexible thumbnail naming: ROM file name - database name - short name */
next_flag = playlist_get_next_thumbnail_name_flag(playlist,idx);
if (next_flag == PLAYLIST_THUMBNAIL_FLAG_NONE)
/* Since task_push_pl_entry_download will shift the flag, do not attempt if it is already
* at second to last option. */
curr_flag = playlist_get_curr_thumbnail_name_flag(playlist,idx);
if (curr_flag & PLAYLIST_THUMBNAIL_FLAG_NONE || curr_flag & PLAYLIST_THUMBNAIL_FLAG_SHORT_NAME)
goto end;
/* Trigger thumbnail download *
* Note: download will grab all 3 possible thumbnails, no matter
* what left/right thumbnails are set at the moment */
playlist_update_thumbnail_name_flag(playlist, idx, next_flag);
task_push_pl_entry_thumbnail_download(
system, playlist, (unsigned)idx,
false, true);

View file

@ -48,8 +48,14 @@ static void gfx_thumbnail_fill_content_img(char *s, size_t len, const char *src,
/* Shortening logic: up to first space + bracket */
if (shorten) {
bracketpos = string_find_index_substring_string(src, cut);
if (bracketpos > 2)
if (bracketpos > 0)
_len = bracketpos;
/* Explicit zero if short name is same as standard name - saves some queries later. */
else
{
s[0] = '\0';
return;
}
}
/* Scrub characters that are not cross-platform and/or violate the
* No-Intro filename standard:
@ -123,6 +129,8 @@ void gfx_thumbnail_path_reset(gfx_thumbnail_path_data_t *path_data)
path_data->content_core_name[0] = '\0';
path_data->content_db_name[0] = '\0';
path_data->content_img[0] = '\0';
path_data->content_img_full[0] = '\0';
path_data->content_img_short[0] = '\0';
path_data->right_path[0] = '\0';
path_data->left_path[0] = '\0';
@ -284,6 +292,8 @@ bool gfx_thumbnail_set_content(gfx_thumbnail_path_data_t *path_data, const char
path_data->content_core_name[0] = '\0';
path_data->content_db_name[0] = '\0';
path_data->content_img[0] = '\0';
path_data->content_img_full[0] = '\0';
path_data->content_img_short[0] = '\0';
/* Must also reset playlist thumbnail display modes */
path_data->playlist_right_mode = PLAYLIST_THUMBNAIL_MODE_DEFAULT;
@ -332,6 +342,8 @@ bool gfx_thumbnail_set_content_image(
path_data->content_core_name[0] = '\0';
path_data->content_db_name[0] = '\0';
path_data->content_img[0] = '\0';
path_data->content_img_full[0] = '\0';
path_data->content_img_short[0] = '\0';
/* Must also reset playlist thumbnail display modes */
path_data->playlist_right_mode = PLAYLIST_THUMBNAIL_MODE_DEFAULT;
@ -407,6 +419,8 @@ bool gfx_thumbnail_set_content_playlist(
path_data->content_core_name[0] = '\0';
path_data->content_db_name[0] = '\0';
path_data->content_img[0] = '\0';
path_data->content_img_full[0] = '\0';
path_data->content_img_short[0] = '\0';
/* Must also reset playlist thumbnail display modes */
path_data->playlist_right_mode = PLAYLIST_THUMBNAIL_MODE_DEFAULT;
@ -472,6 +486,11 @@ bool gfx_thumbnail_set_content_playlist(
sizeof(path_data->content_img_full), content_name_no_ext,false);
gfx_thumbnail_fill_content_img(path_data->content_img,
sizeof(path_data->content_img), path_data->content_label,false);
/* Explicit zero if full name is same as standard name - saves some queries later. */
if(strcmp(path_data->content_img, path_data->content_img_full) == 0)
{
path_data->content_img_full[0] = '\0';
}
gfx_thumbnail_fill_content_img(path_data->content_img_short,
sizeof(path_data->content_img_short), path_data->content_label,true);
}

View file

@ -14625,6 +14625,10 @@ MSG_HASH(
MSG_NO_THUMBNAIL_AVAILABLE,
"No thumbnail available"
)
MSG_HASH(
MSG_NO_THUMBNAIL_DOWNLOAD_POSSIBLE,
"All possible thumbnail downloads were already tried for this playlist entry."
)
MSG_HASH(
MSG_PRESS_AGAIN_TO_QUIT,
"Press again to quit..."

View file

@ -439,6 +439,7 @@ enum msg_hash_enums
MSG_TOGGLE_FULLSCREEN_THUMBNAILS,
MSG_TOGGLE_CONTENT_METADATA,
MSG_NO_THUMBNAIL_AVAILABLE,
MSG_NO_THUMBNAIL_DOWNLOAD_POSSIBLE,
MSG_PRESS_AGAIN_TO_QUIT,
MSG_BLUETOOTH_PAIRING_REMOVED,
MSG_BLUETOOTH_SCAN_COMPLETE,

View file

@ -464,7 +464,10 @@ static void task_pl_thumbnail_download_handler(retro_task_t *task)
pl_thumb->status = PL_THUMB_END;
break;
} else {
/* Increment the name flag to cover the 3 supported naming conventions. */
/* Increment the name flag to cover the 3 supported naming conventions.
* Side-effect: all combinations will be tried (3x3 requests for 1 playlist entry)
* even if some files were already downloaded, but that may be useful if later on
* different view priorities are implemented. */
pl_thumb->type_idx = 1;
playlist_update_thumbnail_name_flag(pl_thumb->playlist, pl_thumb->list_index, next_flag);
pl_thumb->name_flags = next_flag;
@ -829,7 +832,7 @@ bool task_push_pl_entry_thumbnail_download(
gfx_thumbnail_path_data_t *
thumbnail_path_data = NULL;
const char *dir_thumbnails = NULL;
enum playlist_thumbnail_name_flags curr_flag = PLAYLIST_THUMBNAIL_FLAG_INVALID;
enum playlist_thumbnail_name_flags next_flag = PLAYLIST_THUMBNAIL_FLAG_INVALID;
/* Sanity check */
if (!settings || !task || !pl_thumb || !playlist || !entry_id)
@ -886,9 +889,17 @@ bool task_push_pl_entry_thumbnail_download(
thumbnail_path_data, playlist, idx))
goto error;
curr_flag = playlist_get_curr_thumbnail_name_flag(playlist,idx);
if (curr_flag == PLAYLIST_THUMBNAIL_FLAG_NONE)
goto error;
/* Apply flexible thumbnail naming: ROM file name - database name - short name */
next_flag = playlist_get_next_thumbnail_name_flag(playlist,idx);
playlist_update_thumbnail_name_flag(playlist, idx, next_flag);
if (next_flag == PLAYLIST_THUMBNAIL_FLAG_NONE) {
runloop_msg_queue_push(
msg_hash_to_str(MSG_NO_THUMBNAIL_DOWNLOAD_POSSIBLE),
1, 100, true,
NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
goto error;
}
/* Configure handle
* > Note: playlist_config is unused by this task */
@ -901,7 +912,7 @@ bool task_push_pl_entry_thumbnail_download(
pl_thumb->list_size = playlist_size(playlist);
pl_thumb->list_index = idx;
pl_thumb->type_idx = 1;
pl_thumb->name_flags = curr_flag;
pl_thumb->name_flags = next_flag;
pl_thumb->status = PL_THUMB_BEGIN;
if (overwrite)