summaryrefslogtreecommitdiff
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
parent83fd36204202b4b5cca7e6cdb37c025919f32f08 (diff)
downloadmana-da61b7e9cb40e75ad0d74cc64853bf1b08d0a031.tar.gz
mana-da61b7e9cb40e75ad0d74cc64853bf1b08d0a031.tar.bz2
mana-da61b7e9cb40e75ad0d74cc64853bf1b08d0a031.tar.xz
mana-da61b7e9cb40e75ad0d74cc64853bf1b08d0a031.zip
Finish merging registration dialog
-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
-rw-r--r--src/main.cpp17
-rw-r--r--src/net/ea/generalhandler.cpp1
-rw-r--r--src/net/logindata.h4
-rw-r--r--src/net/tmwserv/generalhandler.cpp4
-rw-r--r--src/net/tmwserv/loginhandler.cpp3
11 files changed, 66 insertions, 35 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;
};
diff --git a/src/main.cpp b/src/main.cpp
index 4699e072..63f56818 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1129,19 +1129,14 @@ int main(int argc, char *argv[])
break;
- case STATE_CHANGEEMAIL_ATTEMPT:
- logger->log("State: CHANGE EMAIL ATTEMPT");
- Net::getLoginHandler()->changeEmail(loginData.newEmail);
- break;
-
case STATE_CHANGEEMAIL:
logger->log("State: CHANGE EMAIL");
- currentDialog = new OkDialog(_("Email Address Change"),
- _("Email address changed successfully!"));
- currentDialog->addActionListener(&accountListener);
- currentDialog = NULL; // OkDialog deletes itself
- loginData.email = loginData.newEmail;
- loginData.newEmail = "";
+ // TODO
+ break;
+
+ case STATE_CHANGEEMAIL_ATTEMPT:
+ logger->log("State: CHANGE EMAIL ATTEMPT");
+ // TODO
break;
case STATE_CHANGEPASSWORD_ATTEMPT:
diff --git a/src/net/ea/generalhandler.cpp b/src/net/ea/generalhandler.cpp
index 1dde3b3f..fac3dcd1 100644
--- a/src/net/ea/generalhandler.cpp
+++ b/src/net/ea/generalhandler.cpp
@@ -207,6 +207,7 @@ void GeneralHandler::guiWindowsLoaded()
{
partyTab = new PartyTab;
inventoryWindow->setSplitAllowed(false);
+ RegisterDialog::setEmail(NULL);
RegisterDialog::setGender(&netToken.sex);
skillDialog->loadSkills("ea-skills.xml");
diff --git a/src/net/logindata.h b/src/net/logindata.h
index 5e72f8fd..c0ca0a4e 100644
--- a/src/net/logindata.h
+++ b/src/net/logindata.h
@@ -33,8 +33,6 @@ struct LoginData
std::string password;
std::string newPassword;
std::string updateHost;
- std::string email;
- std::string newEmail;
bool remember; /**< Whether to store the username. */
bool registerLogin; /**< Whether an account is being registered. */
@@ -45,8 +43,6 @@ struct LoginData
password.clear();
newPassword.clear();
updateHost.clear();
- email.clear();
- newEmail.clear();
}
};
diff --git a/src/net/tmwserv/generalhandler.cpp b/src/net/tmwserv/generalhandler.cpp
index 81bb46be..68f8c918 100644
--- a/src/net/tmwserv/generalhandler.cpp
+++ b/src/net/tmwserv/generalhandler.cpp
@@ -21,6 +21,7 @@
#include "net/tmwserv/generalhandler.h"
+#include "gui/changeemaildialog.h"
#include "gui/inventorywindow.h"
#include "gui/partywindow.h"
#include "gui/register.h"
@@ -61,6 +62,7 @@ Net::Connection *accountServerConnection = 0;
namespace TmwServ {
+std::string userEmail = "";
std::string netToken = "";
ServerInfo gameServer;
ServerInfo chatServer;
@@ -155,8 +157,10 @@ void GeneralHandler::tick()
void GeneralHandler::guiWindowsLoaded()
{
+ ChangeEmailDialog::setEmail(*userEmail);
inventoryWindow->setSplitAllowed(true);
partyWindow->clearPartyName();
+ RegisterDialog::setEmail(&userEmail);
RegisterDialog::setGender(NULL);
skillDialog->loadSkills("tmw-skills.xml");
specialsWindow->loadSpecials("specials.xml");
diff --git a/src/net/tmwserv/loginhandler.cpp b/src/net/tmwserv/loginhandler.cpp
index 74b8abad..81079a3a 100644
--- a/src/net/tmwserv/loginhandler.cpp
+++ b/src/net/tmwserv/loginhandler.cpp
@@ -39,6 +39,7 @@ Net::LoginHandler *loginHandler;
extern Net::Connection *accountServerConnection;
namespace TmwServ {
+extern std::string userEmail;
LoginHandler::LoginHandler()
{
@@ -333,7 +334,7 @@ void LoginHandler::registerAccount(LoginData *loginData)
0, // client version
loginData->username,
loginData->password,
- loginData->email);
+ userEmail);
}
void LoginHandler::unregisterAccount(const std::string &username,