The Battle for Wesnoth  1.19.7+dev
synced_choice_wait.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014 - 2024
3  by Iris Morelle <shadowm2006@gmail.com>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
17 
18 #include "gui/widgets/label.hpp"
19 #include "gui/widgets/button.hpp"
20 #include "gui/widgets/window.hpp"
21 #include "quit_confirmation.hpp"
22 
23 
24 
25 #include <functional>
26 
27 namespace gui2::dialogs
28 {
29 
30 REGISTER_DIALOG(synched_choice_wait)
31 
33  : modal_dialog(window_id())
34  , mgr_(mgr)
35  , message_()
36 {
37  mgr_.changed_event_.attach_handler(this);
38 }
39 
41 {
43 }
44 
46 {
47  message_ = find_widget<label>("lblMessage", false, true);
48 
49  button& quit_button = find_widget<button>("btn_quit_game");
50 
53 
55  if(mgr_.finished() || !mgr_.waiting()) {
56  close();
57  }
58 }
59 
60 void synched_choice_wait::handle_generic_event(const std::string& event_name)
61 {
62  assert(event_name == "user_choice_update");
63  assert(message_);
65  if(mgr_.finished() || !mgr_.waiting()) {
66  close();
67  }
68 }
69 
70 } // namespace dialogs
virtual bool detach_handler(observer *obs)
Simple push button.
Definition: button.hpp:36
Abstract base class for all modal dialogs.
virtual void pre_show() override
Actions to be taken before showing the window.
virtual void handle_generic_event(const std::string &event_name) override
virtual void set_label(const t_string &text)
void close()
Requests to close the window.
Definition: window.hpp:219
static void quit_to_title()
events::generic_event changed_event_
bool waiting() const
Note: currently finished() does not imply !waiting() so you may need to check both.
const std::string & wait_message() const
This file contains the window object, this object is a top level container which has the event manage...
REGISTER_DIALOG(editor_edit_unit)
void connect_signal_mouse_left_click(dispatcher &dispatcher, const signal &signal)
Connects a signal handler for a left mouse button click.
Definition: dispatcher.cpp:177