diff options
author | Jared Adams <jaxad0127@gmail.com> | 2009-10-04 12:27:07 -0600 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2009-10-04 12:27:07 -0600 |
commit | cff9f1947bac8fa49aaf6f846a6e4335a439ac2e (patch) | |
tree | a1b2272c9541bb1ee40323948970787459187ae6 | |
parent | 95b54aee1b20e6fd2bf8f99766d810e0ab2e5477 (diff) | |
download | mana-client-cff9f1947bac8fa49aaf6f846a6e4335a439ac2e.tar.gz mana-client-cff9f1947bac8fa49aaf6f846a6e4335a439ac2e.tar.bz2 mana-client-cff9f1947bac8fa49aaf6f846a6e4335a439ac2e.tar.xz mana-client-cff9f1947bac8fa49aaf6f846a6e4335a439ac2e.zip |
Add ability to delect characters from account
-rw-r--r-- | src/gui/charselectdialog.cpp | 17 | ||||
-rw-r--r-- | src/main.cpp | 3 | ||||
-rw-r--r-- | src/main.h | 2 | ||||
-rw-r--r-- | src/net/charhandler.h | 3 | ||||
-rw-r--r-- | src/net/ea/charserverhandler.cpp | 19 | ||||
-rw-r--r-- | src/net/ea/charserverhandler.h | 3 | ||||
-rw-r--r-- | src/net/tmwserv/charhandler.cpp | 11 | ||||
-rw-r--r-- | src/net/tmwserv/charhandler.h | 2 |
8 files changed, 43 insertions, 17 deletions
diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp index 2fe83849..43748765 100644 --- a/src/gui/charselectdialog.cpp +++ b/src/gui/charselectdialog.cpp @@ -115,6 +115,7 @@ class CharEntry : public Container Label *mName; Label *mMoney; Button *mButton; + Button *mDelete; }; CharSelectDialog::CharSelectDialog(LockedArray<LocalPlayer*> *charInfo, @@ -169,6 +170,8 @@ CharSelectDialog::CharSelectDialog(LockedArray<LocalPlayer*> *charInfo, center(); mCharEntries[0]->requestFocus(); setVisible(true); + + Net::getCharHandler()->setCharSelectDialog(this); } void CharSelectDialog::action(const gcn::ActionEvent &event) @@ -295,6 +298,8 @@ CharEntry::CharEntry(CharSelectDialog *m, char slot, LocalPlayer *chr): mName = new Label("wwwwwwwwwwwwwwwwwwwwwwww (888)"); mMoney = new Label("wwwwwwwww"); + mDelete = new Button(_("Delete"), "delete", m); + LayoutHelper h(this); ContainerPlacer place = h.getPlacer(0, 0); @@ -302,9 +307,10 @@ CharEntry::CharEntry(CharSelectDialog *m, char slot, LocalPlayer *chr): place(0, 5, mName, 3); place(0, 6, mMoney, 3); place(0, 7, mButton, 3); + place(0, 8, mDelete, 3); - h.reflowLayout(65, 120 + mName->getHeight() + mMoney->getHeight() + - mButton->getHeight()); + h.reflowLayout(74, 123 + mName->getHeight() + mMoney->getHeight() + + mButton->getHeight() + mDelete->getHeight()); update(); } @@ -313,8 +319,7 @@ void CharEntry::setChar(LocalPlayer *chr) { mCharacter = chr; - if (chr) - mPlayerBox->setPlayer(chr); + mPlayerBox->setPlayer(chr); update(); } @@ -333,6 +338,8 @@ void CharEntry::update() mName->setCaption(strprintf("%s (%d)", mCharacter->getName().c_str(), mCharacter->getLevel())); mMoney->setCaption(Units::formatCurrency(mCharacter->getMoney())); + + mDelete->setVisible(true); } else { @@ -340,6 +347,8 @@ void CharEntry::update() mButton->setActionEventId("new"); mName->setCaption(_("(empty)")); mMoney->setCaption(Units::formatCurrency(0)); + + mDelete->setVisible(false); } // Recompute layout diff --git a/src/main.cpp b/src/main.cpp index b1d00ce4..6b9d3227 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -141,9 +141,6 @@ namespace static const int defaultSfxVolume = 100; static const int defaultMusicVolume = 60; -// Account infos -char n_character; - #ifdef TMWSERV_SUPPORT extern Net::Connection *gameServerConnection; extern Net::Connection *chatServerConnection; @@ -126,8 +126,6 @@ enum { LEN_MIN_PASSWORD = 4 }; -extern char n_character; - extern State state; extern std::string errorMessage; diff --git a/src/net/charhandler.h b/src/net/charhandler.h index ac235df5..f3d7a6bc 100644 --- a/src/net/charhandler.h +++ b/src/net/charhandler.h @@ -30,6 +30,7 @@ #include <vector> class CharCreateDialog; +class CharSelectDialog; class LocalPlayer; namespace Net { @@ -39,6 +40,8 @@ class CharHandler public: virtual void setCharInfo(LockedArray<LocalPlayer*> *charInfo) = 0; + virtual void setCharSelectDialog(CharSelectDialog *window) = 0; + virtual void setCharCreateDialog(CharCreateDialog *window) = 0; virtual void getCharacters() = 0; diff --git a/src/net/ea/charserverhandler.cpp b/src/net/ea/charserverhandler.cpp index 83f8f9fc..e538eeaf 100644 --- a/src/net/ea/charserverhandler.cpp +++ b/src/net/ea/charserverhandler.cpp @@ -49,6 +49,7 @@ extern ServerInfo charServer; extern ServerInfo mapServer; CharServerHandler::CharServerHandler(): + mCharSelectDialog(0), mCharCreateDialog(0) { static const Uint16 _messages[] = { @@ -67,7 +68,7 @@ CharServerHandler::CharServerHandler(): void CharServerHandler::handleMessage(MessageIn &msg) { - int slot; + int count, slot; LocalPlayer *tempPlayer; logger->log("CharServerHandler: Packet ID: %x, Length: %d", @@ -79,9 +80,9 @@ void CharServerHandler::handleMessage(MessageIn &msg) msg.skip(20); // Unused // Derive number of characters from message length - n_character = (msg.getLength() - 24) / 106; + count = (msg.getLength() - 24) / 106; - for (int i = 0; i < n_character; i++) + for (int i = 0; i < count; i++) { tempPlayer = readPlayerData(msg, slot); mCharInfo->select(slot); @@ -113,7 +114,6 @@ void CharServerHandler::handleMessage(MessageIn &msg) mCharInfo->unlock(); mCharInfo->select(slot); mCharInfo->setEntry(tempPlayer); - n_character++; // Close the character create dialog if (mCharCreateDialog) @@ -133,11 +133,13 @@ void CharServerHandler::handleMessage(MessageIn &msg) break; case SMSG_CHAR_DELETE_SUCCEEDED: - delete mCharInfo->getEntry(); + tempPlayer = mCharInfo->getEntry(); mCharInfo->setEntry(0); mCharInfo->unlock(); - n_character--; + if (mCharSelectDialog) + mCharSelectDialog->update(mCharInfo->getPos()); new OkDialog(_("Info"), _("Character deleted.")); + delete tempPlayer; break; case SMSG_CHAR_DELETE_FAILED: @@ -219,6 +221,11 @@ LocalPlayer *CharServerHandler::readPlayerData(MessageIn &msg, int &slot) return tempPlayer; } +void CharServerHandler::setCharSelectDialog(CharSelectDialog *window) +{ + mCharSelectDialog = window; +} + void CharServerHandler::setCharCreateDialog(CharCreateDialog *window) { mCharCreateDialog = window; diff --git a/src/net/ea/charserverhandler.h b/src/net/ea/charserverhandler.h index aa36f873..90e7372c 100644 --- a/src/net/ea/charserverhandler.h +++ b/src/net/ea/charserverhandler.h @@ -45,6 +45,8 @@ class CharServerHandler : public MessageHandler, public Net::CharHandler void setCharInfo(LockedArray<LocalPlayer*> *charInfo) { mCharInfo = charInfo; } + void setCharSelectDialog(CharSelectDialog *window); + /** * Sets the character create dialog. The handler will clean up this * dialog when a new character is succesfully created, and will unlock @@ -65,6 +67,7 @@ class CharServerHandler : public MessageHandler, public Net::CharHandler protected: LockedArray<LocalPlayer*> *mCharInfo; + CharSelectDialog *mCharSelectDialog; CharCreateDialog *mCharCreateDialog; LocalPlayer *readPlayerData(MessageIn &msg, int &slot); diff --git a/src/net/tmwserv/charhandler.cpp b/src/net/tmwserv/charhandler.cpp index 841c9a2d..03a6dff0 100644 --- a/src/net/tmwserv/charhandler.cpp +++ b/src/net/tmwserv/charhandler.cpp @@ -100,10 +100,13 @@ void CharHandler::handleMessage(MessageIn &msg) // Character deletion successful if (errMsg == ERRMSG_OK) { - delete mCharInfo->getEntry(); + LocalPlayer *tempPlayer = mCharInfo->getEntry(); mCharInfo->setEntry(0); mCharInfo->unlock(); + if (mCharSelectDialog) + mCharSelectDialog->update(mCharInfo->getPos()); new OkDialog(_("Info"), _("Player deleted.")); + delete tempPlayer; } // Character deletion failed else @@ -291,9 +294,13 @@ void CharHandler::handleCharSelectResponse(MessageIn &msg) } } +void CharHandler::setCharSelectDialog(CharSelectDialog *window) +{ + mCharSelectDialog = window; +} + void CharHandler::setCharCreateDialog(CharCreateDialog *window) { - mCharSelectDialog = window ? window->getSelectDialog() : NULL; mCharCreateDialog = window; if (!mCharCreateDialog) return; diff --git a/src/net/tmwserv/charhandler.h b/src/net/tmwserv/charhandler.h index 5517bd17..03ea51dc 100644 --- a/src/net/tmwserv/charhandler.h +++ b/src/net/tmwserv/charhandler.h @@ -47,6 +47,8 @@ class CharHandler : public MessageHandler, public Net::CharHandler mCharInfo = charInfo; } + void setCharSelectDialog(CharSelectDialog *window); + /** * Sets the character create dialog. The handler will clean up this * dialog when a new character is succesfully created, and will unlock |