diff --git a/src/gui/dialogs/synced_choice_wait.cpp b/src/gui/dialogs/synced_choice_wait.cpp index 4285c556e8a..b6add3016d2 100644 --- a/src/gui/dialogs/synced_choice_wait.cpp +++ b/src/gui/dialogs/synced_choice_wait.cpp @@ -76,10 +76,8 @@ void tsynced_choice_wait::pre_show(CVideo& video, twindow& window) tbutton& quit_button = find_widget( &window, "btn_quit_game", false); - connect_signal_mouse_left_click( - quit_button, - boost::bind(&tsynced_choice_wait::on_btn_quit_game, this, boost::ref(video)) - ); + connect_signal_mouse_left_click(quit_button, + boost::bind(&quit_confirmation::quit, false)); message_->set_label(mgr_.wait_message()); if(mgr_.finished() || !mgr_.waiting()) { @@ -97,11 +95,4 @@ void tsynced_choice_wait::handle_generic_event(const std::string& event_name) } } -void tsynced_choice_wait::on_btn_quit_game(CVideo&) -{ - if (quit_confirmation::default_prompt()) { - throw_quit_game_exception(); - } -} - } diff --git a/src/gui/dialogs/synced_choice_wait.hpp b/src/gui/dialogs/synced_choice_wait.hpp index aa81510f103..7c5fe4e2fa6 100644 --- a/src/gui/dialogs/synced_choice_wait.hpp +++ b/src/gui/dialogs/synced_choice_wait.hpp @@ -38,7 +38,6 @@ private: void pre_show(CVideo& video, twindow& window); virtual void handle_generic_event(const std::string& event_name); - void on_btn_quit_game(CVideo& video); }; } diff --git a/src/hotkey/command_executor.cpp b/src/hotkey/command_executor.cpp index 22014946571..8bbf35cc579 100644 --- a/src/hotkey/command_executor.cpp +++ b/src/hotkey/command_executor.cpp @@ -316,7 +316,7 @@ bool command_executor::execute_command(const hotkey_command& cmd, int /*index*/ quit_confirmation::quit(); break; case HOTKEY_QUIT_GAME: - quit_to_main_menu(); + quit_confirmation::quit(false); break; default: return false; @@ -696,10 +696,4 @@ void command_executor_default::map_screenshot() { make_screenshot(_("Map-Screenshot"), get_video(), boost::bind(&display::screenshot, &get_display(), _1, true)); } -void command_executor_default::quit_to_main_menu() -{ - if(quit_confirmation::default_prompt()) { - throw_quit_game_exception(); - } -} } diff --git a/src/hotkey/command_executor.hpp b/src/hotkey/command_executor.hpp index f22d3af6af7..2262b84ab33 100644 --- a/src/hotkey/command_executor.hpp +++ b/src/hotkey/command_executor.hpp @@ -113,7 +113,6 @@ public: virtual void zoom_out() {} virtual void zoom_default() {} virtual void map_screenshot() {} - virtual void quit_to_main_menu() {} virtual void set_button_state() {} virtual void recalculate_minimap() {} diff --git a/src/quit_confirmation.cpp b/src/quit_confirmation.cpp index 409d56bc997..8e25ad50aad 100644 --- a/src/quit_confirmation.cpp +++ b/src/quit_confirmation.cpp @@ -13,6 +13,7 @@ */ #include "quit_confirmation.hpp" +#include "game_end_exceptions.hpp" #include "gettext.hpp" #include "video.hpp" #include "gui/dialogs/message.hpp" @@ -22,7 +23,7 @@ std::vector quit_confirmation::blockers_ = std::vector(); bool quit_confirmation::open_ = false; -void quit_confirmation::quit() +void quit_confirmation::quit(const bool full_exit) { if(!open_) { @@ -36,6 +37,11 @@ void quit_confirmation::quit() } open_ = false; } + + if(!full_exit) { + throw_quit_game_exception(); + } + throw CVideo::quit(); } diff --git a/src/quit_confirmation.hpp b/src/quit_confirmation.hpp index 1c8c39fe9f6..bfb79633fbb 100644 --- a/src/quit_confirmation.hpp +++ b/src/quit_confirmation.hpp @@ -31,17 +31,22 @@ class CVideo; class quit_confirmation { public: - quit_confirmation(const boost::function& prompt = &quit_confirmation::default_prompt) : prompt_(prompt) { blockers_.push_back(this); } + quit_confirmation(const boost::function& promt = &quit_confirmation::default_prompt) + : prompt_(promt) { blockers_.push_back(this); } + ~quit_confirmation() { blockers_.pop_back(); } /** * Shows the quit confirmation if needed. * + * @param full_exit Whether to quit fully to the desktop or simply + * exit game. Defaults to true. * @throws CVideo::quit If the user chooses to quit or no prompt was * displayed. */ - static void quit(); + static void quit(const bool full_exit = true); static bool default_prompt(); + private: //noncopyable quit_confirmation( const quit_confirmation& );