From 725c8a943ca6ce33a6abefe08003d619de312ddc Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 7 May 2011 23:37:50 +0300 Subject: Ask account password before deleting char. --- src/gui/charselectdialog.cpp | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'src/gui/charselectdialog.cpp') 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. */ -- cgit v1.2.3-70-g09d2