aboutsummaryrefslogtreecommitdiff
path: root/engines/zvision/meta_animation.cpp
diff options
context:
space:
mode:
authorMarisa-Chan2014-01-17 16:52:26 +0700
committerMarisa-Chan2014-01-17 16:52:26 +0700
commit3a1fda6d5760b25acb3bb561b567f6402685bcc6 (patch)
tree853d47b4f6b0cb460cf91b19615ab9f1a4455d41 /engines/zvision/meta_animation.cpp
parent7b7ae43f7fe30782201fba691beee1bad18db60a (diff)
downloadscummvm-rg350-3a1fda6d5760b25acb3bb561b567f6402685bcc6.tar.gz
scummvm-rg350-3a1fda6d5760b25acb3bb561b567f6402685bcc6.tar.bz2
scummvm-rg350-3a1fda6d5760b25acb3bb561b567f6402685bcc6.zip
ZVISION: New class for handle rlf and avi animations.
Diffstat (limited to 'engines/zvision/meta_animation.cpp')
-rw-r--r--engines/zvision/meta_animation.cpp129
1 files changed, 129 insertions, 0 deletions
diff --git a/engines/zvision/meta_animation.cpp b/engines/zvision/meta_animation.cpp
new file mode 100644
index 0000000000..430b1436cb
--- /dev/null
+++ b/engines/zvision/meta_animation.cpp
@@ -0,0 +1,129 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/scummsys.h"
+
+#include "zvision/meta_animation.h"
+
+#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 "graphics/surface.h"
+
+
+namespace ZVision {
+
+MetaAnimation::MetaAnimation(const Common::String &fileName)
+ : _fileType(RLF),
+ _cur_frame(NULL) {
+ 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();
+ } else {
+ warning("Unrecognized animation file type: %s", fileName.c_str());
+ }
+}
+
+MetaAnimation::~MetaAnimation() {
+ if (_fileType == RLF) {
+ delete _animation.rlf;
+ } else if (_fileType == AVI) {
+ delete _animation.avi;
+ }
+}
+
+uint MetaAnimation::frameCount() {
+ if (_fileType == RLF) {
+ return _animation.rlf->frameCount();
+ } else
+ return _animation.avi->getFrameCount();
+
+}
+
+uint MetaAnimation::width() {
+ if (_fileType == RLF) {
+ return _animation.rlf->width();
+ } else
+ return _animation.avi->getWidth();
+}
+uint MetaAnimation::height() {
+ if (_fileType == RLF) {
+ return _animation.rlf->height();
+ } else
+ return _animation.avi->getHeight();
+}
+uint32 MetaAnimation::frameTime() {
+ return _frmDelay;
+}
+
+void MetaAnimation::seekToFrame(int frameNumber) {
+ if (frameNumber >= (int)frameCount())
+ frameNumber = frameCount() - 1;
+
+ if (_fileType == RLF) {
+ _animation.rlf->seekToFrame(frameNumber);
+ } else
+ _animation.avi->seekToFrame(frameNumber);
+}
+
+const Graphics::Surface *MetaAnimation::decodeNextFrame() {
+ if (_fileType == RLF)
+ _cur_frame = _animation.rlf->decodeNextFrame();
+ else
+ _cur_frame = _animation.avi->decodeNextFrame();
+
+ return _cur_frame;
+}
+
+const Graphics::Surface *MetaAnimation::getFrameData(uint frameNumber) {
+ if (frameNumber >= frameCount())
+ frameNumber = frameCount() - 1;
+
+ if (_fileType == RLF) {
+ _cur_frame = _animation.rlf->getFrameData(frameNumber);
+ return _cur_frame;
+ } else {
+ _animation.avi->seekToFrame(frameNumber);
+ _cur_frame = _animation.avi->decodeNextFrame();
+ return _cur_frame;
+ }
+}
+
+bool MetaAnimation::endOfAnimation() {
+ if (_fileType == RLF) {
+ return _animation.rlf->endOfAnimation();
+ } else
+ return _animation.avi->endOfVideo();
+}
+
+} // End of namespace ZVision