summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/char_select.cpp20
-rw-r--r--src/gui/char_select.h2
2 files changed, 22 insertions, 0 deletions
diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp
index c52f73a9..6da0f64d 100644
--- a/src/gui/char_select.cpp
+++ b/src/gui/char_select.cpp
@@ -228,6 +228,26 @@ void CharSelectDialog::logic()
updatePlayerInfo();
}
+bool CharSelectDialog::selectByName(const std::string &name)
+{
+ if (mCharInfo->isLocked())
+ return false;
+
+ unsigned int oldPos = mCharInfo->getPos();
+
+ mCharInfo->select(0);
+ do {
+ LocalPlayer *player = mCharInfo->getEntry();
+
+ if (player && player->getName() == name)
+ return true;
+ } while (mCharInfo->getPos());
+
+ mCharInfo->select(oldPos);
+
+ return false;
+}
+
std::string CharSelectDialog::getName()
{
return mNameLabel->getCaption();
diff --git a/src/gui/char_select.h b/src/gui/char_select.h
index 6784c073..0a1b5eac 100644
--- a/src/gui/char_select.h
+++ b/src/gui/char_select.h
@@ -57,6 +57,8 @@ class CharSelectDialog : public Window, public gcn::ActionListener
void logic();
+ bool selectByName(const std::string &name);
+
/**
* Returns name of selected player
*/