Correct set_thumbnail_system/set_thumbnail_content functions

This commit is contained in:
twinaphex 2017-05-17 09:32:17 +02:00
parent 82c6dd1f3d
commit 9096038e20
5 changed files with 40 additions and 37 deletions

View File

@ -439,7 +439,7 @@ int generic_action_ok_displaylist_push(const char *path,
path, sizeof(tmp));
fill_pathname_base_noext(lpl_basename, path, sizeof(lpl_basename));
menu_driver_ctl(RARCH_MENU_CTL_SET_THUMBNAIL_SYSTEM, lpl_basename);
menu_driver_set_thumbnail_system(lpl_basename, sizeof(lpl_basename));
info.directory_ptr = idx;
info_path = tmp;

View File

@ -1056,24 +1056,31 @@ static void xmb_update_thumbnail_image(void *data)
xmb->thumbnail = 0;
}
static void xmb_set_thumbnail_system(void *data, char* thumbnail_system)
static void xmb_set_thumbnail_system(void *data, char*s, size_t len)
{
xmb_handle_t *xmb = (xmb_handle_t*)data;
if (!xmb)
return;
strlcpy(xmb->thumbnail_system,
thumbnail_system, sizeof(xmb->thumbnail_system));
strlcpy(xmb->thumbnail_system, s, len);
}
static void xmb_set_thumbnail_content(void *data, char* thumbnail_content)
static void xmb_reset_thumbnail_content(void *data)
{
xmb_handle_t *xmb = (xmb_handle_t*)data;
if (!xmb)
return;
memset(xmb->thumbnail_content, 0, sizeof(xmb->thumbnail_content));
xmb->thumbnail_content[0] = '\0';
}
static void xmb_set_thumbnail_content(void *data, char *s, size_t len)
{
xmb_handle_t *xmb = (xmb_handle_t*)data;
if (!xmb)
return;
strlcpy(xmb->thumbnail_content,
thumbnail_content, sizeof(xmb->thumbnail_content));
strlcpy(xmb->thumbnail_content, s, len);
}
static void xmb_update_savestate_thumbnail_image(void *data)
@ -1156,20 +1163,20 @@ static void xmb_selection_pointer_changed(
{
if (xmb_list > XMB_SYSTEM_TAB_SETTINGS && depth == 1)
{
xmb_set_thumbnail_content(xmb, e.path);
xmb_set_thumbnail_content(xmb, e.path, sizeof(e.path));
xmb_update_thumbnail_path(xmb, i);
xmb_update_thumbnail_image(xmb);
}
else if (((e.type == FILE_TYPE_IMAGE || e.type == FILE_TYPE_RDB || e.type == FILE_TYPE_RDB_ENTRY)
&& xmb_list <= XMB_SYSTEM_TAB_SETTINGS))
{
xmb_set_thumbnail_content(xmb, e.path);
xmb_set_thumbnail_content(xmb, e.path, sizeof(e.path));
xmb_update_thumbnail_path(xmb, i);
xmb_update_thumbnail_image(xmb);
}
else if (filebrowser_get_type() != FILEBROWSER_NONE)
{
xmb_set_thumbnail_content(xmb, "");
xmb_reset_thumbnail_content(xmb);
xmb_update_thumbnail_path(xmb, i);
xmb_update_thumbnail_image(xmb);
}
@ -1360,7 +1367,7 @@ static void xmb_list_open_new(xmb_handle_t *xmb,
if (xmb_list_get_selection(xmb) <= XMB_SYSTEM_TAB_SETTINGS)
{
if (xmb->depth < 4)
xmb_set_thumbnail_content(xmb, "");
xmb_reset_thumbnail_content(xmb);
xmb_update_thumbnail_path(xmb, 0);
xmb_update_thumbnail_image(xmb);
}
@ -1662,7 +1669,7 @@ static void xmb_list_switch(xmb_handle_t *xmb)
menu_entry_get(&e, 0, selection, NULL, true);
xmb_set_thumbnail_content(xmb, e.path);
xmb_set_thumbnail_content(xmb, e.path, sizeof(e.path));
xmb_update_thumbnail_path(xmb, 0);
xmb_update_thumbnail_image(xmb);

View File

@ -1829,7 +1829,7 @@ static int menu_displaylist_parse_database_entry(menu_displaylist_info_t *info)
fill_short_pathname_representation_noext(path_base, info->path,
sizeof(path_base));
menu_driver_ctl(RARCH_MENU_CTL_SET_THUMBNAIL_SYSTEM, path_base);
menu_driver_set_thumbnail_system(path_base, sizeof(path_base));
strlcat(path_base,
file_path_str(FILE_PATH_LPL_EXTENSION),
@ -1857,7 +1857,7 @@ static int menu_displaylist_parse_database_entry(menu_displaylist_info_t *info)
snprintf(crc_str, sizeof(crc_str), "%08X", db_info_entry->crc32);
if (db_info_entry->name)
menu_driver_ctl(RARCH_MENU_CTL_SET_THUMBNAIL_CONTENT, db_info_entry->name);
menu_driver_set_thumbnail_content(db_info_entry->name, strlen(db_info_entry->name));
menu_driver_ctl(RARCH_MENU_CTL_UPDATE_THUMBNAIL_PATH, NULL);
menu_driver_ctl(RARCH_MENU_CTL_UPDATE_THUMBNAIL_IMAGE, NULL);
@ -2745,7 +2745,7 @@ static int menu_displaylist_parse_horizontal_list(
item->path,
sizeof(path_playlist));
menu_driver_ctl(RARCH_MENU_CTL_SET_THUMBNAIL_SYSTEM, lpl_basename);
menu_driver_set_thumbnail_system(lpl_basename, sizeof(lpl_basename));
menu_driver_ctl(RARCH_MENU_CTL_PLAYLIST_INIT, (void*)path_playlist);

View File

@ -511,6 +511,18 @@ bool menu_driver_push_list(menu_ctx_displaylist_t *disp_list)
return false;
}
void menu_driver_set_thumbnail_system(char *s, size_t len)
{
if (menu_driver_ctx && menu_driver_ctx->set_thumbnail_system)
menu_driver_ctx->set_thumbnail_system(menu_userdata, s, len);
}
void menu_driver_set_thumbnail_content(char *s, size_t len)
{
if (menu_driver_ctx && menu_driver_ctx->set_thumbnail_content)
menu_driver_ctx->set_thumbnail_content(menu_userdata, s, len);
}
bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data)
{
switch (state)
@ -898,24 +910,6 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data)
menu_driver_ctx->update_thumbnail_image(menu_userdata);
}
break;
case RARCH_MENU_CTL_SET_THUMBNAIL_SYSTEM:
{
char *thumbnail_system = (char*)data;
if (!menu_driver_ctx || !menu_driver_ctx->set_thumbnail_system)
return false;
menu_driver_ctx->set_thumbnail_system(menu_userdata, thumbnail_system);
}
break;
case RARCH_MENU_CTL_SET_THUMBNAIL_CONTENT:
{
char *thumbnail_content = (char*)data;
if (!menu_driver_ctx || !menu_driver_ctx->set_thumbnail_content)
return false;
menu_driver_ctx->set_thumbnail_content(menu_userdata, thumbnail_content);
}
break;
case RARCH_MENU_CTL_UPDATE_SAVESTATE_THUMBNAIL_PATH:
{
size_t selection = menu_navigation_get_selection();

View File

@ -122,8 +122,6 @@ enum rarch_menu_ctl_state
RARCH_MENU_CTL_BIND_INIT,
RARCH_MENU_CTL_UPDATE_THUMBNAIL_PATH,
RARCH_MENU_CTL_UPDATE_THUMBNAIL_IMAGE,
RARCH_MENU_CTL_SET_THUMBNAIL_SYSTEM,
RARCH_MENU_CTL_SET_THUMBNAIL_CONTENT,
RARCH_MENU_CTL_UPDATE_SAVESTATE_THUMBNAIL_PATH,
RARCH_MENU_CTL_UPDATE_SAVESTATE_THUMBNAIL_IMAGE,
MENU_NAVIGATION_CTL_CLEAR,
@ -268,8 +266,8 @@ typedef struct menu_ctx_driver
menu_entry_t *entry, unsigned action);
void (*update_thumbnail_path)(void *data, unsigned i);
void (*update_thumbnail_image)(void *data);
void (*set_thumbnail_system)(void *data, char* thumbnail_system);
void (*set_thumbnail_content)(void *data, char* thumbnail_content);
void (*set_thumbnail_system)(void *data, char* s, size_t len);
void (*set_thumbnail_content)(void *data, char* s, size_t len);
int (*osk_ptr_at_pos)(void *data, int x, int y, unsigned width, unsigned height);
void (*update_savestate_thumbnail_path)(void *data, unsigned i);
void (*update_savestate_thumbnail_image)(void *data);
@ -411,6 +409,10 @@ bool menu_driver_push_list(menu_ctx_displaylist_t *disp_list);
bool menu_driver_init(bool video_is_threaded);
void menu_driver_set_thumbnail_system(char *s, size_t len);
void menu_driver_set_thumbnail_content(char *s, size_t len);
size_t menu_navigation_get_selection(void);
void menu_navigation_set_selection(size_t val);