From a3c66a09efc7f3683f0c247f4a2c5035bff83651 Mon Sep 17 00:00:00 2001 From: Dennis Friis Date: Sun, 24 May 2009 21:49:09 +0200 Subject: Add change password dialog to athena client (cherry picked from commit 050103b8d2e3eb23e7aea188a1a269feb7c181ab) --- src/Makefile.am | 4 ++-- src/gui/charselectdialog.cpp | 43 +++++++++++++++++++------------------------ src/gui/charselectdialog.h | 12 ++++-------- src/main.cpp | 2 +- src/main.h | 4 ++-- 5 files changed, 28 insertions(+), 37 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 47d27ede..dd9177e4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -69,6 +69,8 @@ tmw_SOURCES = gui/widgets/avatar.cpp \ gui/buy.h \ gui/buysell.cpp \ gui/buysell.h \ + gui/changepassworddialog.cpp \ + gui/changepassworddialog.h \ gui/charselectdialog.cpp \ gui/charselectdialog.h \ gui/charcreatedialog.cpp \ @@ -366,8 +368,6 @@ tmw_SOURCES += \ gui/buddywindow.h \ gui/changeemaildialog.cpp \ gui/changeemaildialog.h \ - gui/changepassworddialog.cpp \ - gui/changepassworddialog.h \ gui/connection.cpp \ gui/connection.h \ gui/guildlistbox.cpp \ diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp index 4df0243b..dd91af5c 100644 --- a/src/gui/charselectdialog.cpp +++ b/src/gui/charselectdialog.cpp @@ -25,17 +25,16 @@ #include "gui/confirmdialog.h" #include "gui/okdialog.h" #include "gui/playerbox.h" +#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/changepassworddialog.h" #include "gui/changeemaildialog.h" -#include "net/logindata.h" - #include "net/tmwserv/accountserver/account.h" #endif @@ -91,36 +90,30 @@ void CharDeleteConfirm::action(const gcn::ActionEvent &event) ConfirmDialog::action(event); } -#ifdef TMWSERV_SUPPORT CharSelectDialog::CharSelectDialog(LockedArray *charInfo, LoginData *loginData): Window(_("Account and Character Management")), mCharInfo(charInfo), mCharSelected(false), - mLoginData(loginData) -#else -CharSelectDialog::CharSelectDialog(LockedArray *charInfo, - Gender gender): - Window(_("Select Character")), - mCharInfo(charInfo), - mCharSelected(false), - mGender(gender) +#ifdef EATHENA_SUPPORT + mGender(loginData->sex), #endif + mLoginData(loginData) { mSelectButton = new Button(_("OK"), "ok", this); mCancelButton = new Button(_("Cancel"), "cancel", this); mPreviousButton = new Button(_("Previous"), "previous", this); mNextButton = new Button(_("Next"), "next", this); + mAccountNameLabel = new Label(strprintf(_("Account: %s"), mLoginData->username.c_str())); mNameLabel = new Label(strprintf(_("Name: %s"), "")); mLevelLabel = new Label(strprintf(_("Level: %d"), 0)); + mChangePasswordButton = new Button(_("Change Password"), "change_password", this); #ifdef TMWSERV_SUPPORT mNewCharButton = new Button(_("New"), "new", this); mDelCharButton = new Button(_("Delete"), "delete", this); mUnRegisterButton = new Button(_("Unregister"), "unregister", this); - mChangePasswordButton = new Button(_("Change Password"), "change_password", this); mChangeEmailButton = new Button(_("Change Email Address"), "change_email", this); - mAccountNameLabel = new Label(strprintf(_("Account: %s"), mLoginData->username.c_str())); mNameLabel = new Label(strprintf(_("Name: %s"), "")); mLevelLabel = new Label(strprintf(_("Level: %d"), 0)); mMoneyLabel = new Label(strprintf(_("Money: %d"), 0)); @@ -169,13 +162,15 @@ CharSelectDialog::CharSelectDialog(LockedArray *charInfo, ContainerPlacer place; place = getPlacer(0, 0); - + place(0, 0, mAccountNameLabel); + place(0, 1, mChangePasswordButton); + place = getPlacer(0, 1); place(0, 0, mPlayerBox, 1, 6).setPadding(3); - place(1, 0, mNewDelCharButton); - place(1, 1, mNameLabel, 5); - place(1, 2, mLevelLabel, 5); - place(1, 3, mJobLevelLabel, 5); - place(1, 4, mMoneyLabel, 5); + place(1, 0, mNameLabel, 5); + place(1, 1, mLevelLabel, 5); + place(1, 2, mJobLevelLabel, 5); + place(1, 3, mMoneyLabel, 5); + place(1, 4, mNewDelCharButton); place.getCell().matchColWidth(1, 4); place = getPlacer(0, 2); place(0, 0, mPreviousButton); @@ -276,15 +271,15 @@ void CharSelectDialog::action(const gcn::ActionEvent &event) if (pi) mMoney = Units::formatCurrency(pi->getMoney()); } + else if (event.getId() == "change_password") + { + new ChangePasswordDialog(this, mLoginData); + } #ifdef TMWSERV_SUPPORT else if (event.getId() == "unregister") { new UnRegisterDialog(this, mLoginData); } - else if (event.getId() == "change_password") - { - new ChangePasswordDialog(this, mLoginData); - } else if (event.getId() == "change_email") { new ChangeEmailDialog(this, mLoginData); diff --git a/src/gui/charselectdialog.h b/src/gui/charselectdialog.h index adbf3de1..06ce4b55 100644 --- a/src/gui/charselectdialog.h +++ b/src/gui/charselectdialog.h @@ -47,13 +47,8 @@ class CharSelectDialog : public Window, public gcn::ActionListener /** * Constructor. */ -#ifdef TMWSERV_SUPPORT CharSelectDialog(LockedArray *charInfo, LoginData *loginData); -#else - CharSelectDialog(LockedArray *charInfo, - Gender gender); -#endif void action(const gcn::ActionEvent &event); @@ -70,12 +65,16 @@ class CharSelectDialog : public Window, public gcn::ActionListener gcn::Button *mCancelButton; gcn::Button *mPreviousButton; gcn::Button *mNextButton; + gcn::Button *mChangePasswordButton; gcn::Label *mNameLabel; gcn::Label *mLevelLabel; gcn::Label *mMoneyLabel; + gcn::Label *mAccountNameLabel; std::string mMoney; + LoginData *mLoginData; + PlayerBox *mPlayerBox; bool mCharSelected; @@ -84,11 +83,8 @@ class CharSelectDialog : public Window, public gcn::ActionListener gcn::Button *mNewCharButton; gcn::Button *mDelCharButton; gcn::Button *mUnRegisterButton; - gcn::Button *mChangePasswordButton; gcn::Button *mChangeEmailButton; - gcn::Label *mAccountNameLabel; - LoginData *mLoginData; #else gcn::Button *mNewDelCharButton; gcn::Label *mJobLevelLabel; diff --git a/src/main.cpp b/src/main.cpp index c2e74ff3..d1fba313 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1446,7 +1446,7 @@ int main(int argc, char *argv[]) case STATE_CHAR_SELECT: logger->log("State: CHAR_SELECT"); currentDialog = new CharSelectDialog(&charInfo, - loginData.sex); + &loginData); positionDialog(currentDialog, screenWidth, screenHeight); if (((CharSelectDialog*) currentDialog)-> diff --git a/src/main.h b/src/main.h index 75343944..d33ea14d 100644 --- a/src/main.h +++ b/src/main.h @@ -87,6 +87,8 @@ enum State { STATE_GAME, STATE_ERROR, STATE_UPDATE, + STATE_CHANGEPASSWORD_ATTEMPT, + STATE_CHANGEPASSWORD, #ifdef TMWSERV_SUPPORT STATE_CHOOSE_SERVER, STATE_CONNECT_ACCOUNT, @@ -96,8 +98,6 @@ enum State { STATE_ACCOUNTCHANGE_ERROR, STATE_CHANGEEMAIL_ATTEMPT, STATE_CHANGEEMAIL, - STATE_CHANGEPASSWORD_ATTEMPT, - STATE_CHANGEPASSWORD, STATE_UNREGISTER_ATTEMPT, STATE_UNREGISTER, STATE_SWITCH_CHARACTER, -- cgit v1.2.3-60-g2f50