-
-
Notifications
You must be signed in to change notification settings - Fork 988
/
mp_login.cpp
106 lines (89 loc) · 2.62 KB
/
mp_login.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
99
100
101
102
103
104
105
106
/*
Copyright (C) 2008 - 2017 by Mark de Wever <koraq@xs4all.nl>
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.
*/
#define GETTEXT_DOMAIN "wesnoth-lib"
#include "gui/dialogs/multiplayer/mp_login.hpp"
#include "game_preferences.hpp"
#include "gui/auxiliary/find_widget.hpp"
#include "gui/widgets/button.hpp"
#include "gui/widgets/password_box.hpp"
#include "gui/widgets/settings.hpp"
#include "gui/widgets/scroll_label.hpp"
#include "gui/widgets/toggle_button.hpp"
#include "gui/widgets/window.hpp"
namespace gui2
{
namespace dialogs
{
/*WIKI
* @page = GUIWindowDefinitionWML
* @order = 2_mp_login
*
* == Multiplayer connect ==
*
* This shows the dialog to log in to the MP server
*
* @begin{table}{dialog_widgets}
*
* user_name & & text_box & m &
* The login user name. $
*
* password & & text_box & m &
* The password. $
*
* remember_password & & toggle_button & o &
* A toggle button to offer to remember the password in the
* preferences. $
*
* password_reminder & & button & o &
* Request a password reminder. $
*
* change_username & & button & o &
* Use a different username. $
*
* login_label & & button & o &
* Displays the information received from the server. $
*
* @end{table}
*/
REGISTER_DIALOG(mp_login)
mp_login::mp_login(const std::string& label, const bool focus_password)
{
register_label("login_label", false, label);
register_text("user_name", true,
&preferences::login,
&preferences::set_login,
!focus_password);
register_text("password", true,
&preferences::password,
nullptr /* The password box returns '*' as value. */,
focus_password);
register_bool("remember_password", false,
&preferences::remember_password,
&preferences::set_remember_password);
}
void mp_login::pre_show(window& win)
{
if(button* btn = find_widget<button>(&win, "password_reminder", false, false)) {
btn->set_retval(1);
}
if(button* btn = find_widget<button>(&win, "change_username", false, false)) {
btn->set_retval(2);
}
}
void mp_login::post_show(window& win)
{
if(get_retval() == window::OK) {
preferences::set_password(find_widget<password_box>(&win, "password", false).get_real_value());
}
}
} // namespace dialogs
} // namespace gui2