diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-03-25 22:50:59 +0100 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-03-25 22:50:59 +0100 |
commit | cc79f0fe21e1a2ef73cbe987d54e848b9a47142d (patch) | |
tree | edd316eb6094f0c02d6d014385865dcd88a2bc56 /src/net/ea/npchandler.cpp | |
parent | b0df784f1be44a657ca8092069488602270629b7 (diff) | |
parent | 99e8a3fd77b63a029fe02dcf771b6af1aad252ed (diff) | |
download | mana-cc79f0fe21e1a2ef73cbe987d54e848b9a47142d.tar.gz mana-cc79f0fe21e1a2ef73cbe987d54e848b9a47142d.tar.bz2 mana-cc79f0fe21e1a2ef73cbe987d54e848b9a47142d.tar.xz mana-cc79f0fe21e1a2ef73cbe987d54e848b9a47142d.zip |
Merge branch 'eathena/master'
Conflicts:
A lot of files.
Diffstat (limited to 'src/net/ea/npchandler.cpp')
-rw-r--r-- | src/net/ea/npchandler.cpp | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/src/net/ea/npchandler.cpp b/src/net/ea/npchandler.cpp index 068a3be6..7bd23135 100644 --- a/src/net/ea/npchandler.cpp +++ b/src/net/ea/npchandler.cpp @@ -19,6 +19,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include <SDL_types.h> + #include "../messagein.h" #include "npchandler.h" #include "protocol.h" @@ -32,11 +34,6 @@ #include "../../gui/npclistdialog.h" #include "../../gui/npcstringdialog.h" -extern NpcIntegerDialog *npcIntegerDialog; -extern NpcListDialog *npcListDialog; -extern NpcTextDialog *npcTextDialog; -extern NpcStringDialog *npcStringDialog; - NPCHandler::NPCHandler() { static const Uint16 _messages[] = { @@ -59,40 +56,44 @@ void NPCHandler::handleMessage(MessageIn &msg) { case SMSG_NPC_CHOICE: msg.readInt16(); // length - id = msg.readInt32(); + current_npc = msg.readInt32(); player_node->setAction(LocalPlayer::STAND); - current_npc = dynamic_cast<NPC*>(beingManager->findBeing(id)); npcListDialog->parseItems(msg.readString(msg.getLength() - 8)); - npcListDialog->setVisible(true); + npcListDialog->requestFocus(); break; case SMSG_NPC_MESSAGE: msg.readInt16(); // length - id = msg.readInt32(); + current_npc = msg.readInt32(); player_node->setAction(LocalPlayer::STAND); - current_npc = dynamic_cast<NPC*>(beingManager->findBeing(id)); npcTextDialog->addText(msg.readString(msg.getLength() - 8)); - npcListDialog->setVisible(false); - npcTextDialog->setVisible(true); + npcTextDialog->requestFocus(); break; case SMSG_NPC_CLOSE: id = msg.readInt32(); - current_npc = dynamic_cast<NPC*>(beingManager->findBeing(id)); - npcTextDialog->showCloseButton(); + // If we're talking to that NPC, show the close button + if (id == current_npc) + npcTextDialog->showCloseButton(); + // Otherwise, move on as an empty dialog doesn't help + else + npcTextDialog->closeDialog(id); break; case SMSG_NPC_NEXT: - // Next button in NPC dialog, currently unused id = msg.readInt32(); - current_npc = dynamic_cast<NPC*>(beingManager->findBeing(id)); - npcTextDialog->showNextButton(); + // If we're talking to that NPC, show the next button + if (id == current_npc) + npcTextDialog->showNextButton(); + // Otherwise, move on as an empty dialog doesn't help + else + npcTextDialog->nextDialog(id); break; case SMSG_NPC_INT_INPUT: // Request for an integer - id = msg.readInt32(); - current_npc = dynamic_cast<NPC*>(beingManager->findBeing(id)); + current_npc = msg.readInt32(); + player_node->setAction(LocalPlayer::STAND); npcIntegerDialog->setRange(0, 2147483647); npcIntegerDialog->setDefaultValue(0); npcIntegerDialog->setVisible(true); @@ -101,8 +102,8 @@ void NPCHandler::handleMessage(MessageIn &msg) case SMSG_NPC_STR_INPUT: // Request for a string - id = msg.readInt32(); - current_npc = dynamic_cast<NPC*>(beingManager->findBeing(id)); + current_npc = msg.readInt32(); + player_node->setAction(LocalPlayer::STAND); npcStringDialog->setValue(""); npcStringDialog->setVisible(true); npcStringDialog->requestFocus(); |