diff options
author | Jared Adams <jaxad0127@gmail.com> | 2009-05-02 22:05:37 -0600 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2009-05-02 22:05:37 -0600 |
commit | d592883f61eef2abb7829a6b624d2c85fe54dd5e (patch) | |
tree | f5ee4e94f8d57f251e5389a17538573f441aae98 | |
parent | 8a3a417e3a3c083414d35de0f0dad91edde09276 (diff) | |
download | mana-d592883f61eef2abb7829a6b624d2c85fe54dd5e.tar.gz mana-d592883f61eef2abb7829a6b624d2c85fe54dd5e.tar.bz2 mana-d592883f61eef2abb7829a6b624d2c85fe54dd5e.tar.xz mana-d592883f61eef2abb7829a6b624d2c85fe54dd5e.zip |
Fix up some things in the NPC dialog
-rw-r--r-- | src/gui/npcdialog.cpp | 21 | ||||
-rw-r--r-- | src/gui/npcdialog.h | 10 | ||||
-rw-r--r-- | src/net/ea/npchandler.cpp | 11 | ||||
-rw-r--r-- | src/net/tmwserv/npchandler.cpp | 1 |
4 files changed, 32 insertions, 11 deletions
diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp index a595467d..1fe231df 100644 --- a/src/gui/npcdialog.cpp +++ b/src/gui/npcdialog.cpp @@ -39,7 +39,7 @@ NpcDialog::NpcDialog() : Window(_("NPC")), - mActionState(NPC_ACTION_NEXT), + mActionState(NPC_ACTION_WAIT), mInputState(NPC_INPUT_NONE), mNpcId(0), mText("") @@ -101,6 +101,12 @@ void NpcDialog::addText(const std::string &text) { setText(mText + text + "\n"); mScrollArea->setVerticalScrollAmount(mScrollArea->getVerticalMaxScroll()); + mActionState = NPC_ACTION_WAIT; + buildLayout(); +} + +void NpcDialog::showNextButton() +{ mActionState = NPC_ACTION_NEXT; buildLayout(); } @@ -237,7 +243,11 @@ void NpcDialog::buildLayout() if (mActionState != NPC_ACTION_INPUT) { - if (mActionState == NPC_ACTION_NEXT) + if (mActionState == NPC_ACTION_WAIT) + { + mButton->setCaption(_("Waiting for server")); + } + else if (mActionState == NPC_ACTION_NEXT) { mButton->setCaption(_("Next")); } @@ -269,9 +279,14 @@ void NpcDialog::buildLayout() place(0, 3, mIntField, 3); place(3, 4, mButton, 2); } - } + } Layout &layout = getLayout(); layout.setRowHeight(0, Layout::AUTO_SET); + + mButton->setEnabled(mActionState != NPC_ACTION_WAIT); + redraw(); + + mScrollArea->setVerticalScrollAmount(mScrollArea->getVerticalMaxScroll()); } diff --git a/src/gui/npcdialog.h b/src/gui/npcdialog.h index 93ab5e54..f49976dc 100644 --- a/src/gui/npcdialog.h +++ b/src/gui/npcdialog.h @@ -80,8 +80,13 @@ class NpcDialog : public Window, public gcn::ActionListener, void addText(const std::string &string); /** - * When called, the widget will show a "Close" button instead of the "Next" - * And when clicked it will close the window + * When called, the widget will show a "Next" button. + */ + void showNextButton(); + + /** + * When called, the widget will show a "Close" button and will close + * the dialog when clicked. */ void showCloseButton(); @@ -172,6 +177,7 @@ class NpcDialog : public Window, public gcn::ActionListener, NPCInputState mInputState; enum NPCActionState { + NPC_ACTION_WAIT, NPC_ACTION_NEXT, NPC_ACTION_INPUT, NPC_ACTION_CLOSE diff --git a/src/net/ea/npchandler.cpp b/src/net/ea/npchandler.cpp index abdac169..c53dfae1 100644 --- a/src/net/ea/npchandler.cpp +++ b/src/net/ea/npchandler.cpp @@ -87,20 +87,19 @@ void NpcHandler::handleMessage(MessageIn &msg) npcDialog->showCloseButton(); // Otherwise, move on as an empty dialog doesn't help else - npcDialog->closeDialog(); + closeDialog(id); 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 && dialog) - dialog->showNextButton(); + if (id == current_npc) + npcDialog->showNextButton(); // Otherwise, move on as an empty dialog doesn't help - else if (dialog) + else nextDialog(id); break; - */ + case SMSG_NPC_INT_INPUT: // Request for an integer current_npc = msg.readInt32(); diff --git a/src/net/tmwserv/npchandler.cpp b/src/net/tmwserv/npchandler.cpp index b7bb429c..f0379ade 100644 --- a/src/net/tmwserv/npchandler.cpp +++ b/src/net/tmwserv/npchandler.cpp @@ -101,6 +101,7 @@ void NpcHandler::handleMessage(MessageIn &msg) case GPMSG_NPC_MESSAGE: npcDialog->addText(msg.readString(msg.getUnreadLength())); + npcDialog->showNextButton(); npcDialog->setVisible(true); break; |