summaryrefslogtreecommitdiff
path: root/src/net/ea/npchandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/ea/npchandler.cpp')
-rw-r--r--src/net/ea/npchandler.cpp49
1 files changed, 25 insertions, 24 deletions
diff --git a/src/net/ea/npchandler.cpp b/src/net/ea/npchandler.cpp
index 5c41c380..16137476 100644
--- a/src/net/ea/npchandler.cpp
+++ b/src/net/ea/npchandler.cpp
@@ -32,10 +32,7 @@
#include "localplayer.h"
#include "npc.h"
-#include "gui/npctextdialog.h"
-#include "gui/npcintegerdialog.h"
-#include "gui/npclistdialog.h"
-#include "gui/npcstringdialog.h"
+#include "gui/npcdialog.h"
#include <SDL_types.h>
@@ -68,57 +65,58 @@ void NpcHandler::handleMessage(MessageIn &msg)
msg.readInt16(); // length
current_npc = msg.readInt32();
player_node->setAction(LocalPlayer::STAND);
- npcListDialog->parseItems(msg.readString(msg.getLength() - 8));
- npcListDialog->setVisible(true);
- npcListDialog->requestFocus();
+ npcDialog->setNpc(current_npc);
+ npcDialog->choiceRequest();
+ npcDialog->parseListItems(msg.readString(msg.getLength() - 8));
+ npcDialog->setVisible(true);
break;
case SMSG_NPC_MESSAGE:
msg.readInt16(); // length
current_npc = msg.readInt32();
player_node->setAction(LocalPlayer::STAND);
- npcTextDialog->addText(msg.readString(msg.getLength() - 8));
- npcTextDialog->setVisible(true);
- npcTextDialog->requestFocus();
+ npcDialog->setNpc(current_npc);
+ npcDialog->addText(msg.readString(msg.getLength() - 8));
+ npcDialog->setVisible(true);
break;
case SMSG_NPC_CLOSE:
id = msg.readInt32();
// If we're talking to that NPC, show the close button
if (id == current_npc)
- npcTextDialog->showCloseButton();
+ npcDialog->showCloseButton();
// Otherwise, move on as an empty dialog doesn't help
else
- npcTextDialog->closeDialog(id);
+ npcDialog->closeDialog();
break;
+ /* Note: with the new dialog, we automaticilly assume "Next"
case SMSG_NPC_NEXT:
id = msg.readInt32();
// If we're talking to that NPC, show the next button
- if (id == current_npc)
- npcTextDialog->showNextButton();
+ if (id == current_npc && dialog)
+ dialog->showNextButton();
// Otherwise, move on as an empty dialog doesn't help
- else
- npcTextDialog->nextDialog(id);
+ else if (dialog)
+ nextDialog(id);
break;
-
+ */
case SMSG_NPC_INT_INPUT:
// Request for an integer
current_npc = msg.readInt32();
player_node->setAction(LocalPlayer::STAND);
- npcIntegerDialog->setRange(0, 2147483647);
- npcIntegerDialog->setDefaultValue(0);
- npcIntegerDialog->setVisible(true);
- npcIntegerDialog->requestFocus();
+ npcDialog->setNpc(current_npc);
+ npcDialog->integerRequest(0);
+ npcDialog->setVisible(true);
break;
case SMSG_NPC_STR_INPUT:
// Request for a string
current_npc = msg.readInt32();
player_node->setAction(LocalPlayer::STAND);
- npcStringDialog->setValue("");
- npcStringDialog->setVisible(true);
- npcStringDialog->requestFocus();
+ npcDialog->setNpc(current_npc);
+ npcDialog->textRequest("");
+ npcDialog->setVisible(true);
break;
}
}
@@ -140,6 +138,8 @@ void NpcHandler::closeDialog(int npcId)
{
MessageOut outMsg(CMSG_NPC_CLOSE);
outMsg.writeInt32(npcId);
+ npcDialog->setText("");
+ npcDialog->setVisible(false);
}
void NpcHandler::listInput(int npcId, int value)
@@ -158,6 +158,7 @@ void NpcHandler::integerInput(int npcId, int value)
void NpcHandler::stringInput(int npcId, const std::string &value)
{
+ printf("I got a %s", value.c_str());
MessageOut outMsg(CMSG_NPC_STR_RESPONSE);
outMsg.writeInt16(value.length() + 9);
outMsg.writeInt32(npcId);