From 12287c824f2ef73316169f864cade960356ad099 Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Sun, 29 Nov 2009 09:22:49 -0700 Subject: Fix NPC choice interface Don't allow no selection to be sent. Reset selection on new dialog to fix issues with list size changes. Fixes: http://bugs.manasource.org/view.php?id=36 --- src/gui/npcdialog.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp index 1956ba85..12ea61a6 100644 --- a/src/gui/npcdialog.cpp +++ b/src/gui/npcdialog.cpp @@ -170,22 +170,20 @@ void NpcDialog::action(const gcn::ActionEvent &event) else if (mActionState == NPC_ACTION_INPUT) { std::string printText = ""; // Text that will get printed in the textbox + if (mInputState == NPC_INPUT_LIST) { - int choice = 0; - int selectedIndex = mItemList->getSelected(); - - if (selectedIndex >= (int) mItems.size()) - { - return; - } - else if (selectedIndex > -1) - { - choice = selectedIndex + 1; - printText = mItems[selectedIndex]; - } - - Net::getNpcHandler()->listInput(mNpcId, choice); + int choice = 0; + int selectedIndex = mItemList->getSelected(); + + if (selectedIndex >= (int) mItems.size() || selectedIndex < 0) + { + return; + } + choice = selectedIndex + 1; + printText = mItems[selectedIndex]; + + Net::getNpcHandler()->listInput(mNpcId, choice); } else if (mInputState == NPC_INPUT_STRING) { @@ -343,6 +341,8 @@ void NpcDialog::buildLayout() place(0, 0, mScrollArea, 5, 3); place(0, 3, mListScrollArea, 5, 3); place(3, 6, mButton, 2); + + mItemList->setSelected(-1); } else if (mInputState == NPC_INPUT_STRING) { -- cgit v1.2.3-60-g2f50