diff options
author | Paul Gilbert | 2016-10-31 08:25:22 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-10-31 08:25:22 -0400 |
commit | 22126a90d04c68ca4b058fd70aa12741a29383c3 (patch) | |
tree | a6d098ea12fce7e8c0019c8c34ac148cd28397e3 /engines/titanic/support | |
parent | b34e784c8a6f76f034ebfa62d1c95c809e5414b4 (diff) | |
download | scummvm-rg350-22126a90d04c68ca4b058fd70aa12741a29383c3.tar.gz scummvm-rg350-22126a90d04c68ca4b058fd70aa12741a29383c3.tar.bz2 scummvm-rg350-22126a90d04c68ca4b058fd70aa12741a29383c3.zip |
TITANIC: Implement manual mouse control used during intro
Diffstat (limited to 'engines/titanic/support')
-rw-r--r-- | engines/titanic/support/mouse_cursor.cpp | 32 | ||||
-rw-r--r-- | engines/titanic/support/mouse_cursor.h | 11 |
2 files changed, 34 insertions, 9 deletions
diff --git a/engines/titanic/support/mouse_cursor.cpp b/engines/titanic/support/mouse_cursor.cpp index efb78a8a0a..e9381ddb80 100644 --- a/engines/titanic/support/mouse_cursor.cpp +++ b/engines/titanic/support/mouse_cursor.cpp @@ -159,7 +159,26 @@ void CMouseCursor::setCursor(CursorId cursorId) { } void CMouseCursor::update() { - // No implementation needed + if (!_inputEnabled && _moveStartTime) { + uint32 time = CLIP(g_system->getMillis(), _moveStartTime, _moveEndTime); + Common::Point pt( + _moveStartPos.x + (_moveDestPos.x - _moveStartPos.x) * + (int)(time - _moveStartTime) / (int)(_moveEndTime - _moveStartTime), + _moveStartPos.y + (_moveDestPos.y - _moveStartPos.y) * + (int)(time - _moveStartTime) / (int)(_moveEndTime - _moveStartTime) + ); + + if (pt != g_vm->_events->getMousePos()) { + g_vm->_events->setMousePos(pt); + + CInputHandler &inputHandler = *CScreenManager::_screenManagerPtr->_inputHandler; + CMouseMoveMsg msg(pt, 0); + inputHandler.handleMessage(msg, false); + } + + if (time == _moveEndTime) + _moveStartTime = _moveEndTime = 0; + } } void CMouseCursor::disableControl() { @@ -173,11 +192,12 @@ void CMouseCursor::enableControl() { CScreenManager::_screenManagerPtr->_inputHandler->decLockCount(); } -void CMouseCursor::setPosition(const Point &pt, double rate) { - assert(rate >= 0.0 && rate <= 1.0); - - // TODO: Figure out use of the rate parameter - g_system->warpMouse(pt.x, pt.y); +void CMouseCursor::setPosition(const Point &pt, double duration) { + _moveStartPos = g_vm->_events->getMousePos(); + _moveDestPos = pt; + _moveStartTime = g_system->getMillis(); + _moveEndTime = _moveStartTime + duration; + update(); } } // End of namespace Titanic diff --git a/engines/titanic/support/mouse_cursor.h b/engines/titanic/support/mouse_cursor.h index 39042a5ba1..1662ce743d 100644 --- a/engines/titanic/support/mouse_cursor.h +++ b/engines/titanic/support/mouse_cursor.h @@ -69,14 +69,19 @@ private: int _hideCounter; int _hiddenCount; bool _cursorSuppressed; - bool _inputEnabled; int _fieldE8; + uint32 _priorMoveTime; + Common::Point _moveStartPos; + Common::Point _moveDestPos; + uint _moveStartTime, _moveEndTime; /** * Load the images for each cursor */ void loadCursorImages(); public: + bool _inputEnabled; +public: CMouseCursor(CScreenManager *screenManager); ~CMouseCursor(); @@ -139,9 +144,9 @@ public: void enableControl(); /** - * Sets the mouse to a new position + * Move the mouse to a new position */ - void setPosition(const Point &pt, double rate); + void setPosition(const Point &pt, double duration); }; |