mirror of
https://github.com/libretro/RetroArch.git
synced 2025-02-15 06:58:34 +00:00
Merge pull request #324 from libretro/initcommands
Implement an idea for a start screen.
This commit is contained in:
commit
3d386286e7
@ -406,6 +406,9 @@ static const bool stdin_cmd_enable = false;
|
||||
// Number of entries that will be kept in ROM history file.
|
||||
static const unsigned game_history_size = 100;
|
||||
|
||||
// Show RGUI start-up screen on boot.
|
||||
static const bool rgui_show_start_screen = true;
|
||||
|
||||
|
||||
////////////////////
|
||||
// Keybinds, Joypad
|
||||
|
@ -58,6 +58,7 @@ typedef enum
|
||||
RGUI_FILE_DEVICE,
|
||||
RGUI_FILE_USE_DIRECTORY,
|
||||
RGUI_SETTINGS,
|
||||
RGUI_START_SCREEN,
|
||||
|
||||
// Shader stuff
|
||||
RGUI_SETTINGS_VIDEO_OPTIONS,
|
||||
@ -287,6 +288,7 @@ typedef struct
|
||||
size_t selection_ptr;
|
||||
bool need_refresh;
|
||||
bool msg_force;
|
||||
bool push_start_screen;
|
||||
|
||||
// Quick jumping indices with L/R.
|
||||
// Rebuilt when parsing directory.
|
||||
|
@ -88,6 +88,10 @@ int menu_set_settings(unsigned setting, unsigned action)
|
||||
|
||||
switch (setting)
|
||||
{
|
||||
case RGUI_START_SCREEN:
|
||||
if (action == RGUI_ACTION_OK)
|
||||
rgui_list_push(rgui->menu_stack, "", RGUI_START_SCREEN, 0);
|
||||
break;
|
||||
case RGUI_SETTINGS_REWIND_ENABLE:
|
||||
if (action == RGUI_ACTION_OK ||
|
||||
action == RGUI_ACTION_LEFT ||
|
||||
|
@ -143,6 +143,8 @@ static void *rgui_init(void)
|
||||
rgui->selection_buf = (rgui_list_t*)calloc(1, sizeof(rgui_list_t));
|
||||
rgui_list_push(rgui->menu_stack, "", RGUI_SETTINGS, 0);
|
||||
rgui->selection_ptr = 0;
|
||||
rgui->push_start_screen = g_settings.rgui_show_start_screen;
|
||||
g_settings.rgui_show_start_screen = false;
|
||||
rgui_settings_populate_entries(rgui);
|
||||
|
||||
// Make sure that custom viewport is something sane incase we use it
|
||||
@ -303,6 +305,7 @@ static void rgui_settings_populate_entries(rgui_handle_t *rgui)
|
||||
#endif
|
||||
rgui_list_push(rgui->selection_buf, "RetroArch Config", RGUI_SETTINGS_CONFIG, 0);
|
||||
rgui_list_push(rgui->selection_buf, "Save New Config", RGUI_SETTINGS_SAVE_CONFIG, 0);
|
||||
rgui_list_push(rgui->selection_buf, "Help", RGUI_START_SCREEN, 0);
|
||||
rgui_list_push(rgui->selection_buf, "Quit RetroArch", RGUI_SETTINGS_QUIT_RARCH, 0);
|
||||
}
|
||||
|
||||
@ -572,6 +575,70 @@ static int rgui_custom_bind_iterate(rgui_handle_t *rgui, rgui_action_t action)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rgui_start_screen_iterate(rgui_handle_t *rgui, rgui_action_t action)
|
||||
{
|
||||
render_text(rgui);
|
||||
char msg[1024];
|
||||
|
||||
char desc[6][64];
|
||||
static const unsigned binds[] = {
|
||||
RETRO_DEVICE_ID_JOYPAD_UP,
|
||||
RETRO_DEVICE_ID_JOYPAD_DOWN,
|
||||
RETRO_DEVICE_ID_JOYPAD_A,
|
||||
RETRO_DEVICE_ID_JOYPAD_B,
|
||||
RARCH_MENU_TOGGLE,
|
||||
RARCH_QUIT_KEY,
|
||||
};
|
||||
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(binds); i++)
|
||||
{
|
||||
if (driver.input && driver.input->set_keybinds)
|
||||
{
|
||||
struct platform_bind key_label;
|
||||
strlcpy(key_label.desc, "Unknown", sizeof(key_label.desc));
|
||||
key_label.joykey = g_settings.input.binds[0][binds[i]].joykey;
|
||||
driver.input->set_keybinds(&key_label, 0, 0, 0, 1ULL << KEYBINDS_ACTION_GET_BIND_LABEL);
|
||||
strlcpy(desc[i], key_label.desc, sizeof(desc[i]));
|
||||
}
|
||||
else
|
||||
{
|
||||
const struct retro_keybind *bind = &g_settings.input.binds[0][binds[i]];
|
||||
input_get_bind_string(desc[i], bind, sizeof(desc[i]));
|
||||
}
|
||||
}
|
||||
|
||||
snprintf(msg, sizeof(msg),
|
||||
"-- Welcome to RetroArch / RGUI --\n"
|
||||
" \n" // strtok_r doesn't split empty strings.
|
||||
|
||||
"Basic RGUI controls:\n"
|
||||
" Scroll (Up): %-20s\n"
|
||||
" Scroll (Down): %-20s\n"
|
||||
" Accept/OK: %-20s\n"
|
||||
" Back: %-20s\n"
|
||||
"Enter/Exit RGUI: %-20s\n"
|
||||
" Exit RetroArch: %-20s\n"
|
||||
" \n"
|
||||
|
||||
"To play a game:\n"
|
||||
"Load a libretro core (Core).\n"
|
||||
"Load a ROM (Load Game). \n"
|
||||
" \n"
|
||||
|
||||
"See Path Options 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]);
|
||||
|
||||
render_messagebox(rgui, msg);
|
||||
|
||||
if (action == RGUI_ACTION_OK)
|
||||
rgui_list_pop(rgui->menu_stack, &rgui->selection_ptr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rgui_viewport_iterate(rgui_handle_t *rgui, rgui_action_t action)
|
||||
{
|
||||
rarch_viewport_t *custom = &g_extern.console.screen.viewports.custom_vp;
|
||||
@ -893,6 +960,13 @@ static int rgui_settings_iterate(rgui_handle_t *rgui, rgui_action_t action)
|
||||
|
||||
render_text(rgui);
|
||||
|
||||
// Have to defer it so we let settings refresh.
|
||||
if (rgui->push_start_screen)
|
||||
{
|
||||
rgui->push_start_screen = false;
|
||||
rgui_list_push(rgui->menu_stack, "", RGUI_START_SCREEN, 0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1127,7 +1201,9 @@ static int rgui_iterate(void *data, unsigned action)
|
||||
driver.video_poke->set_texture_frame(driver.video_data, menu_framebuf,
|
||||
false, RGUI_WIDTH, RGUI_HEIGHT, 1.0f);
|
||||
|
||||
if (menu_type_is_settings(menu_type))
|
||||
if (menu_type == RGUI_START_SCREEN)
|
||||
return rgui_start_screen_iterate(rgui, action);
|
||||
else if (menu_type_is_settings(menu_type))
|
||||
return rgui_settings_iterate(rgui, action);
|
||||
else if (menu_type == RGUI_SETTINGS_CUSTOM_VIEWPORT || menu_type == RGUI_SETTINGS_CUSTOM_VIEWPORT_2)
|
||||
return rgui_viewport_iterate(rgui, action);
|
||||
|
@ -257,6 +257,7 @@ static void render_text(rgui_handle_t *rgui)
|
||||
(menu_type == RGUI_SETTINGS_OPTIONS) ||
|
||||
(menu_type == RGUI_SETTINGS_CUSTOM_VIEWPORT || menu_type == RGUI_SETTINGS_CUSTOM_VIEWPORT_2) ||
|
||||
menu_type == RGUI_SETTINGS_CUSTOM_BIND ||
|
||||
menu_type == RGUI_START_SCREEN ||
|
||||
menu_type == RGUI_SETTINGS)
|
||||
snprintf(title, sizeof(title), "MENU %s", dir);
|
||||
else if (menu_type == RGUI_SETTINGS_OPEN_HISTORY)
|
||||
@ -587,6 +588,7 @@ static void render_text(rgui_handle_t *rgui)
|
||||
case RGUI_SETTINGS_OPTIONS:
|
||||
case RGUI_SETTINGS_CUSTOM_BIND_ALL:
|
||||
case RGUI_SETTINGS_CUSTOM_BIND_DEFAULT_ALL:
|
||||
case RGUI_START_SCREEN:
|
||||
strlcpy(type_str, "...", sizeof(type_str));
|
||||
break;
|
||||
#ifdef HAVE_OVERLAY
|
||||
|
@ -286,6 +286,7 @@ struct settings
|
||||
#if defined(HAVE_RGUI) || defined(HAVE_RMENU) || defined(HAVE_RMENU_XUI)
|
||||
char rgui_browser_directory[PATH_MAX];
|
||||
char rgui_config_directory[PATH_MAX];
|
||||
bool rgui_show_start_screen;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -46,6 +46,11 @@
|
||||
# Sets start directory for RGUI config browser.
|
||||
# rgui_config_directory =
|
||||
|
||||
# Show startup screen in RGUI.
|
||||
# Is automatically set to false when seen for the first time.
|
||||
# This is only updated in config if config_save_on_exit is set to true, however.
|
||||
# rgui_show_start_screen = true
|
||||
|
||||
# Flushes config to disk on exit. Useful for RGUI as settings can be modified.
|
||||
# Overwrites the config. #include's and comments are not preserved.
|
||||
# config_save_on_exit = false
|
||||
|
@ -230,6 +230,8 @@ void config_set_defaults(void)
|
||||
g_settings.stdin_cmd_enable = stdin_cmd_enable;
|
||||
g_settings.game_history_size = game_history_size;
|
||||
|
||||
g_settings.rgui_show_start_screen = rgui_show_start_screen;
|
||||
|
||||
rarch_assert(sizeof(g_settings.input.binds[0]) >= sizeof(retro_keybinds_1));
|
||||
rarch_assert(sizeof(g_settings.input.binds[1]) >= sizeof(retro_keybinds_rest));
|
||||
memcpy(g_settings.input.binds[0], retro_keybinds_1, sizeof(retro_keybinds_1));
|
||||
@ -760,6 +762,7 @@ bool config_load_file(const char *path)
|
||||
CONFIG_GET_PATH(rgui_config_directory, "rgui_config_directory");
|
||||
if (!strcmp(g_settings.rgui_config_directory, "default"))
|
||||
*g_settings.rgui_config_directory = '\0';
|
||||
CONFIG_GET_BOOL(rgui_show_start_screen, "rgui_show_start_screen");
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_OVERLAY
|
||||
@ -1088,6 +1091,7 @@ bool config_save_file(const char *path)
|
||||
#if defined(HAVE_RGUI) || defined(HAVE_RMENU) || defined(HAVE_RMENU_XUI)
|
||||
config_set_string(conf, "rgui_browser_directory", *g_settings.rgui_browser_directory ? g_settings.rgui_browser_directory : "default");
|
||||
config_set_string(conf, "rgui_config_directory", *g_settings.rgui_config_directory ? g_settings.rgui_config_directory : "default");
|
||||
config_set_bool(conf, "rgui_show_start_screen", g_settings.rgui_show_start_screen);
|
||||
#endif
|
||||
|
||||
config_set_string(conf, "game_history_path", g_settings.game_history_path);
|
||||
|
Loading…
x
Reference in New Issue
Block a user