From 9dfc4ea2f30f43fb5ffd239b90b2a7259fbe0330 Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Mon, 16 Feb 2009 14:41:24 +0000 Subject: 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). --- src/gui/npc_text.cpp | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) (limited to 'src/gui/npc_text.cpp') 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) -- cgit v1.2.3-70-g09d2