diff options
author | Paul Gilbert | 2017-08-04 22:00:49 -0400 |
---|---|---|
committer | Paul Gilbert | 2017-08-04 22:00:49 -0400 |
commit | e44c5bdcc6ca300d70d2455a70ee466552e52dc2 (patch) | |
tree | bdba17efbfcae4808bccc5c4b0da5c14665cc194 /engines/titanic/core | |
parent | f9c370d942d28c15b44a7f1786fac3e9e3bb545f (diff) | |
download | scummvm-rg350-e44c5bdcc6ca300d70d2455a70ee466552e52dc2.tar.gz scummvm-rg350-e44c5bdcc6ca300d70d2455a70ee466552e52dc2.tar.bz2 scummvm-rg350-e44c5bdcc6ca300d70d2455a70ee466552e52dc2.zip |
TITANIC: Introduce movement via arrow keys
This also fixes a bug with Page Up, Down, Home, & End not working for
the Conversation tab. Additionally, code for scrolling individual
lines in the conversation and glyphs via the arrow keys has been
removed in favor of this centrallised movement, since they were
somewhat redundant, and the mouse wheel can be used for scrolling.
Diffstat (limited to 'engines/titanic/core')
-rw-r--r-- | engines/titanic/core/view_item.cpp | 53 | ||||
-rw-r--r-- | engines/titanic/core/view_item.h | 1 |
2 files changed, 54 insertions, 0 deletions
diff --git a/engines/titanic/core/view_item.cpp b/engines/titanic/core/view_item.cpp index 243d47f3fd..2b585160ea 100644 --- a/engines/titanic/core/view_item.cpp +++ b/engines/titanic/core/view_item.cpp @@ -36,6 +36,7 @@ BEGIN_MESSAGE_MAP(CViewItem, CNamedItem) ON_MESSAGE(MouseButtonUpMsg) ON_MESSAGE(MouseDoubleClickMsg) ON_MESSAGE(MouseMoveMsg) + ON_MESSAGE(VirtualKeyCharMsg) END_MESSAGE_MAP() CViewItem::CViewItem() : CNamedItem() { @@ -337,4 +338,56 @@ CString CViewItem::getNodeViewName() const { return CString::format("%s.%s", node->getName().c_str(), getName().c_str()); } +bool CViewItem::VirtualKeyCharMsg(CVirtualKeyCharMsg *msg) { + enum Movement { LEFT, RIGHT, FORWARDS, BACKWARDS }; + Movement move; + + switch (msg->_keyState.keycode) { + case Common::KEYCODE_LEFT: + case Common::KEYCODE_KP4: + // Left arrow + move = LEFT; + break; + case Common::KEYCODE_RIGHT: + case Common::KEYCODE_KP6: + // Right arrow + move = RIGHT; + break; + case Common::KEYCODE_UP: + case Common::KEYCODE_KP8: + // Up arrow + move = FORWARDS; + break; + case Common::KEYCODE_DOWN: + case Common::KEYCODE_KP2: + // Down arrow + move = BACKWARDS; + break; + default: + return false; + } + + // Iterate through the links to find an appropriate link + for (CTreeItem *treeItem = getFirstChild(); treeItem; + treeItem = treeItem->scan(this)) { + CLinkItem *link = dynamic_cast<CLinkItem *>(treeItem); + if (!link) + continue; + + CursorId c = link->_cursorId; + if ((move == LEFT && c == CURSOR_MOVE_LEFT) || + (move == RIGHT && c == CURSOR_MOVE_RIGHT) || + (move == FORWARDS && (c == CURSOR_MOVE_FORWARD || + c == CURSOR_MOVE_THROUGH || c == CURSOR_DOWN)) || + (move == BACKWARDS && c == CURSOR_BACKWARDS)) { + // Found a matching link + CGameManager *gm = getGameManager(); + gm->_gameState.triggerLink(link); + return true; + } + } + + return false; +} + } // End of namespace Titanic diff --git a/engines/titanic/core/view_item.h b/engines/titanic/core/view_item.h index ceb8a020da..e18536dc36 100644 --- a/engines/titanic/core/view_item.h +++ b/engines/titanic/core/view_item.h @@ -36,6 +36,7 @@ class CViewItem : public CNamedItem { bool MouseButtonUpMsg(CMouseButtonUpMsg *msg); bool MouseMoveMsg(CMouseMoveMsg *msg); bool MouseDoubleClickMsg(CMouseDoubleClickMsg *msg); + bool VirtualKeyCharMsg(CVirtualKeyCharMsg *msg); private: CTreeItem *_buttonUpTargets[4]; private: |