From 16da077d4094fd6941ae4de60f1b6f3e133f1b5a Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 6 Oct 2014 00:46:45 +0300 Subject: Update visible character name and character rename. --- src/gui/windows/charselectdialog.cpp | 20 ++++++++++++++++++++ src/gui/windows/charselectdialog.h | 2 ++ 2 files changed, 22 insertions(+) (limited to 'src/gui/windows') diff --git a/src/gui/windows/charselectdialog.cpp b/src/gui/windows/charselectdialog.cpp index 8d80fe1f7..768de6c03 100644 --- a/src/gui/windows/charselectdialog.cpp +++ b/src/gui/windows/charselectdialog.cpp @@ -605,3 +605,23 @@ void CharSelectDialog::updateState() mPlayButton->setCaption(_("Create")); } } + +void CharSelectDialog::setName(const int id, const std::string &newName) +{ + for (unsigned int i = 0, sz = static_cast( + mCharacterEntries.size()); i < sz; ++i) + { + if (!mCharacterEntries[i]) + continue; + CharacterDisplay *const character = mCharacterEntries[i]; + if (!character) + continue; + LocalPlayer *const player = character->getCharacter()->dummy; + if (player && player->getId() == id) + { + player->setName(newName); + character->update(); + return; + } + } +} diff --git a/src/gui/windows/charselectdialog.h b/src/gui/windows/charselectdialog.h index 97981df5b..36e6330d2 100644 --- a/src/gui/windows/charselectdialog.h +++ b/src/gui/windows/charselectdialog.h @@ -91,6 +91,8 @@ class CharSelectDialog final : public Window, void postInit() override final; + void setName(const int id, const std::string &newName); + private: void attemptCharacterDelete(const int index); -- cgit v1.2.3-70-g09d2