summaryrefslogtreecommitdiff
path: root/src/gui/npcdialog.cpp
diff options
context:
space:
mode:
authorChuck Miller <shadowmil@gmail.com>2010-11-12 20:58:30 -0500
committerChuck Miller <shadowmil@gmail.com>2010-11-12 21:16:08 -0500
commit009cfa4b2959bf89370e9d271f2244ef5446f3a0 (patch)
tree88f9185140a636b8c6fc3badfdec55cfee826290 /src/gui/npcdialog.cpp
parent9ac7645f10d1e419703bdd35b276ce6e4eaf8152 (diff)
downloadmana-009cfa4b2959bf89370e9d271f2244ef5446f3a0.tar.gz
mana-009cfa4b2959bf89370e9d271f2244ef5446f3a0.tar.bz2
mana-009cfa4b2959bf89370e9d271f2244ef5446f3a0.tar.xz
mana-009cfa4b2959bf89370e9d271f2244ef5446f3a0.zip
Change NPC handling in the net code
Instead of using events to invoke netcode, invoke netcode directly and have it send events Reviewed-by: Freeyorp
Diffstat (limited to 'src/gui/npcdialog.cpp')
-rw-r--r--src/gui/npcdialog.cpp30
1 files changed, 10 insertions, 20 deletions
diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp
index 33c18eca..5b1939a6 100644
--- a/src/gui/npcdialog.cpp
+++ b/src/gui/npcdialog.cpp
@@ -37,6 +37,9 @@
#include "gui/widgets/textbox.h"
#include "gui/widgets/textfield.h"
+#include "net/net.h"
+#include "net/npchandler.h"
+
#include "utils/gettext.h"
#include "utils/stringutils.h"
@@ -47,9 +50,6 @@
#define CAPTION_CLOSE _("Close")
#define CAPTION_SUBMIT _("Submit")
-#define NpcEvent(name) Mana::Event event(name);\
-event.setInt("npcId", mNpcId);
-
typedef std::map<int, NpcDialog*> NpcDialogs;
class NpcEventListener : public Mana::Listener
@@ -225,25 +225,19 @@ void NpcDialog::action(const gcn::ActionEvent &event)
printText = mItems[selectedIndex];
- NpcEvent(EVENT_DOMENU)
- event.setInt("choice", selectedIndex + 1);
- event.trigger(CHANNEL_NPC);
+ Net::getNpcHandler()->menuSelect(mNpcId, selectedIndex + 1);
}
else if (mInputState == NPC_INPUT_STRING)
{
printText = mTextField->getText();
- NpcEvent(EVENT_DOSTRINGINPUT)
- event.setString("value", printText);
- event.trigger(CHANNEL_NPC);
+ Net::getNpcHandler()->stringInput(mNpcId, printText);
}
else if (mInputState == NPC_INPUT_INTEGER)
{
printText = strprintf("%d", mIntField->getValue());
- NpcEvent(EVENT_DOINTEGERINPUT)
- event.setInt("value", mIntField->getValue());
- event.trigger(CHANNEL_NPC);
+ Net::getNpcHandler()->integerInput(mNpcId, mIntField->getValue());
}
// addText will auto remove the input layout
addText(strprintf("\n> \"%s\"\n", printText.c_str()), false);
@@ -281,14 +275,12 @@ void NpcDialog::action(const gcn::ActionEvent &event)
void NpcDialog::nextDialog()
{
- NpcEvent(EVENT_DONEXT);
- event.trigger(CHANNEL_NPC);
+ Net::getNpcHandler()->nextDialog(mNpcId);
}
void NpcDialog::closeDialog()
{
- NpcEvent(EVENT_DOCLOSE);
- event.trigger(CHANNEL_NPC);
+ Net::getNpcHandler()->closeDialog(mNpcId);
close();
}
@@ -559,8 +551,7 @@ void NpcEventListener::event(Channels channel,
if (!dialog)
{
int mNpcId = id;
- NpcEvent(EVENT_DONEXT);
- event.trigger(CHANNEL_NPC);
+ Net::getNpcHandler()->nextDialog(mNpcId);
return;
}
@@ -574,8 +565,7 @@ void NpcEventListener::event(Channels channel,
if (!dialog)
{
int mNpcId = id;
- NpcEvent(EVENT_DOCLOSE);
- event.trigger(CHANNEL_NPC);
+ Net::getNpcHandler()->closeDialog(mNpcId);
return;
}