MP Lobby: use exit hook for quit confirmation
By design, this extends the confirmation popup to exiting the lobby with the Log Out button too (previously, only the Esc key triggered it. However, given the proximity of the button to other control buttons, it's not inconceivable that someone might click it by accident, so the confirmation is useful.
This commit is contained in:
parent
45a606556a
commit
8675bbbe89
2 changed files with 8 additions and 14 deletions
|
@ -654,16 +654,13 @@ void lobby_main::update_selected_game()
|
|||
player_list_dirty_ = true;
|
||||
}
|
||||
|
||||
void lobby_main::signal_handler_key_down(SDL_Keycode key, bool& handled, bool& halt)
|
||||
bool lobby_main::exit_hook(window& window)
|
||||
{
|
||||
if(key == SDLK_ESCAPE) {
|
||||
if(quit()) {
|
||||
window_->set_retval(window::OK);
|
||||
window_->close();
|
||||
}
|
||||
handled = true;
|
||||
halt = true;
|
||||
if(window.get_retval() == window::CANCEL) {
|
||||
return quit();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void lobby_main::pre_show(window& window)
|
||||
|
@ -694,12 +691,9 @@ void lobby_main::pre_show(window& window)
|
|||
std::bind(&lobby_main::player_filter_callback, this, _1));
|
||||
|
||||
window.set_enter_disabled(true);
|
||||
window.set_escape_disabled(true);
|
||||
|
||||
// A new key handler to deal with escape in a different manner.
|
||||
window.connect_signal<event::SDL_KEY_DOWN>(
|
||||
std::bind(&lobby_main::signal_handler_key_down, this, _5, _3, _4),
|
||||
event::dispatcher::front_pre_child);
|
||||
// Exit hook to add a confirmation when quitting the Lobby.
|
||||
window.set_exit_hook(std::bind(&lobby_main::exit_hook, this, std::ref(window)));
|
||||
|
||||
window_ = &window;
|
||||
|
||||
|
|
|
@ -158,7 +158,7 @@ private:
|
|||
|
||||
void skip_replay_changed_callback(window& window);
|
||||
|
||||
void signal_handler_key_down(SDL_Keycode key, bool& handled, bool& halt);
|
||||
bool exit_hook(window& window);
|
||||
|
||||
static bool logout_prompt();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue