Start refactoring action_iterate_help

This commit is contained in:
twinaphex 2015-07-08 05:45:43 +02:00
parent a59fd029b1
commit bfb996dbcd
4 changed files with 61 additions and 39 deletions

View File

@ -154,7 +154,7 @@ static int load_or_open_zip_iterate(char *s, size_t len, unsigned action)
static int action_iterate_help(char *s, size_t len, const char *label) static int action_iterate_help(char *s, size_t len, const char *label)
{ {
unsigned i; unsigned i;
static const unsigned binds[] = { const unsigned binds[] = {
RETRO_DEVICE_ID_JOYPAD_UP, RETRO_DEVICE_ID_JOYPAD_UP,
RETRO_DEVICE_ID_JOYPAD_DOWN, RETRO_DEVICE_ID_JOYPAD_DOWN,
RETRO_DEVICE_ID_JOYPAD_A, RETRO_DEVICE_ID_JOYPAD_A,
@ -165,47 +165,61 @@ static int action_iterate_help(char *s, size_t len, const char *label)
RETRO_DEVICE_ID_JOYPAD_X, RETRO_DEVICE_ID_JOYPAD_X,
RETRO_DEVICE_ID_JOYPAD_Y, RETRO_DEVICE_ID_JOYPAD_Y,
}; };
char desc[ARRAY_SIZE(binds)][64] = {{0}}; menu_handle_t *menu = menu_driver_get_ptr();
settings_t *settings = config_get_ptr();
menu_driver_render(); menu_driver_render();
for (i = 0; i < ARRAY_SIZE(binds); i++) switch (menu->help_screen_type)
{ {
const struct retro_keybind *keybind = (const struct retro_keybind*) case MENU_HELP_DEFAULT:
&settings->input.binds[0][binds[i]]; {
const struct retro_keybind *auto_bind = (const struct retro_keybind*) char desc[ARRAY_SIZE(binds)][64] = {{0}};
input_get_auto_bind(0, binds[i]); settings_t *settings = config_get_ptr();
input_get_bind_string(desc[i], keybind, auto_bind, sizeof(desc[i])); for (i = 0; i < ARRAY_SIZE(binds); i++)
{
const struct retro_keybind *keybind = (const struct retro_keybind*)
&settings->input.binds[0][binds[i]];
const struct retro_keybind *auto_bind = (const struct retro_keybind*)
input_get_auto_bind(0, binds[i]);
input_get_bind_string(desc[i], keybind, auto_bind, sizeof(desc[i]));
}
snprintf(s, len,
"Welcome to RetroArch\n"
" \n" /* strtok_r doesn't split empty strings. */
"Basic Menu controls:\n"
" Scroll (Up): %-20s\n"
" Scroll (Down): %-20s\n"
" Accept/OK: %-20s\n"
" Back: %-20s\n"
" Info: %-20s\n"
"Enter/Exit Menu: %-20s\n"
" Exit RetroArch: %-20s\n"
"Toggle Keyboard: %-20s\n"
" \n"
"To run content:\n"
"Load a libretro core (Core).\n"
"Load a content file (Load Content). \n"
" \n"
"See Path Settings to set directories \n"
"for faster access to files.\n"
" \n"
"Press Accept/OK to continue.",
desc[0], desc[1], desc[2], desc[3], desc[4], desc[5], desc[6], desc[7]);
}
break;
case MENU_HELP_EXTRACTING:
strlcpy(s, "Extracting, please wait...\n", len);
break;
default:
break;
} }
snprintf(s, len,
"Welcome to RetroArch\n"
" \n" /* strtok_r doesn't split empty strings. */
"Basic Menu controls:\n"
" Scroll (Up): %-20s\n"
" Scroll (Down): %-20s\n"
" Accept/OK: %-20s\n"
" Back: %-20s\n"
" Info: %-20s\n"
"Enter/Exit Menu: %-20s\n"
" Exit RetroArch: %-20s\n"
"Toggle Keyboard: %-20s\n"
" \n"
"To run content:\n"
"Load a libretro core (Core).\n"
"Load a content file (Load Content). \n"
" \n"
"See Path Settings to set directories \n"
"for faster access to files.\n"
" \n"
"Press Accept/OK to continue.",
desc[0], desc[1], desc[2], desc[3], desc[4], desc[5], desc[6], desc[7]);
return 0; return 0;
} }
@ -561,7 +575,7 @@ static int action_iterate_main(const char *label, unsigned action)
do_render = true; do_render = true;
/* Have to defer it so we let settings refresh. */ /* Have to defer it so we let settings refresh. */
if (menu->push_start_screen) if (menu->push_help_screen)
{ {
menu_displaylist_info_t info = {0}; menu_displaylist_info_t info = {0};

View File

@ -227,7 +227,7 @@ void *menu_init(const void *data)
goto error; goto error;
#endif #endif
menu->push_start_screen = settings->menu_show_start_screen; menu->push_help_screen = settings->menu_show_start_screen;
settings->menu_show_start_screen = false; settings->menu_show_start_screen = false;
menu_shader_manager_init(menu); menu_shader_manager_init(menu);

View File

@ -2170,7 +2170,7 @@ int menu_displaylist_push_list(menu_displaylist_info_t *info, unsigned type)
break; break;
case DISPLAYLIST_HELP: case DISPLAYLIST_HELP:
menu_list_push(info->list, info->path, info->label, info->type, info->directory_ptr, 0); menu_list_push(info->list, info->path, info->label, info->type, info->directory_ptr, 0);
menu->push_start_screen = false; menu->push_help_screen = false;
menu_display_fb_set_dirty(); menu_display_fb_set_dirty();
break; break;
case DISPLAYLIST_MAIN_MENU: case DISPLAYLIST_MAIN_MENU:

View File

@ -50,13 +50,21 @@ typedef enum
MENU_ENVIRON_LAST MENU_ENVIRON_LAST
} menu_environ_cb_t; } menu_environ_cb_t;
typedef enum
{
MENU_HELP_DEFAULT = 0,
MENU_HELP_EXTRACTING,
MENU_HELP_LAST
} menu_help_type_t;
typedef struct typedef struct
{ {
void *userdata; void *userdata;
float scroll_y; float scroll_y;
bool push_start_screen; bool push_help_screen;
menu_help_type_t help_screen_type;
bool defer_core; bool defer_core;
char deferred_path[PATH_MAX_LENGTH]; char deferred_path[PATH_MAX_LENGTH];