Unified
Split
Showing
with
34 additions
and 1 deletion.
- +4 −0 engines/director/events.cpp
- +9 −0 engines/director/frame.cpp
- +1 −0 engines/director/frame.h
- +17 −1 engines/director/score.cpp
- +3 −0 engines/director/score.h
| @@ -75,6 +75,10 @@ void DirectorEngine::processEvents() { | ||
| _lingo->processEvent(kEventMouseDown, kCastScript, currentFrame->_sprites[spriteId]->_castId); | ||
| _lingo->processEvent(kEventMouseDown, kSpriteScript, currentFrame->_sprites[spriteId]->_scriptId); | ||
| } | ||
|
|
||
| if (currentFrame->_sprites[spriteId]->_moveable) { | ||
| warning("Moveable"); | ||
| } | ||
| break; | ||
|
|
||
| case Common::EVENT_LBUTTONUP: | ||
| @@ -36,6 +36,7 @@ | ||
| #include "director/score.h" | ||
| #include "director/sprite.h" | ||
| #include "director/util.h" | ||
| #include "director/lingo/lingo.h" | ||
|
|
||
| namespace Director { | ||
|
|
||
| @@ -539,6 +540,14 @@ void Frame::playTransition(Score *score) { | ||
| } | ||
| } | ||
|
|
||
| void Frame::executeImmediateScripts() { | ||
| for (uint16 i = 0; i < CHANNEL_COUNT; i++) { | ||
| if (_vm->getCurrentScore()->_immediateActions.contains(_sprites[i]->_scriptId)) { | ||
| g_lingo->processEvent(kEventMouseUp, kFrameScript, _sprites[i]->_scriptId); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| void Frame::renderSprites(Graphics::ManagedSurface &surface, bool renderTrail) { | ||
| for (uint16 i = 0; i < CHANNEL_COUNT; i++) { | ||
| if (_sprites[i]->_enabled) { | ||
| @@ -121,6 +121,7 @@ class Frame { | ||
| uint16 getSpriteIDFromPos(Common::Point pos); | ||
| bool checkSpriteIntersection(uint16 spriteId, Common::Point pos); | ||
|
|
||
| void executeImmediateScripts(); | ||
|
|
||
| private: | ||
| void playTransition(Score *score); | ||
| @@ -693,8 +693,22 @@ void Score::loadActions(Common::SeekableSubReadStreamEndian &stream) { | ||
| } | ||
|
|
||
| for (j = _actions.begin(); j != _actions.end(); ++j) | ||
| if (!j->_value.empty()) | ||
| if (!j->_value.empty()) { | ||
| _lingo->addCode(j->_value.c_str(), kFrameScript, j->_key); | ||
|
|
||
| processImmediateFrameScript(j->_value, j->_key); | ||
| } | ||
| } | ||
|
|
||
| bool Score::processImmediateFrameScript(Common::String s, int id) { | ||
| s.trim(); | ||
|
|
||
| // In D2/D3 this specifies immediately the sprite/field properties | ||
| if (!s.compareToIgnoreCase("moveableSprite") || !s.compareToIgnoreCase("editableText")) { | ||
| _immediateActions[id] = true; | ||
| } | ||
|
|
||
| return false; | ||
| } | ||
|
|
||
| void Score::loadScriptText(Common::SeekableSubReadStreamEndian &stream) { | ||
| @@ -1047,6 +1061,8 @@ void Score::update() { | ||
| _surface->clear(); | ||
| _surface->copyFrom(*_trailSurface); | ||
|
|
||
| _frames[_currentFrame]->executeImmediateScripts(); | ||
|
|
||
| // Enter and exit from previous frame (Director 4) | ||
| _lingo->processEvent(kEventEnterFrame, kFrameScript, _frames[_currentFrame]->_actionId); | ||
| _lingo->processEvent(kEventExitFrame, kFrameScript, _frames[_currentFrame]->_actionId); | ||
| @@ -106,13 +106,16 @@ class Score { | ||
| Common::String getString(Common::String str); | ||
| Common::Array<Common::String> loadStrings(Common::SeekableSubReadStreamEndian &stream, uint32 &entryType, bool hasHeader = true); | ||
|
|
||
| bool processImmediateFrameScript(Common::String s, int id); | ||
|
|
||
| public: | ||
| Common::Array<Frame *> _frames; | ||
| Common::HashMap<int, CastType> _castTypes; | ||
| Common::HashMap<uint16, CastInfo *> _castsInfo; | ||
| Common::HashMap<Common::String, int> _castsNames; | ||
| Common::SortedArray<Label *> *_labels; | ||
| Common::HashMap<uint16, Common::String> _actions; | ||
| Common::HashMap<uint16, bool> _immediateActions; | ||
| Common::HashMap<uint16, Common::String> _fontMap; | ||
| Graphics::ManagedSurface *_surface; | ||
| Graphics::ManagedSurface *_trailSurface; | ||