diff options
author | Jared Adams <jaxad0127@gmail.com> | 2010-02-13 15:04:58 -0700 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2010-02-13 15:08:54 -0700 |
commit | 8bc425ff48b7a874ca0fb9d2285044c75f3010ab (patch) | |
tree | 5904c7f53cde9ffbe7df2a63f088561141e06b66 /src/gui/buy.cpp | |
parent | 28c9cec5d39c9a1b98694eba9a28281cf111e34a (diff) | |
download | mana-8bc425ff48b7a874ca0fb9d2285044c75f3010ab.tar.gz mana-8bc425ff48b7a874ca0fb9d2285044c75f3010ab.tar.bz2 mana-8bc425ff48b7a874ca0fb9d2285044c75f3010ab.tar.xz mana-8bc425ff48b7a874ca0fb9d2285044c75f3010ab.zip |
Make NPC dialogs instance instead of global
This change allows players to talk to multiple NPCs at a time (if the server agrees). Manaserv's netcode allows multiple commerce instances too. eAthena's is limited to one commerce instance, due to protocol limitations.
Diffstat (limited to 'src/gui/buy.cpp')
-rw-r--r-- | src/gui/buy.cpp | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp index bc58ef09..71589374 100644 --- a/src/gui/buy.cpp +++ b/src/gui/buy.cpp @@ -43,12 +43,14 @@ #include "utils/gettext.h" #include "utils/stringutils.h" -BuyDialog::BuyDialog(): +BuyDialog::DialogList BuyDialog::instances; + +BuyDialog::BuyDialog(int npcId): Window(_("Buy")), - mMoney(0), mAmountItems(0), mMaxItems(0) + mNpcId(npcId), mMoney(0), mAmountItems(0), mMaxItems(0) { setWindowName("Buy"); - setupWindow->registerWindowForReset(this); + //setupWindow->registerWindowForReset(this); setResizable(true); setCloseButton(true); setMinWidth(260); @@ -107,11 +109,16 @@ BuyDialog::BuyDialog(): center(); loadWindowState(); + + instances.push_back(this); + setVisible(true); } BuyDialog::~BuyDialog() { delete mShopItems; + + instances.remove(this); } void BuyDialog::setMoney(int amount) @@ -186,7 +193,7 @@ void BuyDialog::action(const gcn::ActionEvent &event) else if (event.getId() == "buy" && mAmountItems > 0 && mAmountItems <= mMaxItems) { - Net::getNpcHandler()->buyItem(current_npc, + Net::getNpcHandler()->buyItem(mNpcId, mShopItems->at(selectedItem)->getId(), mAmountItems); @@ -251,23 +258,27 @@ void BuyDialog::updateButtonsAndLabels() Units::formatCurrency(mMoney - price).c_str())); } -void BuyDialog::logic() -{ - Window::logic(); - - if (!current_npc) setVisible(false); -} - void BuyDialog::setVisible(bool visible) { Window::setVisible(visible); if (visible) + { mShopItemList->requestFocus(); + } + else + { + scheduleDelete(); + } } -void BuyDialog::close() +void BuyDialog::closeAll() { - setVisible(false); - current_npc = 0; + DialogList::iterator it = instances.begin(); + DialogList::iterator it_end = instances.end(); + + for (; it != it_end; it++) + { + (*it)->close(); + } } |