aboutsummaryrefslogtreecommitdiff
path: root/engines/zvision/scripting
diff options
context:
space:
mode:
authorFilippos Karapetis2014-12-16 00:48:16 +0200
committerFilippos Karapetis2014-12-16 01:58:55 +0200
commit7f61a094781256f7c2734aa08637494c1dfac6bf (patch)
tree2dd89d28d338daeb8bdf06e41bcc9e5768cf9885 /engines/zvision/scripting
parent67bd78a95f6efab6d0da4b3bef1b0cebc79c537c (diff)
downloadscummvm-rg350-7f61a094781256f7c2734aa08637494c1dfac6bf.tar.gz
scummvm-rg350-7f61a094781256f7c2734aa08637494c1dfac6bf.tar.bz2
scummvm-rg350-7f61a094781256f7c2734aa08637494c1dfac6bf.zip
ZVISION: Make the RLF decoder a subclass of the common video decoder
This way, the redundant MetaAnimation class can now be removed
Diffstat (limited to 'engines/zvision/scripting')
-rw-r--r--engines/zvision/scripting/controls/fist_control.cpp14
-rw-r--r--engines/zvision/scripting/controls/fist_control.h8
-rw-r--r--engines/zvision/scripting/controls/hotmov_control.cpp10
-rw-r--r--engines/zvision/scripting/controls/hotmov_control.h8
-rw-r--r--engines/zvision/scripting/controls/input_control.cpp14
-rw-r--r--engines/zvision/scripting/controls/input_control.h7
-rw-r--r--engines/zvision/scripting/controls/lever_control.cpp8
-rw-r--r--engines/zvision/scripting/controls/lever_control.h9
-rw-r--r--engines/zvision/scripting/controls/safe_control.cpp10
-rw-r--r--engines/zvision/scripting/controls/safe_control.h9
-rw-r--r--engines/zvision/scripting/sidefx/animation_node.cpp10
-rw-r--r--engines/zvision/scripting/sidefx/animation_node.h11
12 files changed, 64 insertions, 54 deletions
diff --git a/engines/zvision/scripting/controls/fist_control.cpp b/engines/zvision/scripting/controls/fist_control.cpp
index dd6a7f11a9..c3a69084f2 100644
--- a/engines/zvision/scripting/controls/fist_control.cpp
+++ b/engines/zvision/scripting/controls/fist_control.cpp
@@ -22,20 +22,19 @@
#include "common/scummsys.h"
-#include "zvision/scripting/controls/fist_control.h"
-
#include "zvision/zvision.h"
#include "zvision/scripting/script_manager.h"
+#include "zvision/scripting/controls/fist_control.h"
#include "zvision/graphics/render_manager.h"
#include "zvision/cursors/cursor_manager.h"
-#include "zvision/animation/meta_animation.h"
#include "zvision/utility/utility.h"
+#include "zvision/video/rlf_decoder.h"
#include "common/stream.h"
#include "common/file.h"
#include "common/system.h"
-
#include "graphics/surface.h"
+#include "video/video_decoder.h"
namespace ZVision {
@@ -106,7 +105,8 @@ void FistControl::renderFrame(uint frameNumber) {
const Graphics::Surface *frameData;
if (_animation) {
- frameData = _animation->getFrameData(frameNumber);
+ _animation->seekToFrame(frameNumber);
+ frameData = _animation->decodeNextFrame();
if (frameData)
_engine->getRenderManager()->blitSurfaceToBkgScaled(*frameData, _anmRect);
}
@@ -121,7 +121,7 @@ bool FistControl::process(uint32 deltaTimeInMillis) {
_frameTime -= deltaTimeInMillis;
if (_frameTime <= 0) {
- _frameTime = _animation->frameTime();
+ _frameTime = 1000.0 / _animation->getDuration().framerate();
renderFrame(_frameCur);
@@ -194,7 +194,7 @@ void FistControl::readDescFile(const Common::String &fileName) {
if (param.matchString("animation_id", true)) {
// Not used
} else if (param.matchString("animation", true)) {
- _animation = new MetaAnimation(values, _engine);
+ _animation = _engine->loadAnimation(values);
} else if (param.matchString("anim_rect", true)) {
int left, top, right, bottom;
sscanf(values.c_str(), "%d %d %d %d", &left, &top, &right, &bottom);
diff --git a/engines/zvision/scripting/controls/fist_control.h b/engines/zvision/scripting/controls/fist_control.h
index cb765c429a..0a6b977ead 100644
--- a/engines/zvision/scripting/controls/fist_control.h
+++ b/engines/zvision/scripting/controls/fist_control.h
@@ -28,9 +28,11 @@
#include "common/array.h"
#include "common/rect.h"
-namespace ZVision {
+namespace Video {
+ class VideoDecoder;
+}
-class MetaAnimation;
+namespace ZVision {
class FistControl : public Control {
public:
@@ -58,7 +60,7 @@ private:
Common::Array<entries> _entries;
- MetaAnimation *_animation;
+ Video::VideoDecoder *_animation;
Common::Rect _anmRect;
int32 _soundKey;
int32 _frameCur;
diff --git a/engines/zvision/scripting/controls/hotmov_control.cpp b/engines/zvision/scripting/controls/hotmov_control.cpp
index 68861dc221..dfa0200f47 100644
--- a/engines/zvision/scripting/controls/hotmov_control.cpp
+++ b/engines/zvision/scripting/controls/hotmov_control.cpp
@@ -28,14 +28,13 @@
#include "zvision/scripting/script_manager.h"
#include "zvision/graphics/render_manager.h"
#include "zvision/cursors/cursor_manager.h"
-#include "zvision/animation/meta_animation.h"
#include "zvision/utility/utility.h"
#include "common/stream.h"
#include "common/file.h"
#include "common/system.h"
-
#include "graphics/surface.h"
+#include "video/video_decoder.h"
namespace ZVision {
@@ -79,7 +78,7 @@ HotMovControl::HotMovControl(ZVision *engine, uint32 key, Common::SeekableReadSt
char filename[64];
sscanf(values.c_str(), "%s", filename);
values = Common::String(filename);
- _animation = new MetaAnimation(values, _engine);
+ _animation = _engine->loadAnimation(values);
} else if (param.matchString("venus_id", true)) {
_venusId = atoi(values.c_str());
}
@@ -106,7 +105,8 @@ void HotMovControl::renderFrame(uint frameNumber) {
const Graphics::Surface *frameData;
if (_animation) {
- frameData = _animation->getFrameData(frameNumber);
+ _animation->seekToFrame(frameNumber);
+ frameData = _animation->decodeNextFrame();
if (frameData)
_engine->getRenderManager()->blitSurfaceToBkgScaled(*frameData, _rectangle);
}
@@ -130,7 +130,7 @@ bool HotMovControl::process(uint32 deltaTimeInMillis) {
else
_engine->getScriptManager()->setStateValue(_key, 2);
- _frameTime = _animation->frameTime();
+ _frameTime = 1000.0 / _animation->getDuration().framerate();
}
}
diff --git a/engines/zvision/scripting/controls/hotmov_control.h b/engines/zvision/scripting/controls/hotmov_control.h
index 86600d65dc..b18d44c7a6 100644
--- a/engines/zvision/scripting/controls/hotmov_control.h
+++ b/engines/zvision/scripting/controls/hotmov_control.h
@@ -28,9 +28,11 @@
#include "common/array.h"
#include "common/rect.h"
-namespace ZVision {
+namespace Video {
+ class VideoDecoder;
+}
-class MetaAnimation;
+namespace ZVision {
class HotMovControl : public Control {
public:
@@ -44,7 +46,7 @@ private:
int32 _lastRenderedFrame;
int32 _cycle;
int32 _cyclesCount;
- MetaAnimation *_animation;
+ Video::VideoDecoder *_animation;
Common::Rect _rectangle;
Common::Array<Common::Rect> _frames;
public:
diff --git a/engines/zvision/scripting/controls/input_control.cpp b/engines/zvision/scripting/controls/input_control.cpp
index c541693ec3..60dcd37453 100644
--- a/engines/zvision/scripting/controls/input_control.cpp
+++ b/engines/zvision/scripting/controls/input_control.cpp
@@ -34,6 +34,7 @@
#include "common/str.h"
#include "common/stream.h"
#include "common/rect.h"
+#include "video/video_decoder.h"
namespace ZVision {
@@ -96,7 +97,7 @@ InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStre
sscanf(values.c_str(), "%25s %*u", fileName);
- _animation = new MetaAnimation(fileName, _engine);
+ _animation = _engine->loadAnimation(fileName);
_frame = -1;
_frameDelay = 0;
} else if (param.matchString("focus", true)) {
@@ -213,16 +214,17 @@ bool InputControl::process(uint32 deltaTimeInMillis) {
bool needDraw = true;// = _textChanged;
_frameDelay -= deltaTimeInMillis;
if (_frameDelay <= 0) {
- _frame = (_frame + 1) % _animation->frameCount();
- _frameDelay = _animation->frameTime();
+ _frame = (_frame + 1) % _animation->getFrameCount();
+ _frameDelay = 1000.0 / _animation->getDuration().framerate();
needDraw = true;
}
if (needDraw) {
- const Graphics::Surface *srf = _animation->getFrameData(_frame);
+ _animation->seekToFrame(_frame);
+ const Graphics::Surface *srf = _animation->decodeNextFrame();
uint32 xx = _textRectangle.left + _txtWidth;
- if (xx >= _textRectangle.left + (_textRectangle.width() - _animation->width()))
- xx = _textRectangle.left + _textRectangle.width() - _animation->width();
+ if (xx >= _textRectangle.left + (_textRectangle.width() - (int16)_animation->getWidth()))
+ xx = _textRectangle.left + _textRectangle.width() - (int16)_animation->getWidth();
_engine->getRenderManager()->blitSurfaceToBkg(*srf, xx, _textRectangle.top);
}
}
diff --git a/engines/zvision/scripting/controls/input_control.h b/engines/zvision/scripting/controls/input_control.h
index 410caf6d49..99f7f5287d 100644
--- a/engines/zvision/scripting/controls/input_control.h
+++ b/engines/zvision/scripting/controls/input_control.h
@@ -24,12 +24,15 @@
#define ZVISION_INPUT_CONTROL_H
#include "zvision/scripting/control.h"
-#include "zvision/animation/meta_animation.h"
#include "zvision/text/text.h"
#include "zvision/text/string_manager.h"
#include "common/rect.h"
+namespace Video {
+ class VideoDecoder;
+}
+
namespace ZVision {
class InputControl : public Control {
@@ -51,7 +54,7 @@ private:
bool _readOnly;
int16 _txtWidth;
- MetaAnimation *_animation;
+ Video::VideoDecoder *_animation;
int32 _frameDelay;
int16 _frame;
diff --git a/engines/zvision/scripting/controls/lever_control.cpp b/engines/zvision/scripting/controls/lever_control.cpp
index 1e4087963e..9566e4e038 100644
--- a/engines/zvision/scripting/controls/lever_control.cpp
+++ b/engines/zvision/scripting/controls/lever_control.cpp
@@ -28,15 +28,14 @@
#include "zvision/scripting/script_manager.h"
#include "zvision/graphics/render_manager.h"
#include "zvision/cursors/cursor_manager.h"
-#include "zvision/animation/meta_animation.h"
#include "zvision/utility/utility.h"
#include "common/stream.h"
#include "common/file.h"
#include "common/tokenizer.h"
#include "common/system.h"
-
#include "graphics/surface.h"
+#include "video/video_decoder.h"
namespace ZVision {
@@ -106,7 +105,7 @@ void LeverControl::parseLevFile(const Common::String &fileName) {
if (param.matchString("animation_id", true)) {
// Not used
} else if (param.matchString("filename", true)) {
- _animation = new MetaAnimation(values, _engine);
+ _animation = _engine->loadAnimation(values);
} else if (param.matchString("skipcolor", true)) {
// Not used
} else if (param.matchString("anim_coords", true)) {
@@ -374,7 +373,8 @@ void LeverControl::renderFrame(uint frameNumber) {
const Graphics::Surface *frameData;
- frameData = _animation->getFrameData(frameNumber);
+ _animation->seekToFrame(frameNumber);
+ frameData = _animation->decodeNextFrame();
if (frameData)
_engine->getRenderManager()->blitSurfaceToBkgScaled(*frameData, _animationCoords);
}
diff --git a/engines/zvision/scripting/controls/lever_control.h b/engines/zvision/scripting/controls/lever_control.h
index 37d4d3bd8d..fdf4a649dc 100644
--- a/engines/zvision/scripting/controls/lever_control.h
+++ b/engines/zvision/scripting/controls/lever_control.h
@@ -28,10 +28,11 @@
#include "common/list.h"
#include "common/rect.h"
-namespace ZVision {
+namespace Video {
+ class VideoDecoder;
+}
-class ZorkAVIDecoder;
-class MetaAnimation;
+namespace ZVision {
class LeverControl : public Control {
public:
@@ -59,7 +60,7 @@ private:
};
private:
- MetaAnimation *_animation;
+ Video::VideoDecoder *_animation;
int _cursor;
Common::Rect _animationCoords;
diff --git a/engines/zvision/scripting/controls/safe_control.cpp b/engines/zvision/scripting/controls/safe_control.cpp
index 3ad5d3a8ae..9f4e29acae 100644
--- a/engines/zvision/scripting/controls/safe_control.cpp
+++ b/engines/zvision/scripting/controls/safe_control.cpp
@@ -28,15 +28,14 @@
#include "zvision/scripting/script_manager.h"
#include "zvision/graphics/render_manager.h"
#include "zvision/cursors/cursor_manager.h"
-#include "zvision/animation/meta_animation.h"
#include "zvision/utility/utility.h"
#include "common/stream.h"
#include "common/file.h"
#include "common/tokenizer.h"
#include "common/system.h"
-
#include "graphics/surface.h"
+#include "video/video_decoder.h"
namespace ZVision {
@@ -65,7 +64,7 @@ SafeControl::SafeControl(ZVision *engine, uint32 key, Common::SeekableReadStream
while (!stream.eos() && !line.contains('}')) {
if (param.matchString("animation", true)) {
- _animation = new MetaAnimation(values, _engine);
+ _animation = _engine->loadAnimation(values);
} else if (param.matchString("rectangle", true)) {
int x;
int y;
@@ -129,7 +128,8 @@ void SafeControl::renderFrame(uint frameNumber) {
int x = _rectangle.left;
int y = _rectangle.top;
- frameData = _animation->getFrameData(frameNumber);
+ _animation->seekToFrame(frameNumber);
+ frameData = _animation->decodeNextFrame();
if (frameData)
_engine->getRenderManager()->blitSurfaceToBkg(*frameData, x, y);
}
@@ -149,7 +149,7 @@ bool SafeControl::process(uint32 deltaTimeInMillis) {
_curFrame--;
renderFrame(_curFrame);
}
- _frameTime = _animation->frameTime();
+ _frameTime = 1000.0 / _animation->getDuration().framerate();
}
}
return false;
diff --git a/engines/zvision/scripting/controls/safe_control.h b/engines/zvision/scripting/controls/safe_control.h
index e32ca97b70..6e1095e304 100644
--- a/engines/zvision/scripting/controls/safe_control.h
+++ b/engines/zvision/scripting/controls/safe_control.h
@@ -28,10 +28,11 @@
#include "common/list.h"
#include "common/rect.h"
-namespace ZVision {
+namespace Video {
+ class VideoDecoder;
+}
-class ZorkAVIDecoder;
-class MetaAnimation;
+namespace ZVision {
class SafeControl : public Control {
public:
@@ -41,7 +42,7 @@ public:
private:
int16 _statesCount;
int16 _curState;
- MetaAnimation *_animation;
+ Video::VideoDecoder *_animation;
Common::Point _center;
Common::Rect _rectangle;
int16 _innerRaduis;
diff --git a/engines/zvision/scripting/sidefx/animation_node.cpp b/engines/zvision/scripting/sidefx/animation_node.cpp
index 74e4cadbe9..e15f8ec00f 100644
--- a/engines/zvision/scripting/sidefx/animation_node.cpp
+++ b/engines/zvision/scripting/sidefx/animation_node.cpp
@@ -27,9 +27,9 @@
#include "zvision/zvision.h"
#include "zvision/graphics/render_manager.h"
#include "zvision/scripting/script_manager.h"
-#include "zvision/animation/meta_animation.h"
#include "graphics/surface.h"
+#include "video/video_decoder.h"
namespace ZVision {
@@ -39,8 +39,8 @@ AnimationNode::AnimationNode(ZVision *engine, uint32 controlKey, const Common::S
_mask(mask),
_animation(NULL) {
- _animation = new MetaAnimation(fileName, engine);
- _frmDelay = _animation->frameTime();
+ _animation = engine->loadAnimation(fileName);
+ _frmDelay = 1000.0 / _animation->getDuration().framerate();
if (frate > 0)
_frmDelay = 1000.0 / frate;
@@ -164,8 +164,8 @@ void AnimationNode::addPlayNode(int32 slot, int x, int y, int x2, int y2, int st
nod.start = startFrame;
nod.stop = endFrame;
- if (nod.stop >= (int)_animation->frameCount())
- nod.stop = _animation->frameCount() - 1;
+ if (nod.stop >= (int)_animation->getFrameCount())
+ nod.stop = _animation->getFrameCount() - 1;
nod.slot = slot;
nod._curFrame = -1;
diff --git a/engines/zvision/scripting/sidefx/animation_node.h b/engines/zvision/scripting/sidefx/animation_node.h
index 94428d2542..3adfd91f32 100644
--- a/engines/zvision/scripting/sidefx/animation_node.h
+++ b/engines/zvision/scripting/sidefx/animation_node.h
@@ -27,18 +27,17 @@
#include "common/rect.h"
#include "common/list.h"
-namespace Common {
-class String;
-}
-
namespace Graphics {
struct Surface;
}
+namespace Video {
+ class VideoDecoder;
+}
+
namespace ZVision {
class ZVision;
-class MetaAnimation;
class AnimationNode : public SideFX {
public:
@@ -64,7 +63,7 @@ private:
int32 _mask;
bool _DisposeAfterUse;
- MetaAnimation *_animation;
+ Video::VideoDecoder *_animation;
int32 _frmDelay;
public: