aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Hoops2010-09-01 23:22:12 +0000
committerMatthew Hoops2010-09-01 23:22:12 +0000
commita053ef7cd18400058af9ec39e53481ba88455b96 (patch)
treea1e022293fe3abf5b28ee825ec6678d553a662d6
parentf36f8270cd6d1ce54bcd1c9afac3b21b8b851713 (diff)
downloadscummvm-rg350-a053ef7cd18400058af9ec39e53481ba88455b96.tar.gz
scummvm-rg350-a053ef7cd18400058af9ec39e53481ba88455b96.tar.bz2
scummvm-rg350-a053ef7cd18400058af9ec39e53481ba88455b96.zip
MOHAWK: Cleanup mouse cursor position handling in Riven
This fixes some cursors showing up incorrectly if the cursor moved during ie. a video and then the card changes. Also, remove an unneeded rect check in loadHotspots() that's from the ancient times before script size calculation was fixed and some warnings that don't affect gameplay. svn-id: r52487
-rw-r--r--engines/mohawk/riven.cpp36
-rw-r--r--engines/mohawk/riven.h1
-rw-r--r--engines/mohawk/riven_external.cpp16
3 files changed, 21 insertions, 32 deletions
diff --git a/engines/mohawk/riven.cpp b/engines/mohawk/riven.cpp
index 07b08dc220..18ebea20db 100644
--- a/engines/mohawk/riven.cpp
+++ b/engines/mohawk/riven.cpp
@@ -143,11 +143,10 @@ Common::Error MohawkEngine_Riven::run() {
while (_eventMan->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_MOUSEMOVE:
- _mousePos = event.mouse;
checkHotspotChange();
// Check to show the inventory
- if (_mousePos.y >= 392)
+ if (_eventMan->getMousePos().y >= 392)
_gfx->showInventory();
else
_gfx->hideInventory();
@@ -384,7 +383,6 @@ void MohawkEngine_Riven::loadHotspots(uint16 id) {
_hotspotCount = inStream->readUint16BE();
_hotspots = new RivenHotspot[_hotspotCount];
-
for (uint16 i = 0; i < _hotspotCount; i++) {
_hotspots[i].enabled = true;
@@ -396,26 +394,12 @@ void MohawkEngine_Riven::loadHotspots(uint16 id) {
int16 right = inStream->readSint16BE();
int16 bottom = inStream->readSint16BE();
- // Riven has some weird hotspots, disable them here
- if (left >= right || top >= bottom) {
- left = top = right = bottom = 0;
- _hotspots[i].enabled = 0;
- }
-
_hotspots[i].rect = Common::Rect(left, top, right, bottom);
_hotspots[i].u0 = inStream->readUint16BE();
-
- if (_hotspots[i].u0 != 0)
- warning("Hotspot %d u0 non-zero", i);
-
_hotspots[i].mouse_cursor = inStream->readUint16BE();
_hotspots[i].index = inStream->readUint16BE();
_hotspots[i].u1 = inStream->readSint16BE();
-
- if (_hotspots[i].u1 != -1)
- warning("Hotspot %d u1 not -1", i);
-
_hotspots[i].zipModeHotspot = inStream->readUint16BE();
// Read in the scripts now
@@ -455,7 +439,7 @@ void MohawkEngine_Riven::checkHotspotChange() {
uint16 hotspotIndex = 0;
bool foundHotspot = false;
for (uint16 i = 0; i < _hotspotCount; i++)
- if (_hotspots[i].enabled && _hotspots[i].rect.contains(_mousePos)) {
+ if (_hotspots[i].enabled && _hotspots[i].rect.contains(_eventMan->getMousePos())) {
foundHotspot = true;
hotspotIndex = i;
}
@@ -481,8 +465,10 @@ Common::String MohawkEngine_Riven::getHotspotName(uint16 hotspot) {
}
void MohawkEngine_Riven::checkInventoryClick() {
+ Common::Point mousePos = _eventMan->getMousePos();
+
// Don't even bother. We're not in the inventory portion of the screen.
- if (_mousePos.y < 392)
+ if (mousePos.y < 392)
return;
// No inventory in the demo or opening screens.
@@ -500,31 +486,31 @@ void MohawkEngine_Riven::checkInventoryClick() {
// Go to the book if a hotspot contains the mouse
if (!hasCathBook) {
- if (g_atrusJournalRect1->contains(_mousePos)) {
+ if (g_atrusJournalRect1->contains(mousePos)) {
_gfx->hideInventory();
changeToStack(aspit);
changeToCard(5);
}
} else if (!hasTrapBook) {
- if (g_atrusJournalRect2->contains(_mousePos)) {
+ if (g_atrusJournalRect2->contains(mousePos)) {
_gfx->hideInventory();
changeToStack(aspit);
changeToCard(5);
- } else if (g_cathJournalRect2->contains(_mousePos)) {
+ } else if (g_cathJournalRect2->contains(mousePos)) {
_gfx->hideInventory();
changeToStack(aspit);
changeToCard(6);
}
} else {
- if (g_atrusJournalRect3->contains(_mousePos)) {
+ if (g_atrusJournalRect3->contains(mousePos)) {
_gfx->hideInventory();
changeToStack(aspit);
changeToCard(5);
- } else if (g_cathJournalRect3->contains(_mousePos)) {
+ } else if (g_cathJournalRect3->contains(mousePos)) {
_gfx->hideInventory();
changeToStack(aspit);
changeToCard(6);
- } else if (g_trapBookRect3->contains(_mousePos)) {
+ } else if (g_trapBookRect3->contains(mousePos)) {
_gfx->hideInventory();
changeToStack(aspit);
changeToCard(7);
diff --git a/engines/mohawk/riven.h b/engines/mohawk/riven.h
index 631285455e..aa97250627 100644
--- a/engines/mohawk/riven.h
+++ b/engines/mohawk/riven.h
@@ -169,7 +169,6 @@ public:
uint16 matchRMAPToCard(uint32);
uint32 getCurCardRMAP();
- Common::Point _mousePos;
RivenHotspot *_hotspots;
int32 _curHotspot;
Common::Array<ZipMode> _zipModeData;
diff --git a/engines/mohawk/riven_external.cpp b/engines/mohawk/riven_external.cpp
index 2a2a6f4630..8f5b947bb8 100644
--- a/engines/mohawk/riven_external.cpp
+++ b/engines/mohawk/riven_external.cpp
@@ -304,7 +304,7 @@ void RivenExternal::checkDomeSliders(uint16 resetSlidersHotspot, uint16 openDome
void RivenExternal::checkSliderCursorChange(uint16 startHotspot) {
// Set the cursor based on _sliderState and what hotspot we're over
for (uint16 i = 0; i < kDomeSliderSlotCount; i++) {
- if (_vm->_hotspots[i + startHotspot].rect.contains(_vm->_mousePos)) {
+ if (_vm->_hotspots[i + startHotspot].rect.contains(_vm->_system->getEventManager()->getMousePos())) {
if (_sliderState & (1 << (24 - i)))
_vm->_gfx->changeCursor(kRivenOpenHandCursor);
else
@@ -318,7 +318,7 @@ void RivenExternal::dragDomeSlider(uint16 bitmapId, uint16 soundId, uint16 reset
int16 foundSlider = -1;
for (uint16 i = 0; i < kDomeSliderSlotCount; i++) {
- if (_vm->_hotspots[i + startHotspot].rect.contains(_vm->_mousePos)) {
+ if (_vm->_hotspots[i + startHotspot].rect.contains(_vm->_system->getEventManager()->getMousePos())) {
// If the slider is not at this hotspot, we can't do anything else
if (!(_sliderState & (1 << (24 - i))))
return;
@@ -887,6 +887,8 @@ void RivenExternal::xbisland_domecheck(uint16 argc, uint16 *argv) {
}
void RivenExternal::xvalvecontrol(uint16 argc, uint16 *argv) {
+ Common::Point startPos = _vm->_system->getEventManager()->getMousePos();
+
// Get the variable for the valve
uint32 *valve = _vm->matchVarToString("bvalve");
@@ -904,8 +906,8 @@ void RivenExternal::xvalvecontrol(uint16 argc, uint16 *argv) {
while (_vm->_system->getEventManager()->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_MOUSEMOVE:
- changeX = event.mouse.x - _vm->_mousePos.x;
- changeY = _vm->_mousePos.y - event.mouse.y;
+ changeX = event.mouse.x - startPos.x;
+ changeY = startPos.y - event.mouse.y;
_vm->_system->updateScreen();
break;
case Common::EVENT_LBUTTONUP:
@@ -1290,6 +1292,8 @@ void RivenExternal::xjisland3500_domecheck(uint16 argc, uint16 *argv) {
}
int RivenExternal::jspitElevatorLoop() {
+ Common::Point startPos = _vm->_system->getEventManager()->getMousePos();
+
Common::Event event;
int changeLevel = 0;
@@ -1299,9 +1303,9 @@ int RivenExternal::jspitElevatorLoop() {
while (_vm->_system->getEventManager()->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_MOUSEMOVE:
- if (event.mouse.y > (_vm->_mousePos.y + 10)) {
+ if (event.mouse.y > (startPos.y + 10)) {
changeLevel = -1;
- } else if (event.mouse.y < (_vm->_mousePos.y - 10)) {
+ } else if (event.mouse.y < (startPos.y - 10)) {
changeLevel = 1;
} else {
changeLevel = 0;