diff options
author | Ira Rice <irarice@gmail.com> | 2009-02-25 00:50:33 -0700 |
---|---|---|
committer | Ira Rice <irarice@gmail.com> | 2009-02-25 00:50:33 -0700 |
commit | d8bc3a6418c5027d7f6c42ce8f8dceca8dee8971 (patch) | |
tree | fbb0b461bd151cbf3ad5aeedb80257140253f57c /src/gui/npclistdialog.cpp | |
parent | a1e483913672e55704e8fbafeff5ea0ccc0c9b07 (diff) | |
download | mana-d8bc3a6418c5027d7f6c42ce8f8dceca8dee8971.tar.gz mana-d8bc3a6418c5027d7f6c42ce8f8dceca8dee8971.tar.bz2 mana-d8bc3a6418c5027d7f6c42ce8f8dceca8dee8971.tar.xz mana-d8bc3a6418c5027d7f6c42ce8f8dceca8dee8971.zip |
Fixed up NPC list dialogs to be navigatable by keyboard (scrolling
through the list requires the use of the mouse wheel at the moment),
fixed wrapping behavior for wrapping around lists to actually wrap
around lists properly, and placed a few checks for current_npc where
they were assumed before which could cause the client to hang or crash
in case the NPC is no longer around.
Signed-off-by: Ira Rice <irarice@gmail.com>
Diffstat (limited to 'src/gui/npclistdialog.cpp')
-rw-r--r-- | src/gui/npclistdialog.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/gui/npclistdialog.cpp b/src/gui/npclistdialog.cpp index 81c33049..f3bb949a 100644 --- a/src/gui/npclistdialog.cpp +++ b/src/gui/npclistdialog.cpp @@ -45,7 +45,9 @@ NpcListDialog::NpcListDialog(): mItemList = new ListBox(this); mItemList->setWrappingEnabled(true); + scrollArea = new ScrollArea(mItemList); + okButton = new Button(_("OK"), "ok", this); cancelButton = new Button(_("Cancel"), "cancel", this); @@ -95,10 +97,9 @@ void NpcListDialog::action(const gcn::ActionEvent &event) { // Send the selected index back to the server int selectedIndex = mItemList->getSelected(); + if (selectedIndex > -1) - { choice = selectedIndex + 1; - } } else if (event.getId() == "cancel") { @@ -109,7 +110,16 @@ void NpcListDialog::action(const gcn::ActionEvent &event) { setVisible(false); reset(); - current_npc->dialogChoice(choice); + + if (current_npc) + current_npc->dialogChoice(choice); + current_npc = NULL; } } + +void NpcListDialog::requestFocus() +{ + mItemList->requestFocus(); + mItemList->setSelected(0); +} |