summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--src/gui/char_select.cpp20
-rw-r--r--src/gui/char_select.h2
-rw-r--r--src/main.cpp17
4 files changed, 28 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index 5e8145ea..ea6d7b32 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,12 +1,14 @@
2006-09-14 Philipp Sehmisch <tmw@crushnet.org>
- * src/animation.h, src/animatedsprite.h,
+ * src/animation.h, src/animatedsprite.h,
data/graphics/sprites/weapon.xml: Some modifications at the animation
system. No more "undefined action foo" warnings in the tmw.log. Not
visible actions must now be declared explicitely.
2006-09-14 Björn Steinbrink <B.Steinbrink@gmx.de>
+ * src/gui/char_select.cpp, src/gui/char_select.h, src/main.cpp: Clean
+ up the player selection stuff, it's a bit nicer now.
* src/main.cpp: Fix up the player selection command line option.
2006-09-12 Bjørn Lindeijer <bjorn@lindeijer.nl>
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
*/
diff --git a/src/main.cpp b/src/main.cpp
index 127b2a84..0d4b54d7 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -654,20 +654,9 @@ int main(int argc, char *argv[])
currentDialog = new CharSelectDialog(network, &charInfo,
1 - loginData.sex);
- if (options.playername != "") {
- charInfo.select(0);
- do {
- LocalPlayer *player = charInfo.getEntry();
-
- if (player && player->getName() ==
- options.playername) {
- options.chooseDefault = true;
- break;
- }
-
- charInfo.next();
- } while (charInfo.getPos());
- }
+ if (((CharSelectDialog*)currentDialog)->
+ selectByName(options.playername))
+ options.chooseDefault = true;
if (options.chooseDefault)
((CharSelectDialog*)currentDialog)->action("ok", NULL);