MOHAWK: Disabled hotspots are now unclickable areas. Display blue rects for unreachable zip destinations when drawing resource rects.

svn-id: r54615
This commit is contained in:
Bastien Bouclet 2010-11-29 20:55:11 +00:00
parent 0ac6af59d1
commit 92d74fa56d
7 changed files with 53 additions and 31 deletions

View File

@ -191,7 +191,7 @@ bool MystConsole::Cmd_DrawRect(int argc, const char **argv) {
return true; 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; return false;
} }

View File

@ -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. // 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) if (rect.left < 0 || rect.top < 0 || rect.right > 544 || rect.bottom > 333 || !rect.isValidRect() || rect.width() == 0 || rect.height() == 0)
return; return;
Graphics::Surface *screen = _vm->_system->lockScreen(); Graphics::Surface *screen = _vm->_system->lockScreen();
if (active) if (state == kRectEnabled)
screen->frameRect(rect, _pixelFormat.RGBToColor(0, 255, 0)); screen->frameRect(rect, _pixelFormat.RGBToColor(0, 255, 0));
else if (state == kRectUnreachable)
screen->frameRect(rect, _pixelFormat.RGBToColor(0, 0, 255));
else else
screen->frameRect(rect, _pixelFormat.RGBToColor(255, 0, 0)); screen->frameRect(rect, _pixelFormat.RGBToColor(255, 0, 0));

View File

