diff options
author | Andreas Habel <mail@exceptionfault.de> | 2009-10-08 00:38:53 +0200 |
---|---|---|
committer | Andreas Habel <mail@exceptionfault.de> | 2009-10-08 00:38:53 +0200 |
commit | 91119464a20e29d7b125ee697e91bfce2d100d19 (patch) | |
tree | fd8fd3b7438370cd9b2c4516ed818914ca853cd1 /src | |
parent | 81934dc041da371fc94c19de9936714bc065528a (diff) | |
parent | 11b3ff85e9dc8f39ddcfdff511c6340b899ba414 (diff) | |
download | mana-91119464a20e29d7b125ee697e91bfce2d100d19.tar.gz mana-91119464a20e29d7b125ee697e91bfce2d100d19.tar.bz2 mana-91119464a20e29d7b125ee697e91bfce2d100d19.tar.xz mana-91119464a20e29d7b125ee697e91bfce2d100d19.zip |
Merge branch 'master' of git@gitorious.org:tmw/mainline
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/changeemaildialog.cpp | 9 | ||||
-rw-r--r-- | src/gui/changeemaildialog.h | 2 | ||||
-rw-r--r-- | src/gui/changepassworddialog.cpp | 10 | ||||
-rw-r--r-- | src/gui/changepassworddialog.h | 2 | ||||
-rw-r--r-- | src/gui/charselectdialog.cpp | 6 | ||||
-rw-r--r-- | src/gui/unregisterdialog.cpp | 12 | ||||
-rw-r--r-- | src/gui/unregisterdialog.h | 2 | ||||
-rw-r--r-- | src/main.cpp | 309 | ||||
-rw-r--r-- | src/main.h | 15 | ||||
-rw-r--r-- | src/net/ea/loginhandler.cpp | 2 | ||||
-rw-r--r-- | src/net/tmwserv/loginhandler.cpp | 4 |
11 files changed, 204 insertions, 169 deletions
diff --git a/src/gui/changeemaildialog.cpp b/src/gui/changeemaildialog.cpp index 45dcc5f8..f536bd4f 100644 --- a/src/gui/changeemaildialog.cpp +++ b/src/gui/changeemaildialog.cpp @@ -39,8 +39,8 @@ #include <string> #include <sstream> -ChangeEmailDialog::ChangeEmailDialog(Window *parent, LoginData *loginData): - Window(_("Change Email Address"), true, parent), +ChangeEmailDialog::ChangeEmailDialog(LoginData *loginData): + Window(_("Change Email Address"), true), mWrongDataNoticeListener(new WrongDataNoticeListener), mLoginData(loginData) { @@ -85,7 +85,7 @@ ChangeEmailDialog::ChangeEmailDialog(Window *parent, LoginData *loginData): add(mChangeEmailButton); add(mCancelButton); - setLocationRelativeTo(getParent()); + center(); setVisible(true); mFirstEmailField->requestFocus(); @@ -102,7 +102,7 @@ void ChangeEmailDialog::action(const gcn::ActionEvent &event) { if (event.getId() == "cancel") { - scheduleDelete(); + state = STATE_CHAR_SELECT; } else if (event.getId() == "change_email") { @@ -160,7 +160,6 @@ void ChangeEmailDialog::action(const gcn::ActionEvent &event) // Set the new email address mLoginData->email = newFirstEmail; state = STATE_CHANGEEMAIL_ATTEMPT; - scheduleDelete(); } } } diff --git a/src/gui/changeemaildialog.h b/src/gui/changeemaildialog.h index ae9aa6cc..87e99068 100644 --- a/src/gui/changeemaildialog.h +++ b/src/gui/changeemaildialog.h @@ -45,7 +45,7 @@ class ChangeEmailDialog : public Window, public gcn::ActionListener * * @see Window::Window */ - ChangeEmailDialog(Window *parent, LoginData *loginData); + ChangeEmailDialog(LoginData *loginData); /** * Destructor. diff --git a/src/gui/changepassworddialog.cpp b/src/gui/changepassworddialog.cpp index cabccc8f..0ad9071a 100644 --- a/src/gui/changepassworddialog.cpp +++ b/src/gui/changepassworddialog.cpp @@ -41,9 +41,8 @@ #include <string> #include <sstream> -ChangePasswordDialog::ChangePasswordDialog(Window *parent, - LoginData *loginData): - Window(_("Change Password"), true, parent), +ChangePasswordDialog::ChangePasswordDialog(LoginData *loginData): + Window(_("Change Password"), true), mWrongDataNoticeListener(new WrongDataNoticeListener), mLoginData(loginData) { @@ -66,7 +65,7 @@ ChangePasswordDialog::ChangePasswordDialog(Window *parent, place(2, 6, mChangePassButton); reflowLayout(200); - setLocationRelativeTo(getParent()); + center(); setVisible(true); mOldPassField->requestFocus(); @@ -84,7 +83,7 @@ void ChangePasswordDialog::action(const gcn::ActionEvent &event) { if (event.getId() == "cancel") { - scheduleDelete(); + state = STATE_CHAR_SELECT; } else if (event.getId() == "change_password") { @@ -154,7 +153,6 @@ void ChangePasswordDialog::action(const gcn::ActionEvent &event) mLoginData->password = oldPassword; mLoginData->newPassword = newFirstPass; state = STATE_CHANGEPASSWORD_ATTEMPT; - scheduleDelete(); } } } diff --git a/src/gui/changepassworddialog.h b/src/gui/changepassworddialog.h index 17c628db..d54c0e1a 100644 --- a/src/gui/changepassworddialog.h +++ b/src/gui/changepassworddialog.h @@ -45,7 +45,7 @@ class ChangePasswordDialog : public Window, public gcn::ActionListener * * @see Window::Window */ - ChangePasswordDialog(Window *parent,LoginData *loginData); + ChangePasswordDialog(LoginData *loginData); /** * Destructor diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp index 43748765..2bb9cff3 100644 --- a/src/gui/charselectdialog.cpp +++ b/src/gui/charselectdialog.cpp @@ -210,15 +210,15 @@ void CharSelectDialog::action(const gcn::ActionEvent &event) } else if (event.getId() == "change_password") { - new ChangePasswordDialog(this, mLoginData); + state = STATE_CHANGEPASSWORD; } else if (event.getId() == "change_email") { - new ChangeEmailDialog(this, mLoginData); + state = STATE_CHANGEEMAIL; } else if (event.getId() == "unregister") { - new UnRegisterDialog(this, mLoginData); + state = STATE_UNREGISTER; } } diff --git a/src/gui/unregisterdialog.cpp b/src/gui/unregisterdialog.cpp index be54453d..0dfc8df9 100644 --- a/src/gui/unregisterdialog.cpp +++ b/src/gui/unregisterdialog.cpp @@ -41,12 +41,13 @@ #include <string> #include <sstream> -UnRegisterDialog::UnRegisterDialog(Window *parent, LoginData *loginData): - Window(_("Unregister"), true, parent), +UnRegisterDialog::UnRegisterDialog(LoginData *loginData): + Window(_("Unregister"), true), mWrongDataNoticeListener(new WrongDataNoticeListener), mLoginData(loginData) { - gcn::Label *userLabel = new Label(strprintf(_("Name: %s"), mLoginData->username.c_str())); + gcn::Label *userLabel = new Label(strprintf(_("Name: %s"), mLoginData-> + username.c_str())); gcn::Label *passwordLabel = new Label(_("Password:")); mPasswordField = new PasswordField(mLoginData->password); mUnRegisterButton = new Button(_("Unregister"), "unregister", this); @@ -77,7 +78,7 @@ UnRegisterDialog::UnRegisterDialog(Window *parent, LoginData *loginData): add(mUnRegisterButton); add(mCancelButton); - setLocationRelativeTo(getParent()); + center(); setVisible(true); mPasswordField->requestFocus(); mPasswordField->setActionEventId("cancel"); @@ -93,7 +94,7 @@ UnRegisterDialog::action(const gcn::ActionEvent &event) { if (event.getId() == "cancel") { - scheduleDelete(); + state = STATE_CHAR_SELECT; } else if (event.getId() == "unregister") { @@ -135,7 +136,6 @@ UnRegisterDialog::action(const gcn::ActionEvent &event) mUnRegisterButton->setEnabled(false); mLoginData->password = password; state = STATE_UNREGISTER_ATTEMPT; - scheduleDelete(); } } } diff --git a/src/gui/unregisterdialog.h b/src/gui/unregisterdialog.h index 18dbef5d..222dab2f 100644 --- a/src/gui/unregisterdialog.h +++ b/src/gui/unregisterdialog.h @@ -45,7 +45,7 @@ class UnRegisterDialog : public Window, public gcn::ActionListener * * @see Window::Window */ - UnRegisterDialog(Window *parent, LoginData *loginData); + UnRegisterDialog(LoginData *loginData); ~UnRegisterDialog(); diff --git a/src/main.cpp b/src/main.cpp index c1715fd1..0df822b9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -43,6 +43,8 @@ #include "gui/widgets/label.h" #include "gui/widgets/progressbar.h" +#include "gui/changeemaildialog.h" +#include "gui/changepassworddialog.h" #include "gui/charselectdialog.h" #include "gui/connectiondialog.h" #include "gui/gui.h" @@ -55,6 +57,7 @@ #include "gui/sdlinput.h" #include "gui/serverdialog.h" #include "gui/setup.h" +#include "gui/unregisterdialog.h" #include "gui/updatewindow.h" #include "gui/worldselectdialog.h" @@ -923,7 +926,7 @@ int main(int argc, char *argv[]) loadUpdates(); } - //printf("State change: %d to %d\n", oldstate, state); + printf("State change: %d to %d\n", oldstate, state); oldstate = state; @@ -940,7 +943,7 @@ int main(int argc, char *argv[]) switch (state) { case STATE_CHOOSE_SERVER: - logger->log("State: CHOOSE_SERVER"); + logger->log("State: CHOOSE SERVER"); // Don't allow an alpha opacity // lower than the default value @@ -962,30 +965,10 @@ int main(int argc, char *argv[]) break; case STATE_CONNECT_SERVER: - logger->log("State: CONNECT_SERVER"); + logger->log("State: CONNECT SERVER"); currentDialog = new ConnectionDialog(STATE_SWITCH_SERVER); break; - case STATE_UPDATE: - if (options.skipUpdate) - { - state = STATE_LOAD_DATA; - } - else - { - // Determine which source to use for the update host - if (!options.updateHost.empty()) - updateHost = options.updateHost; - else - updateHost = loginData.updateHost; - - setUpdatesDir(); - logger->log("State: UPDATE"); - currentDialog = new UpdaterWindow(updateHost, - homeDir + "/" + updatesDir); - } - break; - case STATE_LOGIN: logger->log("State: LOGIN"); // Don't allow an alpha opacity @@ -1004,33 +987,10 @@ int main(int argc, char *argv[]) break; case STATE_LOGIN_ATTEMPT: + logger->log("State: LOGIN ATTEMPT"); accountLogin(&loginData); break; - case STATE_LOAD_DATA: - logger->log("State: LOAD DATA"); - - // Add customdata directory - ResourceManager::getInstance()->searchAndAddArchives( - "customdata/", - "zip", - false); - - // Load XML databases - ColorDB::load(); - ItemDB::load(); - Being::load(); // Hairstyles - MonsterDB::load(); - NPCDB::load(); - EmoteDB::load(); - StatusEffect::load(); - Units::loadUnits(); - - desktop->reloadWallpaper(); - - state = STATE_GET_CHARACTERS; - break; - case STATE_WORLD_SELECT: logger->log("State: WORLD SELECT"); { @@ -1059,55 +1019,61 @@ int main(int argc, char *argv[]) break; case STATE_WORLD_SELECT_ATTEMPT: - logger->log("State: Attempting world selection"); + logger->log("State: WORLD SELECT ATTEMPT"); currentDialog = new ConnectionDialog(STATE_WORLD_SELECT); break; - case STATE_LOGIN_ERROR: - logger->log("State: LOGIN ERROR"); - currentDialog = new OkDialog(_("Error"), errorMessage); - currentDialog->addActionListener(&loginListener); - currentDialog = NULL; // OkDialog deletes itself - break; - - case STATE_SWITCH_SERVER: - logger->log("State: SWITCH SERVER"); - -#ifdef TMWSERV_SUPPORT - gameServerConnection->disconnect(); - chatServerConnection->disconnect(); - accountServerConnection->disconnect(); -#endif + case STATE_UPDATE: + if (options.skipUpdate) + { + state = STATE_LOAD_DATA; + } + else + { + // Determine which source to use for the update host + if (!options.updateHost.empty()) + updateHost = options.updateHost; + else + updateHost = loginData.updateHost; - state = STATE_CHOOSE_SERVER; + setUpdatesDir(); + logger->log("State: UPDATE"); + currentDialog = new UpdaterWindow(updateHost, + homeDir + "/" + updatesDir); + } break; - case STATE_SWITCH_LOGIN: - logger->log("State: SWITCH LOGIN"); - - Net::getLoginHandler()->logout(); + case STATE_LOAD_DATA: + logger->log("State: LOAD DATA"); - state = STATE_LOGIN; - break; + // Add customdata directory + ResourceManager::getInstance()->searchAndAddArchives( + "customdata/", + "zip", + false); - case STATE_REGISTER: - logger->log("State: REGISTER"); - currentDialog = new RegisterDialog(&loginData); - break; + // Load XML databases + ColorDB::load(); + ItemDB::load(); + Being::load(); // Hairstyles + MonsterDB::load(); + NPCDB::load(); + EmoteDB::load(); + StatusEffect::load(); + Units::loadUnits(); - case STATE_REGISTER_ATTEMPT: - logger->log("Username is %s", loginData.username.c_str()); + desktop->reloadWallpaper(); - Net::getCharHandler()->setCharInfo(&charInfo); - Net::getLoginHandler()->registerAccount(&loginData); + state = STATE_GET_CHARACTERS; break; case STATE_GET_CHARACTERS: + logger->log("State: GET CHARACTERS"); Net::getCharHandler()->getCharacters(); break; case STATE_CHAR_SELECT: - logger->log("State: CHAR_SELECT"); + logger->log("State: CHAR SELECT"); // Don't allow an alpha opacity // lower than the default value SkinLoader::instance()->setMinimumOpacity(0.8f); @@ -1125,14 +1091,72 @@ int main(int argc, char *argv[]) break; - case STATE_CHANGEEMAIL: - logger->log("State: CHANGE EMAIL"); - // TODO + case STATE_CONNECT_GAME: + logger->log("State: CONNECT GAME"); + Net::getGameHandler()->connect(); + currentDialog = new ConnectionDialog(STATE_SWITCH_CHARACTER); break; - case STATE_CHANGEEMAIL_ATTEMPT: - logger->log("State: CHANGE EMAIL ATTEMPT"); - Net::getLoginHandler()->changeEmail(loginData.email); + case STATE_GAME: + logger->log("Memorizing selected character %s", + player_node->getName().c_str()); + config.setValue("lastCharacter", player_node->getName()); + + Net::getGameHandler()->inGame(); + + // Allow any alpha opacity + SkinLoader::instance()->setMinimumOpacity(-1.0f); + + sound.fadeOutMusic(1000); + + delete setupButton; + delete desktop; + setupButton = NULL; + desktop = NULL; + + currentDialog = NULL; + + logger->log("State: GAME"); + game = new Game; + game->logic(); + delete game; + game = 0; + + state = STATE_EXIT; + + Net::getGeneralHandler()->unload(); + + break; + + case STATE_LOGIN_ERROR: + logger->log("State: LOGIN ERROR"); + currentDialog = new OkDialog(_("Error"), errorMessage); + currentDialog->addActionListener(&loginListener); + currentDialog = NULL; // OkDialog deletes itself + break; + + case STATE_ACCOUNTCHANGE_ERROR: + logger->log("State: ACCOUNT CHANGE ERROR"); + currentDialog = new OkDialog(_("Error"), errorMessage); + currentDialog->addActionListener(&accountListener); + currentDialog = NULL; // OkDialog deletes itself + break; + + case STATE_REGISTER: + logger->log("State: REGISTER"); + currentDialog = new RegisterDialog(&loginData); + break; + + case STATE_REGISTER_ATTEMPT: + logger->log("Username is %s", loginData.username.c_str()); + + Net::getCharHandler()->setCharInfo(&charInfo); + Net::getLoginHandler()->registerAccount(&loginData); + break; + + case STATE_CHANGEPASSWORD: + logger->log("State: CHANGE PASSWORD"); + currentDialog = new ChangePasswordDialog(&loginData); break; case STATE_CHANGEPASSWORD_ATTEMPT: @@ -1142,8 +1166,8 @@ int main(int argc, char *argv[]) loginData.newPassword); break; - case STATE_CHANGEPASSWORD: - logger->log("State: CHANGE PASSWORD"); + case STATE_CHANGEPASSWORD_SUCCESS: + logger->log("State: CHANGE PASSWORD SUCCESS"); currentDialog = new OkDialog(_("Password Change"), _("Password changed successfully!")); currentDialog->addActionListener(&accountListener); @@ -1152,14 +1176,37 @@ int main(int argc, char *argv[]) loginData.newPassword = ""; break; + case STATE_CHANGEEMAIL: + logger->log("State: CHANGE EMAIL"); + currentDialog = new ChangeEmailDialog(&loginData); + break; + + case STATE_CHANGEEMAIL_ATTEMPT: + logger->log("State: CHANGE EMAIL ATTEMPT"); + Net::getLoginHandler()->changeEmail(loginData.email); + break; + + case STATE_CHANGEEMAIL_SUCCESS: + logger->log("State: CHANGE EMAIL SUCCESS"); + currentDialog = new OkDialog(_("Email Change"), + _("Email changed successfully!")); + currentDialog->addActionListener(&accountListener); + currentDialog = NULL; // OkDialog deletes itself + break; + + case STATE_UNREGISTER: + logger->log("State: UNREGISTER"); + currentDialog = new UnRegisterDialog(&loginData); + break; + case STATE_UNREGISTER_ATTEMPT: logger->log("State: UNREGISTER ATTEMPT"); Net::getLoginHandler()->unregisterAccount( loginData.username, loginData.password); break; - case STATE_UNREGISTER: - logger->log("State: UNREGISTER"); + case STATE_UNREGISTER_SUCCESS: + logger->log("State: UNREGISTER SUCCESS"); #ifdef TMWSERV_SUPPORT accountServerConnection->disconnect(); #endif @@ -1171,62 +1218,28 @@ int main(int argc, char *argv[]) currentDialog = NULL; // OkDialog deletes itself break; - case STATE_ACCOUNTCHANGE_ERROR: - logger->log("State: ACCOUNT CHANGE ERROR"); - currentDialog = new OkDialog(_("Error"), errorMessage); - currentDialog->addActionListener(&accountListener); - currentDialog = NULL; // OkDialog deletes itself - break; - + case STATE_SWITCH_SERVER: + logger->log("State: SWITCH SERVER"); - case STATE_ERROR: - logger->log("State: ERROR"); - currentDialog = new OkDialog(_("Error"), errorMessage); - currentDialog->addActionListener(&errorListener); - currentDialog = NULL; // OkDialog deletes itself - Net::getGameHandler()->clear(); - Net::getGeneralHandler()->clearHandlers(); - break; +#ifdef TMWSERV_SUPPORT + gameServerConnection->disconnect(); + chatServerConnection->disconnect(); + accountServerConnection->disconnect(); +#endif - case STATE_CONNECT_GAME: - logger->log("State: CONNECT_GAME"); - Net::getGameHandler()->connect(); - currentDialog = new ConnectionDialog(STATE_SWITCH_CHARACTER); + state = STATE_CHOOSE_SERVER; break; - case STATE_GAME: - logger->log("Memorizing selected character %s", - player_node->getName().c_str()); - config.setValue("lastCharacter", player_node->getName()); - - Net::getGameHandler()->inGame(); - - // Allow any alpha opacity - SkinLoader::instance()->setMinimumOpacity(-1.0f); - - sound.fadeOutMusic(1000); - - delete setupButton; - delete desktop; - setupButton = NULL; - desktop = NULL; - - currentDialog = NULL; - - logger->log("State: GAME"); - game = new Game; - game->logic(); - delete game; - game = 0; - - state = STATE_EXIT; + case STATE_SWITCH_LOGIN: + logger->log("State: SWITCH LOGIN"); - Net::getGeneralHandler()->unload(); + Net::getLoginHandler()->logout(); + state = STATE_LOGIN; break; case STATE_SWITCH_CHARACTER: - logger->log("State: SWITCH_CHARACTER"); + logger->log("State: SWITCH CHARACTER"); // Done with game Net::getGameHandler()->clear(); @@ -1234,13 +1247,35 @@ int main(int argc, char *argv[]) Net::getCharHandler()->getCharacters(); break; + case STATE_LOGOUT_ATTEMPT: + logger->log("State: LOGOUT ATTEMPT"); + // TODO + break; + + case STATE_WAIT: + logger->log("State: WAIT"); + break; + + case STATE_EXIT: + logger->log("State: EXIT"); + break; + case STATE_FORCE_QUIT: - logger->log("State: FORCE_QUIT"); + logger->log("State: FORCE QUIT"); if (Net::getGeneralHandler()) Net::getGeneralHandler()->unload(); state = STATE_EXIT; break; + case STATE_ERROR: + logger->log("State: ERROR"); + currentDialog = new OkDialog(_("Error"), errorMessage); + currentDialog->addActionListener(&errorListener); + currentDialog = NULL; // OkDialog deletes itself + Net::getGameHandler()->clear(); + Net::getGeneralHandler()->clearHandlers(); + break; + default: state = STATE_FORCE_QUIT; break; @@ -106,19 +106,22 @@ enum State { STATE_ACCOUNTCHANGE_ERROR, // 15 STATE_REGISTER, STATE_REGISTER_ATTEMPT, - STATE_CHANGEPASSWORD_ATTEMPT, STATE_CHANGEPASSWORD, - STATE_CHANGEEMAIL_ATTEMPT, // 20 + STATE_CHANGEPASSWORD_ATTEMPT, + STATE_CHANGEPASSWORD_SUCCESS, // 20 STATE_CHANGEEMAIL, - STATE_UNREGISTER_ATTEMPT, + STATE_CHANGEEMAIL_ATTEMPT, + STATE_CHANGEEMAIL_SUCCESS, STATE_UNREGISTER, + STATE_UNREGISTER_ATTEMPT, // 25 + STATE_UNREGISTER_SUCCESS, STATE_SWITCH_SERVER, - STATE_SWITCH_LOGIN, // 25 + STATE_SWITCH_LOGIN, STATE_SWITCH_CHARACTER, - STATE_LOGOUT_ATTEMPT, + STATE_LOGOUT_ATTEMPT, // 30 STATE_WAIT, STATE_EXIT, - STATE_FORCE_QUIT // 30 + STATE_FORCE_QUIT }; /* length definitions for several char[]s in order diff --git a/src/net/ea/loginhandler.cpp b/src/net/ea/loginhandler.cpp index 5a77cce7..ca2b628f 100644 --- a/src/net/ea/loginhandler.cpp +++ b/src/net/ea/loginhandler.cpp @@ -68,7 +68,7 @@ void LoginHandler::handleMessage(MessageIn &msg) // Successful pass change if (errMsg == 1) { - state = STATE_CHANGEPASSWORD; + state = STATE_CHANGEPASSWORD_SUCCESS; } // pass change failed else diff --git a/src/net/tmwserv/loginhandler.cpp b/src/net/tmwserv/loginhandler.cpp index 9c102031..5035a4db 100644 --- a/src/net/tmwserv/loginhandler.cpp +++ b/src/net/tmwserv/loginhandler.cpp @@ -102,7 +102,7 @@ void LoginHandler::handleMessage(MessageIn &msg) // Successful pass change if (errMsg == ERRMSG_OK) { - state = STATE_CHANGEPASSWORD; + state = STATE_CHANGEPASSWORD_SUCCESS; } // pass change failed else @@ -132,7 +132,7 @@ void LoginHandler::handleMessage(MessageIn &msg) // Successful pass change if (errMsg == ERRMSG_OK) { - state = STATE_CHANGEEMAIL; + state = STATE_CHANGEEMAIL_SUCCESS; } // pass change failed else |