diff options
author | Paul Gilbert | 2014-04-07 22:37:22 -0400 |
---|---|---|
committer | Paul Gilbert | 2014-04-07 22:37:22 -0400 |
commit | 7e13f488abeb6a7530d591bae880fdb185c8fef1 (patch) | |
tree | f761b8479267909be151dbefe0f4f7176b23b3c1 /engines/mads/user_interface.cpp | |
parent | f6a6ea974117cd8401a2caecdba9ef553821d41a (diff) | |
download | scummvm-rg350-7e13f488abeb6a7530d591bae880fdb185c8fef1.tar.gz scummvm-rg350-7e13f488abeb6a7530d591bae880fdb185c8fef1.tar.bz2 scummvm-rg350-7e13f488abeb6a7530d591bae880fdb185c8fef1.zip |
MADS: Implement loading logic for UI background animations
Diffstat (limited to 'engines/mads/user_interface.cpp')
-rw-r--r-- | engines/mads/user_interface.cpp | 76 |
1 files changed, 75 insertions, 1 deletions
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp index c371f3d837..d7f198f3ce 100644 --- a/engines/mads/user_interface.cpp +++ b/engines/mads/user_interface.cpp @@ -48,7 +48,7 @@ void UISlots::add(const Common::Point &pt, int frameNumber, int spritesIndex) { assert(size() < 50); UISlot ie; - ie._flags = -3; + ie._flags = IMG_OVERPRINT; ie._segmentId = IMG_TEXT_UPDATE; ie._position = pt; ie._frameNumber = frameNumber; @@ -57,6 +57,20 @@ void UISlots::add(const Common::Point &pt, int frameNumber, int spritesIndex) { push_back(ie); } +void UISlots::add(const AnimFrameEntry &frameEntry) { + assert(size() < 50); + + UISlot ie; + ie._flags = IMG_UPDATE; + ie._segmentId = frameEntry._seqIndex; + ie._spritesIndex = frameEntry._spriteSlot._spritesIndex; + ie._frameNumber = frameEntry._frameNumber; + ie._position = frameEntry._spriteSlot._position; + + push_back(ie); +} + + void UISlots::draw(bool updateFlag, bool delFlag) { Scene &scene = _vm->_game->_scene; UserInterface &userInterface = scene._userInterface; @@ -633,6 +647,66 @@ void UserInterface::inventoryAnim() { _uiSlots.push_back(slot); } +void UserInterface::doBackgroundAnimation() { + Scene &scene = _vm->_game->_scene; + Common::Array<AnimUIEntry> &uiEntries = scene._animationData->_uiEntries; + Common::Array<AnimFrameEntry> &frameEntries = scene._animationData->_frameEntries; + + _noSegmentsActive = !_someSegmentsActive; + _someSegmentsActive = false; + + for (int idx = 0; idx < uiEntries.size(); ++idx) { + AnimUIEntry &uiEntry = uiEntries[idx]; + + if (uiEntry._counter < 0) { + if (uiEntry._counter == -1) { + int probabilityRandom = _vm->getRandomNumber(1, 30000); + int probability = uiEntry._probability; + if (uiEntry._probability > 30000) { + if (_noSegmentsActive) { + probability -= 30000; + } else { + probability = -1; + } + } + if (probabilityRandom <= probability) { + uiEntry._counter = uiEntry._firstImage; + _someSegmentsActive = true; + } + } else { + uiEntry._counter = uiEntry._firstImage; + _someSegmentsActive = true; + } + } else { + for (int idx2 = 0; idx2 < ANIM_SPAWN_COUNT; idx2++) { + if (uiEntry._spawnFrame[idx2] == (uiEntry._counter - uiEntry._firstImage)) { + int tempIndex = uiEntry._spawn[idx2]; + if (idx >= tempIndex) { + uiEntries[tempIndex]._counter = uiEntries[tempIndex]._firstImage; + } else { + uiEntries[tempIndex]._counter = -2; + } + _someSegmentsActive = true; + } + } + + ++uiEntry._counter; + if (uiEntry._counter > uiEntry._lastImage) { + uiEntry._counter = -1; + } else { + _someSegmentsActive = true; + } + } + } + + for (int idx = 0; idx < uiEntries.size(); ++idx) { + int imgScan = uiEntries[idx]._counter; + if (imgScan >= 0) { + _uiSlots.add(frameEntries[imgScan]); + } + } +} + void UserInterface::categoryChanged() { _highlightedItemIndex = -1; _vm->_events->initVars(); |