The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
quit_confirmation.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2015 - 2016 by the Battle for Wesnoth Project
3  <http://www.wesnoth.org/>
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #include "quit_confirmation.hpp"
16 #include "game_end_exceptions.hpp"
17 #include "gettext.hpp"
18 #include "video.hpp"
19 #include "gui/dialogs/message.hpp"
20 #include "gui/widgets/window.hpp"
21 #include "resources.hpp"
22 #include <boost/range/adaptor/reversed.hpp>
23 
24 std::vector<quit_confirmation*> quit_confirmation::blockers_ = std::vector<quit_confirmation*>();
25 bool quit_confirmation::open_ = false;
26 
28 {
29  if(!open_) {
30  open_ = true;
31  for(quit_confirmation* blocker : boost::adaptors::reverse(blockers_))
32  {
33  if(!blocker->prompt_()) {
34  open_ = false;
35  return false;
36  }
37  }
38  open_ = false;
39  }
40 
41  return true;
42 }
43 
45 {
46  if(quit()) { throw_quit_game_exception(); }
47 }
48 
50 {
51  if(quit()) { throw CVideo::quit(); }
52 }
53 
55 {
56  return gui2::show_message(CVideo::get_singleton(), _("Quit"), message,
58 }
59 
61 {
62  return show_prompt(_("Do you really want to quit?"));
63 }
static void quit_to_title()
This file contains the window object, this object is a top level container which has the event manage...
static bool show_prompt(const std::string &message)
static CVideo & get_singleton()
Definition: video.hpp:75
Contains the exception interfaces used to signal completion of a scenario, campaign or turn...
-file util.hpp
static UNUSEDNOWARN std::string _(const char *str)
Definition: gettext.hpp:82
void throw_quit_game_exception()
Implements a quit confirmation dialog.
Dialog is closed with the cancel button.
Definition: window.hpp:126
void show_message(CVideo &video, const std::string &title, const std::string &message, const std::string &button_caption, const bool auto_close, const bool message_use_markup)
Shows a message to the user.
Definition: message.cpp:143
static bool quit()
Shows the quit confirmation if needed.
static void quit_to_desktop()
static bool default_prompt()
GLsizei GLenum GLuint GLuint GLsizei char * message
Definition: glew.h:2499
static std::vector< quit_confirmation * > blockers_
GLsizei const GLcharARB ** string
Definition: glew.h:4503
Shows a yes and no button.
Definition: message.hpp:75