From 734cf89900cde0526043429c3028cb69616f7cb8 Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Tue, 13 Dec 2011 05:08:17 +0800 Subject: Made the first choice item be selected at the beginning Resolves Mana-Mantis: #432. Reviewed-by: Bertram, Ablu. --- src/gui/npcdialog.cpp | 6 ++++++ src/gui/npcdialog.h | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp index 61e2204d..ec863c79 100644 --- a/src/gui/npcdialog.cpp +++ b/src/gui/npcdialog.cpp @@ -307,6 +307,11 @@ void NpcDialog::addChoice(const std::string &choice) mItems.push_back(choice); } +void NpcDialog::initChoiceSelection() +{ + mItemList->setSelected(0); +} + void NpcDialog::textRequest(const std::string &defaultText) { mActionState = NPC_ACTION_INPUT; @@ -542,6 +547,7 @@ void NpcEventListener::event(Event::Channel channel, int count = event.getInt("choiceCount"); for (int i = 1; i <= count; i++) dialog->addChoice(event.getString("choice" + toString(i))); + dialog->initChoiceSelection(); } else if (event.getType() == Event::IntegerInput) { diff --git a/src/gui/npcdialog.h b/src/gui/npcdialog.h index 86a0e70c..abea5753 100644 --- a/src/gui/npcdialog.h +++ b/src/gui/npcdialog.h @@ -115,6 +115,11 @@ class NpcDialog : public Window, */ void addChoice(const std::string &); + /** + * Put focus on the first choice. + */ + void initChoiceSelection(); + /** * Requests a text string from the user. */ -- cgit v1.2.3-70-g09d2