summaryrefslogtreecommitdiff
path: root/src/gui/sell.cpp
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2010-02-13 15:04:58 -0700
committerJared Adams <jaxad0127@gmail.com>2010-02-13 15:08:54 -0700
commit8bc425ff48b7a874ca0fb9d2285044c75f3010ab (patch)
tree5904c7f53cde9ffbe7df2a63f088561141e06b66 /src/gui/sell.cpp
parent28c9cec5d39c9a1b98694eba9a28281cf111e34a (diff)
downloadmana-client-8bc425ff48b7a874ca0fb9d2285044c75f3010ab.tar.gz
mana-client-8bc425ff48b7a874ca0fb9d2285044c75f3010ab.tar.bz2
mana-client-8bc425ff48b7a874ca0fb9d2285044c75f3010ab.tar.xz
mana-client-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/sell.cpp')
-rw-r--r--src/gui/sell.cpp39
1 files changed, 25 insertions, 14 deletions
diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp
index 3e3fdad5..214c70ab 100644
--- a/src/gui/sell.cpp
+++ b/src/gui/sell.cpp
@@ -43,12 +43,14 @@
#include "utils/gettext.h"
#include "utils/stringutils.h"
-SellDialog::SellDialog():
+SellDialog::DialogList SellDialog::instances;
+
+SellDialog::SellDialog(int npcId):
Window(_("Sell")),
- mMaxItems(0), mAmountItems(0)
+ mNpcId(npcId), mMaxItems(0), mAmountItems(0)
{
setWindowName("Sell");
- setupWindow->registerWindowForReset(this);
+ //setupWindow->registerWindowForReset(this);
setResizable(true);
setCloseButton(true);
setMinWidth(260);
@@ -106,11 +108,16 @@ SellDialog::SellDialog():
center();
loadWindowState();
+
+ instances.push_back(this);
+ setVisible(true);
}
SellDialog::~SellDialog()
{
delete mShopItems;
+
+ instances.remove(this);
}
void SellDialog::reset()
@@ -190,7 +197,7 @@ void SellDialog::action(const gcn::ActionEvent &event)
// the inventory index of the next Duplicate otherwise.
itemIndex = item->getCurrentInvIndex();
sellCount = item->sellCurrentDuplicate(mAmountItems);
- Net::getNpcHandler()->sellItem(current_npc, itemIndex, sellCount);
+ Net::getNpcHandler()->sellItem(mNpcId, itemIndex, sellCount);
mAmountItems -= sellCount;
}
@@ -271,23 +278,27 @@ void SellDialog::updateButtonsAndLabels()
Units::formatCurrency(mPlayerMoney + income).c_str()));
}
-void SellDialog::logic()
-{
- Window::logic();
-
- if (!current_npc) setVisible(false);
-}
-
void SellDialog::setVisible(bool visible)
{
Window::setVisible(visible);
if (visible)
+ {
mShopItemList->requestFocus();
+ }
+ else
+ {
+ scheduleDelete();
+ }
}
-void SellDialog::close()
+void SellDialog::closeAll()
{
- setVisible(false);
- current_npc = 0;
+ DialogList::iterator it = instances.begin();
+ DialogList::iterator it_end = instances.end();
+
+ for (; it != it_end; it++)
+ {
+ (*it)->close();
+ }
}