From a20cd41d4b81b2cb5849587c514c5d5ff4aedafd Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 4 Sep 2016 23:07:10 +0200 Subject: [PATCH] More cleanups/move more state to menu_popup.c --- menu/cbs/menu_cbs_ok.c | 4 ++-- menu/menu_displaylist.c | 3 ++- menu/menu_driver.c | 12 +++++++----- menu/menu_popup.c | 26 +++++++++++++++++++++++++- menu/menu_popup.h | 9 +++++++++ 5 files changed, 45 insertions(+), 9 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 2004a19630..7cb4461068 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -27,6 +27,7 @@ #include "../menu_setting.h" #include "../menu_shader.h" #include "../menu_navigation.h" +#include "../menu_popup.h" #include "../menu_content.h" #include "../../configuration.h" @@ -240,9 +241,8 @@ int generic_action_ok_displaylist_push(const char *path, break; case ACTION_OK_DL_HELP: info_label = label; - menu->help_screen.type = type; - menu->help_screen.push = true; dl_type = DISPLAYLIST_HELP; + menu_popup_push_pending(menu, true, type); break; case ACTION_OK_DL_RPL_ENTRY: strlcpy(menu->deferred_path, label, sizeof(menu->deferred_path)); diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 86547bdcc2..ec8a8fe882 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -28,6 +28,7 @@ #include "menu_content.h" #include "menu_driver.h" #include "menu_navigation.h" +#include "menu_popup.h" #include "menu_cbs.h" #ifdef HAVE_LIBRETRODB @@ -4177,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->help_screen.push = false; + menu_popup_push_pending(menu, false, MENU_HELP_NONE); break; case DISPLAYLIST_SETTING_ENUM: { diff --git a/menu/menu_driver.c b/menu/menu_driver.c index d78349dcf6..6060574149 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -24,6 +24,7 @@ #include "menu_cbs.h" #include "menu_display.h" #include "menu_navigation.h" +#include "menu_popup.h" #include "menu_shader.h" #include "../config.def.h" @@ -171,8 +172,9 @@ static bool menu_init(menu_handle_t *menu_data) if (settings->menu_show_start_screen) { - menu_data->help_screen.push = true; - menu_data->help_screen.type = MENU_HELP_WELCOME; + menu_popup_push_pending(menu_data, true, + MENU_HELP_WELCOME); + settings->menu_show_start_screen = false; command_event(CMD_EVENT_MENU_SAVE_CURRENT_CONFIG, NULL); } @@ -181,15 +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_data->help_screen.push + && menu_popup_is_push_pending(menu_data) #else && (settings->bundle_assets_extract_version_current != settings->bundle_assets_extract_last_version) #endif ) { - menu_data->help_screen.type = MENU_HELP_EXTRACT; - menu_data->help_screen.push = true; + menu_popup_push_pending(menu_data, true, MENU_HELP_EXTRACT); #ifdef HAVE_ZLIB task_push_decompress(settings->path.bundle_assets_src, settings->path.bundle_assets_dst, @@ -567,6 +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); free(menu_driver_data); } menu_driver_data = NULL; diff --git a/menu/menu_popup.c b/menu/menu_popup.c index 48674d6364..e4018a7eb8 100644 --- a/menu/menu_popup.c +++ b/menu/menu_popup.c @@ -220,11 +220,27 @@ int menu_popup_iterate_help(menu_handle_t *menu, return 0; } +void menu_popup_push_pending(menu_handle_t *menu, + bool push, enum menu_help_type type) +{ + if (!menu) + return; + menu->help_screen.push = push; + menu->help_screen.type = type; +} + +bool menu_popup_is_push_pending(menu_handle_t *menu) +{ + if (!menu) + return false; + return menu->help_screen.push; +} + void menu_popup_push(menu_handle_t *menu) { menu_displaylist_info_t info = {0}; - if (!menu->help_screen.push) + if (!menu_popup_is_push_pending(menu)) return; info.list = menu_entries_get_menu_stack_ptr(0); @@ -235,3 +251,11 @@ void menu_popup_push(menu_handle_t *menu) menu_displaylist_ctl(DISPLAYLIST_HELP, &info); } + +void menu_popup_deinit(menu_handle_t *menu) +{ + if (!menu) + return; + menu->help_screen.push = false; + menu->help_screen.type = MENU_HELP_NONE; +} diff --git a/menu/menu_popup.h b/menu/menu_popup.h index 898dd01460..136cc36c64 100644 --- a/menu/menu_popup.h +++ b/menu/menu_popup.h @@ -20,6 +20,8 @@ #include #include +#include + #include RETRO_BEGIN_DECLS @@ -27,8 +29,15 @@ RETRO_BEGIN_DECLS int menu_popup_iterate_help(menu_handle_t *menu, char *s, size_t len, const char *label); +bool menu_popup_is_push_pending(menu_handle_t *menu); + +void menu_popup_push_pending(menu_handle_t *menu, + bool push, enum menu_help_type type); + void menu_popup_push(menu_handle_t *menu); +void menu_popup_deinit(menu_handle_t *menu); + RETRO_END_DECLS #endif