diff options
Diffstat (limited to 'src/gui/npc_text.cpp')
-rw-r--r-- | src/gui/npc_text.cpp | 45 |
1 files changed, 33 insertions, 12 deletions
diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp index ed75b76e..e6f039a0 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 @@ -32,7 +31,8 @@ #include "../utils/gettext.h" NpcTextDialog::NpcTextDialog(): - Window(_("NPC")) + Window(_("NPC")), + mState(NPC_TEXT_STATE_WAITING) { setResizable(true); @@ -46,8 +46,7 @@ NpcTextDialog::NpcTextDialog(): 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); @@ -71,20 +70,42 @@ 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")); + 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") { - setText(""); - setVisible(false); - - if (current_npc) + if (mState == NPC_TEXT_STATE_NEXT && current_npc) { current_npc->nextDialog(); - - current_npc = NULL; + addText("\n> Next\n"); + } else if (mState == NPC_TEXT_STATE_CLOSE || + mState == NPC_TEXT_STATE_NEXT && !current_npc) { + setText(""); + setVisible(false); + if (current_npc) current_npc->handleDeath(); + } else return; } + else return; + + mButton->setEnabled(false); + mButton->setCaption(_("Waiting for server")); + mState = NPC_TEXT_STATE_WAITING; } void NpcTextDialog::widgetResized(const gcn::Event &event) |