diff options
author | Bastien Bouclet | 2010-11-29 20:55:11 +0000 |
---|---|---|
committer | Bastien Bouclet | 2010-11-29 20:55:11 +0000 |
commit | 92d74fa56df2583ad01616c2afa394baf2ea5a9f (patch) | |
tree | ea01085fdb3bc66ca088b73f55f7946fde11f47e | |
parent | 0ac6af59d122319715145883d986ac652f99738d (diff) | |
download | scummvm-rg350-92d74fa56df2583ad01616c2afa394baf2ea5a9f.tar.gz scummvm-rg350-92d74fa56df2583ad01616c2afa394baf2ea5a9f.tar.bz2 scummvm-rg350-92d74fa56df2583ad01616c2afa394baf2ea5a9f.zip |
MOHAWK: Disabled hotspots are now unclickable areas. Display blue rects for unreachable zip destinations when drawing resource rects.
svn-id: r54615
-rw-r--r-- | engines/mohawk/console.cpp | 2 | ||||
-rw-r--r-- | engines/mohawk/graphics.cpp | 6 | ||||
-rw-r--r-- | engines/mohawk/graphics.h | 9 | ||||
-rw-r--r-- | engines/mohawk/myst.cpp | 29 | ||||
-rw-r--r-- | engines/mohawk/myst_areas.cpp | 26 | ||||
-rw-r--r-- | engines/mohawk/myst_areas.h | 6 | ||||
-rw-r--r-- | engines/mohawk/myst_scripts_selenitic.cpp | 6 |
7 files changed, 53 insertions, 31 deletions
diff --git a/engines/mohawk/console.cpp b/engines/mohawk/console.cpp index 1e669c2b20..613826e895 100644 --- a/engines/mohawk/console.cpp +++ b/engines/mohawk/console.cpp @@ -191,7 +191,7 @@ bool MystConsole::Cmd_DrawRect(int argc, const char **argv) { return true; } - _vm->_gfx->drawRect(Common::Rect((uint16)atoi(argv[1]), (uint16)atoi(argv[2]), (uint16)atoi(argv[3]), (uint16)atoi(argv[4])), true); + _vm->_gfx->drawRect(Common::Rect((uint16)atoi(argv[1]), (uint16)atoi(argv[2]), (uint16)atoi(argv[3]), (uint16)atoi(argv[4])), kRectEnabled); return false; } diff --git a/engines/mohawk/graphics.cpp b/engines/mohawk/graphics.cpp index 4170b24aad..ee1ffb26f1 100644 --- a/engines/mohawk/graphics.cpp +++ b/engines/mohawk/graphics.cpp @@ -287,15 +287,17 @@ void MystGraphics::updateScreen() { } } -void MystGraphics::drawRect(Common::Rect rect, bool active) { +void MystGraphics::drawRect(Common::Rect rect, RectState state) { // Useful with debugging. Shows where hotspots are on the screen and whether or not they're active. if (rect.left < 0 || rect.top < 0 || rect.right > 544 || rect.bottom > 333 || !rect.isValidRect() || rect.width() == 0 || rect.height() == 0) return; Graphics::Surface *screen = _vm->_system->lockScreen(); - if (active) + if (state == kRectEnabled) screen->frameRect(rect, _pixelFormat.RGBToColor(0, 255, 0)); + else if (state == kRectUnreachable) + screen->frameRect(rect, _pixelFormat.RGBToColor(0, 0, 255)); else screen->frameRect(rect, _pixelFormat.RGBToColor(255, 0, 0)); diff --git a/engines/mohawk/graphics.h b/engines/mohawk/graphics.h index 1f184b30d0..75ffe12987 100644 --- a/engines/mohawk/graphics.h +++ b/engines/mohawk/graphics.h @@ -41,6 +41,12 @@ class MohawkEngine_Riven; class MohawkBitmap; class MystBitmap; +enum RectState{ + kRectEnabled, + kRectDisabled, + kRectUnreachable +}; + class MohawkSurface { public: MohawkSurface(); @@ -99,8 +105,7 @@ public: void copyImageSectionToScreen(uint16 image, Common::Rect src, Common::Rect dest); void copyImageToScreen(uint16 image, Common::Rect dest); void updateScreen(); - - void drawRect(Common::Rect rect, bool active); + void drawRect(Common::Rect rect, RectState state); protected: MohawkSurface *decodeImage(uint16 id); diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp index c1a6123635..10cca563bf 100644 --- a/engines/mohawk/myst.cpp +++ b/engines/mohawk/myst.cpp @@ -250,12 +250,12 @@ Common::Error MohawkEngine_Myst::run() { else if (getFeatures() & GF_DEMO) changeToStack(kDemoStack); else - changeToStack(kIntroStack); + changeToStack(kSeleniticStack); if (getFeatures() & GF_DEMO) changeToCard(2000); else - changeToCard(1); + changeToCard(1285); // Load game from launcher/command line if requested if (ConfMan.hasKey("save_slot") && !(getFeatures() & GF_DEMO)) { @@ -299,21 +299,21 @@ Common::Error MohawkEngine_Myst::run() { if (!_dragResource) { checkCurrentResource(); } - if (_curResource >= 0 && _mouseClicked) { + if (_curResource >= 0 && _resources[_curResource]->isEnabled() && _mouseClicked) { debug(2, "Sending mouse move event to resource %d\n", _curResource); _resources[_curResource]->handleMouseDrag(&event.mouse); } break; case Common::EVENT_LBUTTONUP: _mouseClicked = false; - if (_curResource >= 0) { + if (_curResource >= 0 && _resources[_curResource]->isEnabled()) { debug(2, "Sending mouse up event to resource %d\n", _curResource); _resources[_curResource]->handleMouseUp(&event.mouse); } break; case Common::EVENT_LBUTTONDOWN: _mouseClicked = true; - if (_curResource >= 0) { + if (_curResource >= 0 && _resources[_curResource]->isEnabled()) { debug(2, "Sending mouse up event to resource %d\n", _curResource); _resources[_curResource]->handleMouseDown(&event.mouse); } @@ -496,8 +496,14 @@ void MohawkEngine_Myst::changeToCard(uint16 card) { void MohawkEngine_Myst::drawResourceRects() { for (uint16 i = 0; i < _resources.size(); i++) { _resources[i]->getRect().debugPrint(0); - if (_resources[i]->getRect().isValidRect()) - _gfx->drawRect(_resources[i]->getRect(), _resources[i]->isEnabled()); + if (_resources[i]->getRect().isValidRect()) { + if (_resources[i]->unreachableZipDest()) + _gfx->drawRect(_resources[i]->getRect(), kRectUnreachable); + else if (_resources[i]->isEnabled()) + _gfx->drawRect(_resources[i]->getRect(), kRectEnabled); + else + _gfx->drawRect(_resources[i]->getRect(), kRectDisabled); + } } _system->updateScreen(); @@ -508,11 +514,14 @@ void MohawkEngine_Myst::checkCurrentResource() { bool foundResource = false; for (uint16 i = 0; i < _resources.size(); i++) - if (_resources[i]->isEnabled() && _resources[i]->contains(_system->getEventManager()->getMousePos())) { + if (!_resources[i]->unreachableZipDest() && + _resources[i]->contains(_system->getEventManager()->getMousePos())) { if (_curResource != i) { - if (_curResource != -1) + if (_curResource != -1 && _resources[_curResource]->isEnabled()) _resources[_curResource]->handleMouseLeave(); - _resources[i]->handleMouseEnter(); + + if (_resources[i]->isEnabled()) + _resources[i]->handleMouseEnter(); } _curResource = i; diff --git a/engines/mohawk/myst_areas.cpp b/engines/mohawk/myst_areas.cpp index dec6bdcc72..9ce5c9b296 100644 --- a/engines/mohawk/myst_areas.cpp +++ b/engines/mohawk/myst_areas.cpp @@ -63,16 +63,6 @@ MystResource::MystResource(MohawkEngine_Myst *vm, Common::SeekableReadStream *rl debugC(kDebugResource, "\tright: %d", _rect.right); debugC(kDebugResource, "\tbottom: %d", _rect.bottom); debugC(kDebugResource, "\tdest: %d", _dest); - - // Default Enable based on flags... - if (_vm->_zipMode) - _enabled = (_flags & kMystZipModeEnableFlag) != 0 || - (_flags & kMystHotspotEnableFlag) != 0 || - (_flags & kMystSubimageEnableFlag) != 0; - else - _enabled = (_flags & kMystZipModeEnableFlag) == 0 && - ((_flags & kMystHotspotEnableFlag) != 0 || - (_flags & kMystSubimageEnableFlag) != 0); } MystResource::~MystResource() { @@ -85,6 +75,22 @@ void MystResource::handleMouseUp(Common::Point *mouse) { warning("Movement type resource with null destination at position (%d, %d), (%d, %d)", _rect.left, _rect.top, _rect.right, _rect.bottom); } +bool MystResource::unreachableZipDest() { + return (_flags & kMystZipModeEnableFlag) && !_vm->_zipMode; +} + +bool MystResource::isEnabled() { + return _flags & kMystHotspotEnableFlag; +} + +void MystResource::setEnabled(bool enabled) { + if (enabled) { + _flags |= kMystHotspotEnableFlag; + } else { + _flags &= ~kMystHotspotEnableFlag; + } +} + MystResourceType5::MystResourceType5(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent) : MystResource(vm, rlstStream, parent) { debugC(kDebugResource, "\tResource Type 5 Script:"); diff --git a/engines/mohawk/myst_areas.h b/engines/mohawk/myst_areas.h index 4a53577a3d..e28b683eb6 100644 --- a/engines/mohawk/myst_areas.h +++ b/engines/mohawk/myst_areas.h @@ -44,10 +44,11 @@ public: virtual void drawConditionalDataToScreen(uint16 state) {} virtual void handleAnimation() {} virtual Common::Rect getRect() { return _rect; } - bool isEnabled() { return _enabled; } - void setEnabled(bool enabled) { _enabled = enabled; } + bool isEnabled(); + void setEnabled(bool enabled); uint16 getDest() { return _dest; } virtual uint16 getType8Var() { return 0xFFFF; } + bool unreachableZipDest(); // Mouse interface virtual void handleMouseUp(Common::Point *mouse); @@ -62,7 +63,6 @@ protected: uint16 _flags; Common::Rect _rect; uint16 _dest; - bool _enabled; }; class MystResourceType5 : public MystResource { diff --git a/engines/mohawk/myst_scripts_selenitic.cpp b/engines/mohawk/myst_scripts_selenitic.cpp index ffb9f21936..04b34fe79c 100644 --- a/engines/mohawk/myst_scripts_selenitic.cpp +++ b/engines/mohawk/myst_scripts_selenitic.cpp @@ -594,7 +594,7 @@ void MystScriptParser_Selenitic::o_113_soundLockStartMove(uint16 op, uint16 var, MystResourceType10 *slider = soundLockSliderFromVar(var); - _vm->_gfx->changeCursor(700); + _vm->_cursor->setCursor(700); _vm->_sound->pauseBackground(); _sound_lock_sound_id = soundLockCurrentSound(slider->_pos.y, true); @@ -668,7 +668,7 @@ void MystScriptParser_Selenitic::o_115_soundLockButton(uint16 op, uint16 var, ui _vm->_sound->pauseBackground(); _vm->_sound->playSound(1147); _sound_lock_button->drawConditionalDataToScreen(1); - _vm->_gfx->hideCursor(); + _vm->_cursor->hideCursor(); soundLockCheckSolution(_sound_lock_slider_1, selenitic_vars[13], 5, solved); soundLockCheckSolution(_sound_lock_slider_2, selenitic_vars[14], 9, solved); @@ -690,7 +690,7 @@ void MystScriptParser_Selenitic::o_115_soundLockButton(uint16 op, uint16 var, ui _sound_lock_button->drawConditionalDataToScreen(0); } - _vm->_gfx->showCursor(); + _vm->_cursor->showCursor(); } void MystScriptParser_Selenitic::o_117_soundReceiverEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { |