The Battle for Wesnoth  1.15.2+dev
synced_choice_wait.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014 - 2018 by Iris Morelle <shadowm2006@gmail.com>
3  Part of the Battle for Wesnoth Project https://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 
16 
18 #include "gui/widgets/label.hpp"
19 #include "gui/widgets/button.hpp"
20 #include "gui/widgets/settings.hpp"
21 #include "gui/widgets/window.hpp"
22 #include "quit_confirmation.hpp"
23 
24 #include "gui/dialogs/message.hpp"
25 #include "game_end_exceptions.hpp"
26 #include "gettext.hpp"
27 
28 
29 #include "utils/functional.hpp"
30 
31 namespace gui2
32 {
33 namespace dialogs
34 {
35 
36 /*WIKI
37  * @page = GUIWindowDefinitionWML
38  * @order = 2_theme_list
39  *
40  * == Theme list ==
41  *
42  * Dialog for selecting a GUI theme.
43  *
44  * @begin{table}{dialog_widgets}
45  *
46  * themes & & listbox & m &
47  * Listbox displaying user choices. $
48  *
49  * -name & & styled_widget & m &
50  * Widget which shows a theme item name. $
51  *
52  * -description & & styled_widget & m &
53  * Widget which shows a theme item description. $
54  *
55  * @end{table}
56  */
57 
58 REGISTER_DIALOG(synched_choice_wait)
59 
61  : mgr_(mgr)
62  , message_()
63 {
64  mgr_.changed_event_.attach_handler(this);
65 }
66 
68 {
70 }
71 
73 {
74  message_ = find_widget<label>(&window, "lblMessage", false, true);
75 
76 
77  button& quit_button = find_widget<button>(
78  &window, "btn_quit_game", false);
79 
82 
84  if(mgr_.finished() || !mgr_.waiting()) {
85  window.close();
86  }
87 }
88 
89 void synched_choice_wait::handle_generic_event(const std::string& event_name)
90 {
91  assert(event_name == "user_choice_update");
92  assert(message_);
94  if(mgr_.finished() || !mgr_.waiting()) {
95  get_window()->close();
96  }
97 }
98 
99 } // namespace dialogs
100 } // namespace gui2
void close()
Requests to close the window.
Definition: window.hpp:182
static void quit_to_title()
This file contains the window object, this object is a top level container which has the event manage...
window * get_window() const
Returns a pointer to the dialog&#39;s window.
Contains the exception interfaces used to signal completion of a scenario, campaign or turn...
bool waiting() const
Note: currently finished() does not imply !waiting() so you may need to check both.
Generic file dialog.
Definition: field-fwd.hpp:22
virtual void set_label(const t_string &label)
This file contains the settings handling of the widget library.
virtual void handle_generic_event(const std::string &event_name) override
void connect_signal_mouse_left_click(dispatcher &dispatcher, const signal_function &signal)
Connects a signal handler for a left mouse button click.
Definition: dispatcher.cpp:233
events::generic_event changed_event_
Various uncategorised dialogs.
virtual void pre_show(window &window) override
Inherited from modal_dialog.
Simple push button.
Definition: button.hpp:35
virtual bool detach_handler(observer *obs)
base class of top level items, the only item which needs to store the final canvases to draw on ...
Definition: window.hpp:62
const std::string & wait_message() const