aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/titanic/carry/carry.cpp2
-rw-r--r--engines/titanic/events.cpp6
-rw-r--r--engines/titanic/events.h10
-rw-r--r--engines/titanic/main_game_window.cpp42
-rw-r--r--engines/titanic/main_game_window.h6
-rw-r--r--engines/titanic/npcs/doorbot.cpp5
-rw-r--r--engines/titanic/support/mouse_cursor.cpp32
-rw-r--r--engines/titanic/support/mouse_cursor.h11
8 files changed, 98 insertions, 16 deletions
diff --git a/engines/titanic/carry/carry.cpp b/engines/titanic/carry/carry.cpp
index 58b7996493..deac2d5128 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 fa057de432..9a246eb83e 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 3ea9b63217..497c867217 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 80da792e4a..8785921640 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 7bd918df04..5065b9fa58 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 096b433873..a3d5a669bf 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 efb78a8a0a..e9381ddb80 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 39042a5ba1..1662ce743d 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);
};