Make menu_popup.c self-contained

This commit is contained in:
twinaphex 2016-09-04 23:14:04 +02:00
parent a20cd41d4b
commit 9e2a148b7e
7 changed files with 47 additions and 59 deletions

View File

@ -242,7 +242,7 @@ int generic_action_ok_displaylist_push(const char *path,
case ACTION_OK_DL_HELP: case ACTION_OK_DL_HELP:
info_label = label; info_label = label;
dl_type = DISPLAYLIST_HELP; dl_type = DISPLAYLIST_HELP;
menu_popup_push_pending(menu, true, type); menu_popup_push_pending(true, type);
break; break;
case ACTION_OK_DL_RPL_ENTRY: case ACTION_OK_DL_RPL_ENTRY:
strlcpy(menu->deferred_path, label, sizeof(menu->deferred_path)); strlcpy(menu->deferred_path, label, sizeof(menu->deferred_path));

View File

@ -100,7 +100,7 @@ int generic_menu_iterate(void *data, void *userdata, enum menu_action action)
switch (iterate_type) switch (iterate_type)
{ {
case ITERATE_TYPE_HELP: 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); menu->menu_state.msg, sizeof(menu->menu_state.msg), label);
BIT64_SET(menu->state, MENU_STATE_RENDER_MESSAGEBOX); BIT64_SET(menu->state, MENU_STATE_RENDER_MESSAGEBOX);
BIT64_SET(menu->state, MENU_STATE_POST_ITERATE); 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); BIT64_SET(menu->state, MENU_STATE_POST_ITERATE);
/* Have to defer it so we let settings refresh. */ /* Have to defer it so we let settings refresh. */
menu_popup_push(menu); menu_popup_push();
break; break;
} }

View File

