From 7cddbca0dcfff234b6c6f124cb91840279c36118 Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Wed, 13 May 2009 10:57:05 -0600 Subject: Allow more control of NpcDialog using the keyboard The move up and move down keys will now let you navigate the list mode and change the value on the integer mode. --- src/game.cpp | 5 +++++ src/gui/npcdialog.cpp | 16 ++++++++++++++++ src/gui/npcdialog.h | 2 ++ 3 files changed, 23 insertions(+) (limited to 'src') diff --git a/src/game.cpp b/src/game.cpp index c07d6520..d60a4225 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -582,6 +582,11 @@ void Game::handleInput() if (chatWindow->requestChatFocus()) used = true; } + if (npcDialog->isVisible()) + if (keyboard.isKeyActive(keyboard.KEY_MOVE_UP)) + npcDialog->move(1); + else if (keyboard.isKeyActive(keyboard.KEY_MOVE_DOWN)) + npcDialog->move(-1); } diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp index eeb76b88..3fa86b28 100644 --- a/src/gui/npcdialog.cpp +++ b/src/gui/npcdialog.cpp @@ -281,6 +281,22 @@ void NpcDialog::integerRequest(int defaultValue, int min, int max) buildLayout(); } +void NpcDialog::move(int amount) +{ + if (mActionState != NPC_ACTION_INPUT) + return; + + switch (mInputState) + { + case NPC_INPUT_INTEGER: + mIntField->setValue(mIntField->getValue() + amount); + break; + case NPC_INPUT_LIST: + mItemList->setSelected(mItemList->getSelected() - amount); + break; + } +} + void NpcDialog::widgetResized(const gcn::Event &event) { Window::widgetResized(event); diff --git a/src/gui/npcdialog.h b/src/gui/npcdialog.h index bd738e81..ecce0c62 100644 --- a/src/gui/npcdialog.h +++ b/src/gui/npcdialog.h @@ -141,6 +141,8 @@ class NpcDialog : public Window, public gcn::ActionListener, */ void integerRequest(int defaultValue = 0, int min = 0, int max = 2000); + void move(int amount); + /** * Called when resizing the window. * -- cgit v1.2.3-70-g09d2