summaryrefslogtreecommitdiff
path: root/src/gui/npc_text.cpp
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-02-16 14:41:24 +0000
committerJared Adams <jaxad0127@gmail.com>2009-02-16 14:43:19 +0000
commit9dfc4ea2f30f43fb5ffd239b90b2a7259fbe0330 (patch)
tree37b2da3fc74946fb180b8e60d6e32b1190775a3f /src/gui/npc_text.cpp
parenta1a5ebb9ef14e013ae63a71c2c28609f2a65cdaa (diff)
downloadmana-9dfc4ea2f30f43fb5ffd239b90b2a7259fbe0330.tar.gz
mana-9dfc4ea2f30f43fb5ffd239b90b2a7259fbe0330.tar.bz2
mana-9dfc4ea2f30f43fb5ffd239b90b2a7259fbe0330.tar.xz
mana-9dfc4ea2f30f43fb5ffd239b90b2a7259fbe0330.zip
Add next/close buttons for NPCs
And keep the text dialog open for the whole transaction, logging user input and keep a full record of text from the NPC (for the current transaction only).
Diffstat (limited to 'src/gui/npc_text.cpp')
-rw-r--r--src/gui/npc_text.cpp33
1 files changed, 27 insertions, 6 deletions
diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp
index 3e40d1bb..19e46e6b 100644
--- a/src/gui/npc_text.cpp
+++ b/src/gui/npc_text.cpp
@@ -45,13 +45,13 @@ NpcTextDialog::NpcTextDialog():
mTextBox->setOpaque(false);
mScrollArea = new ScrollArea(mTextBox);
- gcn::Button *okButton = new Button(_("OK"), "ok", this);
+ mButton = new Button(_("Waiting for server"), "", this);
mScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
mScrollArea->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_ALWAYS);
place(0, 0, mScrollArea, 5).setPadding(3);
- place(4, 1, okButton);
+ place(4, 1, mButton);
Layout &layout = getLayout();
layout.setRowHeight(0, Layout::AUTO_SET);
@@ -69,18 +69,39 @@ void NpcTextDialog::setText(const std::string &text)
void NpcTextDialog::addText(const std::string &text)
{
setText(mText + text + "\n");
+ mScrollArea->setVerticalScrollAmount(mScrollArea->getVerticalMaxScroll());
+}
+
+void NpcTextDialog::showNextButton()
+{
+ mButton->setCaption(_("Next"));
+ mButton->setActionEventId("next");
+ mButton->setEnabled(true);
+}
+
+void NpcTextDialog::showCloseButton()
+{
+ mButton->setCaption(_("Close"));
+ mButton->setActionEventId("close");
+ mButton->setEnabled(true);
}
void NpcTextDialog::action(const gcn::ActionEvent &event)
{
- if (event.getId() == "ok")
+ if (event.getId() == "next")
+ {
+ current_npc->nextDialog();
+ npcTextDialog->addText("\n> Next\n");
+ }
+ else if (event.getId() == "close")
{
setText("");
setVisible(false);
- if (current_npc)
- current_npc->nextDialog();
- current_npc = 0;
+ current_npc = NULL;
}
+ mButton->setEnabled(false);
+ mButton->setCaption(_("Waiting for server"));
+ mButton->setActionEventId("");
}
void NpcTextDialog::widgetResized(const gcn::Event &event)