gui/dialogs/mp_login.cpp

Go to the documentation of this file.
00001 /* $Id: mp_login.cpp 52533 2012-01-07 02:35:17Z shadowmaster $ */
00002 /*
00003    Copyright (C) 2008 - 2012 by Mark de Wever <koraq@xs4all.nl>
00004    Part of the Battle for Wesnoth Project http://www.wesnoth.org/
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY.
00012 
00013    See the COPYING file for more details.
00014 */
00015 
00016 #define GETTEXT_DOMAIN "wesnoth-lib"
00017 
00018 #include "gui/dialogs/mp_login.hpp"
00019 
00020 #include "game_preferences.hpp"
00021 #include "gui/widgets/button.hpp"
00022 #include "gui/widgets/password_box.hpp"
00023 #include "gui/widgets/settings.hpp"
00024 #include "gui/widgets/scroll_label.hpp"
00025 #include "gui/widgets/toggle_button.hpp"
00026 #include "gui/widgets/window.hpp"
00027 
00028 namespace gui2 {
00029 
00030 /*WIKI
00031  * @page = GUIWindowDefinitionWML
00032  * @order = 2_mp_login
00033  *
00034  * == Multiplayer connect ==
00035  *
00036  * This shows the dialog to log in to the MP server
00037  *
00038  * @begin{table}{dialog_widgets}
00039  *
00040  * user_name & & text_box & m &
00041  *         The login user name. $
00042  *
00043  * password & & text_box & m &
00044  *         The password. $
00045  *
00046  * remember_password & & toggle_button & o &
00047  *         A toggle button to offer to remember the password in the
00048  *         preferences. $
00049  *
00050  * password_reminder & & button & o &
00051  *         Request a password reminder. $
00052  *
00053  * change_username & & button & o &
00054  *         Use a different username. $
00055  *
00056  * login_label & & button & o &
00057  *         Displays the information received from the server. $
00058  *
00059  * @end{table}
00060  */
00061 
00062 REGISTER_DIALOG(mp_login)
00063 
00064 tmp_login::tmp_login(const std::string& label, const bool focus_password)
00065 {
00066     register_label("login_label", false, label);
00067     register_text("user_name"
00068             , true
00069             , &preferences::login
00070             , &preferences::set_login
00071             , !focus_password);
00072 
00073     register_text("password"
00074             , true
00075             , &preferences::password
00076             , NULL /* The password box returns '*' as value. */
00077             , focus_password);
00078 
00079     register_bool("remember_password"
00080             , false
00081             , &preferences::remember_password
00082             , &preferences::set_remember_password);
00083 }
00084 
00085 void tmp_login::pre_show(CVideo& /*video*/, twindow& window)
00086 {
00087     if(tbutton* button = find_widget<tbutton>(
00088             &window, "password_reminder", false, false)) {
00089 
00090         button->set_retval(1);
00091     }
00092 
00093     if(tbutton* button = find_widget<tbutton>(
00094             &window, "change_username", false, false)) {
00095 
00096         button->set_retval(2);
00097     }
00098 }
00099 
00100 void tmp_login::post_show(twindow& window)
00101 {
00102     if(get_retval() == twindow::OK) {
00103         preferences::set_password(find_widget<tpassword_box>(
00104                 &window, "password", false).get_real_value());
00105     }
00106 }
00107 
00108 } // namespace gui2
00109 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Fri May 25 2012 01:02:58 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs