-
-
Notifications
You must be signed in to change notification settings - Fork 991
/
quit_confirmation.cpp
45 lines (39 loc) · 1.21 KB
/
quit_confirmation.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
Copyright (C) 2015 by the Battle for Wesnoth Project
<http://www.wesnoth.org/>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
#include "quit_confirmation.hpp"
#include "gettext.hpp"
#include "video.hpp"
#include "gui/dialogs/message.hpp"
#include "gui/widgets/window.hpp"
#include "resources.hpp"
std::vector<quit_confirmation*> quit_confirmation::blockers_ = std::vector<quit_confirmation*>();
bool quit_confirmation::open_ = false;
void quit_confirmation::quit()
{
if(!open_)
{
open_ = true;
BOOST_REVERSE_FOREACH(quit_confirmation* blocker, blockers_)
{
if(!blocker->promt_()) {
open_ = false;
return;
}
}
open_ = false;
}
throw CVideo::quit();
}
bool quit_confirmation::default_promt()
{
return gui2::show_message(CVideo::get_singleton(), _("Quit"), _("Do you really want to quit?"), gui2::tmessage::yes_no_buttons) != gui2::twindow::CANCEL;
}