summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-10-01 12:48:28 -0600
committerJared Adams <jaxad0127@gmail.com>2009-10-01 12:48:28 -0600
commitda61b7e9cb40e75ad0d74cc64853bf1b08d0a031 (patch)
treea1d5157ac530b42ce4ca2c316fcaa419cc23c01c /src/gui
parent83fd36204202b4b5cca7e6cdb37c025919f32f08 (diff)
downloadMana-da61b7e9cb40e75ad0d74cc64853bf1b08d0a031.tar.gz
Mana-da61b7e9cb40e75ad0d74cc64853bf1b08d0a031.tar.bz2
Mana-da61b7e9cb40e75ad0d74cc64853bf1b08d0a031.tar.xz
Mana-da61b7e9cb40e75ad0d74cc64853bf1b08d0a031.zip
Finish merging registration dialog
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/changeemaildialog.cpp12
-rw-r--r--src/gui/changeemaildialog.h7
-rw-r--r--src/gui/charselectdialog.cpp12
-rw-r--r--src/gui/charselectdialog.h5
-rw-r--r--src/gui/register.cpp26
-rw-r--r--src/gui/register.h10
6 files changed, 53 insertions, 19 deletions
diff --git a/src/gui/changeemaildialog.cpp b/src/gui/changeemaildialog.cpp
index eb05e25e..62d2a3f7 100644
--- a/src/gui/changeemaildialog.cpp
+++ b/src/gui/changeemaildialog.cpp
@@ -39,10 +39,11 @@
#include <string>
#include <sstream>
+std::string *ChangeEmailDialog::emailPointer = NULL;
+
ChangeEmailDialog::ChangeEmailDialog(Window *parent, LoginData *loginData):
Window(_("Change Email Address"), true, parent),
- mWrongDataNoticeListener(new WrongDataNoticeListener),
- mLoginData(loginData)
+ mWrongDataNoticeListener(new WrongDataNoticeListener)
{
gcn::Label *accountLabel = new Label(strprintf(_("Account: %s"),
mLoginData->username.c_str()));
@@ -159,10 +160,15 @@ ChangeEmailDialog::action(const gcn::ActionEvent &event)
// No errors detected, change account password.
mChangeEmailButton->setEnabled(false);
// Set the new email address
- mLoginData->newEmail = newFirstEmail;
+ *emailPointer = newFirstEmail;
state = STATE_CHANGEEMAIL_ATTEMPT;
scheduleDelete();
}
}
}
+
+void ChangeEmailDialog::setEmail(std::string *email)
+{
+ emailPointer = email;
+}
diff --git a/src/gui/changeemaildialog.h b/src/gui/changeemaildialog.h
index 486d8b03..23aab080 100644
--- a/src/gui/changeemaildialog.h
+++ b/src/gui/changeemaildialog.h
@@ -57,6 +57,12 @@ class ChangeEmailDialog : public Window, public gcn::ActionListener
*/
void action(const gcn::ActionEvent &event);
+ /**
+ * This is used to pass the pointer to where the new email should be
+ * put when the dialog finishes.
+ */
+ static void setEmail(std::string *email);
+
private:
gcn::TextField *mFirstEmailField;
gcn::TextField *mSecondEmailField;
@@ -67,6 +73,7 @@ class ChangeEmailDialog : public Window, public gcn::ActionListener
WrongDataNoticeListener *mWrongDataNoticeListener;
LoginData *mLoginData;
+ static std::string *emailPointer;
};
#endif // GUI_CHANGEEMAIL_H
diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp
index be1cd3de..d4758a8d 100644
--- a/src/gui/charselectdialog.cpp
+++ b/src/gui/charselectdialog.cpp
@@ -28,13 +28,13 @@
#include "gui/changepassworddialog.h"
#include "net/logindata.h"
-#ifdef TMWSERV_SUPPORT
#include "gui/widgets/radiobutton.h"
#include "gui/widgets/slider.h"
#include "gui/unregisterdialog.h"
#include "gui/changeemaildialog.h"
+#ifdef TMWSERV_SUPPORT
#include "net/tmwserv/accountserver/account.h"
#else
#include "net/ea/protocol.h"
@@ -92,6 +92,9 @@ void CharDeleteConfirm::action(const gcn::ActionEvent &event)
ConfirmDialog::action(event);
}
+bool CharSelectDialog::doAllowUnregister = true;
+bool CharSelectDialog::doAllowChangeEmail = true;
+
CharSelectDialog::CharSelectDialog(LockedArray<LocalPlayer*> *charInfo,
LoginData *loginData):
Window(_("Account and Character Management")),
@@ -369,3 +372,10 @@ bool CharSelectDialog::selectByName(const std::string &name)
return false;
}
+
+static void CharSelectDialog::setNetworkOptions(bool allowUnregister,
+ bool allowChangeEmail)
+{
+ doAllowUnregister = allowUnregister;
+ doAllowChangeEmail = allowChangeEmail;
+}
diff --git a/src/gui/charselectdialog.h b/src/gui/charselectdialog.h
index 5f067404..cfd36390 100644
--- a/src/gui/charselectdialog.h
+++ b/src/gui/charselectdialog.h
@@ -57,6 +57,9 @@ class CharSelectDialog : public Window, public gcn::ActionListener
bool selectByName(const std::string &name);
+ static void setNetworkOptions(bool allowUnregister,
+ bool allowChangeEmail);
+
private:
LockedArray<LocalPlayer*> *mCharInfo;
@@ -97,6 +100,8 @@ class CharSelectDialog : public Window, public gcn::ActionListener
* Communicate character selection to the server.
*/
void attemptCharSelect();
+
+ static bool doAllowUnregister, doAllowChangeEmail;
};
#endif
diff --git a/src/gui/register.cpp b/src/gui/register.cpp
index ec91c098..50f63c69 100644
--- a/src/gui/register.cpp
+++ b/src/gui/register.cpp
@@ -52,6 +52,7 @@ void WrongDataNoticeListener::action(const gcn::ActionEvent &event)
mTarget->requestFocus();
}
+std::string *RegisterDialog::useEmail = NULL;
Gender *RegisterDialog::useGender = NULL;
RegisterDialog::RegisterDialog(LoginData *loginData):
@@ -62,17 +63,13 @@ RegisterDialog::RegisterDialog(LoginData *loginData):
gcn::Label *userLabel = new Label(_("Name:"));
gcn::Label *passwordLabel = new Label(_("Password:"));
gcn::Label *confirmLabel = new Label(_("Confirm:"));
-#ifdef TMWSERV_SUPPORT
gcn::Label *emailLabel = new Label(_("Email:"));
-#endif
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);
-#ifdef TMWSERV_SUPPORT
mEmailField = new TextField;
-#endif
mRegisterButton = new Button(_("Register"), "register", this);
mCancelButton = new Button(_("Cancel"), "cancel", this);
@@ -88,15 +85,14 @@ RegisterDialog::RegisterDialog(LoginData *loginData):
place(2, 3, mFemaleButton);
}
-#ifdef TMWSERV_SUPPORT
- place(0, 3, emailLabel);
-#endif
+ if (useEmail)
+ {
+ 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);
-#ifdef TMWSERV_SUPPORT
- place(1, 3, mEmailField, 3).setPadding(2);
-#endif
place = getPlacer(0, 2);
place(1, 0, mRegisterButton);
place(2, 0, mCancelButton);
@@ -215,9 +211,8 @@ void RegisterDialog::action(const gcn::ActionEvent &event)
if (useGender)
*useGender = mFemaleButton->isSelected() ? GENDER_FEMALE :
GENDER_MALE;
-#ifdef TMWSERV_SUPPORT
- mLoginData->email = mEmailField->getText();
-#endif
+ if (useEmail)
+ *useEmail = mEmailField->getText();
mLoginData->registerLogin = true;
state = STATE_REGISTER_ATTEMPT;
@@ -230,6 +225,11 @@ void RegisterDialog::keyPressed(gcn::KeyEvent &keyEvent)
mRegisterButton->setEnabled(canSubmit());
}
+void RegisterDialog::setEmail(std::string *email)
+{
+ useEmail = email;
+}
+
void RegisterDialog::setGender(Gender *gender)
{
useGender = gender;
diff --git a/src/gui/register.h b/src/gui/register.h
index 729b21c3..8fe3d9fb 100644
--- a/src/gui/register.h
+++ b/src/gui/register.h
@@ -81,6 +81,13 @@ class RegisterDialog : public Window, public gcn::ActionListener,
void keyPressed(gcn::KeyEvent &keyEvent);
/**
+ * Tell the dialog to show an email field. Value stored in the passed
+ * string pointer. Default email from pointer. Passing NULL disables
+ * the feature.
+ */
+ static void setEmail(std::string *email);
+
+ /**
* Tell the dialog to show a gender selection. Value stored in the
* passed Gender pointer. Default Gender from pointer. Passing NULL
* disables the feature.
@@ -97,9 +104,7 @@ class RegisterDialog : public Window, public gcn::ActionListener,
gcn::TextField *mUserField;
gcn::TextField *mPasswordField;
gcn::TextField *mConfirmField;
-#ifdef TMWSERV_SUPPORT
gcn::TextField *mEmailField;
-#endif
gcn::Button *mRegisterButton;
gcn::Button *mCancelButton;
@@ -110,6 +115,7 @@ class RegisterDialog : public Window, public gcn::ActionListener,
LoginData *mLoginData;
+ static std::string *useEmail;
static Gender *useGender;
};