summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/windows/charselectdialog.cpp22
-rw-r--r--src/gui/windows/charselectdialog.h1
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;