The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
mp_login.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2016 by Mark de Wever <[email protected]>
3  Part of the Battle for Wesnoth Project 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 #define GETTEXT_DOMAIN "wesnoth-lib"
16 
18 
19 #include "game_preferences.hpp"
21 #include "gui/widgets/button.hpp"
23 #include "gui/widgets/settings.hpp"
26 #include "gui/widgets/window.hpp"
27 
28 namespace gui2
29 {
30 
31 /*WIKI
32  * @page = GUIWindowDefinitionWML
33  * @order = 2_mp_login
34  *
35  * == Multiplayer connect ==
36  *
37  * This shows the dialog to log in to the MP server
38  *
39  * @begin{table}{dialog_widgets}
40  *
41  * user_name & & text_box & m &
42  * The login user name. $
43  *
44  * password & & text_box & m &
45  * The password. $
46  *
47  * remember_password & & toggle_button & o &
48  * A toggle button to offer to remember the password in the
49  * preferences. $
50  *
51  * password_reminder & & button & o &
52  * Request a password reminder. $
53  *
54  * change_username & & button & o &
55  * Use a different username. $
56  *
57  * login_label & & button & o &
58  * Displays the information received from the server. $
59  *
60  * @end{table}
61  */
62 
63 REGISTER_DIALOG(mp_login)
64 
65 tmp_login::tmp_login(const std::string& label, const bool focus_password)
66 {
67  register_label("login_label", false, label);
68  register_text("user_name",
69  true,
72  !focus_password);
73 
74  register_text("password",
75  true,
77  nullptr /* The password box returns '*' as value. */
78  ,
79  focus_password);
80 
81  register_bool("remember_password",
82  false,
85 }
86 
88 {
89  if(tbutton* button
90  = find_widget<tbutton>(&window, "password_reminder", false, false)) {
91 
92  button->set_retval(1);
93  }
94 
95  if(tbutton* button
96  = find_widget<tbutton>(&window, "change_username", false, false)) {
97 
98  button->set_retval(2);
99  }
100 }
101 
103 {
104  if(get_retval() == twindow::OK) {
106  find_widget<tpassword_box>(&window, "password", false)
107  .get_real_value());
108  }
109 }
110 
111 } // namespace gui2
void set_password(const std::string &password)
void pre_show(twindow &window)
Inherited from tdialog.
Definition: mp_login.cpp:87
bool remember_password()
int get_retval() const
Definition: dialog.hpp:161
void set_remember_password(bool remember)
This file contains the window object, this object is a top level container which has the event manage...
REGISTER_DIALOG(label_settings)
void set_login(const std::string &username)
STL namespace.
base class of top level items, the only item which needs to store the final canvases to draw on ...
Definition: window.hpp:62
A class inherited from ttext_box that displays its input as stars.
Definition: field-fwd.hpp:23
Simple push button.
Definition: button.hpp:32
Dialog is closed with ok button.
Definition: window.hpp:125
This file contains the settings handling of the widget library.
std::string login()
void post_show(twindow &window)
Inherited from tdialog.
Definition: mp_login.cpp:102
std::string password()