[Scummvm-git-logs] scummvm master -> 22126a90d04c68ca4b058fd70aa12741a29383c3

dreammaster dreammaster at scummvm.org
Mon Oct 31 13:25:39 CET 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:
22126a90d0 TITANIC: Implement manual mouse control used during intro


Commit: 22126a90d04c68ca4b058fd70aa12741a29383c3
    https://github.com/scummvm/scummvm/commit/22126a90d04c68ca4b058fd70aa12741a29383c3
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-10-31T08:25:22-04:00

Commit Message:
TITANIC: Implement manual mouse control used during intro

Changed paths:
    engines/titanic/carry/carry.cpp
    engines/titanic/events.cpp
    engines/titanic/events.h
    engines/titanic/main_game_window.cpp
    engines/titanic/main_game_window.h
    engines/titanic/npcs/doorbot.cpp
    engines/titanic/support/mouse_cursor.cpp
    engines/titanic/support/mouse_cursor.h



diff --git a/engines/titanic/carry/carry.cpp b/engines/titanic/carry/carry.cpp
index 58b7996..deac2d5 100644
--- a/engines/titanic/carry/carry.cpp
+++ b/engines/titanic/carry/carry.cpp
@@ -241,7 +241,7 @@ bool CCarry::PassOnDragStartMsg(CPassOnDragStartMsg *msg) {
 		_tempPos = msg->_mousePos - _bounds;
 	}
 
-	setPosition(_tempPos - getMousePos());
+	setPosition(getMousePos() - _tempPos);
 	return true;
 }
 
diff --git a/engines/titanic/events.cpp b/engines/titanic/events.cpp
index fa057de..9a246eb 100644
--- a/engines/titanic/events.cpp
+++ b/engines/titanic/events.cpp
@@ -152,4 +152,10 @@ bool Events::waitForPress(uint expiry) {
 	return false;
 }
 
+void Events::setMousePos(const Common::Point &pt) {
+	g_system->warpMouse(pt.x, pt.y);
+	_mousePos = pt;
+	eventTarget()->mouseMove(_mousePos);
+}
+
 } // End of namespace Titanic
diff --git a/engines/titanic/events.h b/engines/titanic/events.h
index 3ea9b63..497c867 100644
--- a/engines/titanic/events.h
+++ b/engines/titanic/events.h
@@ -138,6 +138,16 @@ public:
 	 * Wait for a mouse or keypress
 	 */
 	bool waitForPress(uint expiry);
+
+	/**
+	 * Get the mouse position
+	 */
+	Common::Point getMousePos() const { return _mousePos; }
+
+	/**
+	 * Sets the mouse position
+	 */
+	void setMousePos(const Common::Point &pt);
 };
 
 } // End of namespace Titanic
