diff options
author | Paul Gilbert | 2017-08-04 22:20:25 -0400 |
---|---|---|
committer | Paul Gilbert | 2017-08-04 22:20:25 -0400 |
commit | 3a798b09bea2bd49536e061388ad58d5a6d0742c (patch) | |
tree | 844ad39c37d7ea6a98b817f75dbc6c126816b5d9 /engines/titanic | |
parent | e44c5bdcc6ca300d70d2455a70ee466552e52dc2 (diff) | |
download | scummvm-rg350-3a798b09bea2bd49536e061388ad58d5a6d0742c.tar.gz scummvm-rg350-3a798b09bea2bd49536e061388ad58d5a6d0742c.tar.bz2 scummvm-rg350-3a798b09bea2bd49536e061388ad58d5a6d0742c.zip |
TITANIC: Fix arrow movements ignoring restricted moves
Diffstat (limited to 'engines/titanic')
-rw-r--r-- | engines/titanic/core/view_item.cpp | 24 | ||||
-rw-r--r-- | engines/titanic/core/view_item.h | 6 |
2 files changed, 29 insertions, 1 deletions
diff --git a/engines/titanic/core/view_item.cpp b/engines/titanic/core/view_item.cpp index 2b585160ea..5f51cfc931 100644 --- a/engines/titanic/core/view_item.cpp +++ b/engines/titanic/core/view_item.cpp @@ -374,7 +374,7 @@ bool CViewItem::VirtualKeyCharMsg(CVirtualKeyCharMsg *msg) { if (!link) continue; - CursorId c = link->_cursorId; + CursorId c = getLinkCursor(link); if ((move == LEFT && c == CURSOR_MOVE_LEFT) || (move == RIGHT && c == CURSOR_MOVE_RIGHT) || (move == FORWARDS && (c == CURSOR_MOVE_FORWARD || @@ -390,4 +390,26 @@ bool CViewItem::VirtualKeyCharMsg(CVirtualKeyCharMsg *msg) { return false; } +CursorId CViewItem::getLinkCursor(CLinkItem *link) { + Common::Point pt(link->_bounds.left, link->_bounds.top); + Common::Array<CGameObject *> gameObjects; + + // Scan for a restricted object covering the link + for (CTreeItem *treeItem = scan(this); treeItem; treeItem = treeItem->scan(this)) { + CGameObject *gameObject = dynamic_cast<CGameObject *>(treeItem); + if (gameObject) { + if (gameObject->checkPoint(pt, false, true)) + gameObjects.push_back(gameObject); + } + } + + for (int idx = (int)gameObjects.size() - 1; idx >= 0; --idx) { + if (gameObjects[idx]->_cursorId == CURSOR_INVALID) + return CURSOR_INVALID; + } + + // No obscuring objects, so we're free to return the link's cursor + return link->_cursorId; +} + } // End of namespace Titanic diff --git a/engines/titanic/core/view_item.h b/engines/titanic/core/view_item.h index e18536dc36..d8ec3c1b98 100644 --- a/engines/titanic/core/view_item.h +++ b/engines/titanic/core/view_item.h @@ -54,6 +54,12 @@ private: * Handles mouse button up messages */ void handleButtonUpMsg(CMouseButtonUpMsg *msg); + + /** + * Gets the cursor for a link, taking into account any + * "restricted" surface that may be covering it + */ + CursorId getLinkCursor(CLinkItem *link); protected: int _field24; CResourceKey _resourceKey; |