aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarisa-Chan2014-01-17 16:52:26 +0700
committerMarisa-Chan2014-01-17 16:52:26 +0700
commit3a1fda6d5760b25acb3bb561b567f6402685bcc6 (patch)
tree853d47b4f6b0cb460cf91b19615ab9f1a4455d41
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.
-rw-r--r--engines/zvision/meta_animation.cpp129
-rw-r--r--engines/zvision/meta_animation.h98
-rw-r--r--engines/zvision/module.mk3
3 files changed, 229 insertions, 1 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
diff --git a/engines/zvision/meta_animation.h b/engines/zvision/meta_animation.h
new file mode 100644
index 0000000000..fea7a6a6c1
--- /dev/null
+++ b/engines/zvision/meta_animation.h
@@ -0,0 +1,98 @@
+/* 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.
+ *
+ */
+
+#ifndef ZVISION_METAANIM_NODE_H
+#define ZVISION_METAANIM_NODE_H
+
+#include "zvision/sidefx.h"
+#include "common/rect.h"
+#include "common/list.h"
+
+
+namespace Common {
+class String;
+}
+
+namespace Video {
+class VideoDecoder;
+}
+
+namespace Graphics {
+struct Surface;
+}
+
+namespace ZVision {
+
+class ZVision;
+class RlfAnimation;
+
+class MetaAnimation {
+public:
+ MetaAnimation(const Common::String &fileName);
+ ~MetaAnimation();
+
+ struct playnode {
+ Common::Rect pos;
+ int32 slot;
+ int32 start;
+ int32 stop;
+ int32 loop;
+ int32 _cur_frm;
+ int32 _delay;
+ Graphics::Surface *_scaled;
+ };
+
+private:
+ enum FileType {
+ RLF = 1,
+ AVI = 2
+ };
+
+private:
+ union {
+ RlfAnimation *rlf;
+ Video::VideoDecoder *avi;
+ } _animation;
+
+ FileType _fileType;
+ int32 _frmDelay;
+
+ const Graphics::Surface *_cur_frame;
+
+public:
+
+ uint frameCount();
+ uint width();
+ uint height();
+ uint32 frameTime();
+
+ void seekToFrame(int frameNumber);
+
+ const Graphics::Surface *decodeNextFrame();
+ const Graphics::Surface *getFrameData(uint frameNumber);
+
+ bool endOfAnimation();
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index af90923f9a..62a1293663 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -34,7 +34,8 @@ MODULE_OBJS := \
music_node.o \
inventory_manager.o \
slot_control.o \
- menu.o
+ menu.o \
+ meta_animation.o
MODULE_DIRS += \
engines/zvision