[Scummvm-git-logs] scummvm master -> 45d208b2ec058d2709c3a5da58abff41d08d782c

dreammaster dreammaster at scummvm.org
Wed Oct 26 05:10:54 CEST 2016


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
45d208b2ec TITANIC: Further work on mouse cursor enablement logic


Commit: 45d208b2ec058d2709c3a5da58abff41d08d782c
    https://github.com/scummvm/scummvm/commit/45d208b2ec058d2709c3a5da58abff41d08d782c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-10-25T23:10:46-04:00

Commit Message:
TITANIC: Further work on mouse cursor enablement logic

Changed paths:
    engines/titanic/carry/arm.cpp
    engines/titanic/carry/carry.cpp
    engines/titanic/carry/carry_parrot.cpp
    engines/titanic/carry/chicken.cpp
    engines/titanic/core/game_object.cpp
    engines/titanic/game/cdrom.cpp
    engines/titanic/game_manager.cpp
    engines/titanic/support/mouse_cursor.cpp
    engines/titanic/support/mouse_cursor.h
    engines/titanic/support/screen_manager.cpp



diff --git a/engines/titanic/carry/arm.cpp b/engines/titanic/carry/arm.cpp
index cbc14da..f6d1f28 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 90e35c8..7cd1361 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 57d82af..9e36ddb 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 0e8f6b3..08ebd28 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 8f71b3d..af1ec9c 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 cd913d0..0d1cd3a 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 6023244..015296f 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 18591e6..e1022c7 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 8881c9b..8960c54 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 6d80428..a688cf0 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() {





More information about the Scummvm-git-logs mailing list