summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp42
1 files changed, 37 insertions, 5 deletions
diff --git a/src/main.cpp b/src/main.cpp
index c2e74ff3..32bf2e2f 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -53,7 +53,7 @@
#include "gui/serverselectdialog.h"
#include "gui/setup.h"
#ifdef TMWSERV_SUPPORT
-#include "gui/connection.h"
+#include "gui/connectiondialog.h"
#include "gui/quitdialog.h"
#include "gui/serverdialog.h"
#endif
@@ -313,7 +313,7 @@ static void setUpdatesDir()
static void initHomeDir(const Options &options)
{
homeDir = options.homeDir;
-
+
if (homeDir.empty())
{
homeDir = std::string(PHYSFS_getUserDir()) +
@@ -710,7 +710,6 @@ struct ErrorListener : public gcn::ActionListener
}
} errorListener;
-#ifdef TMWSERV_SUPPORT
struct AccountListener : public gcn::ActionListener
{
void action(const gcn::ActionEvent &event)
@@ -719,6 +718,7 @@ struct AccountListener : public gcn::ActionListener
}
} accountListener;
+#ifdef TMWSERV_SUPPORT
struct LoginListener : public gcn::ActionListener
{
void action(const gcn::ActionEvent &event)
@@ -1343,8 +1343,16 @@ int main(int argc, char *argv[])
loadUpdates();
break;
- // Those states don't cause a network disconnect
+ // Those states don't cause a network disconnect
case STATE_LOADDATA:
+ case STATE_CHANGEPASSWORD_ATTEMPT:
+ case STATE_CHANGEPASSWORD:
+ case STATE_ACCOUNTCHANGE_ERROR:
+ break;
+
+ case STATE_CHAR_SELECT:
+ if (state == STATE_CONNECTING)
+ network->disconnect();
break;
case STATE_ACCOUNT:
@@ -1446,7 +1454,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)->
@@ -1539,6 +1547,30 @@ int main(int argc, char *argv[])
accountLogin(network, &loginData);
break;
+ case STATE_CHANGEPASSWORD_ATTEMPT:
+ logger->log("State: CHANGE PASSWORD ATTEMPT");
+ Net::getLoginHandler()->changePassword(loginData.username,
+ loginData.password,
+ loginData.newPassword);
+ break;
+
+ case STATE_CHANGEPASSWORD:
+ logger->log("State: CHANGE PASSWORD");
+ currentDialog = new OkDialog("Password change",
+ "Password changed successfully!");
+ currentDialog->addActionListener(&accountListener);
+ currentDialog = NULL; // OkDialog deletes itself
+ loginData.password = loginData.newPassword;
+ loginData.newPassword = "";
+ 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;
+
default:
state = STATE_EXIT;
break;