Skip to content

Commit f7cf730

Browse files
authored
Add confirmation messagebox structure (#19059)
1 parent 15d8d5d commit f7cf730

12 files changed

Lines changed: 947 additions & 165 deletions

File tree

input/input_driver.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7998,6 +7998,8 @@ void input_driver_collect_system_input(input_driver_state_t *input_st,
79987998
* port 0 */
79997999
if (!display_kb && input && input->input_state)
80008000
{
8001+
struct menu_state *menu_st = menu_state_get_ptr();
8002+
bool swap_ok_cancel_buttons = settings->bools.input_menu_swap_ok_cancel_buttons;
80018003
unsigned i;
80028004
unsigned ids[][2] =
80038005
{
@@ -8021,15 +8023,22 @@ void input_driver_collect_system_input(input_driver_state_t *input_st,
80218023
{0, RARCH_UI_COMPANION_TOGGLE },
80228024
{0, RARCH_FPS_TOGGLE },
80238025
{0, RARCH_NETPLAY_HOST_TOGGLE },
8026+
{0, RARCH_BIND_LIST_END_NULL },
80248027
};
80258028

80268029
ids[14][0] = input_config_binds[0][RARCH_QUIT_KEY].key;
80278030
ids[15][0] = input_config_binds[0][RARCH_FULLSCREEN_TOGGLE_KEY].key;
80288031
ids[16][0] = input_config_binds[0][RARCH_UI_COMPANION_TOGGLE].key;
80298032
ids[17][0] = input_config_binds[0][RARCH_FPS_TOGGLE].key;
80308033
ids[18][0] = input_config_binds[0][RARCH_NETPLAY_HOST_TOGGLE].key;
8034+
ids[19][0] = RETROK_ESCAPE;
80318035

8032-
if (settings->bools.input_menu_swap_ok_cancel_buttons)
8036+
/* Escape cancels dialogs */
8037+
if (menu_st && menu_st->driver_data && *menu_st->driver_data->menu_state_msg)
8038+
ids[19][1] = (swap_ok_cancel_buttons)
8039+
? RETRO_DEVICE_ID_JOYPAD_A : RETRO_DEVICE_ID_JOYPAD_B;
8040+
8041+
if (swap_ok_cancel_buttons)
80338042
{
80348043
ids[0][1] = RETRO_DEVICE_ID_JOYPAD_B;
80358044
ids[1][1] = RETRO_DEVICE_ID_JOYPAD_A;
@@ -8046,7 +8055,14 @@ void input_driver_collect_system_input(input_driver_state_t *input_st,
80468055
!!(input_st->flags & INP_FLAG_KB_MAPPING_BLOCKED),
80478056
0,
80488057
RETRO_DEVICE_KEYBOARD, 0, ids[i][0]))
8058+
{
8059+
/* Wait for release when closing dialogs with Escape,
8060+
* otherwise quit hotkey will also get triggered */
8061+
if (ids[i][0] == RETROK_ESCAPE && ids[19][1] != RARCH_BIND_LIST_END_NULL)
8062+
input_st->flags |= INP_FLAG_WAIT_INPUT_RELEASE;
8063+
80498064
BIT256_SET_PTR(current_bits, ids[i][1]);
8065+
}
80508066
}
80518067
}
80528068
else if (display_kb && input && input->input_state)

menu/cbs/menu_cbs_ok.c

Lines changed: 66 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -5828,79 +5828,87 @@ static int action_ok_core_options_flush(const char *path,
58285828
return 0;
58295829
}
58305830

5831-
int action_ok_close_content(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx)
5831+
static int action_ok_dialog_init(struct menu_state *menu_st)
58325832
{
5833-
int ret;
5834-
struct menu_state *menu_st = menu_state_get_ptr();
5835-
bool contentless_core = false;
5836-
5837-
/* Reset navigation pointer
5838-
* > If we are returning to the quick menu, want
5839-
* the active entry to be 'Run' (first item in
5840-
* menu list) */
5841-
menu_st->selection_ptr = 0;
5842-
5843-
/* Check if we need to quit */
5844-
if (should_quit_on_close())
5845-
return generic_action_ok_command(CMD_EVENT_QUIT);
5846-
5847-
/* Otherwise, unload core */
5848-
ret = generic_action_ok_command(CMD_EVENT_UNLOAD_CORE);
5849-
5850-
/* If close content was selected via any means other than
5851-
* 'Playlist > Quick Menu', have to flush the menu stack
5852-
* (otherwise users will be presented with an empty
5853-
* 'No items' quick menu, requiring needless backwards
5854-
* navigation) */
5855-
if (type == MENU_SETTING_ACTION_CLOSE)
5856-
{
5857-
const char *parent_label = NULL;
5858-
const char *flush_target = MENU_ENUM_LABEL_MAIN_MENU_STR;
5859-
file_list_t *list = NULL;
5860-
if (menu_st->entries.list)
5861-
list = MENU_LIST_GET(menu_st->entries.list, 0);
5862-
if (list && (list->size > 1))
5863-
{
5864-
parent_label = list->list[list->size - 2].label;
5833+
menu_displaylist_info_t info;
5834+
menu_list_t *menu_list = menu_st->entries.list;
5835+
file_list_t *menu_stack = MENU_LIST_GET(menu_list, 0);
5836+
size_t selection = menu_st->selection_ptr;
5837+
settings_t *settings = config_get_ptr();
5838+
#ifdef HAVE_AUDIOMIXER
5839+
bool audio_enable_menu = settings->bools.audio_enable_menu;
5840+
bool audio_enable_menu_notice = settings->bools.audio_enable_menu_notice;
5841+
#endif
58655842

5866-
if ( string_is_equal(parent_label, MENU_ENUM_LABEL_CONTENTLESS_CORES_TAB_STR)
5867-
|| string_is_equal(parent_label, MENU_ENUM_LABEL_DEFERRED_CONTENTLESS_CORES_LIST_STR))
5868-
{
5869-
flush_target = parent_label;
5870-
contentless_core = true;
5871-
}
5872-
}
5843+
menu_displaylist_info_init(&info);
5844+
5845+
info.list = menu_stack;
5846+
info.directory_ptr = selection;
5847+
info.enum_idx = MENU_ENUM_LABEL_INFO_SCREEN;
5848+
info.label = strdup(MENU_ENUM_LABEL_INFO_SCREEN_STR);
5849+
5850+
if (!menu_displaylist_ctl(DISPLAYLIST_HELP, &info, settings))
5851+
goto error;
5852+
5853+
#ifdef HAVE_AUDIOMIXER
5854+
if (audio_enable_menu && audio_enable_menu_notice)
5855+
audio_driver_mixer_play_menu_sound(AUDIO_MIXER_SYSTEM_SLOT_NOTICE);
5856+
#endif
5857+
5858+
if (!menu_displaylist_process(&info))
5859+
goto error;
5860+
5861+
menu_displaylist_info_free(&info);
5862+
return 0;
5863+
5864+
error:
5865+
menu_displaylist_info_free(&info);
5866+
return -1;
5867+
}
5868+
5869+
int action_ok_quit(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx)
5870+
{
5871+
settings_t *settings = config_get_ptr();
58735872

5874-
menu_entries_flush_stack(flush_target, 0);
5875-
/* An annoyance - some menu drivers (Ozone...) set
5876-
* MENU_ST_FLAG_PREVENT_POPULATE in awkward places,
5877-
* which can cause breakage here when flushing
5878-
* the menu stack. We therefore have to unset
5879-
* MENU_ST_FLAG_PREVENT_POPULATE */
5880-
menu_st->flags &= ~MENU_ST_FLAG_PREVENT_POPULATE;
5873+
if (settings->bools.confirm_quit)
5874+
{
5875+
struct menu_state *menu_st = menu_state_get_ptr();
5876+
menu_dialog_confirm_set(menu_st, MSG_PRESS_AGAIN_TO_QUIT, CMD_EVENT_QUIT);
5877+
return action_ok_dialog_init(menu_st);
58815878
}
5879+
return generic_action_ok_command(CMD_EVENT_QUIT);
5880+
}
58825881

5883-
/* Single-click playlist return */
5884-
if (config_get_ptr()->bools.input_menu_singleclick_playlists && !contentless_core)
5882+
int action_ok_restart_content(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx)
5883+
{
5884+
settings_t *settings = config_get_ptr();
5885+
5886+
if (settings->bools.confirm_reset)
58855887
{
5886-
size_t new_selection = menu_st->selection_ptr;
5887-
menu_entries_pop_stack(&new_selection, 0, 0);
5888-
menu_st->selection_ptr = new_selection;
5889-
menu_st->flags &= ~MENU_ST_FLAG_PREVENT_POPULATE;
5888+
struct menu_state *menu_st = menu_state_get_ptr();
5889+
menu_dialog_confirm_set(menu_st, MSG_PRESS_AGAIN_TO_RESET, CMD_EVENT_RESET);
5890+
return action_ok_dialog_init(menu_st);
58905891
}
5892+
return generic_action_ok_command(CMD_EVENT_RESET);
5893+
}
58915894

5892-
/* Try to reload last core if loaded manually */
5893-
menu_st->flags |= MENU_ST_FLAG_PENDING_RELOAD_CORE;
5895+
int action_ok_close_content(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx)
5896+
{
5897+
settings_t *settings = config_get_ptr();
58945898

5895-
return ret;
5899+
if (settings->bools.confirm_close)
5900+
{
5901+
struct menu_state *menu_st = menu_state_get_ptr();
5902+
menu_dialog_confirm_set(menu_st, MSG_PRESS_AGAIN_TO_CLOSE_CONTENT, CMD_EVENT_CLOSE_CONTENT);
5903+
return action_ok_dialog_init(menu_st);
5904+
}
5905+
return generic_action_ok_command(CMD_EVENT_CLOSE_CONTENT);
58965906
}
58975907

58985908
STATIC_DEFAULT_ACTION_OK_CMD_FUNC(action_ok_cheat_apply_changes, CMD_EVENT_CHEATS_APPLY)
5899-
STATIC_DEFAULT_ACTION_OK_CMD_FUNC(action_ok_quit, CMD_EVENT_QUIT)
59005909
STATIC_DEFAULT_ACTION_OK_CMD_FUNC(action_ok_save_new_config, CMD_EVENT_MENU_SAVE_CONFIG)
59015910
STATIC_DEFAULT_ACTION_OK_CMD_FUNC(action_ok_save_main_config, CMD_EVENT_MENU_SAVE_MAIN_CONFIG)
59025911
STATIC_DEFAULT_ACTION_OK_CMD_FUNC(action_ok_resume_content, CMD_EVENT_RESUME)
5903-
STATIC_DEFAULT_ACTION_OK_CMD_FUNC(action_ok_restart_content, CMD_EVENT_RESET)
59045912
STATIC_DEFAULT_ACTION_OK_CMD_FUNC(action_ok_screenshot, CMD_EVENT_TAKE_SCREENSHOT)
59055913
#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL)
59065914
STATIC_DEFAULT_ACTION_OK_CMD_FUNC(action_ok_shader_apply_changes, CMD_EVENT_SHADERS_APPLY_CHANGES)

0 commit comments

Comments
 (0)