diff options
Diffstat (limited to 'engines/titanic/core/view_item.cpp')
-rw-r--r-- | engines/titanic/core/view_item.cpp | 42 |
1 files changed, 6 insertions, 36 deletions
diff --git a/engines/titanic/core/view_item.cpp b/engines/titanic/core/view_item.cpp index 3355dcb074..979fea81fe 100644 --- a/engines/titanic/core/view_item.cpp +++ b/engines/titanic/core/view_item.cpp @@ -36,7 +36,7 @@ BEGIN_MESSAGE_MAP(CViewItem, CNamedItem) ON_MESSAGE(MouseButtonUpMsg) ON_MESSAGE(MouseDoubleClickMsg) ON_MESSAGE(MouseMoveMsg) - ON_MESSAGE(VirtualKeyCharMsg) + ON_MESSAGE(MovementMsg) END_MESSAGE_MAP() CViewItem::CViewItem() : CNamedItem() { @@ -338,35 +338,9 @@ 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; - } - +bool CViewItem::MovementMsg(CMovementMsg *msg) { + Movement move = msg->_movement; + // Iterate through the links to find an appropriate link for (CTreeItem *treeItem = getFirstChild(); treeItem; treeItem = treeItem->scan(this)) { @@ -374,12 +348,8 @@ bool CViewItem::VirtualKeyCharMsg(CVirtualKeyCharMsg *msg) { if (!link) continue; - CursorId c = getLinkCursor(link); - 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)) { + Movement m = link->getMovement(); + if (move == m) { // Found a matching link CGameManager *gm = getGameManager(); gm->_gameState.triggerLink(link); |