diff --git a/engines/titanic/main_game_window.cpp b/engines/titanic/main_game_window.cpp
index 80da792..8785921 100644
--- a/engines/titanic/main_game_window.cpp
+++ b/engines/titanic/main_game_window.cpp
@@ -252,10 +252,16 @@ void CMainGameWindow::onIdle() {
 
 
 void CMainGameWindow::mouseMove(const Point &mousePos) {
+	if (!isMouseControlEnabled())
+		return;
+
 	HANDLE_MESSAGE(mouseMove)
 }
 
 void CMainGameWindow::leftButtonDown(const Point &mousePos) {
+	if (!isMouseControlEnabled())
+		return;
+
 	_specialButtons |= MK_LBUTTON;
 
 	if ((_vm->_events->getTicksCount() - _priorLeftDownTime) < DOUBLE_CLICK_TIME) {
@@ -268,15 +274,24 @@ void CMainGameWindow::leftButtonDown(const Point &mousePos) {
 }
 
 void CMainGameWindow::leftButtonUp(const Point &mousePos) {
+	if (!isMouseControlEnabled())
+		return;
+
 	_specialButtons &= ~MK_LBUTTON;
 	HANDLE_MESSAGE(leftButtonUp)
 }
 
 void CMainGameWindow::leftButtonDoubleClick(const Point &mousePos) {
+	if (!isMouseControlEnabled())
+		return;
+
 	HANDLE_MESSAGE(leftButtonDoubleClick)
 }
 
 void CMainGameWindow::middleButtonDown(const Point &mousePos) {
+	if (!isMouseControlEnabled())
+		return;
+
 	_specialButtons |= MK_MBUTTON;
 
 	if ((_vm->_events->getTicksCount() - _priorMiddleDownTime) < DOUBLE_CLICK_TIME) {
@@ -289,15 +304,24 @@ void CMainGameWindow::middleButtonDown(const Point &mousePos) {
 }
 
 void CMainGameWindow::middleButtonUp(const Point &mousePos) {
+	if (!isMouseControlEnabled())
+		return;
+
 	_specialButtons &= ~MK_MBUTTON;
 	HANDLE_MESSAGE(middleButtonUp)
 }
 
 void CMainGameWindow::middleButtonDoubleClick(const Point &mousePos) {
+	if (!isMouseControlEnabled())
+		return;
+
 	HANDLE_MESSAGE(middleButtonDoubleClick)
 }
 
 void CMainGameWindow::rightButtonDown(const Point &mousePos) {
+	if (!isMouseControlEnabled())
+		return;
+
 	_specialButtons |= MK_RBUTTON;
 
 	if ((_vm->_events->getTicksCount() - _priorRightDownTime) < DOUBLE_CLICK_TIME) {
@@ -310,16 +334,18 @@ void CMainGameWindow::rightButtonDown(const Point &mousePos) {
 }
 
 void CMainGameWindow::rightButtonUp(const Point &mousePos) {
+	if (!isMouseControlEnabled())
+		return;
+
 	_specialButtons &= ~MK_RBUTTON;
 	HANDLE_MESSAGE(rightButtonUp)
 }
 
 void CMainGameWindow::rightButtonDoubleClick(const Point &mousePos) {
-	HANDLE_MESSAGE(rightButtonDoubleClick)
-}
-
-void CMainGameWindow::charPress(char c) {
+	if (!isMouseControlEnabled())
+		return;
 
+	HANDLE_MESSAGE(rightButtonDoubleClick)
 }
 
 void CMainGameWindow::keyDown(Common::KeyState keyState) {
@@ -351,4 +377,12 @@ void CMainGameWindow::handleKbdSpecial(Common::KeyState keyState) {
 		_specialButtons &= ~MK_SHIFT;
 }
 
+bool CMainGameWindow::isMouseControlEnabled() const {
+	CScreenManager *screenMan = CScreenManager::_screenManagerPtr;
+	if (!screenMan || !screenMan->_mouseCursor)
+		return true;
+
+	return screenMan->_mouseCursor->_inputEnabled;
+}
+
 } // End of namespace Titanic
diff --git a/engines/titanic/main_game_window.h b/engines/titanic/main_game_window.h
index 7bd918d..5065b9f 100644
--- a/engines/titanic/main_game_window.h
+++ b/engines/titanic/main_game_window.h
@@ -74,8 +74,12 @@ private:
 	void leftButtonDoubleClick(const Point &mousePos);
 	void middleButtonDoubleClick(const Point &mousePos);
 	void rightButtonDoubleClick(const Point &mousePos);
-	void charPress(char c);
 	void handleKbdSpecial(Common::KeyState keyState);
+
+	/**
+	 * Returns true if the player can control the mouse
+	 */
+	bool isMouseControlEnabled() const;
 public:
 	CGameView *_gameView;
 	CGameManager *_gameManager;
diff --git a/engines/titanic/npcs/doorbot.cpp b/engines/titanic/npcs/doorbot.cpp
index 096b433..a3d5a66 100644
--- a/engines/titanic/npcs/doorbot.cpp
+++ b/engines/titanic/npcs/doorbot.cpp
@@ -293,13 +293,15 @@ bool CDoorbot::TimerMsg(CTimerMsg *msg) {
 			break;
 
 		case 6:
+			// Start dragging photograph to PET
 			CMouseButtonDownMsg::generate();
 			mouseSetPosition(Point(200, 430), 2500);
 			_timerId = addTimer(7, 2500, 0);
 			break;
 
 		case 7:
-			CMouseButtonDownMsg::generate();
+			// Drop photograph in PET
+			CMouseButtonUpMsg::generate();
 			startTalking(this, 221486);
 			mouseEnableControl();
 			unlockInputHandler();
@@ -490,6 +492,7 @@ bool CDoorbot::TrueTalkNotifySpeechEndedMsg(CTrueTalkNotifySpeechEndedMsg *msg)
 		}
 
 		case 10568:
+			// Start moving cursor to photograph
 			mouseDisableControl();
 			mouseSetPosition(Point(600, 250), 2500);
 			_timerId = addTimer(6, 2500, 0);
diff --git a/engines/titanic/support/mouse_cursor.cpp b/engines/titanic/support/mouse_cursor.cpp
index efb78a8..e9381dd 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 39042a5..1662ce7 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);
 };
 
 





More information about the Scummvm-git-logs mailing list