Author: mordante
Date: Sat Mar 19 22:04:04 2011
New Revision: 48936

URL: http://svn.gna.org/viewcvs/wesnoth?rev=48936&view=rev
Log:
Update tmp_create_game_set_password.

Use the register_xxx functions.

Modified:
    trunk/src/gui/dialogs/mp_create_game_set_password.cpp
    trunk/src/gui/dialogs/mp_create_game_set_password.hpp
    trunk/src/multiplayer_create.cpp

Modified: trunk/src/gui/dialogs/mp_create_game_set_password.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/mp_create_game_set_password.cpp?rev=48936&r1=48935&r2=48936&view=diff
==============================================================================
--- trunk/src/gui/dialogs/mp_create_game_set_password.cpp (original)
+++ trunk/src/gui/dialogs/mp_create_game_set_password.cpp Sat Mar 19 22:04:04 
2011
@@ -17,9 +17,8 @@
 
 #include "gui/dialogs/mp_create_game_set_password.hpp"
 
-#include "gui/dialogs/field.hpp"
+//#include "gui/dialogs/field.hpp"
 #include "gui/widgets/settings.hpp"
-#include "gui/widgets/window.hpp"
 
 namespace gui2 {
 
@@ -41,26 +40,11 @@
 
 REGISTER_DIALOG(mp_create_game_set_password)
 
-tmp_create_game_set_password::tmp_create_game_set_password(const std::string& 
password)
-       : password_(password)
-       , password_field_(register_text("password", false))
+tmp_create_game_set_password::tmp_create_game_set_password(
+               std::string& password)
 {
+       register_text2("password", true, password, true);
 }
 
-void tmp_create_game_set_password::pre_show(CVideo& /*video*/, twindow& window)
-{
-       assert(password_field_);
-       password_field_->set_widget_value(window, password_);
-       window.keyboard_capture(password_field_->widget(window));
-}
+} // namespace gui2
 
-void tmp_create_game_set_password::post_show(twindow& window)
-{
-       if(get_retval() != twindow::OK) {
-               return;
-       }
-
-       password_ = password_field_->get_widget_value(window);
-}
-
-}

Modified: trunk/src/gui/dialogs/mp_create_game_set_password.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/mp_create_game_set_password.hpp?rev=48936&r1=48935&r2=48936&view=diff
==============================================================================
--- trunk/src/gui/dialogs/mp_create_game_set_password.hpp (original)
+++ trunk/src/gui/dialogs/mp_create_game_set_password.hpp Sat Mar 19 22:04:04 
2011
@@ -17,37 +17,35 @@
 #define GUI_DIALOGS_MP_CREATE_GAME_SET_PASSWORD_HPP_INCLUDED
 
 #include "gui/dialogs/dialog.hpp"
-#include "gui/dialogs/field-fwd.hpp"
 
 namespace gui2 {
 
 class tmp_create_game_set_password : public tdialog
 {
 public:
-       tmp_create_game_set_password(const std::string& password);
 
-       const std::string& password() const {
-               return password_;
-       }
+       /**
+        * Constructor.
+        *
+        * @param password [in]       The initial value for the password.
+        * @param password [out]      The password selected by the user if the
+        *                            dialog returns @ref twindow::OK undefined
+        *                            otherwise.
+        */
+       explicit tmp_create_game_set_password(std::string& password);
 
-       void set_password(const std::string& password) {
-               password_ = password;
+       /** The excute function see @ref tdialog for more information. */
+       static bool execute(std::string& password, CVideo& video)
+       {
+               return tmp_create_game_set_password(password).show(video);
        }
 
 private:
-       std::string password_;
-       tfield_text* password_field_;
 
        /** Inherited from tdialog, implemented by REGISTER_DIALOG. */
        virtual const std::string& window_id() const;
-
-       /** Inherited from tdialog. */
-       void pre_show(CVideo& video, twindow& window);
-
-       /** Inherited from tdialog. */
-       void post_show(twindow& window);
 };
 
-}
+} // namespace gui2
 
 #endif /* ! GUI_DIALOGS_MP_CREATE_GAME_SET_PASSWORD_HPP_INCLUDED */

Modified: trunk/src/multiplayer_create.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/multiplayer_create.cpp?rev=48936&r1=48935&r2=48936&view=diff
==============================================================================
--- trunk/src/multiplayer_create.cpp (original)
+++ trunk/src/multiplayer_create.cpp Sat Mar 19 22:04:04 2011
@@ -343,9 +343,10 @@
        }
 
        if(password_button_.pressed()) {
-               gui2::tmp_create_game_set_password 
pwd_dlg(parameters_.password);
-               pwd_dlg.show(disp_.video());
-               parameters_.password = pwd_dlg.password();
+               gui2::tmp_create_game_set_password::execute(
+                                 parameters_.password
+                               , disp_.video());
+
        }
 
        // Turns per game


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

Reply via email to