summaryrefslogtreecommitdiff
path: root/src/gui/npcdialog.cpp
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-11-29 09:22:49 -0700
committerJared Adams <jaxad0127@gmail.com>2009-11-29 09:23:16 -0700
commit12287c824f2ef73316169f864cade960356ad099 (patch)
tree4f40244b94424418746e71ea2fcde98ecabe7a49 /src/gui/npcdialog.cpp
parentf637a4e66fbb015020cdc874d33c759f5ab40884 (diff)
downloadmana-12287c824f2ef73316169f864cade960356ad099.tar.gz
mana-12287c824f2ef73316169f864cade960356ad099.tar.bz2
mana-12287c824f2ef73316169f864cade960356ad099.tar.xz
mana-12287c824f2ef73316169f864cade960356ad099.zip
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
Diffstat (limited to 'src/gui/npcdialog.cpp')
-rw-r--r--src/gui/npcdialog.cpp28
1 files 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)
{