From f8d64ae6bc47c0d1ea6efea45c28dd4902780ecb Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 15 Aug 2014 20:26:09 -0400 Subject: ACCESS: Added code to update animations each frame --- engines/access/animation.cpp | 7 +++++++ engines/access/animation.h | 17 ++++++++++++++--- engines/access/events.cpp | 19 ++++++++++++------- engines/access/events.h | 2 ++ 4 files changed, 35 insertions(+), 10 deletions(-) (limited to 'engines') diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp index 4965f41105..31e53e5cf0 100644 --- a/engines/access/animation.cpp +++ b/engines/access/animation.cpp @@ -331,4 +331,11 @@ void AnimationManager::animate(int animId) { anim->animate(); } +void AnimationManager::updateTimers() { + for (uint idx = 0; idx < _animationTimers.size(); ++idx) { + if (_animationTimers[idx]->_countdownTicks > 0) + _animationTimers[idx]->_countdownTicks--; + } +} + } // End of namespace Access diff --git a/engines/access/animation.h b/engines/access/animation.h index c1b44a5621..f70aa3239d 100644 --- a/engines/access/animation.h +++ b/engines/access/animation.h @@ -49,14 +49,25 @@ public: void freeAnimationData(); void loadAnimations(const byte *data, int size); - void clearTimers(); - Animation *findAnimation(int animId); Animation *setAnimation(int animId); + void animate(int animId); + + /** + * Clear the list of currently active animations + */ + void clearTimers(); + + /** + * Add an animation to the list of currently animating ones + */ void setAnimTimer(Animation *anim); - void animate(int animId); + /** + * Update the timing of all currently active animation + */ + void updateTimers(); }; class AnimationResource { diff --git a/engines/access/events.cpp b/engines/access/events.cpp index 88e783e6d2..db69f7ba2d 100644 --- a/engines/access/events.cpp +++ b/engines/access/events.cpp @@ -144,15 +144,20 @@ void EventsManager::checkForNextFrameCounter() { ++_frameCounter; _priorFrameTime = milli; - // Give time to the debugger - _vm->_debugger->onFrame(); + nextFrame(); + } +} - // Signal the ScummVM debugger - _vm->_debugger->onFrame(); +void EventsManager::nextFrame() { - // TODO: Refactor for dirty rects - _vm->_screen->updateScreen(); - } + // Give time to the debugger + _vm->_debugger->onFrame(); + + // Update timers + _vm->_animation->updateTimers(); + + // TODO: Refactor for dirty rects + _vm->_screen->updateScreen(); } void EventsManager::delay(int time) { diff --git a/engines/access/events.h b/engines/access/events.h index aa01543381..c3faf6333b 100644 --- a/engines/access/events.h +++ b/engines/access/events.h @@ -47,6 +47,8 @@ private: uint32 _priorFrameTime; void checkForNextFrameCounter(); + + void nextFrame(); public: CursorType _cursorId; bool _leftButton; -- cgit v1.2.3