summaryrefslogtreecommitdiff
path: root/src/gui/charselectdialog.cpp
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2009-10-03 23:28:45 +0200
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2009-10-03 23:35:24 +0200
commit076bcc1f8361c705d7dbe9088b18cca7d7fe21de (patch)
tree4c80fe2a407c71c228755a7f2a1283ace4c60ae9 /src/gui/charselectdialog.cpp
parentde3fc40ec9ddffdf0546b06e53fd8daf48e76d61 (diff)
downloadmana-076bcc1f8361c705d7dbe9088b18cca7d7fe21de.tar.gz
mana-076bcc1f8361c705d7dbe9088b18cca7d7fe21de.tar.bz2
mana-076bcc1f8361c705d7dbe9088b18cca7d7fe21de.tar.xz
mana-076bcc1f8361c705d7dbe9088b18cca7d7fe21de.zip
Made passing character name on the command line work again
It was only selecting it when found, instead of also logging in with the character.
Diffstat (limited to 'src/gui/charselectdialog.cpp')
-rw-r--r--src/gui/charselectdialog.cpp43
1 files changed, 26 insertions, 17 deletions
diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp
index ec9c4818..6407e05e 100644
--- a/src/gui/charselectdialog.cpp
+++ b/src/gui/charselectdialog.cpp
@@ -91,11 +91,11 @@ class CharEntry : public Container
public:
CharEntry(CharSelectDialog *m, char slot, LocalPlayer *chr);
- char getSlot()
+ char getSlot() const
{ return mSlot; }
- LocalPlayer *getChar()
- { return mChr; }
+ LocalPlayer *getChar() const
+ { return mCharacter; }
void requestFocus();
@@ -104,7 +104,7 @@ class CharEntry : public Container
protected:
friend class CharSelectDialog;
char mSlot;
- LocalPlayer *mChr;
+ LocalPlayer *mCharacter;
PlayerBox *mPlayerBox;
Label *mName;
@@ -173,16 +173,15 @@ CharSelectDialog::CharSelectDialog(LockedArray<LocalPlayer*> *charInfo,
void CharSelectDialog::action(const gcn::ActionEvent &event)
{
- CharEntry *entry = dynamic_cast<CharEntry*>(event.getSource()->getParent());
+ const gcn::Widget *sourceParent = event.getSource()->getParent();
- // Update the locked array
- if (entry)
+ // Update which character is selected when applicable
+ if (const CharEntry *entry = dynamic_cast<const CharEntry*>(sourceParent))
mCharInfo->select(entry->getSlot());
if (event.getId() == "use")
{
- setVisible(false);
- attemptCharSelect();
+ chooseSelected();
}
else if (event.getId() == "switch")
{
@@ -245,9 +244,10 @@ bool CharSelectDialog::selectByName(const std::string &name)
LocalPlayer *player = mCharInfo->getEntry();
if (player && player->getName() == name)
- {
+ {
mCharEntries[mCharInfo->getPos()]->requestFocus();
- }
+ return true;
+ }
mCharInfo->next();
} while (mCharInfo->getPos());
@@ -257,8 +257,17 @@ bool CharSelectDialog::selectByName(const std::string &name)
return false;
}
+void CharSelectDialog::chooseSelected()
+{
+ if (!mCharInfo->getSize())
+ return;
+
+ setVisible(false);
+ attemptCharSelect();
+}
+
void CharSelectDialog::setNetworkOptions(bool allowUnregister,
- bool allowChangeEmail)
+ bool allowChangeEmail)
{
doAllowUnregister = allowUnregister;
doAllowChangeEmail = allowChangeEmail;
@@ -266,7 +275,7 @@ void CharSelectDialog::setNetworkOptions(bool allowUnregister,
CharEntry::CharEntry(CharSelectDialog *m, char slot, LocalPlayer *chr):
mSlot(slot),
- mChr(chr),
+ mCharacter(chr),
mPlayerBox(new PlayerBox(chr))
{
mButton = new Button("wwwwwwwww", "go", m);
@@ -294,13 +303,13 @@ void CharEntry::requestFocus()
void CharEntry::update()
{
- if (mChr)
+ if (mCharacter)
{
mButton->setCaption(_("Choose"));
mButton->setActionEventId("use");
- mName->setCaption(strprintf("%s (%d)", mChr->getName().c_str(),
- mChr->getLevel()));
- mMoney->setCaption(Units::formatCurrency(mChr->getMoney()));
+ mName->setCaption(strprintf("%s (%d)", mCharacter->getName().c_str(),
+ mCharacter->getLevel()));
+ mMoney->setCaption(Units::formatCurrency(mCharacter->getMoney()));
}
else
{