diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/changeemaildialog.cpp | 3 | ||||
-rw-r--r-- | src/gui/changepassworddialog.cpp | 1 | ||||
-rw-r--r-- | src/gui/changepassworddialog.h | 3 | ||||
-rw-r--r-- | src/gui/charselectdialog.cpp | 65 | ||||
-rw-r--r-- | src/gui/charselectdialog.h | 31 | ||||
-rw-r--r-- | src/gui/widgets/layout.h | 8 | ||||
-rw-r--r-- | src/net/charhandler.h | 4 | ||||
-rw-r--r-- | src/net/ea/generalhandler.cpp | 1 | ||||
-rw-r--r-- | src/net/ea/loginhandler.h | 3 | ||||
-rw-r--r-- | src/net/loginhandler.h | 7 | ||||
-rw-r--r-- | src/net/tmwserv/generalhandler.cpp | 3 | ||||
-rw-r--r-- | src/net/tmwserv/loginhandler.h | 3 |
12 files changed, 63 insertions, 69 deletions
diff --git a/src/gui/changeemaildialog.cpp b/src/gui/changeemaildialog.cpp index 62d2a3f7..15e54895 100644 --- a/src/gui/changeemaildialog.cpp +++ b/src/gui/changeemaildialog.cpp @@ -99,8 +99,7 @@ ChangeEmailDialog::~ChangeEmailDialog() delete mWrongDataNoticeListener; } -void -ChangeEmailDialog::action(const gcn::ActionEvent &event) +void ChangeEmailDialog::action(const gcn::ActionEvent &event) { if (event.getId() == "cancel") { diff --git a/src/gui/changepassworddialog.cpp b/src/gui/changepassworddialog.cpp index 9d66d13a..cabccc8f 100644 --- a/src/gui/changepassworddialog.cpp +++ b/src/gui/changepassworddialog.cpp @@ -156,6 +156,5 @@ void ChangePasswordDialog::action(const gcn::ActionEvent &event) state = STATE_CHANGEPASSWORD_ATTEMPT; scheduleDelete(); } - } } diff --git a/src/gui/changepassworddialog.h b/src/gui/changepassworddialog.h index 18c13606..17c628db 100644 --- a/src/gui/changepassworddialog.h +++ b/src/gui/changepassworddialog.h @@ -37,7 +37,8 @@ class WrongDataNoticeListener; * * \ingroup Interface */ -class ChangePasswordDialog : public Window, public gcn::ActionListener { +class ChangePasswordDialog : public Window, public gcn::ActionListener +{ public: /** * Constructor diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp index 6407e05e..13dc8dd6 100644 --- a/src/gui/charselectdialog.cpp +++ b/src/gui/charselectdialog.cpp @@ -49,6 +49,7 @@ #include "net/charhandler.h" #include "net/logindata.h" +#include "net/loginhandler.h" #include "net/messageout.h" #include "net/net.h" @@ -112,25 +113,19 @@ class CharEntry : public Container Button *mButton; }; -bool CharSelectDialog::doAllowUnregister = true; -bool CharSelectDialog::doAllowChangeEmail = true; - CharSelectDialog::CharSelectDialog(LockedArray<LocalPlayer*> *charInfo, LoginData *loginData): Window(_("Account and Character Management")), mCharInfo(charInfo), - mLoginData(loginData) + mLoginData(loginData), + mCharHandler(Net::getCharHandler()) { setCloseButton(false); mAccountNameLabel = new Label(loginData->username); - mSwitchLoginButton = new Button(_("Switch Login"), "switch", this); - mUnregisterButton = new Button(_("Unregister"), "unregister", this); - mChangePasswordButton = new Button(_("Change Password"), "change_password", this); - mChangeEmailButton = new Button(_("Change Email"), "change_email", this); for (int i = 0; i < MAX_CHARACTER_COUNT; i++) { @@ -138,33 +133,34 @@ CharSelectDialog::CharSelectDialog(LockedArray<LocalPlayer*> *charInfo, mCharEntries[i] = new CharEntry(this, i, charInfo->getEntry()); } - place(0, 0, mAccountNameLabel, 6); + int optionalActions = Net::getLoginHandler()->supportedOptionalActions(); - place(0, 1, mSwitchLoginButton, 3); + ContainerPlacer place; + place = getPlacer(0, 0); - if (doAllowUnregister) - place(3, 1, mUnregisterButton, 3); + place(0, 0, mAccountNameLabel, 2); + place(0, 1, mSwitchLoginButton); - place(0, 2, mChangePasswordButton, 3); + if (optionalActions & Net::LoginHandler::Unregister) { + gcn::Button *unregisterButton = new Button(_("Unregister"), + "unregister", this); + place(3, 1, unregisterButton); + } - if (doAllowChangeEmail) - place(3, 2, mChangeEmailButton, 3); + place(0, 2, mChangePasswordButton); - place(0, 3, mCharEntries[0], 2, 3); - place(2, 3, mCharEntries[1], 2, 3); - place(4, 3, mCharEntries[2], 2, 3); + if (optionalActions & Net::LoginHandler::ChangeEmail) { + gcn::Button *changeEmailButton = new Button(_("Change Email"), + "change_email", this); + place(3, 2, changeEmailButton); + } - int width = mAccountNameLabel->getWidth(); - width = std::max(width, mSwitchLoginButton->getWidth() + - mUnregisterButton->getWidth()); - width = std::max(width, mChangePasswordButton->getWidth() + - mChangeEmailButton->getWidth()); - width = std::max(width, 3 * mCharEntries[0]->getWidth()); + place = getPlacer(0, 1); + place(0, 0, mCharEntries[0]); + place(1, 0, mCharEntries[1]); + place(2, 0, mCharEntries[2]); - reflowLayout(width + 10, mAccountNameLabel->getHeight() + - mSwitchLoginButton->getHeight() + - mChangePasswordButton->getHeight() + - mCharEntries[0]->getHeight() + 20); + reflowLayout(); center(); mCharEntries[0]->requestFocus(); @@ -195,7 +191,7 @@ void CharSelectDialog::action(const gcn::ActionEvent &event) // Start new character dialog CharCreateDialog *charCreateDialog = new CharCreateDialog(this, mCharInfo->getPos()); - Net::getCharHandler()->setCharCreateDialog(charCreateDialog); + mCharHandler->setCharCreateDialog(charCreateDialog); } } else if (event.getId() == "delete") @@ -221,13 +217,13 @@ void CharSelectDialog::action(const gcn::ActionEvent &event) void CharSelectDialog::attemptCharDelete() { - Net::getCharHandler()->deleteCharacter(mCharInfo->getPos(), mCharInfo->getEntry()); + mCharHandler->deleteCharacter(mCharInfo->getPos(), mCharInfo->getEntry()); mCharInfo->lock(); } void CharSelectDialog::attemptCharSelect() { - Net::getCharHandler()->chooseCharacter(mCharInfo->getPos(), mCharInfo->getEntry()); + mCharHandler->chooseCharacter(mCharInfo->getPos(), mCharInfo->getEntry()); mCharInfo->lock(); } @@ -266,13 +262,6 @@ void CharSelectDialog::chooseSelected() attemptCharSelect(); } -void CharSelectDialog::setNetworkOptions(bool allowUnregister, - bool allowChangeEmail) -{ - doAllowUnregister = allowUnregister; - doAllowChangeEmail = allowChangeEmail; -} - CharEntry::CharEntry(CharSelectDialog *m, char slot, LocalPlayer *chr): mSlot(slot), mCharacter(chr), diff --git a/src/gui/charselectdialog.h b/src/gui/charselectdialog.h index e1c8071e..0bb8e27f 100644 --- a/src/gui/charselectdialog.h +++ b/src/gui/charselectdialog.h @@ -36,6 +36,10 @@ class LocalPlayer; class LoginData; class PlayerBox; +namespace Net { +class CharHandler; +} + /** * Character selection dialog. * @@ -58,34 +62,29 @@ class CharSelectDialog : public Window, public gcn::ActionListener void chooseSelected(); - static void setNetworkOptions(bool allowUnregister, - bool allowChangeEmail); - private: + /** + * Communicate character deletion to the server. + */ + void attemptCharDelete(); + + /** + * Communicate character selection to the server. + */ + void attemptCharSelect(); + LockedArray<LocalPlayer*> *mCharInfo; gcn::Label *mAccountNameLabel; gcn::Button *mSwitchLoginButton; gcn::Button *mChangePasswordButton; - gcn::Button *mChangeEmailButton; - gcn::Button *mUnregisterButton; CharEntry *mCharEntries[MAX_CHARACTER_COUNT]; LoginData *mLoginData; - /** - * Communicate character deletion to the server. - */ - void attemptCharDelete(); - - /** - * Communicate character selection to the server. - */ - void attemptCharSelect(); - - static bool doAllowUnregister, doAllowChangeEmail; + Net::CharHandler *mCharHandler; }; #endif diff --git a/src/gui/widgets/layout.h b/src/gui/widgets/layout.h index b9359e91..994c25fe 100644 --- a/src/gui/widgets/layout.h +++ b/src/gui/widgets/layout.h @@ -34,7 +34,6 @@ class LayoutCell; class ContainerPlacer { public: - ContainerPlacer(gcn::Container *c = NULL, LayoutCell *l = NULL): mContainer(c), mCell(l) {} @@ -58,7 +57,6 @@ class ContainerPlacer (int x, int y, gcn::Widget *, int w = 1, int h = 1); private: - gcn::Container *mContainer; LayoutCell *mCell; }; @@ -164,7 +162,6 @@ class LayoutCell friend class LayoutArray; public: - enum Alignment { LEFT, RIGHT, CENTER, FILL @@ -235,7 +232,6 @@ class LayoutCell void computeSizes(); private: - // Copy not allowed, as the cell may own an array. LayoutCell(LayoutCell const &); LayoutCell &operator=(LayoutCell const &); @@ -283,10 +279,9 @@ class LayoutCell * pixels between rows and between columns, and a margin of 6 pixels around the * whole layout. */ -class Layout: public LayoutCell +class Layout : public LayoutCell { public: - Layout(); /** @@ -313,7 +308,6 @@ class Layout: public LayoutCell }; private: - bool mComputed; }; diff --git a/src/net/charhandler.h b/src/net/charhandler.h index 9ca36a9f..ac235df5 100644 --- a/src/net/charhandler.h +++ b/src/net/charhandler.h @@ -33,6 +33,7 @@ class CharCreateDialog; class LocalPlayer; namespace Net { + class CharHandler { public: @@ -50,6 +51,7 @@ class CharHandler virtual void deleteCharacter(int slot, LocalPlayer* character) = 0; }; -} + +} // namespace Net #endif // CHARHANDLER_H diff --git a/src/net/ea/generalhandler.cpp b/src/net/ea/generalhandler.cpp index 46a115ff..692ebec0 100644 --- a/src/net/ea/generalhandler.cpp +++ b/src/net/ea/generalhandler.cpp @@ -103,7 +103,6 @@ GeneralHandler::GeneralHandler(): ItemDB::setStatsList(stats); - CharSelectDialog::setNetworkOptions(false, false); RegisterDialog::setEmail(NULL); RegisterDialog::setGender(&netToken.sex); } diff --git a/src/net/ea/loginhandler.h b/src/net/ea/loginhandler.h index bc1aa816..780aa832 100644 --- a/src/net/ea/loginhandler.h +++ b/src/net/ea/loginhandler.h @@ -46,6 +46,9 @@ class LoginHandler : public MessageHandler, public Net::LoginHandler void disconnect(); + int supportedOptionalActions() const + { return 0; } + void loginAccount(LoginData *loginData); void changeEmail(const std::string &email); diff --git a/src/net/loginhandler.h b/src/net/loginhandler.h index 26dfb53b..5274bbea 100644 --- a/src/net/loginhandler.h +++ b/src/net/loginhandler.h @@ -35,6 +35,11 @@ namespace Net { class LoginHandler { public: + enum OptionalAction { + Unregister = 0x1, + ChangeEmail = 0x2 + }; + virtual void setServer(const ServerInfo &server) { mServer = server; } @@ -47,6 +52,8 @@ class LoginHandler virtual void disconnect() = 0; + virtual int supportedOptionalActions() const = 0; + virtual void loginAccount(LoginData *loginData) = 0; virtual void changeEmail(const std::string &email) = 0; diff --git a/src/net/tmwserv/generalhandler.cpp b/src/net/tmwserv/generalhandler.cpp index ede20ff0..0f4b5109 100644 --- a/src/net/tmwserv/generalhandler.cpp +++ b/src/net/tmwserv/generalhandler.cpp @@ -102,9 +102,8 @@ GeneralHandler::GeneralHandler(): stats.push_back(ItemDB::Stat("will", N_("Willpower %+d"))); ItemDB::setStatsList(stats); - + ChangeEmailDialog::setEmail(&userEmail); - CharSelectDialog::setNetworkOptions(true, true); RegisterDialog::setEmail(&userEmail); RegisterDialog::setGender(NULL); } diff --git a/src/net/tmwserv/loginhandler.h b/src/net/tmwserv/loginhandler.h index 50b3d8c7..754fa71b 100644 --- a/src/net/tmwserv/loginhandler.h +++ b/src/net/tmwserv/loginhandler.h @@ -44,6 +44,9 @@ class LoginHandler : public MessageHandler, public Net::LoginHandler void disconnect(); + int supportedOptionalActions() const + { return Unregister | ChangeEmail; } + void loginAccount(LoginData *loginData); void changeEmail(const std::string &email); |