From 9e2a148b7e1293196d4365726cda54678a4b5899 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 4 Sep 2016 23:14:04 +0200 Subject: [PATCH] Make menu_popup.c self-contained --- menu/cbs/menu_cbs_ok.c | 2 +- menu/drivers/menu_generic.c | 4 ++-- menu/menu_displaylist.c | 2 +- menu/menu_driver.c | 8 ++++---- menu/menu_driver.h | 22 -------------------- menu/menu_popup.c | 41 +++++++++++++++++-------------------- menu/menu_popup.h | 27 +++++++++++++++++------- 7 files changed, 47 insertions(+), 59 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 7cb4461068..28d2cdaf77 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -242,7 +242,7 @@ int generic_action_ok_displaylist_push(const char *path, case ACTION_OK_DL_HELP: info_label = label; dl_type = DISPLAYLIST_HELP; - menu_popup_push_pending(menu, true, type); + menu_popup_push_pending(true, type); break; case ACTION_OK_DL_RPL_ENTRY: strlcpy(menu->deferred_path, label, sizeof(menu->deferred_path)); diff --git a/menu/drivers/menu_generic.c b/menu/drivers/menu_generic.c index 3ce95bcb61..684e1d3b7a 100644 --- a/menu/drivers/menu_generic.c +++ b/menu/drivers/menu_generic.c @@ -100,7 +100,7 @@ int generic_menu_iterate(void *data, void *userdata, enum menu_action action) switch (iterate_type) { case ITERATE_TYPE_HELP: - ret = menu_popup_iterate_help(menu, + ret = menu_popup_iterate_help( menu->menu_state.msg, sizeof(menu->menu_state.msg), label); BIT64_SET(menu->state, MENU_STATE_RENDER_MESSAGEBOX); BIT64_SET(menu->state, MENU_STATE_POST_ITERATE); @@ -232,7 +232,7 @@ int generic_menu_iterate(void *data, void *userdata, enum menu_action action) BIT64_SET(menu->state, MENU_STATE_POST_ITERATE); /* Have to defer it so we let settings refresh. */ - menu_popup_push(menu); + menu_popup_push(); break; } diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index ec8a8fe882..0b6e7f3675 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -4178,7 +4178,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) case DISPLAYLIST_HELP: menu_entries_append_enum(info->list, info->path, info->label, MSG_UNKNOWN, info->type, info->directory_ptr, 0); - menu_popup_push_pending(menu, false, MENU_HELP_NONE); + menu_popup_push_pending(false, MENU_HELP_NONE); break; case DISPLAYLIST_SETTING_ENUM: { diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 6060574149..b8a2b66f1d 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -172,7 +172,7 @@ static bool menu_init(menu_handle_t *menu_data) if (settings->menu_show_start_screen) { - menu_popup_push_pending(menu_data, true, + menu_popup_push_pending(true, MENU_HELP_WELCOME); settings->menu_show_start_screen = false; @@ -183,14 +183,14 @@ static bool menu_init(menu_handle_t *menu_data) && !string_is_empty(settings->path.bundle_assets_src) && !string_is_empty(settings->path.bundle_assets_dst) #ifdef IOS - && menu_popup_is_push_pending(menu_data) + && menu_popup_is_push_pending() #else && (settings->bundle_assets_extract_version_current != settings->bundle_assets_extract_last_version) #endif ) { - menu_popup_push_pending(menu_data, true, MENU_HELP_EXTRACT); + menu_popup_push_pending(true, MENU_HELP_EXTRACT); #ifdef HAVE_ZLIB task_push_decompress(settings->path.bundle_assets_src, settings->path.bundle_assets_dst, @@ -568,7 +568,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) core_info_deinit_list(); core_info_free_current_core(); - menu_popup_deinit(menu_driver_data); + menu_popup_deinit(); free(menu_driver_data); } menu_driver_data = NULL; diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 9eda349d35..9990999c7f 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -64,21 +64,6 @@ enum menu_environ_cb MENU_ENVIRON_LAST }; -enum menu_help_type -{ - MENU_HELP_NONE = 0, - MENU_HELP_WELCOME, - MENU_HELP_EXTRACT, - MENU_HELP_CONTROLS, - MENU_HELP_CHEEVOS_DESCRIPTION, - MENU_HELP_LOADING_CONTENT, - MENU_HELP_WHAT_IS_A_CORE, - MENU_HELP_CHANGE_VIRTUAL_GAMEPAD, - MENU_HELP_AUDIO_VIDEO_TROUBLESHOOTING, - MENU_HELP_SCANNING_CONTENT, - MENU_HELP_LAST -}; - enum menu_state_changes { MENU_STATE_RENDER_FRAMEBUFFER = 0, @@ -233,13 +218,6 @@ enum menu_settings_type typedef struct { - struct - { - bool push; - unsigned id; - enum menu_help_type type; - } help_screen; - char deferred_path[PATH_MAX_LENGTH]; char scratch_buf[PATH_MAX_LENGTH]; diff --git a/menu/menu_popup.c b/menu/menu_popup.c index e4018a7eb8..b0640bc5de 100644 --- a/menu/menu_popup.c +++ b/menu/menu_popup.c @@ -26,8 +26,11 @@ #include "../input/input_autodetect.h" #include "../input/input_config.h" -int menu_popup_iterate_help(menu_handle_t *menu, - char *s, size_t len, const char *label) +static bool menu_popup_pending_push = false; +static unsigned menu_popup_id = 0; +static enum menu_help_type menu_popup_type = MENU_HELP_NONE; + +int menu_popup_iterate_help(char *s, size_t len, const char *label) { #ifdef HAVE_CHEEVOS cheevos_ctx_desc_t desc_info; @@ -35,7 +38,7 @@ int menu_popup_iterate_help(menu_handle_t *menu, bool do_exit = false; settings_t *settings = config_get_ptr(); - switch (menu->help_screen.type) + switch (menu_popup_type) { case MENU_HELP_WELCOME: { @@ -167,7 +170,7 @@ int menu_popup_iterate_help(menu_handle_t *menu, #ifdef HAVE_CHEEVOS case MENU_HELP_CHEEVOS_DESCRIPTION: - desc_info.idx = menu->help_screen.id; + desc_info.idx = menu_popup_id; desc_info.s = s; desc_info.len = len; cheevos_get_description(&desc_info); @@ -213,34 +216,29 @@ int menu_popup_iterate_help(menu_handle_t *menu, if (do_exit) { - menu->help_screen.type = MENU_HELP_NONE; + menu_popup_type = MENU_HELP_NONE; return 1; } return 0; } -void menu_popup_push_pending(menu_handle_t *menu, - bool push, enum menu_help_type type) +void menu_popup_push_pending(bool push, enum menu_help_type type) { - if (!menu) - return; - menu->help_screen.push = push; - menu->help_screen.type = type; + menu_popup_pending_push = push; + menu_popup_type = type; } -bool menu_popup_is_push_pending(menu_handle_t *menu) +bool menu_popup_is_push_pending(void) { - if (!menu) - return false; - return menu->help_screen.push; + return menu_popup_pending_push; } -void menu_popup_push(menu_handle_t *menu) +void menu_popup_push(void) { menu_displaylist_info_t info = {0}; - if (!menu_popup_is_push_pending(menu)) + if (!menu_popup_is_push_pending()) return; info.list = menu_entries_get_menu_stack_ptr(0); @@ -252,10 +250,9 @@ void menu_popup_push(menu_handle_t *menu) menu_displaylist_ctl(DISPLAYLIST_HELP, &info); } -void menu_popup_deinit(menu_handle_t *menu) +void menu_popup_deinit(void) { - if (!menu) - return; - menu->help_screen.push = false; - menu->help_screen.type = MENU_HELP_NONE; + menu_popup_pending_push = false; + menu_popup_id = 0; + menu_popup_type = MENU_HELP_NONE; } diff --git a/menu/menu_popup.h b/menu/menu_popup.h index 136cc36c64..bc5b38def5 100644 --- a/menu/menu_popup.h +++ b/menu/menu_popup.h @@ -24,19 +24,32 @@ #include +enum menu_help_type +{ + MENU_HELP_NONE = 0, + MENU_HELP_WELCOME, + MENU_HELP_EXTRACT, + MENU_HELP_CONTROLS, + MENU_HELP_CHEEVOS_DESCRIPTION, + MENU_HELP_LOADING_CONTENT, + MENU_HELP_WHAT_IS_A_CORE, + MENU_HELP_CHANGE_VIRTUAL_GAMEPAD, + MENU_HELP_AUDIO_VIDEO_TROUBLESHOOTING, + MENU_HELP_SCANNING_CONTENT, + MENU_HELP_LAST +}; + RETRO_BEGIN_DECLS -int menu_popup_iterate_help(menu_handle_t *menu, - char *s, size_t len, const char *label); +int menu_popup_iterate_help(char *s, size_t len, const char *label); -bool menu_popup_is_push_pending(menu_handle_t *menu); +bool menu_popup_is_push_pending(void); -void menu_popup_push_pending(menu_handle_t *menu, - bool push, enum menu_help_type type); +void menu_popup_push_pending(bool push, enum menu_help_type type); -void menu_popup_push(menu_handle_t *menu); +void menu_popup_push(void); -void menu_popup_deinit(menu_handle_t *menu); +void menu_popup_deinit(void); RETRO_END_DECLS