[Scummvm-git-logs] scummvm master -> 20092fb386f752ba5083c0e173380d0be535003d

dreammaster dreammaster at scummvm.org
Wed Oct 26 00:43:28 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:
20092fb386 TITANIC: Implement hide counting for mouse cursor hide/show


Commit: 20092fb386f752ba5083c0e173380d0be535003d
    https://github.com/scummvm/scummvm/commit/20092fb386f752ba5083c0e173380d0be535003d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-10-25T18:43:20-04:00

Commit Message:
TITANIC: Implement hide counting for mouse cursor hide/show

Changed paths:
    engines/titanic/game_state.cpp
    engines/titanic/input_handler.cpp
    engines/titanic/support/mouse_cursor.cpp
    engines/titanic/support/mouse_cursor.h
    engines/titanic/support/screen_manager.cpp



diff --git a/engines/titanic/game_state.cpp b/engines/titanic/game_state.cpp
index ea94dee..51c1ea4 100644
--- a/engines/titanic/game_state.cpp
+++ b/engines/titanic/game_state.cpp
@@ -79,14 +79,14 @@ void CGameState::load(SimpleFile *file) {
 void CGameState::setMode(GameStateMode newMode) {
 	CScreenManager *sm = CScreenManager::_screenManagerPtr;
 
-	if (newMode == GSMODE_CUTSCENE && newMode != _mode) {
+	if (newMode == GSMODE_CUTSCENE && _mode != GSMODE_CUTSCENE) {
 		if (_gameManager)
 			_gameManager->lockInputHandler();
 
 		if (sm && sm->_mouseCursor)
 			sm->_mouseCursor->hide();
 
-	} else if (newMode != GSMODE_CUTSCENE && newMode != _mode) {
+	} else if (newMode != GSMODE_CUTSCENE && _mode == GSMODE_CUTSCENE) {
 		if (sm && sm->_mouseCursor)
 			sm->_mouseCursor->show();
 
diff --git a/engines/titanic/input_handler.cpp b/engines/titanic/input_handler.cpp
index 9fa2b00..d19f8b1 100644
--- a/engines/titanic/input_handler.cpp
+++ b/engines/titanic/input_handler.cpp
@@ -49,7 +49,10 @@ void CInputHandler::incLockCount() {
 }
 
 void CInputHandler::decLockCount() {
-	if (--_lockCount == 0 && _inputTranslator) {
+	--_lockCount;
+	assert(_lockCount >= 0);
+
+	if (_lockCount == 0 && _inputTranslator) {
 		if (_dragging && !_inputTranslator->isMousePressed()) {
 			CMouseButtonUpMsg upMsg(_mousePos, MK_LBUTTON);
 			handleMessage(upMsg);
diff --git a/engines/titanic/support/mouse_cursor.cpp b/engines/titanic/support/mouse_cursor.cpp
index 4dd1ab4..18591e6 100644
--- a/engines/titanic/support/mouse_cursor.cpp
+++ b/engines/titanic/support/mouse_cursor.cpp
@@ -55,9 +55,10 @@ CMouseCursor::CursorEntry::~CursorEntry() {
 
 CMouseCursor::CMouseCursor(CScreenManager *screenManager) :
 		_screenManager(screenManager), _cursorId(CURSOR_HOURGLASS),
-		_setCursorCount(0), _fieldE4(0), _fieldE8(0) {
+		_hideCount(0), _setCursorCount(0), _fieldE4(0), _fieldE8(0) {
 	loadCursorImages();
 	setCursor(CURSOR_ARROW);
+	CursorMan.showMouse(true);
 }
 
 CMouseCursor::~CMouseCursor() {
@@ -87,11 +88,15 @@ void CMouseCursor::loadCursorImages() {
 }
 
 void CMouseCursor::show() {
-	CursorMan.showMouse(true);
+	--_hideCount;
+	assert(_hideCount >= 0);
+	if (_hideCount == 0)
+		CursorMan.showMouse(true);
 }
 
 void CMouseCursor::hide() {
-	CursorMan.showMouse(false);
+	if (_hideCount++ == 0)
+		CursorMan.showMouse(false);
 }
 
 void CMouseCursor::setCursor(CursorId cursorId) {
diff --git a/engines/titanic/support/mouse_cursor.h b/engines/titanic/support/mouse_cursor.h
index 08de28e..8881c9b 100644
--- a/engines/titanic/support/mouse_cursor.h
+++ b/engines/titanic/support/mouse_cursor.h
@@ -66,6 +66,7 @@ private:
 	CursorId _cursorId;
 	CursorEntry _cursors[NUM_CURSORS];
 	uint _setCursorCount;
+	int _hideCount;
 	int _fieldE4;
 	int _fieldE8;
 
diff --git a/engines/titanic/support/screen_manager.cpp b/engines/titanic/support/screen_manager.cpp
index 2e9bbcb..6d80428 100644
--- a/engines/titanic/support/screen_manager.cpp
+++ b/engines/titanic/support/screen_manager.cpp
@@ -308,11 +308,13 @@ CVideoSurface *OSScreenManager::createSurface(const CResourceKey &key) {
 }
 
 void OSScreenManager::showCursor() {
-	CScreenManager::_screenManagerPtr->_mouseCursor->show();
+	// TODO: Figure out what this method actually is
+	//	CScreenManager::_screenManagerPtr->_mouseCursor->show();
 }
 
 void OSScreenManager::hideCursor() {
-	CScreenManager::_screenManagerPtr->_mouseCursor->hide();
+	// TODO: Figure out what this method actually is
+	//CScreenManager::_screenManagerPtr->_mouseCursor->hide();
 }
 
 void OSScreenManager::destroyFrontAndBackBuffers() {





More information about the Scummvm-git-logs mailing list