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/npcpostdialog.cpp | |
parent | 28c9cec5d39c9a1b98694eba9a28281cf111e34a (diff) | |
download | mana-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/npcpostdialog.cpp')
-rw-r--r-- | src/gui/npcpostdialog.cpp | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/src/gui/npcpostdialog.cpp b/src/gui/npcpostdialog.cpp index a05008ec..cb6660c6 100644 --- a/src/gui/npcpostdialog.cpp +++ b/src/gui/npcpostdialog.cpp @@ -35,8 +35,11 @@ #include "utils/gettext.h" -NpcPostDialog::NpcPostDialog(): - Window(_("NPC")) +NpcPostDialog::DialogList NpcPostDialog::instances; + +NpcPostDialog::NpcPostDialog(int npcId): + Window(_("NPC")), + mNpcId(npcId) { setContentSize(400, 180); @@ -74,6 +77,14 @@ NpcPostDialog::NpcPostDialog(): add(cancelButton); setLocationRelativeTo(getParent()); + + instances.push_back(this); + setVisible(true); +} + +NpcPostDialog::~NpcPostDialog() +{ + instances.remove(this); } void NpcPostDialog::action(const gcn::ActionEvent &event) @@ -87,21 +98,34 @@ void NpcPostDialog::action(const gcn::ActionEvent &event) } else { - Net::getNpcHandler()->sendLetter(current_npc, mSender->getText(), + Net::getNpcHandler()->sendLetter(mNpcId, mSender->getText(), mText->getText()); } setVisible(false); - clear(); } else if (event.getId() == "cancel") { setVisible(false); - clear(); } } -void NpcPostDialog::clear() +void NpcPostDialog::setVisible(bool visible) +{ + Window::setVisible(visible); + + if (!visible) + { + scheduleDelete(); + } +} + +void NpcPostDialog::closeAll() { - mSender->setText(""); - mText->setText(""); + DialogList::iterator it = instances.begin(); + DialogList::iterator it_end = instances.end(); + + for (; it != it_end; it++) + { + (*it)->close(); + } } |