diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-10-05 20:59:37 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-10-05 21:02:42 +0300 |
commit | 95532bf76d70bafbb7d0bc0e2dd0fc92fd7f74cf (patch) | |
tree | 53c227068936ed4690866f4e13b957678e181dac /src/gui | |
parent | b0361de1fcfc26b4bb497473e9fe1ef0f5013c98 (diff) | |
download | mv-95532bf76d70bafbb7d0bc0e2dd0fc92fd7f74cf.tar.gz mv-95532bf76d70bafbb7d0bc0e2dd0fc92fd7f74cf.tar.bz2 mv-95532bf76d70bafbb7d0bc0e2dd0fc92fd7f74cf.tar.xz mv-95532bf76d70bafbb7d0bc0e2dd0fc92fd7f74cf.zip |
Add char rename button if server support it.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/windows/charselectdialog.cpp | 22 | ||||
-rw-r--r-- | src/gui/windows/charselectdialog.h | 1 |
2 files changed, 23 insertions, 0 deletions
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[ diff --git a/src/gui/windows/charselectdialog.h b/src/gui/windows/charselectdialog.h index a6acd9c32..97981df5b 100644 --- a/src/gui/windows/charselectdialog.h +++ b/src/gui/windows/charselectdialog.h @@ -115,6 +115,7 @@ class CharSelectDialog final : public Window, Button *mPlayButton; Button *mInfoButton; Button *mDeleteButton; + Button *mRenameButton; CharacterViewBase *mCharacterView; std::vector<CharacterDisplay*> mCharacterEntries; |