diff options
author | Bastien Bouclet | 2010-11-29 20:58:10 +0000 |
---|---|---|
committer | Bastien Bouclet | 2010-11-29 20:58:10 +0000 |
commit | 90b336ec344157c1896e409ecbb8beab1c45923d (patch) | |
tree | 9de01789cade3b0f8a62c7f2b0d47812175821e9 | |
parent | a9617cbe2888be357d6dbee9899f34827d159b26 (diff) | |
download | scummvm-rg350-90b336ec344157c1896e409ecbb8beab1c45923d.tar.gz scummvm-rg350-90b336ec344157c1896e409ecbb8beab1c45923d.tar.bz2 scummvm-rg350-90b336ec344157c1896e409ecbb8beab1c45923d.zip |
MOHAWK: Changed sliders to restore the main background instead of doing their own background caching. It is possible now there is the image cache.
svn-id: r54626
-rw-r--r-- | engines/mohawk/myst.cpp | 26 | ||||
-rw-r--r-- | engines/mohawk/myst.h | 1 | ||||
-rw-r--r-- | engines/mohawk/myst_areas.cpp | 45 | ||||
-rw-r--r-- | engines/mohawk/myst_areas.h | 3 | ||||
-rw-r--r-- | engines/mohawk/myst_scripts.cpp | 12 | ||||
-rw-r--r-- | engines/mohawk/myst_scripts_selenitic.cpp | 1 |
6 files changed, 36 insertions, 52 deletions
diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp index 6e24101331..ce6b5e8bc6 100644 --- a/engines/mohawk/myst.cpp +++ b/engines/mohawk/myst.cpp @@ -396,16 +396,24 @@ void MohawkEngine_Myst::changeToStack(uint16 stack) { _gfx->clearCache(); } -void MohawkEngine_Myst::drawCardBackground() { -if (_view.conditionalImageCount != 0) { - for (uint16 i = 0; i < _view.conditionalImageCount; i++) { - if (_scriptParser->getVar(_view.conditionalImages[i].var) < _view.conditionalImages[i].numStates) - _gfx->copyImageToScreen(_view.conditionalImages[i].values[_scriptParser->getVar(_view.conditionalImages[i].var)], Common::Rect(0, 0, 544, 333)); - else - warning("Conditional image %d variable %d: %d exceeds maximum state of %d", i, _view.conditionalImages[i].var, _scriptParser->getVar(_view.conditionalImages[i].var), _view.conditionalImages[i].numStates-1); +uint16 MohawkEngine_Myst::getCardBackgroundId() { + uint16 imageToDraw = 0; + + if (_view.conditionalImageCount == 0) + imageToDraw = _view.mainImage; + else { + for (uint16 i = 0; i < _view.conditionalImageCount; i++) { + uint16 varValue = _scriptParser->getVar(_view.conditionalImages[i].var); + if (varValue < _view.conditionalImages[i].numStates) + imageToDraw = _view.conditionalImages[i].values[varValue]; + } } -} else if (_view.mainImage != 0) - _gfx->copyImageToScreen(_view.mainImage, Common::Rect(0, 0, 544, 333)); + + return imageToDraw; +} + +void MohawkEngine_Myst::drawCardBackground() { + _gfx->copyImageToScreen(getCardBackgroundId(), Common::Rect(0, 0, 544, 333)); } void MohawkEngine_Myst::changeToCard(uint16 card) { diff --git a/engines/mohawk/myst.h b/engines/mohawk/myst.h index 448570c8a1..24653e6a6c 100644 --- a/engines/mohawk/myst.h +++ b/engines/mohawk/myst.h @@ -201,6 +201,7 @@ public: void redrawResource(MystResourceType8 *_resource); void drawResourceImages(); void drawCardBackground(); + uint16 getCardBackgroundId(); void setCacheState(bool state) { _cache.enabled = state; } bool getCacheState(void) { return _cache.enabled; } diff --git a/engines/mohawk/myst_areas.cpp b/engines/mohawk/myst_areas.cpp index 27df1c69a8..37e96beb90 100644 --- a/engines/mohawk/myst_areas.cpp +++ b/engines/mohawk/myst_areas.cpp @@ -468,16 +468,11 @@ MystResourceType10::MystResourceType10(MohawkEngine_Myst *vm, Common::SeekableRe debugC(kDebugResource, "\tdrag sound : %d", _dragSound); - _background = 0; _sliderWidth = _rect.right - _rect.left; _sliderHeigth = _rect.bottom - _rect.top; } MystResourceType10::~MystResourceType10() { - if (_background) { - _background->free(); - delete _background; - } } void MystResourceType10::setStep(uint16 step) { @@ -508,26 +503,19 @@ Common::Rect MystResourceType10::boundingBox() { return bb; } -void MystResourceType10::drawDataToScreen() { - // Save the background to be able to restore it - if (!_background) { - Common::Rect bb = boundingBox(); - Graphics::PixelFormat pixelFormat = _vm->_system->getScreenFormat(); - - _background = new Graphics::Surface(); - _background->create(bb.width(), bb.height(), pixelFormat.bytesPerPixel); - Graphics::Surface *screen = _vm->_system->lockScreen(); - - for (uint16 i = 0; i < bb.height(); i++) - memcpy(_background->getBasePtr(0, i), screen->getBasePtr(bb.left, bb.top + i), bb.width() * _background->bytesPerPixel); - - _vm->_system->unlockScreen(); - } else { - // Restore background - Common::Rect bb = boundingBox(); - _vm->_system->copyRectToScreen((byte *)_background->getBasePtr(0, 0), _background->pitch, bb.left, bb.top, bb.width(), bb.height()); - } +void MystResourceType10::restoreBackground() { + // Restore background + Common::Rect src = boundingBox(); + Common::Rect dest = boundingBox(); + src.top = 333 - dest.bottom; + src.bottom = 333 - dest.top; + _vm->_gfx->copyImageSectionToScreen(_vm->getCardBackgroundId(), src, dest); +} +void MystResourceType10::drawDataToScreen() +{ + // Restore background + restoreBackground(); MystResourceType8::drawDataToScreen(); } @@ -541,8 +529,7 @@ void MystResourceType10::handleMouseDown(Common::Point *mouse) { MystResourceType11::handleMouseDown(mouse); // Restore background - Common::Rect bb = boundingBox(); - _vm->_system->copyRectToScreen((byte *)_background->getBasePtr(0, 0), _background->pitch, bb.left, bb.top, bb.width(), bb.height()); + restoreBackground(); // Draw slider drawConditionalDataToScreen(2); @@ -552,8 +539,7 @@ void MystResourceType10::handleMouseUp(Common::Point *mouse) { updatePosition(mouse); // Restore background - Common::Rect bb = boundingBox(); - _vm->_system->copyRectToScreen((byte *)_background->getBasePtr(0, 0), _background->pitch, bb.left, bb.top, bb.width(), bb.height()); + restoreBackground(); // Draw slider drawConditionalDataToScreen(1); @@ -587,8 +573,7 @@ void MystResourceType10::handleMouseDrag(Common::Point *mouse) { MystResourceType11::handleMouseDrag(mouse); // Restore background - Common::Rect bb = boundingBox(); - _vm->_system->copyRectToScreen((byte *)_background->getBasePtr(0, 0), _background->pitch, bb.left, bb.top, bb.width(), bb.height()); + restoreBackground(); // Draw slider drawConditionalDataToScreen(2); diff --git a/engines/mohawk/myst_areas.h b/engines/mohawk/myst_areas.h index 34b454f47a..a866fca603 100644 --- a/engines/mohawk/myst_areas.h +++ b/engines/mohawk/myst_areas.h @@ -183,12 +183,11 @@ public: protected: Common::Rect boundingBox(); void updatePosition(Common::Point *mouse); + void restoreBackground(); uint16 _dragSound; uint16 _sliderWidth; uint16 _sliderHeigth; - - Graphics::Surface *_background; }; class MystResourceType12 : public MystResourceType11 { diff --git a/engines/mohawk/myst_scripts.cpp b/engines/mohawk/myst_scripts.cpp index e4af5a325f..af8be9b4c9 100644 --- a/engines/mohawk/myst_scripts.cpp +++ b/engines/mohawk/myst_scripts.cpp @@ -572,17 +572,7 @@ void MystScriptParser::o_28_restoreDefaultRect(uint16 op, uint16 var, uint16 arg debugC(kDebugScript, "\trect.right: %d", rect.right); debugC(kDebugScript, "\trect.bottom: %d", rect.bottom); - // TODO: Need to fix VIEW logic so this doesn't need - // calculation at this level. - uint16 imageToDraw = 0; - if (_vm->_view.conditionalImageCount == 0) - imageToDraw = _vm->_view.mainImage; - else { - for (uint16 i = 0; i < _vm->_view.conditionalImageCount; i++) - if (getVar(_vm->_view.conditionalImages[i].var) < _vm->_view.conditionalImages[i].numStates) - imageToDraw = _vm->_view.conditionalImages[i].values[getVar(_vm->_view.conditionalImages[i].var)]; - } - _vm->_gfx->copyImageSectionToScreen(imageToDraw, rect, rect); + _vm->_gfx->copyImageSectionToScreen(_vm->getCardBackgroundId(), rect, rect); } else unknown(op, var, argc, argv); } diff --git a/engines/mohawk/myst_scripts_selenitic.cpp b/engines/mohawk/myst_scripts_selenitic.cpp index eaa5eb22dd..bce7ce53b6 100644 --- a/engines/mohawk/myst_scripts_selenitic.cpp +++ b/engines/mohawk/myst_scripts_selenitic.cpp @@ -663,6 +663,7 @@ void MystScriptParser_Selenitic::o_114_soundLockEndMove(uint16 op, uint16 var, u slider->setStep(stepped); slider->drawDataToScreen(); + _vm->_gfx->updateScreen(); uint16 soundId = slider->getList3(0); if (soundId) |