diff options
author | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2009-10-03 23:28:45 +0200 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2009-10-03 23:35:24 +0200 |
commit | 076bcc1f8361c705d7dbe9088b18cca7d7fe21de (patch) | |
tree | 4c80fe2a407c71c228755a7f2a1283ace4c60ae9 /src | |
parent | de3fc40ec9ddffdf0546b06e53fd8daf48e76d61 (diff) | |
download | mana-client-076bcc1f8361c705d7dbe9088b18cca7d7fe21de.tar.gz mana-client-076bcc1f8361c705d7dbe9088b18cca7d7fe21de.tar.bz2 mana-client-076bcc1f8361c705d7dbe9088b18cca7d7fe21de.tar.xz mana-client-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')
-rw-r--r-- | src/gui/charselectdialog.cpp | 43 | ||||
-rw-r--r-- | src/gui/charselectdialog.h | 3 | ||||
-rw-r--r-- | src/main.cpp | 3 |
3 files changed, 30 insertions, 19 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 { diff --git a/src/gui/charselectdialog.h b/src/gui/charselectdialog.h index 965b4abf..e1c8071e 100644 --- a/src/gui/charselectdialog.h +++ b/src/gui/charselectdialog.h @@ -45,6 +45,7 @@ class CharSelectDialog : public Window, public gcn::ActionListener { public: friend class CharDeleteConfirm; + /** * Constructor. */ @@ -55,6 +56,8 @@ class CharSelectDialog : public Window, public gcn::ActionListener bool selectByName(const std::string &name); + void chooseSelected(); + static void setNetworkOptions(bool allowUnregister, bool allowChangeEmail); diff --git a/src/main.cpp b/src/main.cpp index 3194bf09..2a76f759 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1120,8 +1120,7 @@ int main(int argc, char *argv[]) if (((CharSelectDialog*) currentDialog)-> selectByName(options.character)) { - ((CharSelectDialog*) currentDialog)->action( - gcn::ActionEvent(NULL, "ok")); + ((CharSelectDialog*) currentDialog)->chooseSelected(); } else { ((CharSelectDialog*) currentDialog)->selectByName( config.getValue("lastCharacter", "")); |