diff options
Diffstat (limited to 'engines/titanic/support/mouse_cursor.cpp')
-rw-r--r-- | engines/titanic/support/mouse_cursor.cpp | 76 |
1 files changed, 62 insertions, 14 deletions
diff --git a/engines/titanic/support/mouse_cursor.cpp b/engines/titanic/support/mouse_cursor.cpp index 4dd1ab4366..6300f65a3b 100644 --- a/engines/titanic/support/mouse_cursor.cpp +++ b/engines/titanic/support/mouse_cursor.cpp @@ -54,10 +54,11 @@ CMouseCursor::CursorEntry::~CursorEntry() { } CMouseCursor::CMouseCursor(CScreenManager *screenManager) : - _screenManager(screenManager), _cursorId(CURSOR_HOURGLASS), - _setCursorCount(0), _fieldE4(0), _fieldE8(0) { + _screenManager(screenManager), _cursorId(CURSOR_HOURGLASS), _hideCounter(0), + _hiddenCount(0), _cursorSuppressed(false), _setCursorCount(0), _inputEnabled(true), _fieldE8(0) { loadCursorImages(); setCursor(CURSOR_ARROW); + CursorMan.showMouse(true); } CMouseCursor::~CMouseCursor() { @@ -87,11 +88,38 @@ void CMouseCursor::loadCursorImages() { } void CMouseCursor::show() { - CursorMan.showMouse(true); + assert(_hiddenCount > 0); + + if (--_hiddenCount == 0) + CursorMan.showMouse(!_cursorSuppressed); } void CMouseCursor::hide() { CursorMan.showMouse(false); + ++_hiddenCount; +} + +void CMouseCursor::incHideCounter() { + if (_hideCounter++ == 0) + hide(); +} + +void CMouseCursor::decHideCounter() { + --_hideCounter; + assert(_hideCounter >= 0); + if (_hideCounter == 0) + show(); +} + +void CMouseCursor::suppressCursor() { + _cursorSuppressed = true; + hide(); +} + +void CMouseCursor::unsuppressCursor() { + _cursorSuppressed = false; + if (_hideCounter == 0) + show(); } void CMouseCursor::setCursor(CursorId cursorId) { @@ -108,7 +136,7 @@ void CMouseCursor::setCursor(CursorId cursorId) { Graphics::ManagedSurface surface(CURSOR_SIZE, CURSOR_SIZE, g_system->getScreenFormat()); const uint16 *srcP = srcSurface.getPixels(); - CTransparencySurface transSurface(&ce._transSurface->rawSurface(), TRANS_DEFAULT); + CTransparencySurface transSurface(&ce._transSurface->rawSurface(), TRANS_ALPHA0); uint16 *destP = (uint16 *)surface.getPixels(); for (int y = 0; y < CURSOR_SIZE; ++y) { @@ -131,25 +159,45 @@ 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::lockE4() { - _fieldE4 = 0; +void CMouseCursor::disableControl() { + _inputEnabled = false; CScreenManager::_screenManagerPtr->_inputHandler->incLockCount(); } -void CMouseCursor::unlockE4() { - _fieldE4 = 1; +void CMouseCursor::enableControl() { + _inputEnabled = true; _fieldE8 = 0; 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 |