From 95532bf76d70bafbb7d0bc0e2dd0fc92fd7f74cf Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 5 Oct 2014 20:59:37 +0300 Subject: Add char rename button if server support it. --- src/gui/windows/charselectdialog.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/gui/windows/charselectdialog.cpp') diff --git a/src/gui/windows/charselectdialog.cpp b/src/gui/windows/charselectdialog.cpp index 5b4822a17..32a3ea410 100644 --- a/src/gui/windows/charselectdialog.cpp +++ b/src/gui/windows/charselectdialog.cpp @@ -32,6 +32,7 @@ #include "being/attributes.h" +#include "listeners/charrenamelistener.h" #include "listeners/pincodelistener.h" #include "gui/dialogtype.h" @@ -53,6 +54,7 @@ #include "net/logindata.h" #include "net/loginhandler.h" #include "net/registrationoptions.h" +#include "net/serverfeatures.h" #include "debug.h" @@ -80,6 +82,8 @@ CharSelectDialog::CharSelectDialog(LoginData *const data) : mInfoButton(new Button(this, _("Info"), "info", this)), // TRANSLATORS: char select dialog. button. mDeleteButton(new Button(this, _("Delete"), "delete", this)), + // TRANSLATORS: char select dialog. button. + mRenameButton(nullptr), mCharacterView(nullptr), mCharacterEntries(0), mCharServerHandler(charServerHandler), @@ -123,6 +127,12 @@ CharSelectDialog::CharSelectDialog(LoginData *const data) : placer(n, 0, mDeleteButton); n ++; + if (serverFeatures->haveCharRename()) + { + mRenameButton = new Button(this, _("Rename"), "rename", this); + placer(n, 0, mRenameButton); + n ++; + } placer(n, 0, mInfoButton); n ++; @@ -221,6 +231,18 @@ void CharSelectDialog::action(const ActionEvent &event) (new CharDeleteConfirm(this, selected))->postInit(); return; } + else if (eventId == "rename" + && mCharacterEntries[selected]->getCharacter()) + { + LocalPlayer *const player = mCharacterEntries[ + selected]->getCharacter()->dummy; + EditDialog *const dialog = new EditDialog( + _("Please enter new name"), player->getName(), "OK"); + dialog->postInit(); + charRenameListener.setId(player->getId()); + charRenameListener.setDialog(dialog); + dialog->addActionListener(&charRenameListener); + } else if (eventId == "info") { Net::Character *const character = mCharacterEntries[ -- cgit v1.2.3-60-g2f50