diff options
author | Marisa-Chan | 2014-01-17 16:54:59 +0700 |
---|---|---|
committer | Marisa-Chan | 2014-01-17 16:54:59 +0700 |
commit | ff2a20889cfead5075c252dd5cdcdba658a40844 (patch) | |
tree | 9c85c5203d99c1217b98466e6a136efee0937cce /engines | |
parent | 3a1fda6d5760b25acb3bb561b567f6402685bcc6 (diff) | |
download | scummvm-rg350-ff2a20889cfead5075c252dd5cdcdba658a40844.tar.gz scummvm-rg350-ff2a20889cfead5075c252dd5cdcdba658a40844.tar.bz2 scummvm-rg350-ff2a20889cfead5075c252dd5cdcdba658a40844.zip |
ZVISION: Move code of animation_node to use meta_animation.
Diffstat (limited to 'engines')
-rw-r--r-- | engines/zvision/animation_node.cpp | 65 | ||||
-rw-r--r-- | engines/zvision/animation_node.h | 22 |
2 files changed, 23 insertions, 64 deletions
diff --git a/engines/zvision/animation_node.cpp b/engines/zvision/animation_node.cpp index 27ee873f98..11275b5c7d 100644 --- a/engines/zvision/animation_node.cpp +++ b/engines/zvision/animation_node.cpp @@ -27,10 +27,7 @@ #include "zvision/zvision.h" #include "zvision/render_manager.h" #include "zvision/script_manager.h" -#include "zvision/rlf_animation.h" -#include "zvision/zork_avi_decoder.h" - -#include "video/video_decoder.h" +#include "zvision/meta_animation.h" #include "graphics/surface.h" @@ -39,18 +36,13 @@ namespace ZVision { AnimationNode::AnimationNode(ZVision *engine, uint32 controlKey, const Common::String &fileName, int32 mask, int32 frate, bool DisposeAfterUse) : SideFX(engine, controlKey, SIDEFX_ANIM), - _fileType(RLF), _DisposeAfterUse(DisposeAfterUse), - _mask(mask) { - if (fileName.hasSuffix(".rlf")) { - _fileType = RLF; - _animation.rlf = new RlfAnimation(fileName, false); - _frmDelay = _animation.rlf->frameTime(); - } else if (fileName.hasSuffix(".avi")) { - _fileType = AVI; - _animation.avi = new ZorkAVIDecoder(); - _animation.avi->loadFile(fileName); - _frmDelay = 1000.0 / _animation.avi->getDuration().framerate(); + _mask(mask), + _animation(NULL) { + + if (fileName.hasSuffix(".rlf") || fileName.hasSuffix(".avi")) { + _animation = new MetaAnimation(fileName); + _frmDelay = _animation->frameTime(); } else { warning("Unrecognized animation file type: %s", fileName.c_str()); } @@ -60,11 +52,8 @@ AnimationNode::AnimationNode(ZVision *engine, uint32 controlKey, const Common::S } AnimationNode::~AnimationNode() { - if (_fileType == RLF) { - delete _animation.rlf; - } else if (_fileType == AVI) { - delete _animation.avi; - } + if (_animation) + delete _animation; _engine->getScriptManager()->setStateValue(_key, 2); @@ -92,13 +81,9 @@ bool AnimationNode::process(uint32 deltaTimeInMillis) { if (nod->_cur_frm == -1) { // Start of new playlist node nod->_cur_frm = nod->start; - if (_fileType == RLF) { - _animation.rlf->seekToFrame(nod->_cur_frm); - frame = _animation.rlf->decodeNextFrame(); - } else if (_fileType == AVI) { - _animation.avi->seekToFrame(nod->_cur_frm); - frame = _animation.avi->decodeNextFrame(); - } + + _animation->seekToFrame(nod->_cur_frm); + frame = _animation->decodeNextFrame(); nod->_delay = _frmDelay; if (nod->slot) @@ -119,19 +104,10 @@ bool AnimationNode::process(uint32 deltaTimeInMillis) { } nod->_cur_frm = nod->start; - if (_fileType == RLF) { - _animation.rlf->seekToFrame(nod->_cur_frm); - frame = _animation.rlf->decodeNextFrame(); - } else if (_fileType == AVI) { - _animation.avi->seekToFrame(nod->_cur_frm); - frame = _animation.avi->decodeNextFrame(); - } - } else { - if (_fileType == RLF) - frame = _animation.rlf->decodeNextFrame(); - else if (_fileType == AVI) - frame = _animation.avi->decodeNextFrame(); + _animation->seekToFrame(nod->_cur_frm); } + + frame = _animation->decodeNextFrame(); } if (frame) { @@ -190,13 +166,10 @@ void AnimationNode::addPlayNode(int32 slot, int x, int y, int x2, int y2, int st nod.pos = Common::Rect(x, y, x2 + 1, y2 + 1); nod.start = start_frame; nod.stop = end_frame; - if (_fileType == RLF) { - if (nod.stop >= (int)_animation.rlf->frameCount()) - nod.stop = _animation.rlf->frameCount() - 1; - } else if (_fileType == AVI) { - if (nod.stop > (int)_animation.avi->getFrameCount()) - nod.stop = _animation.avi->getFrameCount(); - } + + if (nod.stop >= (int)_animation->frameCount()) + nod.stop = _animation->frameCount() - 1; + nod.slot = slot; nod._cur_frm = -1; nod._delay = 0; diff --git a/engines/zvision/animation_node.h b/engines/zvision/animation_node.h index 843e59236b..556ab8a51f 100644 --- a/engines/zvision/animation_node.h +++ b/engines/zvision/animation_node.h @@ -32,10 +32,6 @@ namespace Common { class String; } -namespace Video { -class VideoDecoder; -} - namespace Graphics { struct Surface; } @@ -43,7 +39,7 @@ struct Surface; namespace ZVision { class ZVision; -class RlfAnimation; +class MetaAnimation; class AnimationNode : public SideFX { public: @@ -62,26 +58,16 @@ public: }; private: - enum FileType { - RLF = 1, - AVI = 2 - }; - -private: typedef Common::List<playnode> PlayNodes; PlayNodes _playList; - union { - RlfAnimation *rlf; - Video::VideoDecoder *avi; - } _animation; - - FileType _fileType; - int32 _frmDelay; int32 _mask; bool _DisposeAfterUse; + MetaAnimation *_animation; + int32 _frmDelay; + public: bool process(uint32 deltaTimeInMillis); |