diff options
author | stevenhoefel | 2017-01-12 09:45:23 +1100 |
---|---|---|
committer | stevenhoefel | 2017-01-12 09:45:23 +1100 |
commit | c4cabdef0f61a6a170551733d32e909f7e6061c1 (patch) | |
tree | 3aa2c22d3bfd40896abbce37a60481e0e1b9cc91 /engines | |
parent | 1f95f5c161d8123d4d674dae2917dc6b180ca6aa (diff) | |
download | scummvm-rg350-c4cabdef0f61a6a170551733d32e909f7e6061c1.tar.gz scummvm-rg350-c4cabdef0f61a6a170551733d32e909f7e6061c1.tar.bz2 scummvm-rg350-c4cabdef0f61a6a170551733d32e909f7e6061c1.zip |
DIRECTOR: Hooks for both cast member and cast frame events.
Diffstat (limited to 'engines')
-rw-r--r-- | engines/director/frame.cpp | 27 | ||||
-rw-r--r-- | engines/director/frame.h | 8 | ||||
-rw-r--r-- | engines/director/score.cpp | 15 |
3 files changed, 34 insertions, 16 deletions
diff --git a/engines/director/frame.cpp b/engines/director/frame.cpp index 6978c574ef..1d689abce9 100644 --- a/engines/director/frame.cpp +++ b/engines/director/frame.cpp @@ -604,8 +604,9 @@ void Frame::renderSprites(Graphics::ManagedSurface &surface, bool renderTrail) { int height = _sprites[i]->_height; int width = _sprites[i]->_width; - Common::Rect drawRect = Common::Rect(x, y, x + width, y + height); - _drawRects[i] = drawRect; + Common::Rect drawRect(x, y, x + width, y + height); + + addDrawRect(i, drawRect); switch (_sprites[i]->_ink) { case kInkTypeCopy: @@ -637,6 +638,13 @@ void Frame::renderSprites(Graphics::ManagedSurface &surface, bool renderTrail) { } } +void Frame::addDrawRect(uint16 spriteId, Common::Rect &rect) { + FrameEntity *fi = new FrameEntity(); + fi->spriteId = spriteId; + fi->rect = rect; + _drawRects.push_back(fi); +} + void Frame::renderShape(Graphics::ManagedSurface &surface, uint16 spriteID) { Common::Rect r = Common::Rect(_sprites[spriteID]->_startPoint.x, _sprites[spriteID]->_startPoint.y, @@ -674,7 +682,7 @@ void Frame::renderShape(Graphics::ManagedSurface &surface, uint16 spriteID) { break; } - _drawRects[spriteID] = r; + addDrawRect(spriteID, r); } void Frame::renderButton(Graphics::ManagedSurface &surface, uint16 spriteId, uint16 textId) { @@ -698,13 +706,13 @@ void Frame::renderButton(Graphics::ManagedSurface &surface, uint16 spriteId, uin // Magic numbers: checkbox square need to move left about 5px from text and 12px side size (D4) _rect = Common::Rect(x - 17, y, x + 12, y + 12); surface.frameRect(_rect, 0); - _drawRects[spriteId] = _rect; + addDrawRect(spriteId, _rect); break; case kTypeButton: { _rect = Common::Rect(x, y, x + width - 1, y + height + 5); Graphics::MacPlotData pd(&surface, &_vm->getMacWindowManager()->getPatterns(), Graphics::MacGUIConstants::kPatternSolid, 1); Graphics::drawRoundRect(_rect, 4, 0, false, Graphics::macDrawPixel, &pd); - _drawRects[spriteId] = _rect; + addDrawRect(spriteId, _rect); } break; case kTypeRadio: @@ -1042,11 +1050,10 @@ void Frame::drawMatteSprite(Graphics::ManagedSurface &target, const Graphics::Su } uint16 Frame::getSpriteIDFromPos(Common::Point pos) { - // Find first from top to bottom - //TODO: THIS NEEDS TO BE REVERSED! - for (Common::HashMap<uint16, Common::Rect>::const_iterator dr = _drawRects.begin(); dr != _drawRects.end(); dr++) - if (dr->_value.contains(pos)) - return dr->_key; + // Find first from front to back + for (int dr = _drawRects.size() - 1; dr >= 0; dr--) + if (_drawRects[dr]->rect.contains(pos)) + return _drawRects[dr]->spriteId; return 0; } diff --git a/engines/director/frame.h b/engines/director/frame.h index 29ae9dd596..b71afb795d 100644 --- a/engines/director/frame.h +++ b/engines/director/frame.h @@ -104,6 +104,11 @@ struct PaletteInfo { uint16 cycleCount; }; +struct FrameEntity { + uint16 spriteId; + Common::Rect rect; +}; + class Frame { public: @@ -131,6 +136,7 @@ private: void drawMatteSprite(Graphics::ManagedSurface &target, const Graphics::Surface &sprite, Common::Rect &drawRect); void drawGhostSprite(Graphics::ManagedSurface &target, const Graphics::Surface &sprite, Common::Rect &drawRect); void drawReverseSprite(Graphics::ManagedSurface &target, const Graphics::Surface &sprite, Common::Rect &drawRect); + void addDrawRect(uint16 entityId, Common::Rect &rect); public: byte _channelData[kChannelDataSize]; @@ -150,7 +156,7 @@ public: uint8 _skipFrameFlag; uint8 _blend; Common::Array<Sprite *> _sprites; - Common::HashMap<uint16, Common::Rect> _drawRects; + Common::Array<FrameEntity *> _drawRects; DirectorEngine *_vm; }; diff --git a/engines/director/score.cpp b/engines/director/score.cpp index fb384c2e6b..267536b5d2 100644 --- a/engines/director/score.cpp +++ b/engines/director/score.cpp @@ -935,8 +935,6 @@ void Score::update() { if (_vm->getVersion() >= 6) _lingo->processEvent(kEventPrepareFrame, _currentFrame); - _currentFrame++; - Common::SortedArray<Label *>::iterator i; if (_labels != NULL) { for (i = _labels->begin(); i != _labels->end(); ++i) { @@ -946,6 +944,8 @@ void Score::update() { } } + _currentFrame++; + _frames[_currentFrame]->prepareFrame(this); // Stage is drawn between the prepareFrame and enterFrame events (Lingo in a Nutshell) @@ -998,14 +998,19 @@ void Score::processEvents() { if (event.type == Common::EVENT_LBUTTONDOWN) { Common::Point pos = g_system->getEventManager()->getMousePos(); - // TODO there is dont send frame id - _lingo->processEvent(kEventMouseDown, _frames[_currentFrame]->getSpriteIDFromPos(pos)); + //TODO: check that this is the order of script execution! + uint16 spriteId = _frames[_currentFrame]->getSpriteIDFromPos(pos); + _lingo->processEvent(kEventMouseDown, _frames[_currentFrame]->_sprites[spriteId]->_castId); + _lingo->processEvent(kEventMouseDown, _frames[_currentFrame]->_sprites[spriteId]->_scriptId); } if (event.type == Common::EVENT_LBUTTONUP) { Common::Point pos = g_system->getEventManager()->getMousePos(); - _lingo->processEvent(kEventMouseUp, _frames[_currentFrame]->getSpriteIDFromPos(pos)); + //TODO: check that this is the order of script execution! + uint16 spriteId = _frames[_currentFrame]->getSpriteIDFromPos(pos); + _lingo->processEvent(kEventMouseUp, _frames[_currentFrame]->_sprites[spriteId]->_castId); + _lingo->processEvent(kEventMouseUp, _frames[_currentFrame]->_sprites[spriteId]->_scriptId); } if (event.type == Common::EVENT_KEYDOWN) { |