diff options
-rw-r--r-- | engines/titanic/carry/arm.cpp | 1 | ||||
-rw-r--r-- | engines/titanic/carry/carry.cpp | 4 | ||||
-rw-r--r-- | engines/titanic/carry/carry_parrot.cpp | 1 | ||||
-rw-r--r-- | engines/titanic/carry/chicken.cpp | 6 | ||||
-rw-r--r-- | engines/titanic/core/game_object.cpp | 4 | ||||
-rw-r--r-- | engines/titanic/game/cdrom.cpp | 3 | ||||
-rw-r--r-- | engines/titanic/game_manager.cpp | 5 | ||||
-rw-r--r-- | engines/titanic/support/mouse_cursor.cpp | 35 | ||||
-rw-r--r-- | engines/titanic/support/mouse_cursor.h | 26 | ||||
-rw-r--r-- | engines/titanic/support/screen_manager.cpp | 6 |
10 files changed, 72 insertions, 19 deletions
diff --git a/engines/titanic/carry/arm.cpp b/engines/titanic/carry/arm.cpp index cbc14da477..f6d1f28400 100644 --- a/engines/titanic/carry/arm.cpp +++ b/engines/titanic/carry/arm.cpp @@ -141,6 +141,7 @@ bool CArm::MouseDragStartMsg(CMouseDragStartMsg *msg) { CShowTextMsg textMsg("You can't get this."); textMsg.execute("PET"); } else if (checkStartDragging(msg)) { + hideMouse(); _tempPos = msg->_mousePos - _bounds; setPosition(msg->_mousePos - _tempPos); diff --git a/engines/titanic/carry/carry.cpp b/engines/titanic/carry/carry.cpp index 90e35c8400..7cd136165a 100644 --- a/engines/titanic/carry/carry.cpp +++ b/engines/titanic/carry/carry.cpp @@ -121,6 +121,8 @@ bool CCarry::MouseDragMoveMsg(CMouseDragMoveMsg *msg) { } bool CCarry::MouseDragEndMsg(CMouseDragEndMsg *msg) { + showMouse(); + if (msg->_dropTarget) { if (msg->_dropTarget->isPet()) { petAddToInventory(); @@ -224,6 +226,8 @@ bool CCarry::EnterViewMsg(CEnterViewMsg *msg) { } bool CCarry::PassOnDragStartMsg(CPassOnDragStartMsg *msg) { + hideMouse(); + if (_visibleFrame != -1) loadFrame(_visibleFrame); diff --git a/engines/titanic/carry/carry_parrot.cpp b/engines/titanic/carry/carry_parrot.cpp index 57d82af78a..9e36ddb4d6 100644 --- a/engines/titanic/carry/carry_parrot.cpp +++ b/engines/titanic/carry/carry_parrot.cpp @@ -145,6 +145,7 @@ bool CCarryParrot::MouseDragEndMsg(CMouseDragEndMsg *msg) { } } + showMouse(); return true; } diff --git a/engines/titanic/carry/chicken.cpp b/engines/titanic/carry/chicken.cpp index 0e8f6b3653..08ebd28478 100644 --- a/engines/titanic/carry/chicken.cpp +++ b/engines/titanic/carry/chicken.cpp @@ -200,10 +200,12 @@ bool CChicken::ParrotTriesChickenMsg(CParrotTriesChickenMsg *msg) { } bool CChicken::MouseDragEndMsg(CMouseDragEndMsg *msg) { - if (_field13C) + if (_field13C) { + showMouse(); return true; - else + } else { return CCarry::MouseDragEndMsg(msg); + } } bool CChicken::PETObjectStateMsg(CPETObjectStateMsg *msg) { diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp index 8f71b3d995..af1ec9ca6f 100644 --- a/engines/titanic/core/game_object.cpp +++ b/engines/titanic/core/game_object.cpp @@ -1142,11 +1142,11 @@ void CGameObject::lockMouse() { } void CGameObject::hideMouse() { - CScreenManager::_screenManagerPtr->_mouseCursor->hide(); + CScreenManager::_screenManagerPtr->_mouseCursor->incHideCounter(); } void CGameObject::showMouse() { - CScreenManager::_screenManagerPtr->_mouseCursor->show(); + CScreenManager::_screenManagerPtr->_mouseCursor->decHideCounter(); } void CGameObject::disableMouse() { diff --git a/engines/titanic/game/cdrom.cpp b/engines/titanic/game/cdrom.cpp index cd913d05f7..0d1cd3a6f2 100644 --- a/engines/titanic/game/cdrom.cpp +++ b/engines/titanic/game/cdrom.cpp @@ -50,6 +50,7 @@ void CCDROM::load(SimpleFile *file) { bool CCDROM::MouseDragStartMsg(CMouseDragStartMsg *msg) { if (checkStartDragging(msg)) { + hideMouse(); _tempPos = msg->_mousePos - _bounds; setPosition(msg->_mousePos - _tempPos); return true; @@ -59,6 +60,8 @@ bool CCDROM::MouseDragStartMsg(CMouseDragStartMsg *msg) { } bool CCDROM::MouseDragEndMsg(CMouseDragEndMsg *msg) { + showMouse(); + if (msg->_dropTarget && msg->_dropTarget->getName() == "newComputer") { CCDROMTray *newTray = dynamic_cast<CCDROMTray *>(getRoom()->findByName("newTray")); diff --git a/engines/titanic/game_manager.cpp b/engines/titanic/game_manager.cpp index 6023244325..015296fb14 100644 --- a/engines/titanic/game_manager.cpp +++ b/engines/titanic/game_manager.cpp @@ -150,11 +150,12 @@ void CGameManager::playClip(CMovieClip *clip, CRoomItem *oldRoom, CRoomItem *new if (clip && clip->_startFrame != clip->_endFrame && _movie) { // Clip details specifying a sub-section of movie to play Rect tempRect(20, 10, SCREEN_WIDTH - 20, 350); + CMouseCursor &mouseCursor = *CScreenManager::_screenManagerPtr->_mouseCursor; lockInputHandler(); - CScreenManager::_screenManagerPtr->_mouseCursor->hide(); + mouseCursor.incHideCounter(); _movie->playCutscene(tempRect, clip->_startFrame, clip->_endFrame); - CScreenManager::_screenManagerPtr->_mouseCursor->show(); + mouseCursor.decHideCounter(); unlockInputHandler(); } } diff --git a/engines/titanic/support/mouse_cursor.cpp b/engines/titanic/support/mouse_cursor.cpp index 18591e61ff..e1022c7f08 100644 --- a/engines/titanic/support/mouse_cursor.cpp +++ b/engines/titanic/support/mouse_cursor.cpp @@ -54,8 +54,8 @@ CMouseCursor::CursorEntry::~CursorEntry() { } CMouseCursor::CMouseCursor(CScreenManager *screenManager) : - _screenManager(screenManager), _cursorId(CURSOR_HOURGLASS), - _hideCount(0), _setCursorCount(0), _fieldE4(0), _fieldE8(0) { + _screenManager(screenManager), _cursorId(CURSOR_HOURGLASS), _hideCounter(0), + _cursorSuppressed(false), _setCursorCount(0), _fieldE4(0), _fieldE8(0) { loadCursorImages(); setCursor(CURSOR_ARROW); CursorMan.showMouse(true); @@ -88,15 +88,34 @@ void CMouseCursor::loadCursorImages() { } void CMouseCursor::show() { - --_hideCount; - assert(_hideCount >= 0); - if (_hideCount == 0) - CursorMan.showMouse(true); + CursorMan.showMouse(!_cursorSuppressed); } void CMouseCursor::hide() { - if (_hideCount++ == 0) - CursorMan.showMouse(false); + CursorMan.showMouse(false); +} + +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) { diff --git a/engines/titanic/support/mouse_cursor.h b/engines/titanic/support/mouse_cursor.h index 8881c9b182..8960c54f8a 100644 --- a/engines/titanic/support/mouse_cursor.h +++ b/engines/titanic/support/mouse_cursor.h @@ -66,7 +66,8 @@ private: CursorId _cursorId; CursorEntry _cursors[NUM_CURSORS]; uint _setCursorCount; - int _hideCount; + int _hideCounter; + bool _cursorSuppressed; int _fieldE4; int _fieldE8; @@ -89,6 +90,29 @@ public: void hide(); /** + * Decrements the hide counter, and shows the mouse if + * it's reached zero + */ + void incHideCounter(); + + /** + * Increments the hide counter, hiding the mouse if it's the first call + */ + void decHideCounter(); + + /** + * Suppresses the cursor. When suppressed, the cursor isn't drawn, + * even if it's not otherwise being hidden + */ + void suppressCursor(); + + /** + * Unflags the cursor as being suppressed, allowing it to be drawn + * again if it's enabled + */ + void unsuppressCursor(); + + /** * Set the cursor */ void setCursor(CursorId cursorId); diff --git a/engines/titanic/support/screen_manager.cpp b/engines/titanic/support/screen_manager.cpp index 6d80428011..a688cf0f60 100644 --- a/engines/titanic/support/screen_manager.cpp +++ b/engines/titanic/support/screen_manager.cpp @@ -308,13 +308,11 @@ CVideoSurface *OSScreenManager::createSurface(const CResourceKey &key) { } void OSScreenManager::showCursor() { - // TODO: Figure out what this method actually is - // CScreenManager::_screenManagerPtr->_mouseCursor->show(); + CScreenManager::_screenManagerPtr->_mouseCursor->unsuppressCursor(); } void OSScreenManager::hideCursor() { - // TODO: Figure out what this method actually is - //CScreenManager::_screenManagerPtr->_mouseCursor->hide(); + CScreenManager::_screenManagerPtr->_mouseCursor->suppressCursor(); } void OSScreenManager::destroyFrontAndBackBuffers() { |