diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-05-07 23:37:50 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-05-07 23:37:50 +0300 |
commit | 725c8a943ca6ce33a6abefe08003d619de312ddc (patch) | |
tree | 9fb38e38771416936e59bd5f51627367e7b8c149 /src/gui/charselectdialog.cpp | |
parent | 2a4649185cda0788444452168ddcf665af7f17b5 (diff) | |
download | mv-725c8a943ca6ce33a6abefe08003d619de312ddc.tar.gz mv-725c8a943ca6ce33a6abefe08003d619de312ddc.tar.bz2 mv-725c8a943ca6ce33a6abefe08003d619de312ddc.tar.xz mv-725c8a943ca6ce33a6abefe08003d619de312ddc.zip |
Ask account password before deleting char.
Diffstat (limited to 'src/gui/charselectdialog.cpp')
-rw-r--r-- | src/gui/charselectdialog.cpp | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp index 3179085cc..0e12f024a 100644 --- a/src/gui/charselectdialog.cpp +++ b/src/gui/charselectdialog.cpp @@ -32,8 +32,10 @@ #include "gui/changepassworddialog.h" #include "gui/charcreatedialog.h" #include "gui/confirmdialog.h" +#include "gui/login.h" #include "gui/okdialog.h" #include "gui/sdlinput.h" +#include "gui/textdialog.h" #include "gui/unregisterdialog.h" #include "gui/widgets/button.h" @@ -81,7 +83,7 @@ class CharDeleteConfirm : public ConfirmDialog void action(const gcn::ActionEvent &event) { if (event.getId() == "yes" && mMaster) - mMaster->attemptCharacterDelete(mIndex); + mMaster->askPasswordForDeletion(mIndex); ConfirmDialog::action(event); } @@ -125,7 +127,9 @@ CharSelectDialog::CharSelectDialog(LoginData *loginData): mChangeEmailButton(0), mCharacterEntries(0), mLoginData(loginData), - mCharHandler(Net::getCharHandler()) + mCharHandler(Net::getCharHandler()), + mDeleteDialog(0), + mDeleteIndex(-1) { setCloseButton(false); @@ -235,6 +239,20 @@ void CharSelectDialog::action(const gcn::ActionEvent &event) { Client::setState(STATE_UNREGISTER); } + else if (eventId == "try delete character") + { + if (mDeleteDialog && mDeleteIndex != -1 && mDeleteDialog->getText() + == LoginDialog::savedPassword) + { + attemptCharacterDelete(mDeleteIndex); + mDeleteDialog = 0; + } + else + { + new OkDialog(_("Error"), _("Incorrect password")); + } + mDeleteIndex = -1; + } } void CharSelectDialog::keyPressed(gcn::KeyEvent &keyEvent) @@ -260,6 +278,16 @@ void CharSelectDialog::attemptCharacterDelete(int index) lock(); } +void CharSelectDialog::askPasswordForDeletion(int index) +{ + mDeleteIndex = index; + mDeleteDialog = new TextDialog( + _("Enter password for deleting character"), _("Enter password:"), + this, true); + mDeleteDialog->setActionEventId("try delete character"); + mDeleteDialog->addActionListener(this); +} + /** * Communicate character selection to the server. */ |