@ -41,6 +41,12 @@ class MohawkEngine_Riven;
class MohawkBitmap; class MohawkBitmap;
class MystBitmap; class MystBitmap;
enum RectState{
kRectEnabled,
kRectDisabled,
kRectUnreachable
};
class MohawkSurface { class MohawkSurface {
public: public:
MohawkSurface(); MohawkSurface();
@ -99,8 +105,7 @@ public:
void copyImageSectionToScreen(uint16 image, Common::Rect src, Common::Rect dest); void copyImageSectionToScreen(uint16 image, Common::Rect src, Common::Rect dest);
void copyImageToScreen(uint16 image, Common::Rect dest); void copyImageToScreen(uint16 image, Common::Rect dest);
void updateScreen(); void updateScreen();
void drawRect(Common::Rect rect, RectState state);
void drawRect(Common::Rect rect, bool active);
protected: protected:
MohawkSurface *decodeImage(uint16 id); MohawkSurface *decodeImage(uint16 id);

View File

@ -250,12 +250,12 @@ Common::Error MohawkEngine_Myst::run() {
else if (getFeatures() & GF_DEMO) else if (getFeatures() & GF_DEMO)
changeToStack(kDemoStack); changeToStack(kDemoStack);
else else
changeToStack(kIntroStack); changeToStack(kSeleniticStack);
if (getFeatures() & GF_DEMO) if (getFeatures() & GF_DEMO)
changeToCard(2000); changeToCard(2000);
else else
changeToCard(1); changeToCard(1285);
// Load game from launcher/command line if requested // Load game from launcher/command line if requested
if (ConfMan.hasKey("save_slot") && !(getFeatures() & GF_DEMO)) { if (ConfMan.hasKey("save_slot") && !(getFeatures() & GF_DEMO)) {
@ -299,21 +299,21 @@ Common::Error MohawkEngine_Myst::run() {
if (!_dragResource) { if (!_dragResource) {
checkCurrentResource(); checkCurrentResource();
} }
if (_curResource >= 0 && _mouseClicked) { if (_curResource >= 0 && _resources[_curResource]->isEnabled() && _mouseClicked) {
debug(2, "Sending mouse move event to resource %d\n", _curResource); debug(2, "Sending mouse move event to resource %d\n", _curResource);
_resources[_curResource]->handleMouseDrag(&event.mouse); _resources[_curResource]->handleMouseDrag(&event.mouse);
} }
break; break;
case Common::EVENT_LBUTTONUP: case Common::EVENT_LBUTTONUP:
_mouseClicked = false; _mouseClicked = false;
if (_curResource >= 0) { if (_curResource >= 0 && _resources[_curResource]->isEnabled()) {
debug(2, "Sending mouse up event to resource %d\n", _curResource); debug(2, "Sending mouse up event to resource %d\n", _curResource);
_resources[_curResource]->handleMouseUp(&event.mouse); _resources[_curResource]->handleMouseUp(&event.mouse);
} }
break; break;
case Common::EVENT_LBUTTONDOWN: case Common::EVENT_LBUTTONDOWN:
_mouseClicked = true; _mouseClicked = true;
if (_curResource >= 0) { if (_curResource >= 0 && _resources[_curResource]->isEnabled()) {
debug(2, "Sending mouse up event to resource %d\n", _curResource); debug(2, "Sending mouse up event to resource %d\n", _curResource);
_resources[_curResource]->handleMouseDown(&event.mouse); _resources[_curResource]->handleMouseDown(&event.mouse);
} }
@ -496,8 +496,14 @@ void MohawkEngine_Myst::changeToCard(uint16 card) {
void MohawkEngine_Myst::drawResourceRects() { void MohawkEngine_Myst::drawResourceRects() {
for (uint16 i = 0; i < _resources.size(); i++) { for (uint16 i = 0; i < _resources.size(); i++) {
_resources[i]->getRect().debugPrint(0); _resources[i]->getRect().debugPrint(0);
if (_resources[i]->getRect().isValidRect()) if (_resources[i]->getRect().isValidRect()) {
_gfx->drawRect(_resources[i]->getRect(), _resources[i]->isEnabled()); 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(); _system->updateScreen();
@ -508,11 +514,14 @@ void MohawkEngine_Myst::checkCurrentResource() {
bool foundResource = false; bool foundResource = false;
for (uint16 i = 0; i < _resources.size(); i++) 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 != i) {
if (_curResource != -1) if (_curResource != -1 && _resources[_curResource]->isEnabled())
_resources[_curResource]->handleMouseLeave(); _resources[_curResource]->handleMouseLeave();
_resources[i]->handleMouseEnter();
if (_resources[i]->isEnabled())
_resources[i]->handleMouseEnter();
} }
_curResource = i; _curResource = i;

View File

@ -63,16 +63,6 @@ MystResource::MystResource(MohawkEngine_Myst *vm, Common::SeekableReadStream *rl
debugC(kDebugResource, "\tright: %d", _rect.right); debugC(kDebugResource, "\tright: %d", _rect.right);
debugC(kDebugResource, "\tbottom: %d", _rect.bottom); debugC(kDebugResource, "\tbottom: %d", _rect.bottom);
debugC(kDebugResource, "\tdest: %d", _dest); 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() { 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); 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) { MystResourceType5::MystResourceType5(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent) : MystResource(vm, rlstStream, parent) {
debugC(kDebugResource, "\tResource Type 5 Script:"); debugC(kDebugResource, "\tResource Type 5 Script:");

View File

@ -44,10 +44,11 @@ public:
virtual void drawConditionalDataToScreen(uint16 state) {} virtual void drawConditionalDataToScreen(uint16 state) {}
virtual void handleAnimation() {} virtual void handleAnimation() {}
virtual Common::Rect getRect() { return _rect; } virtual Common::Rect getRect() { return _rect; }
bool isEnabled() { return _enabled; } bool isEnabled();
void setEnabled(bool enabled) { _enabled = enabled; } void setEnabled(bool enabled);
uint16 getDest() { return _dest; } uint16 getDest() { return _dest; }
virtual uint16 getType8Var() { return 0xFFFF; } virtual uint16 getType8Var() { return 0xFFFF; }
bool unreachableZipDest();
// Mouse interface // Mouse interface
virtual void handleMouseUp(Common::Point *mouse); virtual void handleMouseUp(Common::Point *mouse);
@ -62,7 +63,6 @@ protected:
uint16 _flags; uint16 _flags;
Common::Rect _rect; Common::Rect _rect;
uint16 _dest; uint16 _dest;
bool _enabled;
}; };
class MystResourceType5 : public MystResource { class MystResourceType5 : public MystResource {

View File

@ -594,7 +594,7 @@ void MystScriptParser_Selenitic::o_113_soundLockStartMove(uint16 op, uint16 var,
MystResourceType10 *slider = soundLockSliderFromVar(var); MystResourceType10 *slider = soundLockSliderFromVar(var);
_vm->_gfx->changeCursor(700); _vm->_cursor->setCursor(700);
_vm->_sound->pauseBackground(); _vm->_sound->pauseBackground();
_sound_lock_sound_id = soundLockCurrentSound(slider->_pos.y, true); _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->pauseBackground();
_vm->_sound->playSound(1147); _vm->_sound->playSound(1147);
_sound_lock_button->drawConditionalDataToScreen(1); _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_1, selenitic_vars[13], 5, solved);
soundLockCheckSolution(_sound_lock_slider_2, selenitic_vars[14], 9, 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); _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) { void MystScriptParser_Selenitic::o_117_soundReceiverEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {