From 9e61f6ffd0a2c42e1c20ba606a6eceb9526810ef Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 4 Sep 2016 23:34:24 +0200 Subject: [PATCH] Cleanups --- menu/cbs/menu_cbs_ok.c | 2 +- menu/drivers/menu_generic.c | 4 ++-- menu/menu_displaylist.c | 2 +- menu/menu_driver.c | 7 +++--- menu/menu_driver.h | 22 ------------------ menu/menu_popup.c | 45 ++++++++++++++++++++----------------- menu/menu_popup.h | 27 +++++++++++++++++----- 7 files changed, 55 insertions(+), 54 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 5aae177453..ddef65045b 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -241,7 +241,7 @@ int generic_action_ok_displaylist_push(const char *path, break; case ACTION_OK_DL_HELP: info_label = label; - menu_popup_push_pending(menu, true, type); + menu_popup_push_pending(true, type); dl_type = DISPLAYLIST_HELP; break; case ACTION_OK_DL_RPL_ENTRY: 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 e2ccc2ec21..3b2362f983 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_unset_pending_push(menu); + menu_popup_unset_pending_push(); break; case DISPLAYLIST_SETTING_ENUM: { diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 5b7f484fb4..08dff17096 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_HELP_WELCOME); + menu_popup_push_pending(true, MENU_HELP_WELCOME); settings->menu_show_start_screen = false; command_event(CMD_EVENT_MENU_SAVE_CURRENT_CONFIG, NULL); } @@ -181,14 +181,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, @@ -565,6 +565,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) core_info_deinit_list(); core_info_free_current_core(); + menu_popup_reset(); free(menu_driver_data); } 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 ee6575b26c..0bb17f68f9 100644 --- a/menu/menu_popup.c +++ b/menu/menu_popup.c @@ -26,16 +26,19 @@ #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_current_id = 0; +static enum menu_help_type menu_popup_current_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; #endif - bool do_exit = false; + bool do_exit = false; settings_t *settings = config_get_ptr(); - switch (menu->help_screen.type) + switch (menu_popup_current_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_current_id; desc_info.s = s; desc_info.len = len; cheevos_get_description(&desc_info); @@ -213,39 +216,34 @@ int menu_popup_iterate_help(menu_handle_t *menu, if (do_exit) { - menu->help_screen.type = MENU_HELP_NONE; + menu_popup_current_type = MENU_HELP_NONE; return 1; } return 0; } -bool menu_popup_is_push_pending(menu_handle_t *menu) +bool menu_popup_is_push_pending(void) { - return menu->help_screen.push; + return menu_popup_pending_push; } -void menu_popup_unset_pending_push(menu_handle_t *menu) +void menu_popup_unset_pending_push(void) { - if (!menu) - return; - menu->help_screen.push = false; + menu_popup_pending_push = false; } -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_current_type = type; } -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); @@ -256,3 +254,10 @@ void menu_popup_push(menu_handle_t *menu) menu_displaylist_ctl(DISPLAYLIST_HELP, &info); } + +void menu_popup_reset(void) +{ + menu_popup_pending_push = false; + menu_popup_current_id = 0; + menu_popup_current_type = MENU_HELP_NONE; +} diff --git a/menu/menu_popup.h b/menu/menu_popup.h index adb97dfa5b..ee1158730e 100644 --- a/menu/menu_popup.h +++ b/menu/menu_popup.h @@ -24,19 +24,36 @@ #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 -void menu_popup_push_pending(menu_handle_t *menu, +void menu_popup_push_pending( bool push, enum menu_help_type type); -int menu_popup_iterate_help(menu_handle_t *menu, +int menu_popup_iterate_help( char *s, size_t len, const char *label); -void menu_popup_unset_pending_push(menu_handle_t *menu); +void menu_popup_unset_pending_push(void); -bool menu_popup_is_push_pending(menu_handle_t *menu); +bool menu_popup_is_push_pending(void); -void menu_popup_push(menu_handle_t *menu); +void menu_popup_push(void); + +void menu_popup_reset(void); RETRO_END_DECLS