From d2c9c280fe9fcfa0cd298e2bb59b4ae14bfb7ad2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 20 Jun 2016 16:14:59 +0200 Subject: [PATCH] No longer use CB_ hashes --- intl/msg_hash_us.c | 2 ++ menu/cbs/menu_cbs_ok.c | 2 +- menu/drivers/materialui.c | 3 ++- menu/drivers/nuklear.c | 3 ++- menu/drivers/xmb.c | 9 ++++++--- menu/drivers/zarch.c | 5 +++-- msg_hash.h | 1 + tasks/task_image.c | 13 +++---------- tasks/tasks_internal.h | 4 +++- 9 files changed, 23 insertions(+), 19 deletions(-) diff --git a/intl/msg_hash_us.c b/intl/msg_hash_us.c index ad50fe9302..8c783c8f88 100644 --- a/intl/msg_hash_us.c +++ b/intl/msg_hash_us.c @@ -1108,6 +1108,8 @@ static const char *menu_hash_to_str_us_label_enum(enum msg_hash_enums msg) return "core_settings"; case MENU_ENUM_LABEL_CB_MENU_WALLPAPER: return "cb_menu_wallpaper"; + case MENU_ENUM_LABEL_CB_MENU_THUMBNAIL: + return "cb_menu_thumbnail"; case MENU_ENUM_LABEL_CB_LAKKA_LIST: return "cb_lakka_list"; case MENU_ENUM_LABEL_CB_THUMBNAILS_UPDATER_LIST: diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 08b3c5af8b..6094420939 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -929,7 +929,7 @@ static int generic_action_ok(const char *path, strlcpy(settings->path.menu_wallpaper, action_path, sizeof(settings->path.menu_wallpaper)); task_push_image_load(action_path, - msg_hash_to_str(MENU_ENUM_LABEL_CB_MENU_WALLPAPER), + MENU_ENUM_LABEL_CB_MENU_WALLPAPER, menu_display_handle_wallpaper_upload, NULL); } break; diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index c432e06b4d..acabd9f112 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -1216,7 +1216,8 @@ static void mui_context_reset(void *data) menu_display_allocate_white_texture(); mui_context_reset_textures(mui); - task_push_image_load(settings->path.menu_wallpaper, "cb_menu_wallpaper", + task_push_image_load(settings->path.menu_wallpaper, + MENU_ENUM_LABEL_CB_MENU_WALLPAPER, menu_display_handle_wallpaper_upload, NULL); } diff --git a/menu/drivers/nuklear.c b/menu/drivers/nuklear.c index a09be9c1dd..3df34ec6e3 100644 --- a/menu/drivers/nuklear.c +++ b/menu/drivers/nuklear.c @@ -364,7 +364,8 @@ static void nk_menu_context_reset(void *data) wimp_context_bg_destroy(nk); nk_menu_context_reset_textures(nk, iconpath); - task_push_image_load(settings->path.menu_wallpaper, "cb_menu_wallpaper", + task_push_image_load(settings->path.menu_wallpaper, + MENU_ENUM_LABEL_CB_MENU_WALLPAPER, menu_display_handle_wallpaper_upload, NULL); } diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 0f69de3b99..5bcb904332 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -714,7 +714,8 @@ static void xmb_update_thumbnail_image(void *data) return; if (path_file_exists(xmb->thumbnail_file_path)) - task_push_image_load(xmb->thumbnail_file_path, "cb_menu_thumbnail", + task_push_image_load(xmb->thumbnail_file_path, + MENU_ENUM_LABEL_CB_MENU_THUMBNAIL, menu_display_handle_thumbnail_upload, NULL); else if (xmb->depth == 1) xmb->thumbnail = 0; @@ -1051,7 +1052,8 @@ static void xmb_list_switch_new(xmb_handle_t *xmb, { if(path_file_exists(path)) { - task_push_image_load(path, "cb_menu_wallpaper", + task_push_image_load(path, + MENU_ENUM_LABEL_CB_MENU_WALLPAPER, menu_display_handle_wallpaper_upload, NULL); strlcpy(xmb->background_file_path, path, sizeof(xmb->background_file_path)); @@ -2737,7 +2739,8 @@ static void xmb_context_reset_background(const char *iconpath) strlcpy(path, settings->path.menu_wallpaper, sizeof(path)); if (path_file_exists(path)) - task_push_image_load(path, "cb_menu_wallpaper", + task_push_image_load(path, + MENU_ENUM_LABEL_CB_MENU_WALLPAPER, menu_display_handle_wallpaper_upload, NULL); } diff --git a/menu/drivers/zarch.c b/menu/drivers/zarch.c index 34acb5f002..371d640a29 100644 --- a/menu/drivers/zarch.c +++ b/menu/drivers/zarch.c @@ -1006,7 +1006,7 @@ static void *zarch_init(void **userdata) if (!string_is_empty(settings->path.menu_wallpaper)) task_push_image_load(settings->path.menu_wallpaper, - "cb_menu_wallpaper", + MENU_ENUM_LABEL_CB_MENU_WALLPAPER, menu_display_handle_wallpaper_upload, NULL); matrix_4x4_ortho(&zui->mvp, 0, 1, 1, 0, 0, 1); @@ -1091,7 +1091,8 @@ static void zarch_context_reset(void *data) zarch_context_bg_destroy(zui); task_push_image_load(settings->path.menu_wallpaper, - "cb_menu_wallpaper", menu_display_handle_wallpaper_upload, NULL); + MENU_ENUM_LABEL_CB_MENU_WALLPAPER, + menu_display_handle_wallpaper_upload, NULL); menu_display_allocate_white_texture(); diff --git a/msg_hash.h b/msg_hash.h index aa8e925e6f..ab6ea35681 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1489,6 +1489,7 @@ enum msg_hash_enums MENU_ENUM_LABEL_CB_UPDATE_OVERLAYS, MENU_ENUM_LABEL_CB_CORE_UPDATER_LIST, MENU_ENUM_LABEL_CB_MENU_WALLPAPER, + MENU_ENUM_LABEL_CB_MENU_THUMBNAIL, MENU_ENUM_LABEL_CB_THUMBNAILS_UPDATER_LIST, MENU_ENUM_LABEL_CB_LAKKA_LIST, MENU_ENUM_LABEL_CB_CORE_CONTENT_LIST, diff --git a/tasks/task_image.c b/tasks/task_image.c index 26498b1932..60243dd41f 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -322,22 +322,15 @@ bool task_image_load_handler(retro_task_t *task) } bool task_push_image_load(const char *fullpath, - const char *type, retro_task_callback_t cb, void *user_data) + enum msg_hash_enums enum_idx, retro_task_callback_t cb, void *user_data) { nbio_handle_t *nbio = NULL; retro_task_t *t = NULL; - uint32_t cb_type_hash = djb2_calculate(type); struct nbio_t *handle = NULL; nbio_image_handle_t *image = NULL; - switch (cb_type_hash) - { - case CB_MENU_WALLPAPER: - case CB_MENU_THUMBNAIL: - break; - default: - goto error_msg; - } + if (enum_idx == MSG_UNKNOWN) + goto error_msg; t = (retro_task_t*)calloc(1, sizeof(*t)); if (!t) diff --git a/tasks/tasks_internal.h b/tasks/tasks_internal.h index 15a458e0c1..078ee6e6bc 100644 --- a/tasks/tasks_internal.h +++ b/tasks/tasks_internal.h @@ -27,6 +27,7 @@ #include "../content.h" #include "../core_type.h" +#include "../msg_hash.h" RETRO_BEGIN_DECLS @@ -85,7 +86,8 @@ void *task_push_http_transfer(const char *url, bool mute, const char *type, task_retriever_info_t *http_task_get_transfer_list(void); #endif -bool task_push_image_load(const char *fullpath, const char *type, +bool task_push_image_load(const char *fullpath, + enum msg_hash_enums enum_idx, retro_task_callback_t cb, void *userdata); #ifdef HAVE_LIBRETRODB