summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/widgets/characterdisplay.h2
-rw-r--r--src/gui/windows/charselectdialog.cpp20
-rw-r--r--src/gui/windows/charselectdialog.h2
3 files changed, 23 insertions, 1 deletions
diff --git a/src/gui/widgets/characterdisplay.h b/src/gui/widgets/characterdisplay.h
index 866e3e580..12fad1201 100644
--- a/src/gui/widgets/characterdisplay.h
+++ b/src/gui/widgets/characterdisplay.h
@@ -82,9 +82,9 @@ class CharacterDisplay final : public Container,
void mousePressed(MouseEvent &event) override final;
- private:
void update();
+ private:
Net::Character *mCharacter;
PlayerBox *mPlayerBox;
Label *mName;
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<unsigned int>(
+ 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);