summaryrefslogtreecommitdiff
path: root/src/gui/npc_text.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/npc_text.cpp')
-rw-r--r--src/gui/npc_text.cpp79
1 files changed, 59 insertions, 20 deletions
diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp
index f524f8ea..5158e966 100644
--- a/src/gui/npc_text.cpp
+++ b/src/gui/npc_text.cpp
@@ -1,9 +1,8 @@
/*
- * Aethyra
+ * The Mana World
* Copyright (C) 2004 The Mana World Development Team
*
- * This file is part of Aethyra based on original code
- * from The Mana World.
+ * This file is part of The Mana World.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -30,14 +29,26 @@
#include "../npc.h"
#include "../net/messageout.h"
-#include "../net/protocol.h"
+#ifdef TMWSERV_SUPPORT
+#include "../net/tmwserv/gameserver/player.h"
+#else
+#include "../net/ea/protocol.h"
+#endif
#include "../utils/gettext.h"
-NpcTextDialog::NpcTextDialog(Network *network):
- Window("NPC"), mNetwork(network)
+#ifdef TMWSERV_SUPPORT
+NpcTextDialog::NpcTextDialog()
+#else
+NpcTextDialog::NpcTextDialog(Network *network)
+#endif
+ : Window(_("NPC"))
+#ifdef EATHENA_SUPPORT
+ , mNetwork(network)
+#endif
+ , mState(NPC_TEXT_STATE_WAITING)
{
- setWindowName(_("NPC"));
+ setWindowName("NPCText");
setResizable(true);
setMinWidth(200);
@@ -50,8 +61,7 @@ NpcTextDialog::NpcTextDialog(Network *network):
mTextBox->setOpaque(false);
mScrollArea = new ScrollArea(mTextBox);
- mButton = new Button(_("OK"), "", this);
- mButton->setActionEventId("ok");
+ mButton = new Button(_("Waiting for server"), "ok", this);
mScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
mScrollArea->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_ALWAYS);
@@ -62,9 +72,16 @@ NpcTextDialog::NpcTextDialog(Network *network):
Layout &layout = getLayout();
layout.setRowHeight(0, Layout::AUTO_SET);
+ center();
loadWindowState();
}
+void NpcTextDialog::clearText()
+{
+ NPC::isTalking = false;
+ setText("");
+}
+
void NpcTextDialog::setText(const std::string &text)
{
mText = text;
@@ -74,41 +91,64 @@ void NpcTextDialog::setText(const std::string &text)
void NpcTextDialog::addText(const std::string &text)
{
setText(mText + text + "\n");
+ mScrollArea->setVerticalScrollAmount(mScrollArea->getVerticalMaxScroll());
}
-void NpcTextDialog::clearText()
+void NpcTextDialog::showNextButton()
{
- NPC::mTalking = false;
- setText("");
+ mButton->setCaption(_("Next"));
+ mState = NPC_TEXT_STATE_NEXT;
+ mButton->setEnabled(true);
+}
+
+void NpcTextDialog::showCloseButton()
+{
+ mButton->setCaption(_("Close"));
+ mState = NPC_TEXT_STATE_CLOSE;
+ mButton->setEnabled(true);
}
void NpcTextDialog::action(const gcn::ActionEvent &event)
{
if (event.getId() == "ok")
{
- clearText();
- setVisible(false);
- saveWindowState();
-
- if (current_npc)
+ if (mState == NPC_TEXT_STATE_NEXT && current_npc) {
nextDialog();
-
- current_npc = 0;
+ addText("\n> Next\n");
+ } else if (mState == NPC_TEXT_STATE_CLOSE ||
+ (mState == NPC_TEXT_STATE_NEXT && !current_npc)) {
+ setText("");
+ if (current_npc) nextDialog();
+ setVisible(false);
+ current_npc = 0;
+ NPC::isTalking = false;
+ } else return;
}
+ else return;
+
+ mButton->setEnabled(false);
+ mButton->setCaption(_("Waiting for server"));
+ mState = NPC_TEXT_STATE_WAITING;
}
void NpcTextDialog::nextDialog(int npcID)
{
+#ifdef TMWSERV_SUPPORT
+ Net::GameServer::Player::talkToNPC(npcID, false);
+#else
MessageOut outMsg(mNetwork);
outMsg.writeInt16(CMSG_NPC_NEXT_REQUEST);
outMsg.writeInt32(npcID);
+#endif
}
void NpcTextDialog::closeDialog(int npcID)
{
+#ifdef EATHENA_SUPPORT
MessageOut outMsg(mNetwork);
outMsg.writeInt16(CMSG_NPC_CLOSE);
outMsg.writeInt32(npcID);
+#endif
}
void NpcTextDialog::widgetResized(const gcn::Event &event)
@@ -123,4 +163,3 @@ void NpcTextDialog::requestFocus()
loadWindowState();
setVisible(true);
}
-