@ -4178,7 +4178,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data)
case DISPLAYLIST_HELP: case DISPLAYLIST_HELP:
menu_entries_append_enum(info->list, info->path, menu_entries_append_enum(info->list, info->path,
info->label, MSG_UNKNOWN, info->type, info->directory_ptr, 0); 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; break;
case DISPLAYLIST_SETTING_ENUM: case DISPLAYLIST_SETTING_ENUM:
{ {

View File

@ -172,7 +172,7 @@ static bool menu_init(menu_handle_t *menu_data)
if (settings->menu_show_start_screen) if (settings->menu_show_start_screen)
{ {
menu_popup_push_pending(menu_data, true, menu_popup_push_pending(true,
MENU_HELP_WELCOME); MENU_HELP_WELCOME);
settings->menu_show_start_screen = false; 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_src)
&& !string_is_empty(settings->path.bundle_assets_dst) && !string_is_empty(settings->path.bundle_assets_dst)
#ifdef IOS #ifdef IOS
&& menu_popup_is_push_pending(menu_data) && menu_popup_is_push_pending()
#else #else
&& (settings->bundle_assets_extract_version_current && (settings->bundle_assets_extract_version_current
!= settings->bundle_assets_extract_last_version) != settings->bundle_assets_extract_last_version)
#endif #endif
) )
{ {
menu_popup_push_pending(menu_data, true, MENU_HELP_EXTRACT); menu_popup_push_pending(true, MENU_HELP_EXTRACT);
#ifdef HAVE_ZLIB #ifdef HAVE_ZLIB
task_push_decompress(settings->path.bundle_assets_src, task_push_decompress(settings->path.bundle_assets_src,
settings->path.bundle_assets_dst, 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_deinit_list();
core_info_free_current_core(); core_info_free_current_core();
menu_popup_deinit(menu_driver_data); menu_popup_deinit();
free(menu_driver_data); free(menu_driver_data);
} }
menu_driver_data = NULL; menu_driver_data = NULL;

View File

@ -64,21 +64,6 @@ enum menu_environ_cb
MENU_ENVIRON_LAST 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 enum menu_state_changes
{ {
MENU_STATE_RENDER_FRAMEBUFFER = 0, MENU_STATE_RENDER_FRAMEBUFFER = 0,
@ -233,13 +218,6 @@ enum menu_settings_type
typedef struct typedef struct
{ {
struct
{
bool push;
unsigned id;
enum menu_help_type type;
} help_screen;
char deferred_path[PATH_MAX_LENGTH]; char deferred_path[PATH_MAX_LENGTH];
char scratch_buf[PATH_MAX_LENGTH]; char scratch_buf[PATH_MAX_LENGTH];

View File

@ -26,8 +26,11 @@
#include "../input/input_autodetect.h" #include "../input/input_autodetect.h"
#include "../input/input_config.h" #include "../input/input_config.h"
int menu_popup_iterate_help(menu_handle_t *menu, static bool menu_popup_pending_push = false;
char *s, size_t len, const char *label) 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 #ifdef HAVE_CHEEVOS
cheevos_ctx_desc_t desc_info; cheevos_ctx_desc_t desc_info;
@ -35,7 +38,7 @@ int menu_popup_iterate_help(menu_handle_t *menu,
bool do_exit = false; bool do_exit = false;
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
switch (menu->help_screen.type) switch (menu_popup_type)
{ {
case MENU_HELP_WELCOME: case MENU_HELP_WELCOME:
{ {
@ -167,7 +170,7 @@ int menu_popup_iterate_help(menu_handle_t *menu,
#ifdef HAVE_CHEEVOS #ifdef HAVE_CHEEVOS
case MENU_HELP_CHEEVOS_DESCRIPTION: case MENU_HELP_CHEEVOS_DESCRIPTION:
desc_info.idx = menu->help_screen.id; desc_info.idx = menu_popup_id;
desc_info.s = s; desc_info.s = s;
desc_info.len = len; desc_info.len = len;
cheevos_get_description(&desc_info); cheevos_get_description(&desc_info);
@ -213,34 +216,29 @@ int menu_popup_iterate_help(menu_handle_t *menu,
if (do_exit) if (do_exit)
{ {
menu->help_screen.type = MENU_HELP_NONE; menu_popup_type = MENU_HELP_NONE;
return 1; return 1;
} }
return 0; return 0;
} }
void menu_popup_push_pending(menu_handle_t *menu, void menu_popup_push_pending(bool push, enum menu_help_type type)
bool push, enum menu_help_type type)
{ {
if (!menu) menu_popup_pending_push = push;
return; menu_popup_type = type;
menu->help_screen.push = push;
menu->help_screen.type = type;
} }
bool menu_popup_is_push_pending(menu_handle_t *menu) bool menu_popup_is_push_pending(void)
{ {
if (!menu) return menu_popup_pending_push;
return false;
return menu->help_screen.push;
} }
void menu_popup_push(menu_handle_t *menu) void menu_popup_push(void)
{ {
menu_displaylist_info_t info = {0}; menu_displaylist_info_t info = {0};
if (!menu_popup_is_push_pending(menu)) if (!menu_popup_is_push_pending())
return; return;
info.list = menu_entries_get_menu_stack_ptr(0); 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); menu_displaylist_ctl(DISPLAYLIST_HELP, &info);
} }
void menu_popup_deinit(menu_handle_t *menu) void menu_popup_deinit(void)
{ {
if (!menu) menu_popup_pending_push = false;
return; menu_popup_id = 0;
menu->help_screen.push = false; menu_popup_type = MENU_HELP_NONE;
menu->help_screen.type = MENU_HELP_NONE;
} }

View File

@ -24,19 +24,32 @@
#include <retro_common_api.h> #include <retro_common_api.h>
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 RETRO_BEGIN_DECLS
int menu_popup_iterate_help(menu_handle_t *menu, int menu_popup_iterate_help(char *s, size_t len, const char *label);
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, void menu_popup_push_pending(bool push, enum menu_help_type type);
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 RETRO_END_DECLS