diff options
author | Bastien Bouclet | 2016-08-04 07:19:51 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2017-07-03 08:50:10 +0200 |
commit | 2fbe284a311f2eef62126115ddd6d2bb483b3c4b (patch) | |
tree | a2060178230eea11edd7704c5b006ae9d17c55ba /engines/mohawk/riven_graphics.cpp | |
parent | 1bb5424dddca2cf150fa1a09f4845e193b581e3e (diff) | |
download | scummvm-rg350-2fbe284a311f2eef62126115ddd6d2bb483b3c4b.tar.gz scummvm-rg350-2fbe284a311f2eef62126115ddd6d2bb483b3c4b.tar.bz2 scummvm-rg350-2fbe284a311f2eef62126115ddd6d2bb483b3c4b.zip |
MOHAWK: Chane Riven's graphics manager to automatically handle screen updates
Diffstat (limited to 'engines/mohawk/riven_graphics.cpp')
-rw-r--r-- | engines/mohawk/riven_graphics.cpp | 53 |
1 files changed, 38 insertions, 15 deletions
diff --git a/engines/mohawk/riven_graphics.cpp b/engines/mohawk/riven_graphics.cpp index 34da11f6b7..e0cfa365c1 100644 --- a/engines/mohawk/riven_graphics.cpp +++ b/engines/mohawk/riven_graphics.cpp @@ -46,7 +46,8 @@ RivenGraphics::RivenGraphics(MohawkEngine_Riven* vm) : GraphicsManager(), _vm(vm _mainScreen = new Graphics::Surface(); _mainScreen->create(608, 392, _pixelFormat); - _updatesEnabled = true; + _screenUpdateNesting = 0; + _screenUpdateRunning = false; _scheduledTransition = -1; // no transition _dirtyScreen = false; _inventoryDrawn = false; @@ -72,6 +73,8 @@ MohawkSurface *RivenGraphics::decodeImage(uint16 id) { void RivenGraphics::copyImageToScreen(uint16 image, uint32 left, uint32 top, uint32 right, uint32 bottom) { Graphics::Surface *surface = findImage(image)->getSurface(); + beginScreenUpdate(); + // Clip the width to fit on the screen. Fixes some images. if (left + surface->w > 608) surface->w = 608 - left; @@ -80,24 +83,20 @@ void RivenGraphics::copyImageToScreen(uint16 image, uint32 left, uint32 top, uin memcpy(_mainScreen->getBasePtr(left, i + top), surface->getBasePtr(0, i), surface->w * surface->format.bytesPerPixel); _dirtyScreen = true; + applyScreenUpdate(); } void RivenGraphics::updateScreen(Common::Rect updateRect) { - if (_updatesEnabled) { - _vm->runUpdateScreenScript(); - _vm->_sound->triggerDrawSound(); - - if (_dirtyScreen) { - // Copy to screen if there's no transition. Otherwise transition. ;) - if (_scheduledTransition < 0) - _vm->_system->copyRectToScreen(_mainScreen->getBasePtr(updateRect.left, updateRect.top), _mainScreen->pitch, updateRect.left, updateRect.top, updateRect.width(), updateRect.height()); - else - runScheduledTransition(); + if (_dirtyScreen) { + // Copy to screen if there's no transition. Otherwise transition. ;) + if (_scheduledTransition < 0) + _vm->_system->copyRectToScreen(_mainScreen->getBasePtr(updateRect.left, updateRect.top), _mainScreen->pitch, updateRect.left, updateRect.top, updateRect.width(), updateRect.height()); + else + runScheduledTransition(); - // Finally, update the screen. - _vm->_system->updateScreen(); - _dirtyScreen = false; - } + // Finally, update the screen. + _vm->_system->updateScreen(); + _dirtyScreen = false; } } @@ -417,4 +416,28 @@ void RivenGraphics::updateCredits() { } } +void RivenGraphics::beginScreenUpdate() { + _screenUpdateNesting++; +} + +void RivenGraphics::applyScreenUpdate(bool force) { + if (force) { + _screenUpdateNesting = 0; + } else { + _screenUpdateNesting--; + } + + // The screen is only updated when the outermost screen update ends + if (_screenUpdateNesting <= 0 && !_screenUpdateRunning) { + _screenUpdateRunning = true; + + _vm->getCurCard()->runScript(kCardUpdateScript); + _vm->_sound->triggerDrawSound(); + updateScreen(); + + _screenUpdateNesting = 0; + _screenUpdateRunning = false; + } +} + } // End of namespace Mohawk |