diff options
Diffstat (limited to 'engines/director/score.cpp')
-rw-r--r-- | engines/director/score.cpp | 70 |
1 files changed, 69 insertions, 1 deletions
diff --git a/engines/director/score.cpp b/engines/director/score.cpp index 0d11c7b54a..42937add74 100644 --- a/engines/director/score.cpp +++ b/engines/director/score.cpp @@ -28,6 +28,7 @@ #include "engines/util.h" #include "graphics/font.h" #include "graphics/palette.h" +#include "graphics/primitives.h" #include "graphics/macgui/macfontmanager.h" #include "graphics/macgui/macwindowmanager.h" #include "image/bmp.h" @@ -65,6 +66,7 @@ Score::Score(DirectorEngine *vm) { _vm = vm; _surface = new Graphics::ManagedSurface; _trailSurface = new Graphics::ManagedSurface; + _backSurface = new Graphics::ManagedSurface; _lingo = _vm->getLingo(); _soundManager = _vm->getSoundManager(); _currentMouseDownSpriteId = 0; @@ -324,6 +326,10 @@ Score::~Score() { if (_trailSurface) _trailSurface->free(); + if (_backSurface) + _backSurface->free(); + + delete _backSurface; delete _surface; delete _trailSurface; @@ -1261,6 +1267,7 @@ void Score::startLoop() { _surface->create(_movieRect.width(), _movieRect.height()); _trailSurface->create(_movieRect.width(), _movieRect.height()); + _backSurface->create(_movieRect.width(), _movieRect.height()); if (_stageColor == 0) _trailSurface->clear(_vm->getPaletteColorCount() - 1); @@ -1283,8 +1290,10 @@ void Score::startLoop() { } void Score::update() { - if (g_system->getMillis() < _nextFrameTime) + if (g_system->getMillis() < _nextFrameTime) { + renderZoomBox(true); return; + } _surface->clear(); _surface->copyFrom(*_trailSurface); @@ -1372,4 +1381,63 @@ Sprite *Score::getSpriteById(uint16 id) { } } +void Score::addZoomBox(ZoomBox *box) { + _zoomBoxes.push_back(box); +} + +void Score::renderZoomBox(bool redraw) { + if (!_zoomBoxes.size()) + return; + + ZoomBox *box = _zoomBoxes.front(); + uint32 t = g_system->getMillis(); + + if (box->nextTime > t) + return; + + if (redraw) { + _surface->copyFrom(*_backSurface); + } + + const int numSteps = 14; + // We have 15 steps in total, and we have flying rectange + // from switching 3/4 frames + + int start, end; + // Determine, how many rectangles and what are their numbers + if (box->step < 5) { + start = 1; + end = box->step; + } else { + start = box->step - 4; + end = MIN(start + 3 - box->step % 2, 8); + } + + Graphics::MacPlotData pd(_surface, &_vm->_wm->getPatterns(), Graphics::kPatternCheckers, 1, 0); + + for (int i = start; i <= end; i++) { + Common::Rect r(box->start.left + (box->end.left - box->start.left) * i / 8, + box->start.top + (box->end.top - box->start.top) * i / 8, + box->start.right + (box->end.right - box->start.right) * i / 8, + box->start.bottom + (box->end.bottom - box->start.bottom) * i / 8); + + Graphics::drawLine(r.left, r.top, r.right, r.top, 0xffff, Graphics::macDrawPixel, &pd); + Graphics::drawLine(r.right, r.top, r.right, r.bottom, 0xffff, Graphics::macDrawPixel, &pd); + Graphics::drawLine(r.left, r.bottom, r.right, r.bottom, 0xffff, Graphics::macDrawPixel, &pd); + Graphics::drawLine(r.left, r.top, r.left, r.bottom, 0xffff, Graphics::macDrawPixel, &pd); + } + + box->step++; + + if (box->step >= numSteps) { + _zoomBoxes.remove_at(0); + } + + box->nextTime = box->startTime + 1000 * box->step * box->delay / 60; + + if (redraw) { + g_system->copyRectToScreen(_surface->getPixels(), _surface->pitch, 0, 0, _surface->getBounds().width(), _surface->getBounds().height()); + } +} + } // End of namespace Director |