-
-
Notifications
You must be signed in to change notification settings - Fork 991
/
synced_choice_wait.cpp
98 lines (79 loc) · 2.32 KB
/
synced_choice_wait.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
Copyright (C) 2014 - 2016 by Ignacio Riquelme Morelle <shadowm2006@gmail.com>
Part of 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 "gui/dialogs/synced_choice_wait.hpp"
#include "gui/auxiliary/find_widget.tpp"
#include "gui/widgets/label.hpp"
#include "gui/widgets/button.hpp"
#include "gui/widgets/settings.hpp"
#include "gui/widgets/window.hpp"
#include "quit_confirmation.hpp"
#include "message.hpp"
#include "../../game_end_exceptions.hpp"
#include "../../gettext.hpp"
#include <boost/bind.hpp>
namespace gui2
{
/*WIKI
* @page = GUIWindowDefinitionWML
* @order = 2_theme_list
*
* == Theme list ==
*
* Dialog for selecting a GUI theme.
*
* @begin{table}{dialog_widgets}
*
* themes & & listbox & m &
* Listbox displaying user choices. $
*
* -name & & control & m &
* Widget which shows a theme item name. $
*
* -description & & control & m &
* Widget which shows a theme item description. $
*
* @end{table}
*/
REGISTER_DIALOG(synced_choice_wait)
tsynced_choice_wait::tsynced_choice_wait(user_choice_manager& mgr)
: mgr_(mgr)
, message_()
{
mgr_.changed_event_.attach_handler(this);
}
tsynced_choice_wait::~tsynced_choice_wait()
{
mgr_.changed_event_.detach_handler(this);
}
void tsynced_choice_wait::pre_show(CVideo& /*video*/, twindow& window)
{
window_ = &window;
message_ = find_widget<tlabel>(&window, "lblMessage", false, true);
tbutton& quit_button = find_widget<tbutton>(
&window, "btn_quit_game", false);
connect_signal_mouse_left_click(quit_button,
boost::bind(&quit_confirmation::quit_to_title));
message_->set_label(mgr_.wait_message());
if(mgr_.finished() || !mgr_.waiting()) {
window_->close();
}
}
void tsynced_choice_wait::handle_generic_event(const std::string& event_name)
{
assert(event_name == "user_choice_update");
assert(message_);
message_->set_label(mgr_.wait_message());
if(mgr_.finished() || !mgr_.waiting()) {
window_->close();
}
}
}