summaryrefslogtreecommitdiff
path: root/src/gui/npcdialog.h
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/npcdialog.h
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/npcdialog.h')
-rw-r--r--src/gui/npcdialog.h35
1 files changed, 25 insertions, 10 deletions
diff --git a/src/gui/npcdialog.h b/src/gui/npcdialog.h
index 327ab6dd..18e8a8ae 100644
--- a/src/gui/npcdialog.h
+++ b/src/gui/npcdialog.h
@@ -29,6 +29,7 @@
#include <guichan/actionlistener.hpp>
#include <guichan/listmodel.hpp>
+#include <list>
#include <string>
#include <vector>
@@ -52,7 +53,7 @@ class NpcDialog : public Window, public gcn::ActionListener,
*
* @see Window::Window
*/
- NpcDialog();
+ NpcDialog(int npcId);
~NpcDialog();
@@ -61,11 +62,6 @@ class NpcDialog : public Window, public gcn::ActionListener,
*/
void action(const gcn::ActionEvent &event);
- void setNpc(int npc)
- { mNpcId = npc; }
-
- void clearText();
-
/**
* Sets the text shows in the dialog.
*
@@ -136,6 +132,8 @@ class NpcDialog : public Window, public gcn::ActionListener,
bool isInputFocused() const;
+ static bool isAnyInputFocused();
+
/**
* Requests a interger from the user.
*/
@@ -151,7 +149,28 @@ class NpcDialog : public Window, public gcn::ActionListener,
*/
void widgetResized(const gcn::Event &event);
+ void setVisible(bool visible);
+
+ /**
+ * Returns true if any instances exist.
+ */
+ static bool isActive() { return instances.size() > 0; }
+
+ /**
+ * Returns the first active instance. Useful for pushing user
+ * interaction.
+ */
+ static NpcDialog *getActive();
+
+ /**
+ * Closes all instances.
+ */
+ static void closeAll();
+
private:
+ typedef std::list<NpcDialog*> DialogList;
+ static DialogList instances;
+
void buildLayout();
int mNpcId;
@@ -201,8 +220,4 @@ class NpcDialog : public Window, public gcn::ActionListener,
NpcActionState mActionState;
};
-// TODO: This should be made not to be global, later.
-
-extern NpcDialog* npcDialog;
-
#endif // NPCDIALOG_H