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/buysell.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/buysell.cpp')
-rw-r--r-- | src/gui/buysell.cpp | 44 |
1 files changed, 30 insertions, 14 deletions
diff --git a/src/gui/buysell.cpp b/src/gui/buysell.cpp index 1258e1d5..8a149a2d 100644 --- a/src/gui/buysell.cpp +++ b/src/gui/buysell.cpp @@ -32,12 +32,16 @@ #include "utils/gettext.h" -BuySellDialog::BuySellDialog(): +BuySellDialog::DialogList BuySellDialog::instances; + +BuySellDialog::BuySellDialog(int npcId): Window(_("Shop")), + mNpcId(npcId), mBuyButton(0) { setWindowName("BuySell"); - setupWindow->registerWindowForReset(this); + //setupWindow->registerWindowForReset(this); + setCloseButton(true); static const char *buttonNames[] = { N_("Buy"), N_("Sell"), N_("Cancel"), 0 @@ -60,14 +64,14 @@ BuySellDialog::BuySellDialog(): center(); setDefaultSize(); loadWindowState(); + + instances.push_back(this); + setVisible(true); } -void BuySellDialog::logic() +BuySellDialog::~BuySellDialog() { - Window::logic(); - - if (isVisible() && !current_npc) - setVisible(false); + instances.remove(this); } void BuySellDialog::setVisible(bool visible) @@ -75,24 +79,36 @@ void BuySellDialog::setVisible(bool visible) Window::setVisible(visible); if (visible) + { mBuyButton->requestFocus(); + } + else + { + scheduleDelete(); + } } void BuySellDialog::action(const gcn::ActionEvent &event) { - setVisible(false); - if (event.getId() == "Buy") { - Net::getNpcHandler()->buy(current_npc); + Net::getNpcHandler()->buy(mNpcId); } else if (event.getId() == "Sell") { - Net::getNpcHandler()->sell(current_npc); + Net::getNpcHandler()->sell(mNpcId); } - else if (event.getId() == "Cancel") + + close(); +} + +void BuySellDialog::closeAll() +{ + DialogList::iterator it = instances.begin(); + DialogList::iterator it_end = instances.end(); + + for (; it != it_end; it++) { - current_npc = 0; - return; + (*it)->close(); } } |