diff options
author | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2009-10-04 22:28:19 +0200 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2009-10-04 22:31:43 +0200 |
commit | 924e0a887f87ce531bc5bd26cb55e410b7303383 (patch) | |
tree | a592304792e8ae877dabaa2062d6bdff1d406f02 /src/gui/register.cpp | |
parent | cff9f1947bac8fa49aaf6f846a6e4335a439ac2e (diff) | |
download | mana-924e0a887f87ce531bc5bd26cb55e410b7303383.tar.gz mana-924e0a887f87ce531bc5bd26cb55e410b7303383.tar.bz2 mana-924e0a887f87ce531bc5bd26cb55e410b7303383.tar.xz mana-924e0a887f87ce531bc5bd26cb55e410b7303383.zip |
Introduced Net::LoginHandler::SetEmailOnRegister
This "optional action" specifies whether the server expects to get an
email address during registration. It is used now instead of having the
general handlers of eAthena and tmwserv set a pointer to an email
string on the GUI dialogs (to keep things understandable, the dependency
should preferably go one way).
Diffstat (limited to 'src/gui/register.cpp')
-rw-r--r-- | src/gui/register.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/gui/register.cpp b/src/gui/register.cpp index 50f63c69..78c79eeb 100644 --- a/src/gui/register.cpp +++ b/src/gui/register.cpp @@ -37,6 +37,8 @@ #include "gui/widgets/textfield.h" #include "net/logindata.h" +#include "net/net.h" +#include "net/loginhandler.h" #include "utils/gettext.h" #include "utils/stringutils.h" @@ -52,24 +54,24 @@ void WrongDataNoticeListener::action(const gcn::ActionEvent &event) mTarget->requestFocus(); } -std::string *RegisterDialog::useEmail = NULL; Gender *RegisterDialog::useGender = NULL; RegisterDialog::RegisterDialog(LoginData *loginData): Window(_("Register")), + mEmailField(0), mWrongDataNoticeListener(new WrongDataNoticeListener), mLoginData(loginData) { + int optionalActions = Net::getLoginHandler()->supportedOptionalActions(); + gcn::Label *userLabel = new Label(_("Name:")); gcn::Label *passwordLabel = new Label(_("Password:")); gcn::Label *confirmLabel = new Label(_("Confirm:")); - gcn::Label *emailLabel = new Label(_("Email:")); mUserField = new TextField(loginData->username); mPasswordField = new PasswordField(loginData->password); mConfirmField = new PasswordField; mMaleButton = new RadioButton(_("Male"), "sex", true); mFemaleButton = new RadioButton(_("Female"), "sex", false); - mEmailField = new TextField; mRegisterButton = new Button(_("Register"), "register", this); mCancelButton = new Button(_("Cancel"), "cancel", this); @@ -85,11 +87,14 @@ RegisterDialog::RegisterDialog(LoginData *loginData): place(2, 3, mFemaleButton); } - if (useEmail) + if (optionalActions & Net::LoginHandler::SetEmailOnRegister) { + gcn::Label *emailLabel = new Label(_("Email:")); + mEmailField = new TextField; place(0, 3, emailLabel); place(1, 3, mEmailField, 3).setPadding(2); } + place(1, 0, mUserField, 3).setPadding(2); place(1, 1, mPasswordField, 3).setPadding(2); place(1, 2, mConfirmField, 3).setPadding(2); @@ -211,8 +216,8 @@ void RegisterDialog::action(const gcn::ActionEvent &event) if (useGender) *useGender = mFemaleButton->isSelected() ? GENDER_FEMALE : GENDER_MALE; - if (useEmail) - *useEmail = mEmailField->getText(); + if (mEmailField) + mLoginData->email = mEmailField->getText(); mLoginData->registerLogin = true; state = STATE_REGISTER_ATTEMPT; @@ -225,11 +230,6 @@ void RegisterDialog::keyPressed(gcn::KeyEvent &keyEvent) mRegisterButton->setEnabled(canSubmit()); } -void RegisterDialog::setEmail(std::string *email) -{ - useEmail = email; -} - void RegisterDialog::setGender(Gender *gender) { useGender = gender; |