Author: mordante
Date: Sun Mar 13 08:49:40 2011
New Revision: 48879

URL: http://svn.gna.org/viewcvs/wesnoth?rev=48879&view=rev
Log:
Polish the tmp_login class.

- Use the new register functions.
- Updated wiki comment.
- change the scroll_label by a wrapping label.

Modified:
    trunk/data/gui/default/window/mp_login.cfg
    trunk/src/gui/dialogs/mp_login.cpp
    trunk/src/gui/dialogs/mp_login.hpp

Modified: trunk/data/gui/default/window/mp_login.cfg
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/gui/default/window/mp_login.cfg?rev=48879&r1=48878&r2=48879&view=diff
==============================================================================
--- trunk/data/gui/default/window/mp_login.cfg (original)
+++ trunk/data/gui/default/window/mp_login.cfg Sun Mar 13 08:49:40 2011
@@ -52,12 +52,12 @@
                                        border = "all"
                                        border_size = 5
                                        horizontal_alignment = "left"
-                                       [scroll_label]
+                                       [label]
                                                id = "login_label"
                                                definition = "default"
 
-                                               label = ""
-                                       [/scroll_label]
+                                               wrap = "true"
+                                       [/label]
 
                                [/column]
 

Modified: trunk/src/gui/dialogs/mp_login.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/mp_login.cpp?rev=48879&r1=48878&r2=48879&view=diff
==============================================================================
--- trunk/src/gui/dialogs/mp_login.cpp (original)
+++ trunk/src/gui/dialogs/mp_login.cpp Sun Mar 13 08:49:40 2011
@@ -43,6 +43,10 @@
  * 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. $
  *
@@ -57,24 +61,29 @@
 
 REGISTER_DIALOG(mp_login)
 
-tmp_login::tmp_login(const t_string& label,    const bool focus_password)
-       : label_(label)
-       , focus_password_(focus_password)
+tmp_login::tmp_login(const std::string& label, const bool focus_password)
 {
+       register_label2("login_label", false, label);
+       register_text2("user_name"
+                       , true
+                       , &preferences::login
+                       , &preferences::set_login
+                       , !focus_password);
+
+       register_text2("password"
+                       , true
+                       , &preferences::password
+                       , NULL /* The password box returns '*' as value. */
+                       , focus_password);
+
+       register_bool("remember_password"
+                       , true
+                       , &preferences::remember_password
+                       , &preferences::set_remember_password);
 }
 
 void tmp_login::pre_show(CVideo& /*video*/, twindow& window)
 {
-       ttext_box* username =
-                       find_widget<ttext_box>(&window, "user_name", false, 
true);
-       username->set_value(preferences::login());
-
-       tpassword_box* password =
-                       find_widget<tpassword_box>(&window, "password", false, 
true);
-       password->set_value(preferences::password());
-
-       window.keyboard_capture(focus_password_ ? password : username);
-
        if(tbutton* button = find_widget<tbutton>(
                        &window, "password_reminder", false, false)) {
 
@@ -86,32 +95,11 @@
 
                button->set_retval(2);
        }
-
-       // Needs to be a scroll_label since the text can get long and a normal
-       // label can't wrap (at the moment).
-       tcontrol* label =
-               dynamic_cast<tscroll_label*>(window.find("login_label", false));
-       if(label) label->set_label(label_);
-
-       if(ttoggle_button* button = find_widget<ttoggle_button>(
-                       &window, "remember_password", false, false)) {
-
-               button->set_value(preferences::remember_password());
-       }
 }
 
 void tmp_login::post_show(twindow& window)
 {
        if(get_retval() == twindow::OK) {
-               if(ttoggle_button* button = find_widget<ttoggle_button>(
-                               &window, "remember_password", false, false)) {
-
-                       preferences::set_remember_password(button->get_value());
-               }
-
-               preferences::set_login(find_widget<ttext_box>(
-                               &window, "user_name", false).get_value());
-
                preferences::set_password(find_widget<tpassword_box>(
                                &window, "password", false).get_real_value());
        }

Modified: trunk/src/gui/dialogs/mp_login.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/mp_login.hpp?rev=48879&r1=48878&r2=48879&view=diff
==============================================================================
--- trunk/src/gui/dialogs/mp_login.hpp (original)
+++ trunk/src/gui/dialogs/mp_login.hpp Sun Mar 13 08:49:40 2011
@@ -17,14 +17,13 @@
 #define GUI_DIALOGS_MP_LOGIN_HPP_INCLUDED
 
 #include "gui/dialogs/dialog.hpp"
-#include "tstring.hpp"
 
 namespace gui2 {
 
 class tmp_login : public tdialog
 {
 public:
-       tmp_login(const t_string& label,
+       tmp_login(const std::string& label,
                const bool focus_password);
 
 private:
@@ -37,11 +36,6 @@
 
        /** Inherited from tdialog. */
        void post_show(twindow& window);
-
-       t_string label_;
-
-       /** Should the password box be focussed upon showing the dialog? */
-       bool focus_password_;
 };
 
 } // namespace gui2


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to