From 99d21fd70163f605394dcee6575fd5c04cf966c1 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 10 Feb 2016 06:43:56 +0100 Subject: [PATCH] Implement RARCH_MENU_CTL_LIST_CACHE --- menu/cbs/menu_cbs_left.c | 15 +++++++++++---- menu/cbs/menu_cbs_right.c | 15 +++++++++++---- menu/menu_driver.c | 22 ++++++++++++---------- 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/menu/cbs/menu_cbs_left.c b/menu/cbs/menu_cbs_left.c index 368eda4fe6..1fbc70a0a9 100644 --- a/menu/cbs/menu_cbs_left.c +++ b/menu/cbs/menu_cbs_left.c @@ -158,11 +158,18 @@ static int action_left_mainmenu(unsigned type, const char *label, switch (push_list) { case 1: - menu_driver_list_cache(MENU_LIST_HORIZONTAL, action); + { + menu_ctx_list_t list_info; - if (cbs && cbs->action_content_list_switch) - return cbs->action_content_list_switch( - selection_buf, menu_stack, "", "", 0); + list_info.type = MENU_LIST_HORIZONTAL; + list_info.action = action; + + menu_driver_ctl(RARCH_MENU_CTL_LIST_CACHE, &list_info); + + if (cbs && cbs->action_content_list_switch) + return cbs->action_content_list_switch( + selection_buf, menu_stack, "", "", 0); + } break; case 2: action_left_scroll(0, "", false); diff --git a/menu/cbs/menu_cbs_right.c b/menu/cbs/menu_cbs_right.c index 61c1416812..67830b2e9a 100644 --- a/menu/cbs/menu_cbs_right.c +++ b/menu/cbs/menu_cbs_right.c @@ -177,11 +177,18 @@ static int action_right_mainmenu(unsigned type, const char *label, switch (push_list) { case 1: - menu_driver_list_cache(MENU_LIST_HORIZONTAL, action); + { + menu_ctx_list_t list_info; - if (cbs && cbs->action_content_list_switch) - return cbs->action_content_list_switch(selection_buf, menu_stack, - "", "", 0); + list_info.type = MENU_LIST_HORIZONTAL; + list_info.action = action; + + menu_driver_ctl(RARCH_MENU_CTL_LIST_CACHE, &list_info); + + if (cbs && cbs->action_content_list_switch) + return cbs->action_content_list_switch(selection_buf, menu_stack, + "", "", 0); + } break; case 2: action_right_scroll(0, "", false); diff --git a/menu/menu_driver.c b/menu/menu_driver.c index fb95149ea4..259c76f5b3 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -249,9 +249,9 @@ void menu_driver_list_free(file_list_t *list, size_t idx, size_t list_size) size_t menu_driver_list_get_selection(void) { - if (menu_driver_ctx && menu_driver_ctx->list_get_selection) - return menu_driver_ctx->list_get_selection(menu_userdata); - return 0; + if (!menu_driver_ctx || !menu_driver_ctx->list_get_selection) + return 0; + return menu_driver_ctx->list_get_selection(menu_userdata); } bool menu_driver_list_push(menu_displaylist_info_t *info, unsigned type) @@ -263,12 +263,6 @@ bool menu_driver_list_push(menu_displaylist_info_t *info, unsigned type) return false; } -void menu_driver_list_cache(menu_list_type_t type, unsigned action) -{ - if (menu_driver_ctx->list_cache) - menu_driver_ctx->list_cache(menu_userdata, type, action); -} - size_t menu_driver_list_get_size(menu_list_type_t type) { if (!menu_driver_ctx || !menu_driver_ctx->list_get_size) @@ -706,7 +700,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) menu_driver_ctx->context_reset(menu_userdata); break; case RARCH_MENU_CTL_CONTEXT_DESTROY: - if (menu_driver_ctx && menu_driver_ctx->context_destroy) + if (menu_driver_ctx->context_destroy) menu_driver_ctx->context_destroy(menu_userdata); break; case RARCH_MENU_CTL_SHADER_MANAGER_INIT: @@ -725,6 +719,14 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) menu_driver_ctx->list_set_selection(menu_userdata, list); } break; + case RARCH_MENU_CTL_LIST_CACHE: + { + menu_ctx_list_t *list = (menu_ctx_list_t*)data; + if (!list || !menu_driver_ctx || !menu_driver_ctx->list_cache) + return false; + menu_driver_ctx->list_cache(menu_userdata, list->type, list->action); + } + break; case RARCH_MENU_CTL_LIST_INSERT: { menu_ctx_list_t *list = (menu_ctx_list_t*)data;