Add flag to quit_confirmation::quit() to only quit out of game
This commit is contained in:
parent
f067332d0f
commit
ed9ead2ac9
6 changed files with 17 additions and 23 deletions
|
@ -76,10 +76,8 @@ void tsynced_choice_wait::pre_show(CVideo& video, twindow& window)
|
|||
tbutton& quit_button = find_widget<tbutton>(
|
||||
&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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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() {}
|
||||
|
|
|
@ -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*> quit_confirmation::blockers_ = std::vector<quit_confirmation*>();
|
||||
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();
|
||||
}
|
||||
|
||||
|
|
|
@ -31,17 +31,22 @@ class CVideo;
|
|||
class quit_confirmation
|
||||
{
|
||||
public:
|
||||
quit_confirmation(const boost::function<bool()>& prompt = &quit_confirmation::default_prompt) : prompt_(prompt) { blockers_.push_back(this); }
|
||||
quit_confirmation(const boost::function<bool()>& 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& );
|
||||
|
|
Loading…
Add table
Reference in a new issue