[Scummvm-cvs-logs] scummvm master -> 68d3ebd57b0313e517032681a119b47956803e71
RichieSams
adastley at gmail.com
Tue Dec 30 08:11:28 CET 2014
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
68d3ebd57b ZVISION: Rename some scripting classes to better represent what the classes are
Commit: 68d3ebd57b0313e517032681a119b47956803e71
https://github.com/scummvm/scummvm/commit/68d3ebd57b0313e517032681a119b47956803e71
Author: RichieSams (adastley at gmail.com)
Date: 2014-12-30T01:10:36-06:00
Commit Message:
ZVISION: Rename some scripting classes to better represent what the classes are
Also, rename the graphics 'Effect' class in order to avoid naming clashes (and/or coder
confusion) with the newly named ScriptingEffect class.
Lastly, add some documentation for the classes for further clarity.
Changed paths:
A engines/zvision/graphics/graphics_effect.h
A engines/zvision/scripting/effects/animation_effect.cpp
A engines/zvision/scripting/effects/animation_effect.h
A engines/zvision/scripting/effects/distort_effect.cpp
A engines/zvision/scripting/effects/distort_effect.h
A engines/zvision/scripting/effects/music_effect.cpp
A engines/zvision/scripting/effects/music_effect.h
A engines/zvision/scripting/effects/region_effect.cpp
A engines/zvision/scripting/effects/region_effect.h
A engines/zvision/scripting/effects/syncsound_effect.cpp
A engines/zvision/scripting/effects/syncsound_effect.h
A engines/zvision/scripting/effects/timer_effect.cpp
A engines/zvision/scripting/effects/timer_effect.h
A engines/zvision/scripting/effects/ttytext_effect.cpp
A engines/zvision/scripting/effects/ttytext_effect.h
A engines/zvision/scripting/scripting_effect.h
R engines/zvision/graphics/effect.h
R engines/zvision/scripting/sidefx.h
R engines/zvision/scripting/sidefx/animation_node.cpp
R engines/zvision/scripting/sidefx/animation_node.h
R engines/zvision/scripting/sidefx/distort_node.cpp
R engines/zvision/scripting/sidefx/distort_node.h
R engines/zvision/scripting/sidefx/music_node.cpp
R engines/zvision/scripting/sidefx/music_node.h
R engines/zvision/scripting/sidefx/region_node.cpp
R engines/zvision/scripting/sidefx/region_node.h
R engines/zvision/scripting/sidefx/syncsound_node.cpp
R engines/zvision/scripting/sidefx/syncsound_node.h
R engines/zvision/scripting/sidefx/timer_node.cpp
R engines/zvision/scripting/sidefx/timer_node.h
R engines/zvision/scripting/sidefx/ttytext_node.cpp
R engines/zvision/scripting/sidefx/ttytext_node.h
engines/zvision/graphics/effects/fog.cpp
engines/zvision/graphics/effects/fog.h
engines/zvision/graphics/effects/light.cpp
engines/zvision/graphics/effects/light.h
engines/zvision/graphics/effects/wave.cpp
engines/zvision/graphics/effects/wave.h
engines/zvision/graphics/render_manager.cpp
engines/zvision/graphics/render_manager.h
engines/zvision/module.mk
engines/zvision/scripting/actions.cpp
engines/zvision/scripting/control.h
engines/zvision/scripting/script_manager.cpp
engines/zvision/scripting/script_manager.h
diff --git a/engines/zvision/graphics/effect.h b/engines/zvision/graphics/effect.h
deleted file mode 100644
index 234cd82..0000000
--- a/engines/zvision/graphics/effect.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/* 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 EFFECT_H_INCLUDED
-#define EFFECT_H_INCLUDED
-
-#include "common/rect.h"
-#include "common/list.h"
-#include "graphics/surface.h"
-
-#include "zvision/zvision.h"
-
-namespace ZVision {
-
-class ZVision;
-
-class Effect {
-public:
-
- Effect(ZVision *engine, uint32 key, Common::Rect region, bool ported) : _engine(engine), _key(key), _region(region), _ported(ported) {
- _surface.create(_region.width(), _region.height(), _engine->_resourcePixelFormat);
- }
- virtual ~Effect() {}
-
- uint32 getKey() {
- return _key;
- }
-
- Common::Rect getRegion() {
- return _region;
- }
-
- bool isPort() {
- return _ported;
- }
-
- virtual const Graphics::Surface *draw(const Graphics::Surface &srcSubRect) {
- return &_surface;
- }
-
- virtual void update() {}
-
-protected:
- ZVision *_engine;
- uint32 _key;
- Common::Rect _region;
- bool _ported;
- Graphics::Surface _surface;
-
-// Static member functions
-public:
-
-};
-
-struct EffectMapUnit {
- uint32 count;
- bool inEffect;
-};
-
-typedef Common::List<EffectMapUnit> EffectMap;
-
-} // End of namespace ZVision
-
-#endif // EFFECT_H_INCLUDED
diff --git a/engines/zvision/graphics/effects/fog.cpp b/engines/zvision/graphics/effects/fog.cpp
index c28bdde..32a0191 100644
--- a/engines/zvision/graphics/effects/fog.cpp
+++ b/engines/zvision/graphics/effects/fog.cpp
@@ -31,7 +31,7 @@
namespace ZVision {
FogFx::FogFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, EffectMap *Map, const Common::String &clouds):
- Effect(engine, key, region, ported) {
+ GraphicsEffect(engine, key, region, ported) {
_map = Map;
diff --git a/engines/zvision/graphics/effects/fog.h b/engines/zvision/graphics/effects/fog.h
index fe88707..4983476 100644
--- a/engines/zvision/graphics/effects/fog.h
+++ b/engines/zvision/graphics/effects/fog.h
@@ -23,14 +23,14 @@
#ifndef ZVISION_FOG_H
#define ZVISION_FOG_H
-#include "zvision/graphics/effect.h"
+#include "zvision/graphics/graphics_effect.h"
namespace ZVision {
class ZVision;
// Used by Zork: Nemesis for the mixing chamber gas effect in the gas puzzle (location tt5e, when the blinds are down)
-class FogFx : public Effect {
+class FogFx : public GraphicsEffect {
public:
FogFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, EffectMap *Map, const Common::String &clouds);
diff --git a/engines/zvision/graphics/effects/light.cpp b/engines/zvision/graphics/effects/light.cpp
index bf65132..3934168 100644
--- a/engines/zvision/graphics/effects/light.cpp
+++ b/engines/zvision/graphics/effects/light.cpp
@@ -30,7 +30,7 @@
namespace ZVision {
LightFx::LightFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, EffectMap *Map, int8 delta, int8 minD, int8 maxD):
- Effect(engine, key, region, ported) {
+ GraphicsEffect(engine, key, region, ported) {
_map = Map;
_delta = delta;
_up = true;
diff --git a/engines/zvision/graphics/effects/light.h b/engines/zvision/graphics/effects/light.h
index ae87d66..cd73a58 100644
--- a/engines/zvision/graphics/effects/light.h
+++ b/engines/zvision/graphics/effects/light.h
@@ -23,13 +23,13 @@
#ifndef LIGHTFX_H_INCLUDED
#define LIGHTFX_H_INCLUDED
-#include "zvision/graphics/effect.h"
+#include "zvision/graphics/graphics_effect.h"
namespace ZVision {
class ZVision;
-class LightFx : public Effect {
+class LightFx : public GraphicsEffect {
public:
LightFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, EffectMap *Map, int8 delta, int8 minD = -127, int8 maxD = 127);
diff --git a/engines/zvision/graphics/effects/wave.cpp b/engines/zvision/graphics/effects/wave.cpp
index 1b3aa04..cec6316 100644
--- a/engines/zvision/graphics/effects/wave.cpp
+++ b/engines/zvision/graphics/effects/wave.cpp
@@ -30,7 +30,7 @@
namespace ZVision {
WaveFx::WaveFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, int16 frames, int16 centerX, int16 centerY, float ampl, float waveln, float spd):
- Effect(engine, key, region, ported) {
+ GraphicsEffect(engine, key, region, ported) {
_frame = 0;
_frameCount = frames;
diff --git a/engines/zvision/graphics/effects/wave.h b/engines/zvision/graphics/effects/wave.h
index 2e813ed..8e91237 100644
--- a/engines/zvision/graphics/effects/wave.h
+++ b/engines/zvision/graphics/effects/wave.h
@@ -24,13 +24,13 @@
#define WAVEFX_H_INCLUDED
#include "common/array.h"
-#include "zvision/graphics/effect.h"
+#include "zvision/graphics/graphics_effect.h"
namespace ZVision {
class ZVision;
-class WaveFx : public Effect {
+class WaveFx : public GraphicsEffect {
public:
WaveFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, int16 frames, int16 centerX, int16 centerY, float ampl, float waveln, float spd);
diff --git a/engines/zvision/graphics/graphics_effect.h b/engines/zvision/graphics/graphics_effect.h
new file mode 100644
index 0000000..bfa266b
--- /dev/null
+++ b/engines/zvision/graphics/graphics_effect.h
@@ -0,0 +1,83 @@
+/* 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 GRAPHICS_EFFECT_H_INCLUDED
+#define GRAPHICS_EFFECT_H_INCLUDED
+
+#include "common/rect.h"
+#include "common/list.h"
+#include "graphics/surface.h"
+
+#include "zvision/zvision.h"
+
+namespace ZVision {
+
+class ZVision;
+
+class GraphicsEffect {
+public:
+
+ GraphicsEffect(ZVision *engine, uint32 key, Common::Rect region, bool ported) : _engine(engine), _key(key), _region(region), _ported(ported) {
+ _surface.create(_region.width(), _region.height(), _engine->_resourcePixelFormat);
+ }
+ virtual ~GraphicsEffect() {}
+
+ uint32 getKey() {
+ return _key;
+ }
+
+ Common::Rect getRegion() {
+ return _region;
+ }
+
+ bool isPort() {
+ return _ported;
+ }
+
+ virtual const Graphics::Surface *draw(const Graphics::Surface &srcSubRect) {
+ return &_surface;
+ }
+
+ virtual void update() {}
+
+protected:
+ ZVision *_engine;
+ uint32 _key;
+ Common::Rect _region;
+ bool _ported;
+ Graphics::Surface _surface;
+
+// Static member functions
+public:
+
+};
+
+struct EffectMapUnit {
+ uint32 count;
+ bool inEffect;
+};
+
+typedef Common::List<EffectMapUnit> EffectMap;
+
+} // End of namespace ZVision
+
+#endif // GRAPHICS_EFFECT_H_INCLUDED
diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp
index 1b80b37..a1cc8ac 100644
--- a/engines/zvision/graphics/render_manager.cpp
+++ b/engines/zvision/graphics/render_manager.cpp
@@ -772,7 +772,7 @@ Common::Point RenderManager::getBkgSize() {
return Common::Point(_backgroundWidth, _backgroundHeight);
}
-void RenderManager::addEffect(Effect *_effect) {
+void RenderManager::addEffect(GraphicsEffect *_effect) {
_effects.push_back(_effect);
}
diff --git a/engines/zvision/graphics/render_manager.h b/engines/zvision/graphics/render_manager.h
index d9a6c88..9002d66 100644
--- a/engines/zvision/graphics/render_manager.h
+++ b/engines/zvision/graphics/render_manager.h
@@ -31,7 +31,7 @@
#include "graphics/surface.h"
-#include "effect.h"
+#include "graphics_effect.h"
class OSystem;
@@ -61,7 +61,7 @@ private:
};
typedef Common::HashMap<uint16, OneSubtitle> SubtitleMap;
- typedef Common::List<Effect *> EffectsList;
+ typedef Common::List<GraphicsEffect *> EffectsList;
private:
ZVision *_engine;
@@ -302,7 +302,7 @@ public:
void readImageToSurface(const Common::String &fileName, Graphics::Surface &destination, bool transposed);
// Add visual effect to effects list
- void addEffect(Effect *_effect);
+ void addEffect(GraphicsEffect *_effect);
// Delete effect(s) by ID (ID equal to slot of action:region that create this effect)
void deleteEffect(uint32 ID);
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index 8edd67b..93fba28 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -32,13 +32,13 @@ MODULE_OBJS := \
scripting/menu.o \
scripting/scr_file_handling.o \
scripting/script_manager.o \
- scripting/sidefx/animation_node.o \
- scripting/sidefx/distort_node.o \
- scripting/sidefx/music_node.o \
- scripting/sidefx/region_node.o \
- scripting/sidefx/syncsound_node.o \
- scripting/sidefx/timer_node.o \
- scripting/sidefx/ttytext_node.o \
+ scripting/effects/animation_effect.o \
+ scripting/effects/distort_effect.o \
+ scripting/effects/music_effect.o \
+ scripting/effects/region_effect.o \
+ scripting/effects/syncsound_effect.o \
+ scripting/effects/timer_effect.o \
+ scripting/effects/ttytext_effect.o \
sound/midi.o \
sound/zork_raw.o \
text/string_manager.o \
diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp
index a914767..a61fa26 100644
--- a/engines/zvision/scripting/actions.cpp
+++ b/engines/zvision/scripting/actions.cpp
@@ -31,16 +31,16 @@
#include "zvision/video/zork_avi_decoder.h"
#include "zvision/file/save_manager.h"
#include "zvision/scripting/menu.h"
-#include "zvision/scripting/sidefx/timer_node.h"
-#include "zvision/scripting/sidefx/music_node.h"
-#include "zvision/scripting/sidefx/syncsound_node.h"
-#include "zvision/scripting/sidefx/animation_node.h"
-#include "zvision/scripting/sidefx/distort_node.h"
-#include "zvision/scripting/sidefx/ttytext_node.h"
-#include "zvision/scripting/sidefx/region_node.h"
+#include "zvision/scripting/effects/timer_effect.h"
+#include "zvision/scripting/effects/music_effect.h"
+#include "zvision/scripting/effects/syncsound_effect.h"
+#include "zvision/scripting/effects/animation_effect.h"
+#include "zvision/scripting/effects/distort_effect.h"
+#include "zvision/scripting/effects/ttytext_effect.h"
+#include "zvision/scripting/effects/region_effect.h"
#include "zvision/scripting/controls/titler_control.h"
#include "zvision/graphics/render_table.h"
-#include "zvision/graphics/effect.h"
+#include "zvision/graphics/graphics_effect.h"
#include "zvision/graphics/effects/fog.h"
#include "zvision/graphics/effects/light.h"
#include "zvision/graphics/effects/wave.h"
@@ -106,8 +106,8 @@ ActionAttenuate::ActionAttenuate(ZVision *engine, int32 slotkey, const Common::S
}
bool ActionAttenuate::execute() {
- SideFX *fx = _engine->getScriptManager()->getSideFX(_key);
- if (fx && fx->getType() == SideFX::SIDEFX_AUDIO) {
+ ScriptingEffect *fx = _engine->getScriptManager()->getSideFX(_key);
+ if (fx && fx->getType() == ScriptingEffect::SCRIPTING_EFFECT_AUDIO) {
MusicNode *mus = (MusicNode *)fx;
mus->setVolume(255 - (abs(_attenuation) >> 7));
}
@@ -157,8 +157,8 @@ ActionCrossfade::ActionCrossfade(ZVision *engine, int32 slotkey, const Common::S
bool ActionCrossfade::execute() {
if (_keyOne) {
- SideFX *fx = _engine->getScriptManager()->getSideFX(_keyOne);
- if (fx && fx->getType() == SideFX::SIDEFX_AUDIO) {
+ ScriptingEffect *fx = _engine->getScriptManager()->getSideFX(_keyOne);
+ if (fx && fx->getType() == ScriptingEffect::SCRIPTING_EFFECT_AUDIO) {
MusicNode *mus = (MusicNode *)fx;
if (_oneStartVolume >= 0)
mus->setVolume((_oneStartVolume * 255) / 100);
@@ -168,8 +168,8 @@ bool ActionCrossfade::execute() {
}
if (_keyTwo) {
- SideFX *fx = _engine->getScriptManager()->getSideFX(_keyTwo);
- if (fx && fx->getType() == SideFX::SIDEFX_AUDIO) {
+ ScriptingEffect *fx = _engine->getScriptManager()->getSideFX(_keyTwo);
+ if (fx && fx->getType() == ScriptingEffect::SCRIPTING_EFFECT_AUDIO) {
MusicNode *mus = (MusicNode *)fx;
if (_twoStartVolume >= 0)
mus->setVolume((_twoStartVolume * 255) / 100);
@@ -401,28 +401,28 @@ ActionKill::ActionKill(ZVision *engine, int32 slotkey, const Common::String &lin
sscanf(line.c_str(), "%24s", keytype);
if (keytype[0] == '"') {
if (!scumm_stricmp(keytype, "\"ANIM\""))
- _type = SideFX::SIDEFX_ANIM;
+ _type = ScriptingEffect::SCRIPTING_EFFECT_ANIM;
else if (!scumm_stricmp(keytype, "\"AUDIO\""))
- _type = SideFX::SIDEFX_AUDIO;
+ _type = ScriptingEffect::SCRIPTING_EFFECT_AUDIO;
else if (!scumm_stricmp(keytype, "\"DISTORT\""))
- _type = SideFX::SIDEFX_DISTORT;
+ _type = ScriptingEffect::SCRIPTING_EFFECT_DISTORT;
else if (!scumm_stricmp(keytype, "\"PANTRACK\""))
- _type = SideFX::SIDEFX_PANTRACK;
+ _type = ScriptingEffect::SCRIPTING_EFFECT_PANTRACK;
else if (!scumm_stricmp(keytype, "\"REGION\""))
- _type = SideFX::SIDEFX_REGION;
+ _type = ScriptingEffect::SCRIPTING_EFFECT_REGION;
else if (!scumm_stricmp(keytype, "\"TIMER\""))
- _type = SideFX::SIDEFX_TIMER;
+ _type = ScriptingEffect::SCRIPTING_EFFECT_TIMER;
else if (!scumm_stricmp(keytype, "\"TTYTEXT\""))
- _type = SideFX::SIDEFX_TTYTXT;
+ _type = ScriptingEffect::SCRIPTING_EFFECT_TTYTXT;
else if (!scumm_stricmp(keytype, "\"ALL\""))
- _type = SideFX::SIDEFX_ALL;
+ _type = ScriptingEffect::SCRIPTING_EFFECT_ALL;
} else
_key = atoi(keytype);
}
bool ActionKill::execute() {
if (_type)
- _engine->getScriptManager()->killSideFxType((SideFX::SideFXType)_type);
+ _engine->getScriptManager()->killSideFxType((ScriptingEffect::ScriptingEffectType)_type);
else
_engine->getScriptManager()->killSideFx(_key);
return true;
@@ -580,10 +580,10 @@ ActionPreloadAnimation::~ActionPreloadAnimation() {
}
bool ActionPreloadAnimation::execute() {
- AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_slotKey);
+ AnimationEffect *nod = (AnimationEffect *)_engine->getScriptManager()->getSideFX(_slotKey);
if (!nod) {
- nod = new AnimationNode(_engine, _slotKey, _fileName, _mask, _framerate, false);
+ nod = new AnimationEffect(_engine, _slotKey, _fileName, _mask, _framerate, false);
_engine->getScriptManager()->addSideFX(nod);
} else
nod->stop();
@@ -603,9 +603,9 @@ ActionUnloadAnimation::ActionUnloadAnimation(ZVision *engine, int32 slotkey, con
}
bool ActionUnloadAnimation::execute() {
- AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_key);
+ AnimationEffect *nod = (AnimationEffect *)_engine->getScriptManager()->getSideFX(_key);
- if (nod && nod->getType() == SideFX::SIDEFX_ANIM)
+ if (nod && nod->getType() == ScriptingEffect::SCRIPTING_EFFECT_ANIM)
_engine->getScriptManager()->deleteSideFx(_key);
return true;
@@ -648,10 +648,10 @@ ActionPlayAnimation::~ActionPlayAnimation() {
}
bool ActionPlayAnimation::execute() {
- AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_slotKey);
+ AnimationEffect *nod = (AnimationEffect *)_engine->getScriptManager()->getSideFX(_slotKey);
if (!nod) {
- nod = new AnimationNode(_engine, _slotKey, _fileName, _mask, _framerate);
+ nod = new AnimationEffect(_engine, _slotKey, _fileName, _mask, _framerate);
_engine->getScriptManager()->addSideFX(nod);
} else
nod->stop();
@@ -683,7 +683,7 @@ ActionPlayPreloadAnimation::ActionPlayPreloadAnimation(ZVision *engine, int32 sl
}
bool ActionPlayPreloadAnimation::execute() {
- AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_controlKey);
+ AnimationEffect *nod = (AnimationEffect *)_engine->getScriptManager()->getSideFX(_controlKey);
if (nod)
nod->addPlayNode(_slotKey, _x1, _y1, _x2, _y2, _startFrame, _endFrame, _loopCount);
@@ -731,7 +731,7 @@ bool ActionRegion::execute() {
if (_engine->getScriptManager()->getSideFX(_slotKey))
return true;
- Effect *effect = NULL;
+ GraphicsEffect *effect = NULL;
switch (_type) {
case 0: {
uint16 centerX, centerY, frames;
@@ -982,11 +982,11 @@ ActionSyncSound::ActionSyncSound(ZVision *engine, int32 slotkey, const Common::S
}
bool ActionSyncSound::execute() {
- SideFX *fx = _engine->getScriptManager()->getSideFX(_syncto);
+ ScriptingEffect *fx = _engine->getScriptManager()->getSideFX(_syncto);
if (!fx)
return true;
- if (!(fx->getType() & SideFX::SIDEFX_ANIM))
+ if (!(fx->getType() & ScriptingEffect::SCRIPTING_EFFECT_ANIM))
return true;
_engine->getScriptManager()->addSideFX(new SyncSoundNode(_engine, _slotKey, _fileName, _syncto));
diff --git a/engines/zvision/scripting/control.h b/engines/zvision/scripting/control.h
index 803d0cf..108b83f 100644
--- a/engines/zvision/scripting/control.h
+++ b/engines/zvision/scripting/control.h
@@ -36,6 +36,11 @@ namespace ZVision {
class ZVision;
+/**
+ * The base class for all Controls.
+ *
+ * Controls are the things that the user interacts with. Ex: A lever on the door
+ */
class Control {
public:
diff --git a/engines/zvision/scripting/effects/animation_effect.cpp b/engines/zvision/scripting/effects/animation_effect.cpp
new file mode 100644
index 0000000..c3cbc25
--- /dev/null
+++ b/engines/zvision/scripting/effects/animation_effect.cpp
@@ -0,0 +1,213 @@
+/* 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/scripting/effects/animation_effect.h"
+
+#include "zvision/zvision.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/scripting/script_manager.h"
+
+#include "graphics/surface.h"
+#include "video/video_decoder.h"
+
+namespace ZVision {
+
+AnimationEffect::AnimationEffect(ZVision *engine, uint32 controlKey, const Common::String &fileName, int32 mask, int32 frate, bool disposeAfterUse)
+ : ScriptingEffect(engine, controlKey, SCRIPTING_EFFECT_ANIM),
+ _disposeAfterUse(disposeAfterUse),
+ _mask(mask),
+ _animation(NULL) {
+
+ _animation = engine->loadAnimation(fileName);
+
+ if (frate > 0) {
+ _frmDelayOverride = (int32)(1000.0 / frate);
+
+ // WORKAROUND: We do not allow the engine to delay more than 66 msec
+ // per frame (15fps max)
+ if (_frmDelayOverride > 66)
+ _frmDelayOverride = 66;
+ } else {
+ _frmDelayOverride = 0;
+ }
+}
+
+AnimationEffect::~AnimationEffect() {
+ if (_animation)
+ delete _animation;
+
+ _engine->getScriptManager()->setStateValue(_key, 2);
+
+ PlayNodes::iterator it = _playList.begin();
+ if (it != _playList.end()) {
+ _engine->getScriptManager()->setStateValue((*it).slot, 2);
+
+ if ((*it)._scaled) {
+ (*it)._scaled->free();
+ delete(*it)._scaled;
+ }
+ }
+
+ _playList.clear();
+}
+
+bool AnimationEffect::process(uint32 deltaTimeInMillis) {
+ ScriptManager *scriptManager = _engine->getScriptManager();
+ RenderManager *renderManager = _engine->getRenderManager();
+ RenderTable::RenderState renderState = renderManager->getRenderTable()->getRenderState();
+ bool isPanorama = (renderState == RenderTable::PANORAMA);
+ int16 velocity = _engine->getMouseVelocity() + _engine->getKeyboardVelocity();
+
+ // Do not update animation nodes in panoramic mode while turning, if the user
+ // has set this option
+ if (scriptManager->getStateValue(StateKey_NoTurnAnim) == 1 && isPanorama && velocity)
+ return false;
+
+ PlayNodes::iterator it = _playList.begin();
+ if (it != _playList.end()) {
+ playnode *nod = &(*it);
+
+ if (!_animation->isPlaying()) {
+ // The node is just beginning playback
+ _animation->start();
+ _animation->seekToFrame(nod->start);
+
+ nod->_delay = deltaTimeInMillis; // Force the frame to draw
+ if (nod->slot)
+ scriptManager->setStateValue(nod->slot, 1);
+ } else if (_animation->endOfVideo()) {
+ // The node has reached the end; check if we need to loop
+ nod->loop--;
+
+ if (nod->loop == 0) {
+ if (nod->slot >= 0)
+ scriptManager->setStateValue(nod->slot, 2);
+ if (nod->_scaled) {
+ nod->_scaled->free();
+ delete nod->_scaled;
+ }
+ _playList.erase(it);
+ return _disposeAfterUse;
+ }
+
+ _animation->seekToFrame(nod->start);
+ }
+
+ // Check if we need to draw a frame
+ bool needsUpdate = false;
+ if (_frmDelayOverride == 0) {
+ // If not overridden, use the VideoDecoder's check
+ needsUpdate = _animation->needsUpdate();
+ } else {
+ // Otherwise, implement our own timing
+ nod->_delay -= deltaTimeInMillis;
+
+ if (nod->_delay <= 0) {
+ nod->_delay += _frmDelayOverride;
+ needsUpdate = true;
+ }
+ }
+
+ if (needsUpdate) {
+ const Graphics::Surface *frame = _animation->decodeNextFrame();
+
+ if (frame) {
+ uint32 dstw;
+ uint32 dsth;
+ if (isPanorama) {
+ dstw = nod->pos.height();
+ dsth = nod->pos.width();
+ } else {
+ dstw = nod->pos.width();
+ dsth = nod->pos.height();
+ }
+
+ // We only scale down the animation to fit its frame, not up, otherwise we
+ // end up with distorted animations - e.g. the armor visor in location cz1e
+ // in Nemesis (one of the armors inside Irondune), or the planet in location
+ // aa10 in Nemesis (Juperon, outside the asylum). We do allow scaling up only
+ // when a simple 2x filter is requested (e.g. the alchemists and cup sequence
+ // in Nemesis)
+ if (frame->w > dstw || frame->h > dsth || (frame->w == dstw / 2 && frame->h == dsth / 2)) {
+ if (nod->_scaled)
+ if (nod->_scaled->w != dstw || nod->_scaled->h != dsth) {
+ nod->_scaled->free();
+ delete nod->_scaled;
+ nod->_scaled = NULL;
+ }
+
+ if (!nod->_scaled) {
+ nod->_scaled = new Graphics::Surface;
+ nod->_scaled->create(dstw, dsth, frame->format);
+ }
+
+ renderManager->scaleBuffer(frame->getPixels(), nod->_scaled->getPixels(), frame->w, frame->h, frame->format.bytesPerPixel, dstw, dsth);
+ frame = nod->_scaled;
+ }
+
+ if (isPanorama) {
+ Graphics::Surface *transposed = RenderManager::tranposeSurface(frame);
+ renderManager->blitSurfaceToBkg(*transposed, nod->pos.left, nod->pos.top, _mask);
+ transposed->free();
+ delete transposed;
+ } else {
+ renderManager->blitSurfaceToBkg(*frame, nod->pos.left, nod->pos.top, _mask);
+ }
+ }
+ }
+ }
+
+ return false;
+}
+
+void AnimationEffect::addPlayNode(int32 slot, int x, int y, int x2, int y2, int startFrame, int endFrame, int loops) {
+ playnode nod;
+ nod.loop = loops;
+ nod.pos = Common::Rect(x, y, x2 + 1, y2 + 1);
+ nod.start = startFrame;
+ _animation->setEndFrame(CLIP<int>(endFrame, 0, _animation->getFrameCount() - 1));
+
+ nod.slot = slot;
+ nod._delay = 0;
+ nod._scaled = NULL;
+ _playList.push_back(nod);
+}
+
+bool AnimationEffect::stop() {
+ PlayNodes::iterator it = _playList.begin();
+ if (it != _playList.end()) {
+ _engine->getScriptManager()->setStateValue((*it).slot, 2);
+ if ((*it)._scaled) {
+ (*it)._scaled->free();
+ delete(*it)._scaled;
+ }
+ }
+
+ _playList.clear();
+
+ // We don't need to delete, it's may be reused
+ return false;
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/scripting/effects/animation_effect.h b/engines/zvision/scripting/effects/animation_effect.h
new file mode 100644
index 0000000..a564b83
--- /dev/null
+++ b/engines/zvision/scripting/effects/animation_effect.h
@@ -0,0 +1,77 @@
+/* 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_ANIMATION_NODE_H
+#define ZVISION_ANIMATION_NODE_H
+
+#include "zvision/scripting/scripting_effect.h"
+#include "common/rect.h"
+#include "common/list.h"
+
+namespace Graphics {
+struct Surface;
+}
+
+namespace Video {
+ class VideoDecoder;
+}
+
+namespace ZVision {
+
+class ZVision;
+
+class AnimationEffect : public ScriptingEffect {
+public:
+ AnimationEffect(ZVision *engine, uint32 controlKey, const Common::String &fileName, int32 mask, int32 frate, bool disposeAfterUse = true);
+ ~AnimationEffect();
+
+ struct playnode {
+ Common::Rect pos;
+ int32 slot;
+ int32 start;
+ int32 loop;
+ int32 _delay;
+ Graphics::Surface *_scaled;
+ };
+
+private:
+ typedef Common::List<playnode> PlayNodes;
+
+ PlayNodes _playList;
+
+ int32 _mask;
+ bool _disposeAfterUse;
+
+ Video::VideoDecoder *_animation;
+ int32 _frmDelayOverride;
+
+public:
+ bool process(uint32 deltaTimeInMillis);
+
+ void addPlayNode(int32 slot, int x, int y, int x2, int y2, int startFrame, int endFrame, int loops = 1);
+
+ bool stop();
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/scripting/effects/distort_effect.cpp b/engines/zvision/scripting/effects/distort_effect.cpp
new file mode 100644
index 0000000..78c4a1b
--- /dev/null
+++ b/engines/zvision/scripting/effects/distort_effect.cpp
@@ -0,0 +1,104 @@
+/* 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/scripting/effects/distort_effect.h"
+
+#include "zvision/zvision.h"
+#include "zvision/scripting/script_manager.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/graphics/render_table.h"
+
+#include "common/stream.h"
+
+namespace ZVision {
+
+DistortNode::DistortNode(ZVision *engine, uint32 key, int16 speed, float startAngle, float endAngle, float startLineScale, float endLineScale)
+ : ScriptingEffect(engine, key, SCRIPTING_EFFECT_DISTORT) {
+
+ _angle = _engine->getRenderManager()->getRenderTable()->getAngle();
+ _linScale = _engine->getRenderManager()->getRenderTable()->getLinscale();
+
+ _speed = speed;
+ _incr = true;
+ _startAngle = startAngle;
+ _endAngle = endAngle;
+ _startLineScale = startLineScale;
+ _endLineScale = endLineScale;
+
+ _curFrame = 1.0;
+
+ _diffAngle = endAngle - startAngle;
+ _diffLinScale = endLineScale - startLineScale;
+
+ _frmSpeed = (float)speed / 15.0;
+ _frames = ceil((5.0 - _frmSpeed * 2.0) / _frmSpeed);
+ if (_frames <= 0)
+ _frames = 1;
+
+ if (_key != StateKey_NotSet)
+ _engine->getScriptManager()->setStateValue(_key, 1);
+}
+
+DistortNode::~DistortNode() {
+ setParams(_angle, _linScale);
+}
+
+bool DistortNode::process(uint32 deltaTimeInMillis) {
+ float updTime = deltaTimeInMillis / (1000.0 / 60.0);
+
+ if (_incr)
+ _curFrame += updTime;
+ else
+ _curFrame -= updTime;
+
+ if (_curFrame < 1.0) {
+ _curFrame = 1.0;
+ _incr = true;
+ } else if (_curFrame > _frames) {
+ _curFrame = _frames;
+ _incr = false;
+ }
+
+ float diff = (1.0 / (5.0 - (_curFrame * _frmSpeed))) / (5.0 - _frmSpeed);
+ setParams(_startAngle + diff * _diffAngle, _startLineScale + diff * _diffLinScale);
+
+ return false;
+}
+
+void DistortNode::setParams(float angl, float linScale) {
+ RenderTable *table = _engine->getRenderManager()->getRenderTable();
+ if (table->getRenderState() == RenderTable::PANORAMA) {
+ table->setPanoramaFoV(angl);
+ table->setPanoramaScale(linScale);
+ table->generateRenderTable();
+ _engine->getRenderManager()->markDirty();
+ } else if (table->getRenderState() == RenderTable::TILT) {
+ table->setTiltFoV(angl);
+ table->setTiltScale(linScale);
+ table->generateRenderTable();
+ _engine->getRenderManager()->markDirty();
+ }
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/scripting/effects/distort_effect.h b/engines/zvision/scripting/effects/distort_effect.h
new file mode 100644
index 0000000..c64f10e
--- /dev/null
+++ b/engines/zvision/scripting/effects/distort_effect.h
@@ -0,0 +1,63 @@
+/* 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_DISTORT_NODE_H
+#define ZVISION_DISTORT_NODE_H
+
+#include "zvision/scripting/scripting_effect.h"
+
+namespace ZVision {
+
+class ZVision;
+
+class DistortNode : public ScriptingEffect {
+public:
+ DistortNode(ZVision *engine, uint32 key, int16 speed, float startAngle, float endAngle, float startLineScale, float endLineScale);
+ ~DistortNode();
+
+ bool process(uint32 deltaTimeInMillis);
+
+private:
+ int16 _speed;
+ float _startAngle;
+ float _endAngle;
+ float _startLineScale;
+ float _endLineScale;
+
+ float _frmSpeed;
+ float _diffAngle;
+ float _diffLinScale;
+ bool _incr;
+ int16 _frames;
+
+ float _curFrame;
+
+ float _angle;
+ float _linScale;
+
+private:
+ void setParams(float angl, float linScale);
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/scripting/effects/music_effect.cpp b/engines/zvision/scripting/effects/music_effect.cpp
new file mode 100644
index 0000000..102f330
--- /dev/null
+++ b/engines/zvision/scripting/effects/music_effect.cpp
@@ -0,0 +1,248 @@
+/* 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/scripting/effects/music_effect.h"
+
+#include "zvision/zvision.h"
+#include "zvision/scripting/script_manager.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/sound/midi.h"
+#include "zvision/sound/zork_raw.h"
+
+#include "common/stream.h"
+#include "common/file.h"
+#include "audio/decoders/wave.h"
+
+namespace ZVision {
+
+MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool loop, int8 volume)
+ : MusicNodeBASE(engine, key, SCRIPTING_EFFECT_AUDIO) {
+ _loop = loop;
+ _volume = volume;
+ _crossfade = false;
+ _crossfadeTarget = 0;
+ _crossfadeTime = 0;
+ _attenuate = 0;
+ _pantrack = false;
+ _pantrackPosition = 0;
+ _sub = NULL;
+ _stereo = false;
+ _loaded = false;
+
+ Audio::RewindableAudioStream *audioStream = NULL;
+
+ if (filename.contains(".wav")) {
+ Common::File *file = new Common::File();
+ if (_engine->getSearchManager()->openFile(*file, filename)) {
+ audioStream = Audio::makeWAVStream(file, DisposeAfterUse::YES);
+ }
+ } else {
+ audioStream = makeRawZorkStream(filename, _engine);
+ }
+
+ if (audioStream) {
+ _stereo = audioStream->isStereo();
+
+ if (_loop) {
+ Audio::LoopingAudioStream *loopingAudioStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES);
+ _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, loopingAudioStream, -1, _volume);
+ } else {
+ _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, audioStream, -1, _volume);
+ }
+
+ if (_key != StateKey_NotSet)
+ _engine->getScriptManager()->setStateValue(_key, 1);
+
+ // Change filename.raw into filename.sub
+ Common::String subname = filename;
+ subname.setChar('s', subname.size() - 3);
+ subname.setChar('u', subname.size() - 2);
+ subname.setChar('b', subname.size() - 1);
+
+ if (_engine->getSearchManager()->hasFile(subname))
+ _sub = new Subtitle(_engine, subname);
+
+ _loaded = true;
+ }
+}
+
+MusicNode::~MusicNode() {
+ if (_loaded)
+ _engine->_mixer->stopHandle(_handle);
+ if (_key != StateKey_NotSet)
+ _engine->getScriptManager()->setStateValue(_key, 2);
+ if (_sub)
+ delete _sub;
+ debug(1, "MusicNode: %d destroyed\n", _key);
+}
+
+void MusicNode::setPanTrack(int16 pos) {
+ if (!_stereo) {
+ _pantrack = true;
+ _pantrackPosition = pos;
+ setVolume(_volume);
+ }
+}
+
+void MusicNode::unsetPanTrack() {
+ _pantrack = false;
+ setVolume(_volume);
+}
+
+void MusicNode::setFade(int32 time, uint8 target) {
+ _crossfadeTarget = target;
+ _crossfadeTime = time;
+ _crossfade = true;
+}
+
+bool MusicNode::process(uint32 deltaTimeInMillis) {
+ if (!_loaded || ! _engine->_mixer->isSoundHandleActive(_handle))
+ return stop();
+ else {
+ uint8 _newvol = _volume;
+
+ if (_crossfade) {
+ if (_crossfadeTime > 0) {
+ if ((int32)deltaTimeInMillis > _crossfadeTime)
+ deltaTimeInMillis = _crossfadeTime;
+ _newvol += floor(((float)(_crossfadeTarget - _newvol) / (float)_crossfadeTime)) * (float)deltaTimeInMillis;
+ _crossfadeTime -= deltaTimeInMillis;
+ } else {
+ _crossfade = false;
+ _newvol = _crossfadeTarget;
+ }
+ }
+
+ if (_pantrack || _volume != _newvol)
+ setVolume(_newvol);
+
+ if (_sub && _engine->getScriptManager()->getStateValue(StateKey_Subtitles) == 1)
+ _sub->process(_engine->_mixer->getSoundElapsedTime(_handle) / 100);
+ }
+ return false;
+}
+
+void MusicNode::setVolume(uint8 newVolume) {
+ if (!_loaded)
+ return;
+ if (_pantrack) {
+ int curX = _engine->getScriptManager()->getStateValue(StateKey_ViewPos);
+ curX -= _pantrackPosition;
+ int32 _width = _engine->getRenderManager()->getBkgSize().x;
+ if (curX < (-_width) / 2)
+ curX += _width;
+ else if (curX >= _width / 2)
+ curX -= _width;
+
+ float norm = (float)curX / ((float)_width / 2.0);
+ float lvl = fabs(norm);
+ if (lvl > 0.5)
+ lvl = (lvl - 0.5) * 1.7;
+ else
+ lvl = 1.0;
+
+ float bal = sin(-norm * 3.1415926) * 127.0;
+
+ if (_engine->_mixer->isSoundHandleActive(_handle)) {
+ _engine->_mixer->setChannelBalance(_handle, bal);
+ _engine->_mixer->setChannelVolume(_handle, newVolume * lvl);
+ }
+ } else {
+ if (_engine->_mixer->isSoundHandleActive(_handle)) {
+ _engine->_mixer->setChannelBalance(_handle, 0);
+ _engine->_mixer->setChannelVolume(_handle, newVolume);
+ }
+ }
+
+ _volume = newVolume;
+}
+
+PanTrackNode::PanTrackNode(ZVision *engine, uint32 key, uint32 slot, int16 pos)
+ : ScriptingEffect(engine, key, SCRIPTING_EFFECT_PANTRACK) {
+ _slot = slot;
+
+ ScriptingEffect *fx = _engine->getScriptManager()->getSideFX(slot);
+ if (fx && fx->getType() == SCRIPTING_EFFECT_AUDIO) {
+ MusicNodeBASE *mus = (MusicNodeBASE *)fx;
+ mus->setPanTrack(pos);
+ }
+}
+
+PanTrackNode::~PanTrackNode() {
+ ScriptingEffect *fx = _engine->getScriptManager()->getSideFX(_slot);
+ if (fx && fx->getType() == SCRIPTING_EFFECT_AUDIO) {
+ MusicNodeBASE *mus = (MusicNodeBASE *)fx;
+ mus->unsetPanTrack();
+ }
+}
+
+MusicMidiNode::MusicMidiNode(ZVision *engine, uint32 key, int8 program, int8 note, int8 volume)
+ : MusicNodeBASE(engine, key, SCRIPTING_EFFECT_AUDIO) {
+ _volume = volume;
+ _prog = program;
+ _noteNumber = note;
+ _pan = 0;
+
+ _chan = _engine->getMidiManager()->getFreeChannel();
+
+ if (_chan >= 0) {
+ _engine->getMidiManager()->setVolume(_chan, _volume);
+ _engine->getMidiManager()->setPan(_chan, _pan);
+ _engine->getMidiManager()->setProgram(_chan, _prog);
+ _engine->getMidiManager()->noteOn(_chan, _noteNumber, _volume);
+ }
+
+ if (_key != StateKey_NotSet)
+ _engine->getScriptManager()->setStateValue(_key, 1);
+}
+
+MusicMidiNode::~MusicMidiNode() {
+ if (_chan >= 0) {
+ _engine->getMidiManager()->noteOff(_chan);
+ }
+ if (_key != StateKey_NotSet)
+ _engine->getScriptManager()->setStateValue(_key, 2);
+}
+
+void MusicMidiNode::setPanTrack(int16 pos) {
+}
+
+void MusicMidiNode::unsetPanTrack() {
+}
+
+void MusicMidiNode::setFade(int32 time, uint8 target) {
+}
+
+bool MusicMidiNode::process(uint32 deltaTimeInMillis) {
+ return false;
+}
+
+void MusicMidiNode::setVolume(uint8 newVolume) {
+ if (_chan >= 0) {
+ _engine->getMidiManager()->setVolume(_chan, newVolume);
+ }
+ _volume = newVolume;
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/scripting/effects/music_effect.h b/engines/zvision/scripting/effects/music_effect.h
new file mode 100644
index 0000000..31d538f
--- /dev/null
+++ b/engines/zvision/scripting/effects/music_effect.h
@@ -0,0 +1,135 @@
+/* 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_MUSIC_NODE_H
+#define ZVISION_MUSIC_NODE_H
+
+#include "audio/mixer.h"
+#include "zvision/scripting/scripting_effect.h"
+#include "zvision/text/subtitles.h"
+
+namespace Common {
+class String;
+}
+
+namespace ZVision {
+
+class MusicNodeBASE : public ScriptingEffect {
+public:
+ MusicNodeBASE(ZVision *engine, uint32 key, ScriptingEffectType type) : ScriptingEffect(engine, key, type) {}
+ ~MusicNodeBASE() {}
+
+ /**
+ * Decrement the timer by the delta time. If the timer is finished, set the status
+ * in _globalState and let this node be deleted
+ *
+ * @param deltaTimeInMillis The number of milliseconds that have passed since last frame
+ * @return If true, the node can be deleted after process() finishes
+ */
+ virtual bool process(uint32 deltaTimeInMillis) = 0;
+
+ virtual void setVolume(uint8 volume) = 0;
+
+ virtual void setPanTrack(int16 pos) = 0;
+ virtual void unsetPanTrack() = 0;
+
+ virtual void setFade(int32 time, uint8 target) = 0;
+};
+
+class MusicNode : public MusicNodeBASE {
+public:
+ MusicNode(ZVision *engine, uint32 key, Common::String &file, bool loop, int8 volume);
+ ~MusicNode();
+
+ /**
+ * Decrement the timer by the delta time. If the timer is finished, set the status
+ * in _globalState and let this node be deleted
+ *
+ * @param deltaTimeInMillis The number of milliseconds that have passed since last frame
+ * @return If true, the node can be deleted after process() finishes
+ */
+ bool process(uint32 deltaTimeInMillis);
+
+ void setVolume(uint8 volume);
+
+ void setPanTrack(int16 pos);
+ void unsetPanTrack();
+
+ void setFade(int32 time, uint8 target);
+
+private:
+ bool _pantrack;
+ int32 _pantrackPosition;
+ int32 _attenuate;
+ uint8 _volume;
+ bool _loop;
+ bool _crossfade;
+ uint8 _crossfadeTarget;
+ int32 _crossfadeTime;
+ bool _stereo;
+ Audio::SoundHandle _handle;
+ Subtitle *_sub;
+ bool _loaded;
+};
+
+// Only used by Zork: Nemesis, for the flute and piano puzzles (tj4e and ve6f, as well as vr)
+class MusicMidiNode : public MusicNodeBASE {
+public:
+ MusicMidiNode(ZVision *engine, uint32 key, int8 program, int8 note, int8 volume);
+ ~MusicMidiNode();
+
+ /**
+ * Decrement the timer by the delta time. If the timer is finished, set the status
+ * in _globalState and let this node be deleted
+ *
+ * @param deltaTimeInMillis The number of milliseconds that have passed since last frame
+ * @return If true, the node can be deleted after process() finishes
+ */
+ bool process(uint32 deltaTimeInMillis);
+
+ void setVolume(uint8 volume);
+
+ void setPanTrack(int16 pos);
+ void unsetPanTrack();
+
+ void setFade(int32 time, uint8 target);
+
+private:
+ int8 _chan;
+ int8 _noteNumber;
+ int8 _pan;
+ int8 _volume;
+ int8 _prog;
+};
+
+class PanTrackNode : public ScriptingEffect {
+public:
+ PanTrackNode(ZVision *engine, uint32 key, uint32 slot, int16 pos);
+ ~PanTrackNode();
+
+private:
+ uint32 _slot;
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/scripting/effects/region_effect.cpp b/engines/zvision/scripting/effects/region_effect.cpp
new file mode 100644
index 0000000..78061cf
--- /dev/null
+++ b/engines/zvision/scripting/effects/region_effect.cpp
@@ -0,0 +1,56 @@
+/* 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/scripting/effects/region_effect.h"
+
+#include "zvision/zvision.h"
+#include "zvision/scripting/script_manager.h"
+#include "zvision/graphics/render_manager.h"
+
+namespace ZVision {
+
+RegionNode::RegionNode(ZVision *engine, uint32 key, GraphicsEffect *effect, uint32 delay)
+ : ScriptingEffect(engine, key, SCRIPTING_EFFECT_REGION) {
+ _effect = effect;
+ _delay = delay;
+ _timeLeft = 0;
+}
+
+RegionNode::~RegionNode() {
+ _engine->getRenderManager()->deleteEffect(_key);
+}
+
+bool RegionNode::process(uint32 deltaTimeInMillis) {
+ _timeLeft -= deltaTimeInMillis;
+
+ if (_timeLeft <= 0) {
+ _timeLeft = _delay;
+ if (_effect)
+ _effect->update();
+ }
+
+ return false;
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/scripting/effects/region_effect.h b/engines/zvision/scripting/effects/region_effect.h
new file mode 100644
index 0000000..4fc1622
--- /dev/null
+++ b/engines/zvision/scripting/effects/region_effect.h
@@ -0,0 +1,57 @@
+/* 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_REGION_NODE_H
+#define ZVISION_REGION_NODE_H
+
+#include "graphics/surface.h"
+
+#include "zvision/scripting/scripting_effect.h"
+#include "zvision/graphics/graphics_effect.h"
+
+namespace ZVision {
+
+class ZVision;
+
+class RegionNode : public ScriptingEffect {
+public:
+ RegionNode(ZVision *engine, uint32 key, GraphicsEffect *effect, uint32 delay);
+ ~RegionNode();
+
+ /**
+ * Decrement the timer by the delta time. If the timer is finished, set the status
+ * in _globalState and let this node be deleted
+ *
+ * @param deltaTimeInMillis The number of milliseconds that have passed since last frame
+ * @return If true, the node can be deleted after process() finishes
+ */
+ bool process(uint32 deltaTimeInMillis);
+
+private:
+ int32 _timeLeft;
+ uint32 _delay;
+ GraphicsEffect *_effect;
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/scripting/effects/syncsound_effect.cpp b/engines/zvision/scripting/effects/syncsound_effect.cpp
new file mode 100644
index 0000000..70ba97d
--- /dev/null
+++ b/engines/zvision/scripting/effects/syncsound_effect.cpp
@@ -0,0 +1,85 @@
+/* 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/scripting/effects/syncsound_effect.h"
+
+#include "zvision/zvision.h"
+#include "zvision/scripting/script_manager.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/sound/zork_raw.h"
+
+#include "common/stream.h"
+#include "common/file.h"
+#include "audio/decoders/wave.h"
+
+namespace ZVision {
+
+SyncSoundNode::SyncSoundNode(ZVision *engine, uint32 key, Common::String &filename, int32 syncto)
+ : ScriptingEffect(engine, key, SCRIPTING_EFFECT_AUDIO) {
+ _syncto = syncto;
+ _sub = NULL;
+
+ Audio::RewindableAudioStream *audioStream = NULL;
+
+ if (filename.contains(".wav")) {
+ Common::File *file = new Common::File();
+ if (_engine->getSearchManager()->openFile(*file, filename)) {
+ audioStream = Audio::makeWAVStream(file, DisposeAfterUse::YES);
+ }
+ } else {
+ audioStream = makeRawZorkStream(filename, _engine);
+ }
+
+ _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, audioStream);
+
+ Common::String subname = filename;
+ subname.setChar('s', subname.size() - 3);
+ subname.setChar('u', subname.size() - 2);
+ subname.setChar('b', subname.size() - 1);
+
+ if (_engine->getSearchManager()->hasFile(subname))
+ _sub = new Subtitle(_engine, subname);
+}
+
+SyncSoundNode::~SyncSoundNode() {
+ _engine->_mixer->stopHandle(_handle);
+ if (_sub)
+ delete _sub;
+}
+
+bool SyncSoundNode::process(uint32 deltaTimeInMillis) {
+ if (! _engine->_mixer->isSoundHandleActive(_handle))
+ return stop();
+ else {
+
+ if (_engine->getScriptManager()->getSideFX(_syncto) == NULL)
+ return stop();
+
+ if (_sub && _engine->getScriptManager()->getStateValue(StateKey_Subtitles) == 1)
+ _sub->process(_engine->_mixer->getSoundElapsedTime(_handle) / 100);
+ }
+ return false;
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/scripting/effects/syncsound_effect.h b/engines/zvision/scripting/effects/syncsound_effect.h
new file mode 100644
index 0000000..0eabff7
--- /dev/null
+++ b/engines/zvision/scripting/effects/syncsound_effect.h
@@ -0,0 +1,56 @@
+/* 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_SYNCSOUND_NODE_H
+#define ZVISION_SYNCSOUND_NODE_H
+
+#include "audio/mixer.h"
+#include "zvision/scripting/scripting_effect.h"
+#include "zvision/text/subtitles.h"
+
+namespace Common {
+class String;
+}
+
+namespace ZVision {
+class SyncSoundNode : public ScriptingEffect {
+public:
+ SyncSoundNode(ZVision *engine, uint32 key, Common::String &file, int32 syncto);
+ ~SyncSoundNode();
+
+ /**
+ * Decrement the timer by the delta time. If the timer is finished, set the status
+ * in _globalState and let this node be deleted
+ *
+ * @param deltaTimeInMillis The number of milliseconds that have passed since last frame
+ * @return If true, the node can be deleted after process() finishes
+ */
+ bool process(uint32 deltaTimeInMillis);
+private:
+ int32 _syncto;
+ Audio::SoundHandle _handle;
+ Subtitle *_sub;
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/scripting/effects/timer_effect.cpp b/engines/zvision/scripting/effects/timer_effect.cpp
new file mode 100644
index 0000000..778f9de
--- /dev/null
+++ b/engines/zvision/scripting/effects/timer_effect.cpp
@@ -0,0 +1,81 @@
+/* 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/scripting/effects/timer_effect.h"
+
+#include "zvision/zvision.h"
+#include "zvision/scripting/script_manager.h"
+
+#include "common/stream.h"
+
+namespace ZVision {
+
+TimerNode::TimerNode(ZVision *engine, uint32 key, uint timeInSeconds)
+ : ScriptingEffect(engine, key, SCRIPTING_EFFECT_TIMER) {
+ _timeLeft = 0;
+
+ if (_engine->getGameId() == GID_NEMESIS)
+ _timeLeft = timeInSeconds * 1000;
+ else if (_engine->getGameId() == GID_GRANDINQUISITOR)
+ _timeLeft = timeInSeconds * 100;
+
+ if (_key != StateKey_NotSet)
+ _engine->getScriptManager()->setStateValue(_key, 1);
+}
+
+TimerNode::~TimerNode() {
+ if (_key != StateKey_NotSet)
+ _engine->getScriptManager()->setStateValue(_key, 2);
+ int32 timeLeft = _timeLeft / (_engine->getGameId() == GID_NEMESIS ? 1000 : 100);
+ if (timeLeft > 0)
+ _engine->getScriptManager()->setStateValue(_key, timeLeft); // If timer was stopped by stop or kill
+}
+
+bool TimerNode::process(uint32 deltaTimeInMillis) {
+ _timeLeft -= deltaTimeInMillis;
+
+ if (_timeLeft <= 0)
+ return stop();
+
+ return false;
+}
+
+bool TimerNode::stop() {
+ if (_key != StateKey_NotSet)
+ _engine->getScriptManager()->setStateValue(_key, 2);
+ return true;
+}
+
+void TimerNode::serialize(Common::WriteStream *stream) {
+ stream->writeUint32BE(MKTAG('T', 'I', 'M', 'R'));
+ stream->writeUint32LE(8); // size
+ stream->writeUint32LE(_key);
+ stream->writeUint32LE(_timeLeft);
+}
+
+void TimerNode::deserialize(Common::SeekableReadStream *stream) {
+ _timeLeft = stream->readUint32LE();
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/scripting/effects/timer_effect.h b/engines/zvision/scripting/effects/timer_effect.h
new file mode 100644
index 0000000..5e45d54
--- /dev/null
+++ b/engines/zvision/scripting/effects/timer_effect.h
@@ -0,0 +1,59 @@
+/* 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_TIMER_NODE_H
+#define ZVISION_TIMER_NODE_H
+
+#include "zvision/scripting/scripting_effect.h"
+
+namespace ZVision {
+
+class ZVision;
+
+class TimerNode : public ScriptingEffect {
+public:
+ TimerNode(ZVision *engine, uint32 key, uint timeInSeconds);
+ ~TimerNode();
+
+ /**
+ * Decrement the timer by the delta time. If the timer is finished, set the status
+ * in _globalState and let this node be deleted
+ *
+ * @param deltaTimeInMillis The number of milliseconds that have passed since last frame
+ * @return If true, the node can be deleted after process() finishes
+ */
+ bool process(uint32 deltaTimeInMillis);
+ void serialize(Common::WriteStream *stream);
+ void deserialize(Common::SeekableReadStream *stream);
+ inline bool needsSerialization() {
+ return true;
+ }
+
+ bool stop();
+
+private:
+ int32 _timeLeft;
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/scripting/effects/ttytext_effect.cpp b/engines/zvision/scripting/effects/ttytext_effect.cpp
new file mode 100644
index 0000000..c60b3aa
--- /dev/null
+++ b/engines/zvision/scripting/effects/ttytext_effect.cpp
@@ -0,0 +1,174 @@
+/* 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/scripting/effects/ttytext_effect.h"
+
+#include "zvision/zvision.h"
+#include "zvision/scripting/script_manager.h"
+#include "zvision/graphics/render_manager.h"
+#include "zvision/text/text.h"
+
+#include "common/stream.h"
+#include "common/file.h"
+
+namespace ZVision {
+
+ttyTextNode::ttyTextNode(ZVision *engine, uint32 key, const Common::String &file, const Common::Rect &r, int32 delay) :
+ ScriptingEffect(engine, key, SCRIPTING_EFFECT_TTYTXT),
+ _fnt(engine) {
+ _delay = delay;
+ _r = r;
+ _txtpos = 0;
+ _nexttime = 0;
+ _dx = 0;
+ _dy = 0;
+
+ Common::File *infile = _engine->getSearchManager()->openFile(file);
+ if (infile) {
+ while (!infile->eos()) {
+ Common::String asciiLine = readWideLine(*infile);
+ if (asciiLine.empty()) {
+ continue;
+ }
+ _txtbuf += asciiLine;
+ }
+
+ delete infile;
+ }
+ _img.create(_r.width(), _r.height(), _engine->_resourcePixelFormat);
+ _style._sharp = true;
+ _style.readAllStyle(_txtbuf);
+ _style.setFont(_fnt);
+ _engine->getScriptManager()->setStateValue(_key, 1);
+}
+
+ttyTextNode::~ttyTextNode() {
+ _engine->getScriptManager()->setStateValue(_key, 2);
+ _img.free();
+}
+
+bool ttyTextNode::process(uint32 deltaTimeInMillis) {
+ _nexttime -= deltaTimeInMillis;
+
+ if (_nexttime < 0) {
+ if (_txtpos < _txtbuf.size()) {
+ if (_txtbuf[_txtpos] == '<') {
+ int32 strt = _txtpos;
+ int32 endt = 0;
+ int16 ret = 0;
+ while (_txtbuf[_txtpos] != '>' && _txtpos < _txtbuf.size())
+ _txtpos++;
+ endt = _txtpos;
+ if (strt != -1)
+ if ((endt - strt - 1) > 0)
+ ret = _style.parseStyle(_txtbuf.c_str() + strt + 1, endt - strt - 1);
+
+ if (ret & (TXT_RET_FNTCHG | TXT_RET_FNTSTL | TXT_RET_NEWLN)) {
+ if (ret & TXT_RET_FNTCHG)
+ _style.setFont(_fnt);
+ if (ret & TXT_RET_FNTSTL)
+ _style.setFontStyle(_fnt);
+
+ if (ret & TXT_RET_NEWLN)
+ newline();
+ }
+
+ if (ret & TXT_RET_HASSTBOX) {
+ Common::String buf;
+ buf = Common::String::format("%d", _engine->getScriptManager()->getStateValue(_style._statebox));
+
+ for (uint8 j = 0; j < buf.size(); j++)
+ outchar(buf[j]);
+ }
+
+ _txtpos++;
+ } else {
+ int8 charsz = getUtf8CharSize(_txtbuf[_txtpos]);
+
+ uint16 chr = readUtf8Char(_txtbuf.c_str() + _txtpos);
+
+ if (chr == ' ') {
+ uint32 i = _txtpos + charsz;
+ uint16 width = _fnt.getCharWidth(chr);
+
+ while (i < _txtbuf.size() && _txtbuf[i] != ' ' && _txtbuf[i] != '<') {
+
+ int8 chsz = getUtf8CharSize(_txtbuf[i]);
+ uint16 uchr = readUtf8Char(_txtbuf.c_str() + _txtpos);
+
+ width += _fnt.getCharWidth(uchr);
+
+ i += chsz;
+ }
+
+ if (_dx + width > _r.width())
+ newline();
+ else
+ outchar(chr);
+ } else
+ outchar(chr);
+
+ _txtpos += charsz;
+ }
+ _nexttime = _delay;
+ _engine->getRenderManager()->blitSurfaceToBkg(_img, _r.left, _r.top);
+ } else
+ return stop();
+ }
+
+ return false;
+}
+
+void ttyTextNode::scroll() {
+ int32 scrl = 0;
+ while (_dy - scrl > _r.height() - _fnt.getFontHeight())
+ scrl += _fnt.getFontHeight();
+ int8 *pixels = (int8 *)_img.getPixels();
+ for (uint16 h = scrl; h < _img.h; h++)
+ memcpy(pixels + _img.pitch * (h - scrl), pixels + _img.pitch * h, _img.pitch);
+
+ _img.fillRect(Common::Rect(0, _img.h - scrl, _img.w, _img.h), 0);
+ _dy -= scrl;
+}
+
+void ttyTextNode::newline() {
+ _dy += _fnt.getFontHeight();
+ _dx = 0;
+}
+
+void ttyTextNode::outchar(uint16 chr) {
+ uint32 clr = _engine->_resourcePixelFormat.RGBToColor(_style._red, _style._green, _style._blue);
+
+ if (_dx + _fnt.getCharWidth(chr) > _r.width())
+ newline();
+
+ if (_dy + _fnt.getFontHeight() >= _r.height())
+ scroll();
+
+ _fnt.drawChar(&_img, chr, _dx, _dy, clr);
+
+ _dx += _fnt.getCharWidth(chr);
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/scripting/effects/ttytext_effect.h b/engines/zvision/scripting/effects/ttytext_effect.h
new file mode 100644
index 0000000..8d8a251
--- /dev/null
+++ b/engines/zvision/scripting/effects/ttytext_effect.h
@@ -0,0 +1,73 @@
+/* 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_TTYTEXT_NODE_H
+#define ZVISION_TTYTEXT_NODE_H
+
+#include "common/rect.h"
+#include "graphics/surface.h"
+
+#include "zvision/scripting/scripting_effect.h"
+#include "zvision/text/text.h"
+#include "zvision/text/truetype_font.h"
+
+namespace Common {
+class String;
+}
+
+namespace ZVision {
+class ttyTextNode : public ScriptingEffect {
+public:
+ ttyTextNode(ZVision *engine, uint32 key, const Common::String &file, const Common::Rect &r, int32 delay);
+ ~ttyTextNode();
+
+ /**
+ * Decrement the timer by the delta time. If the timer is finished, set the status
+ * in _globalState and let this node be deleted
+ *
+ * @param deltaTimeInMillis The number of milliseconds that have passed since last frame
+ * @return If true, the node can be deleted after process() finishes
+ */
+ bool process(uint32 deltaTimeInMillis);
+private:
+ Common::Rect _r;
+
+ cTxtStyle _style;
+ StyledTTFont _fnt;
+ Common::String _txtbuf;
+ uint32 _txtpos;
+
+ int32 _delay;
+ int32 _nexttime;
+ Graphics::Surface _img;
+ int16 _dx;
+ int16 _dy;
+private:
+
+ void newline();
+ void scroll();
+ void outchar(uint16 chr);
+};
+
+} // End of namespace ZVision
+
+#endif
diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp
index d0ebb18..464e8bf 100644
--- a/engines/zvision/scripting/script_manager.cpp
+++ b/engines/zvision/scripting/script_manager.cpp
@@ -30,7 +30,7 @@
#include "zvision/file/save_manager.h"
#include "zvision/scripting/actions.h"
#include "zvision/scripting/menu.h"
-#include "zvision/scripting/sidefx/timer_node.h"
+#include "zvision/scripting/effects/timer_effect.h"
#include "common/algorithm.h"
#include "common/hashmap.h"
@@ -382,11 +382,11 @@ void ScriptManager::setFocusControlKey(uint32 key) {
_currentlyFocusedControl = key;
}
-void ScriptManager::addSideFX(SideFX *fx) {
+void ScriptManager::addSideFX(ScriptingEffect *fx) {
_activeSideFx.push_back(fx);
}
-SideFX *ScriptManager::getSideFX(uint32 key) {
+ScriptingEffect *ScriptManager::getSideFX(uint32 key) {
for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end(); ++iter) {
if ((*iter)->getKey() == key) {
return (*iter);
@@ -430,7 +430,7 @@ void ScriptManager::killSideFx(uint32 key) {
}
}
-void ScriptManager::killSideFxType(SideFX::SideFXType type) {
+void ScriptManager::killSideFxType(ScriptingEffect::ScriptingEffectType type) {
for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end();) {
if ((*iter)->getType() & type) {
(*iter)->kill();
diff --git a/engines/zvision/scripting/script_manager.h b/engines/zvision/scripting/script_manager.h
index 9f0f2f6..78c1b77 100644
--- a/engines/zvision/scripting/script_manager.h
+++ b/engines/zvision/scripting/script_manager.h
@@ -25,7 +25,7 @@
#include "zvision/scripting/puzzle.h"
#include "zvision/scripting/control.h"
-#include "zvision/scripting/sidefx.h"
+#include "zvision/scripting/scripting_effect.h"
#include "common/hashmap.h"
#include "common/queue.h"
@@ -116,7 +116,7 @@ typedef Common::List<Puzzle *> PuzzleList;
typedef Common::Queue<Puzzle *> PuzzleQueue;
typedef Common::List<Control *> ControlList;
typedef Common::HashMap<uint32, int32> StateMap;
-typedef Common::List<SideFX *> SideFXList;
+typedef Common::List<ScriptingEffect *> SideFXList;
typedef Common::List<Common::Event> EventList;
class ScriptManager {
@@ -196,12 +196,12 @@ public:
// Only change focus control without call focus/unfocus.
void setFocusControlKey(uint32 key);
- void addSideFX(SideFX *fx);
- SideFX *getSideFX(uint32 key);
+ void addSideFX(ScriptingEffect *fx);
+ ScriptingEffect *getSideFX(uint32 key);
void deleteSideFx(uint32 key);
void stopSideFx(uint32 key);
void killSideFx(uint32 key);
- void killSideFxType(SideFX::SideFXType type);
+ void killSideFxType(ScriptingEffect::ScriptingEffectType type);
void addEvent(Common::Event);
void flushEvent(Common::EventType type);
diff --git a/engines/zvision/scripting/scripting_effect.h b/engines/zvision/scripting/scripting_effect.h
new file mode 100644
index 0000000..0af1d9c
--- /dev/null
+++ b/engines/zvision/scripting/scripting_effect.h
@@ -0,0 +1,124 @@
+/* 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 SCRIPTING_EFFECT_H_INCLUDED
+#define SCRIPTING_EFFECT_H_INCLUDED
+
+namespace Common {
+class SeekableReadStream;
+struct Point;
+class WriteStream;
+}
+
+namespace ZVision {
+
+class ZVision;
+
+/**
+ * The base class that represents effects created from Actions.
+ * This class is virtual.
+ *
+ * Detailed Description:
+ * A scene has Controls. By interacting with the controls, the user
+ * causes Actions to execute. Certain Actions create 'effects', for
+ * example, a sound or an animation. This is the base class for
+ * those effects.
+ */
+class ScriptingEffect {
+public:
+
+ enum ScriptingEffectType {
+ SCRIPTING_EFFECT_ANIM = 1,
+ SCRIPTING_EFFECT_AUDIO = 2,
+ SCRIPTING_EFFECT_DISTORT = 4,
+ SCRIPTING_EFFECT_PANTRACK = 8,
+ SCRIPTING_EFFECT_REGION = 16,
+ SCRIPTING_EFFECT_TIMER = 32,
+ SCRIPTING_EFFECT_TTYTXT = 64,
+ SCRIPTING_EFFECT_UNKNOWN = 128,
+ SCRIPTING_EFFECT_ALL = 255
+ };
+
+ ScriptingEffect() : _engine(0), _key(0), _type(SCRIPTING_EFFECT_UNKNOWN) {}
+ ScriptingEffect(ZVision *engine, uint32 key, ScriptingEffectType type) : _engine(engine), _key(key), _type(type) {}
+ virtual ~ScriptingEffect() {}
+
+ uint32 getKey() {
+ return _key;
+ }
+ ScriptingEffectType getType() {
+ return _type;
+ }
+
+ virtual bool process(uint32 deltaTimeInMillis) {
+ return false;
+ }
+ /**
+ * Serialize a SideFX for save game use. This should only be used if a SideFX needs
+ * to save values that would be different from initialization. AKA a TimerNode needs to
+ * store the amount of time left on the timer. Any Controls overriding this *MUST* write
+ * their key as the first data outputted. The default implementation is NOP.
+ *
+ * NOTE: If this method is overridden, you MUST also override deserialize()
+ * and needsSerialization()
+ *
+ * @param stream Stream to write any needed data to
+ */
+ virtual void serialize(Common::WriteStream *stream) {}
+ /**
+ * De-serialize data from a save game stream. This should only be implemented if the
+ * SideFX also implements serialize(). The calling method assumes the size of the
+ * data read from the stream exactly equals that written in serialize(). The default
+ * implementation is NOP.
+ *
+ * NOTE: If this method is overridden, you MUST also override serialize()
+ * and needsSerialization()
+ *
+ * @param stream Save game file stream
+ */
+ virtual void deserialize(Common::SeekableReadStream *stream) {}
+ /**
+ * If a SideFX overrides serialize() and deserialize(), this should return true
+ *
+ * @return Does the SideFX need save game serialization?
+ */
+ virtual inline bool needsSerialization() {
+ return false;
+ }
+
+ virtual bool stop() {
+ return true;
+ }
+ virtual void kill() {}
+
+protected:
+ ZVision *_engine;
+ uint32 _key;
+ ScriptingEffectType _type;
+
+// Static member functions
+public:
+
+};
+} // End of namespace ZVision
+
+#endif // SCRIPTING_EFFECT_H_INCLUDED
diff --git a/engines/zvision/scripting/sidefx.h b/engines/zvision/scripting/sidefx.h
deleted file mode 100644
index 5bb14f0..0000000
--- a/engines/zvision/scripting/sidefx.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/* 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 SIDEFX_H_INCLUDED
-#define SIDEFX_H_INCLUDED
-
-namespace Common {
-class SeekableReadStream;
-struct Point;
-class WriteStream;
-}
-
-namespace ZVision {
-
-class ZVision;
-
-class SideFX {
-public:
-
- enum SideFXType {
- SIDEFX_ANIM = 1,
- SIDEFX_AUDIO = 2,
- SIDEFX_DISTORT = 4,
- SIDEFX_PANTRACK = 8,
- SIDEFX_REGION = 16,
- SIDEFX_TIMER = 32,
- SIDEFX_TTYTXT = 64,
- SIDEFX_UNK = 128,
- SIDEFX_ALL = 255
- };
-
- SideFX() : _engine(0), _key(0), _type(SIDEFX_UNK) {}
- SideFX(ZVision *engine, uint32 key, SideFXType type) : _engine(engine), _key(key), _type(type) {}
- virtual ~SideFX() {}
-
- uint32 getKey() {
- return _key;
- }
- SideFXType getType() {
- return _type;
- }
-
- virtual bool process(uint32 deltaTimeInMillis) {
- return false;
- }
- /**
- * Serialize a SideFX for save game use. This should only be used if a SideFX needs
- * to save values that would be different from initialization. AKA a TimerNode needs to
- * store the amount of time left on the timer. Any Controls overriding this *MUST* write
- * their key as the first data outputted. The default implementation is NOP.
- *
- * NOTE: If this method is overridden, you MUST also override deserialize()
- * and needsSerialization()
- *
- * @param stream Stream to write any needed data to
- */
- virtual void serialize(Common::WriteStream *stream) {}
- /**
- * De-serialize data from a save game stream. This should only be implemented if the
- * SideFX also implements serialize(). The calling method assumes the size of the
- * data read from the stream exactly equals that written in serialize(). The default
- * implementation is NOP.
- *
- * NOTE: If this method is overridden, you MUST also override serialize()
- * and needsSerialization()
- *
- * @param stream Save game file stream
- */
- virtual void deserialize(Common::SeekableReadStream *stream) {}
- /**
- * If a SideFX overrides serialize() and deserialize(), this should return true
- *
- * @return Does the SideFX need save game serialization?
- */
- virtual inline bool needsSerialization() {
- return false;
- }
-
- virtual bool stop() {
- return true;
- }
- virtual void kill() {}
-
-protected:
- ZVision *_engine;
- uint32 _key;
- SideFXType _type;
-
-// Static member functions
-public:
-
-};
-} // End of namespace ZVision
-
-#endif // SIDEFX_H_INCLUDED
diff --git a/engines/zvision/scripting/sidefx/animation_node.cpp b/engines/zvision/scripting/sidefx/animation_node.cpp
deleted file mode 100644
index 07eda69..0000000
--- a/engines/zvision/scripting/sidefx/animation_node.cpp
+++ /dev/null
@@ -1,213 +0,0 @@
-/* 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/scripting/sidefx/animation_node.h"
-
-#include "zvision/zvision.h"
-#include "zvision/graphics/render_manager.h"
-#include "zvision/scripting/script_manager.h"
-
-#include "graphics/surface.h"
-#include "video/video_decoder.h"
-
-namespace ZVision {
-
-AnimationNode::AnimationNode(ZVision *engine, uint32 controlKey, const Common::String &fileName, int32 mask, int32 frate, bool disposeAfterUse)
- : SideFX(engine, controlKey, SIDEFX_ANIM),
- _disposeAfterUse(disposeAfterUse),
- _mask(mask),
- _animation(NULL) {
-
- _animation = engine->loadAnimation(fileName);
-
- if (frate > 0) {
- _frmDelayOverride = (int32)(1000.0 / frate);
-
- // WORKAROUND: We do not allow the engine to delay more than 66 msec
- // per frame (15fps max)
- if (_frmDelayOverride > 66)
- _frmDelayOverride = 66;
- } else {
- _frmDelayOverride = 0;
- }
-}
-
-AnimationNode::~AnimationNode() {
- if (_animation)
- delete _animation;
-
- _engine->getScriptManager()->setStateValue(_key, 2);
-
- PlayNodes::iterator it = _playList.begin();
- if (it != _playList.end()) {
- _engine->getScriptManager()->setStateValue((*it).slot, 2);
-
- if ((*it)._scaled) {
- (*it)._scaled->free();
- delete(*it)._scaled;
- }
- }
-
- _playList.clear();
-}
-
-bool AnimationNode::process(uint32 deltaTimeInMillis) {
- ScriptManager *scriptManager = _engine->getScriptManager();
- RenderManager *renderManager = _engine->getRenderManager();
- RenderTable::RenderState renderState = renderManager->getRenderTable()->getRenderState();
- bool isPanorama = (renderState == RenderTable::PANORAMA);
- int16 velocity = _engine->getMouseVelocity() + _engine->getKeyboardVelocity();
-
- // Do not update animation nodes in panoramic mode while turning, if the user
- // has set this option
- if (scriptManager->getStateValue(StateKey_NoTurnAnim) == 1 && isPanorama && velocity)
- return false;
-
- PlayNodes::iterator it = _playList.begin();
- if (it != _playList.end()) {
- playnode *nod = &(*it);
-
- if (!_animation->isPlaying()) {
- // The node is just beginning playback
- _animation->start();
- _animation->seekToFrame(nod->start);
-
- nod->_delay = deltaTimeInMillis; // Force the frame to draw
- if (nod->slot)
- scriptManager->setStateValue(nod->slot, 1);
- } else if (_animation->endOfVideo()) {
- // The node has reached the end; check if we need to loop
- nod->loop--;
-
- if (nod->loop == 0) {
- if (nod->slot >= 0)
- scriptManager->setStateValue(nod->slot, 2);
- if (nod->_scaled) {
- nod->_scaled->free();
- delete nod->_scaled;
- }
- _playList.erase(it);
- return _disposeAfterUse;
- }
-
- _animation->seekToFrame(nod->start);
- }
-
- // Check if we need to draw a frame
- bool needsUpdate = false;
- if (_frmDelayOverride == 0) {
- // If not overridden, use the VideoDecoder's check
- needsUpdate = _animation->needsUpdate();
- } else {
- // Otherwise, implement our own timing
- nod->_delay -= deltaTimeInMillis;
-
- if (nod->_delay <= 0) {
- nod->_delay += _frmDelayOverride;
- needsUpdate = true;
- }
- }
-
- if (needsUpdate) {
- const Graphics::Surface *frame = _animation->decodeNextFrame();
-
- if (frame) {
- uint32 dstw;
- uint32 dsth;
- if (isPanorama) {
- dstw = nod->pos.height();
- dsth = nod->pos.width();
- } else {
- dstw = nod->pos.width();
- dsth = nod->pos.height();
- }
-
- // We only scale down the animation to fit its frame, not up, otherwise we
- // end up with distorted animations - e.g. the armor visor in location cz1e
- // in Nemesis (one of the armors inside Irondune), or the planet in location
- // aa10 in Nemesis (Juperon, outside the asylum). We do allow scaling up only
- // when a simple 2x filter is requested (e.g. the alchemists and cup sequence
- // in Nemesis)
- if (frame->w > dstw || frame->h > dsth || (frame->w == dstw / 2 && frame->h == dsth / 2)) {
- if (nod->_scaled)
- if (nod->_scaled->w != dstw || nod->_scaled->h != dsth) {
- nod->_scaled->free();
- delete nod->_scaled;
- nod->_scaled = NULL;
- }
-
- if (!nod->_scaled) {
- nod->_scaled = new Graphics::Surface;
- nod->_scaled->create(dstw, dsth, frame->format);
- }
-
- renderManager->scaleBuffer(frame->getPixels(), nod->_scaled->getPixels(), frame->w, frame->h, frame->format.bytesPerPixel, dstw, dsth);
- frame = nod->_scaled;
- }
-
- if (isPanorama) {
- Graphics::Surface *transposed = RenderManager::tranposeSurface(frame);
- renderManager->blitSurfaceToBkg(*transposed, nod->pos.left, nod->pos.top, _mask);
- transposed->free();
- delete transposed;
- } else {
- renderManager->blitSurfaceToBkg(*frame, nod->pos.left, nod->pos.top, _mask);
- }
- }
- }
- }
-
- return false;
-}
-
-void AnimationNode::addPlayNode(int32 slot, int x, int y, int x2, int y2, int startFrame, int endFrame, int loops) {
- playnode nod;
- nod.loop = loops;
- nod.pos = Common::Rect(x, y, x2 + 1, y2 + 1);
- nod.start = startFrame;
- _animation->setEndFrame(CLIP<int>(endFrame, 0, _animation->getFrameCount() - 1));
-
- nod.slot = slot;
- nod._delay = 0;
- nod._scaled = NULL;
- _playList.push_back(nod);
-}
-
-bool AnimationNode::stop() {
- PlayNodes::iterator it = _playList.begin();
- if (it != _playList.end()) {
- _engine->getScriptManager()->setStateValue((*it).slot, 2);
- if ((*it)._scaled) {
- (*it)._scaled->free();
- delete(*it)._scaled;
- }
- }
-
- _playList.clear();
-
- // We don't need to delete, it's may be reused
- return false;
-}
-
-} // End of namespace ZVision
diff --git a/engines/zvision/scripting/sidefx/animation_node.h b/engines/zvision/scripting/sidefx/animation_node.h
deleted file mode 100644
index 1dc0dc7..0000000
--- a/engines/zvision/scripting/sidefx/animation_node.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* 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_ANIMATION_NODE_H
-#define ZVISION_ANIMATION_NODE_H
-
-#include "zvision/scripting/sidefx.h"
-#include "common/rect.h"
-#include "common/list.h"
-
-namespace Graphics {
-struct Surface;
-}
-
-namespace Video {
- class VideoDecoder;
-}
-
-namespace ZVision {
-
-class ZVision;
-
-class AnimationNode : public SideFX {
-public:
- AnimationNode(ZVision *engine, uint32 controlKey, const Common::String &fileName, int32 mask, int32 frate, bool disposeAfterUse = true);
- ~AnimationNode();
-
- struct playnode {
- Common::Rect pos;
- int32 slot;
- int32 start;
- int32 loop;
- int32 _delay;
- Graphics::Surface *_scaled;
- };
-
-private:
- typedef Common::List<playnode> PlayNodes;
-
- PlayNodes _playList;
-
- int32 _mask;
- bool _disposeAfterUse;
-
- Video::VideoDecoder *_animation;
- int32 _frmDelayOverride;
-
-public:
- bool process(uint32 deltaTimeInMillis);
-
- void addPlayNode(int32 slot, int x, int y, int x2, int y2, int startFrame, int endFrame, int loops = 1);
-
- bool stop();
-};
-
-} // End of namespace ZVision
-
-#endif
diff --git a/engines/zvision/scripting/sidefx/distort_node.cpp b/engines/zvision/scripting/sidefx/distort_node.cpp
deleted file mode 100644
index 7d25adc..0000000
--- a/engines/zvision/scripting/sidefx/distort_node.cpp
+++ /dev/null
@@ -1,104 +0,0 @@
-/* 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/scripting/sidefx/distort_node.h"
-
-#include "zvision/zvision.h"
-#include "zvision/scripting/script_manager.h"
-#include "zvision/graphics/render_manager.h"
-#include "zvision/graphics/render_table.h"
-
-#include "common/stream.h"
-
-namespace ZVision {
-
-DistortNode::DistortNode(ZVision *engine, uint32 key, int16 speed, float startAngle, float endAngle, float startLineScale, float endLineScale)
- : SideFX(engine, key, SIDEFX_DISTORT) {
-
- _angle = _engine->getRenderManager()->getRenderTable()->getAngle();
- _linScale = _engine->getRenderManager()->getRenderTable()->getLinscale();
-
- _speed = speed;
- _incr = true;
- _startAngle = startAngle;
- _endAngle = endAngle;
- _startLineScale = startLineScale;
- _endLineScale = endLineScale;
-
- _curFrame = 1.0;
-
- _diffAngle = endAngle - startAngle;
- _diffLinScale = endLineScale - startLineScale;
-
- _frmSpeed = (float)speed / 15.0;
- _frames = ceil((5.0 - _frmSpeed * 2.0) / _frmSpeed);
- if (_frames <= 0)
- _frames = 1;
-
- if (_key != StateKey_NotSet)
- _engine->getScriptManager()->setStateValue(_key, 1);
-}
-
-DistortNode::~DistortNode() {
- setParams(_angle, _linScale);
-}
-
-bool DistortNode::process(uint32 deltaTimeInMillis) {
- float updTime = deltaTimeInMillis / (1000.0 / 60.0);
-
- if (_incr)
- _curFrame += updTime;
- else
- _curFrame -= updTime;
-
- if (_curFrame < 1.0) {
- _curFrame = 1.0;
- _incr = true;
- } else if (_curFrame > _frames) {
- _curFrame = _frames;
- _incr = false;
- }
-
- float diff = (1.0 / (5.0 - (_curFrame * _frmSpeed))) / (5.0 - _frmSpeed);
- setParams(_startAngle + diff * _diffAngle, _startLineScale + diff * _diffLinScale);
-
- return false;
-}
-
-void DistortNode::setParams(float angl, float linScale) {
- RenderTable *table = _engine->getRenderManager()->getRenderTable();
- if (table->getRenderState() == RenderTable::PANORAMA) {
- table->setPanoramaFoV(angl);
- table->setPanoramaScale(linScale);
- table->generateRenderTable();
- _engine->getRenderManager()->markDirty();
- } else if (table->getRenderState() == RenderTable::TILT) {
- table->setTiltFoV(angl);
- table->setTiltScale(linScale);
- table->generateRenderTable();
- _engine->getRenderManager()->markDirty();
- }
-}
-
-} // End of namespace ZVision
diff --git a/engines/zvision/scripting/sidefx/distort_node.h b/engines/zvision/scripting/sidefx/distort_node.h
deleted file mode 100644
index 787a69b..0000000
--- a/engines/zvision/scripting/sidefx/distort_node.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* 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_DISTORT_NODE_H
-#define ZVISION_DISTORT_NODE_H
-
-#include "zvision/scripting/sidefx.h"
-
-namespace ZVision {
-
-class ZVision;
-
-class DistortNode : public SideFX {
-public:
- DistortNode(ZVision *engine, uint32 key, int16 speed, float startAngle, float endAngle, float startLineScale, float endLineScale);
- ~DistortNode();
-
- bool process(uint32 deltaTimeInMillis);
-
-private:
- int16 _speed;
- float _startAngle;
- float _endAngle;
- float _startLineScale;
- float _endLineScale;
-
- float _frmSpeed;
- float _diffAngle;
- float _diffLinScale;
- bool _incr;
- int16 _frames;
-
- float _curFrame;
-
- float _angle;
- float _linScale;
-
-private:
- void setParams(float angl, float linScale);
-};
-
-} // End of namespace ZVision
-
-#endif
diff --git a/engines/zvision/scripting/sidefx/music_node.cpp b/engines/zvision/scripting/sidefx/music_node.cpp
deleted file mode 100644
index 0cada6d..0000000
--- a/engines/zvision/scripting/sidefx/music_node.cpp
+++ /dev/null
@@ -1,248 +0,0 @@
-/* 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/scripting/sidefx/music_node.h"
-
-#include "zvision/zvision.h"
-#include "zvision/scripting/script_manager.h"
-#include "zvision/graphics/render_manager.h"
-#include "zvision/sound/midi.h"
-#include "zvision/sound/zork_raw.h"
-
-#include "common/stream.h"
-#include "common/file.h"
-#include "audio/decoders/wave.h"
-
-namespace ZVision {
-
-MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool loop, int8 volume)
- : MusicNodeBASE(engine, key, SIDEFX_AUDIO) {
- _loop = loop;
- _volume = volume;
- _crossfade = false;
- _crossfadeTarget = 0;
- _crossfadeTime = 0;
- _attenuate = 0;
- _pantrack = false;
- _pantrackPosition = 0;
- _sub = NULL;
- _stereo = false;
- _loaded = false;
-
- Audio::RewindableAudioStream *audioStream = NULL;
-
- if (filename.contains(".wav")) {
- Common::File *file = new Common::File();
- if (_engine->getSearchManager()->openFile(*file, filename)) {
- audioStream = Audio::makeWAVStream(file, DisposeAfterUse::YES);
- }
- } else {
- audioStream = makeRawZorkStream(filename, _engine);
- }
-
- if (audioStream) {
- _stereo = audioStream->isStereo();
-
- if (_loop) {
- Audio::LoopingAudioStream *loopingAudioStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES);
- _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, loopingAudioStream, -1, _volume);
- } else {
- _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, audioStream, -1, _volume);
- }
-
- if (_key != StateKey_NotSet)
- _engine->getScriptManager()->setStateValue(_key, 1);
-
- // Change filename.raw into filename.sub
- Common::String subname = filename;
- subname.setChar('s', subname.size() - 3);
- subname.setChar('u', subname.size() - 2);
- subname.setChar('b', subname.size() - 1);
-
- if (_engine->getSearchManager()->hasFile(subname))
- _sub = new Subtitle(_engine, subname);
-
- _loaded = true;
- }
-}
-
-MusicNode::~MusicNode() {
- if (_loaded)
- _engine->_mixer->stopHandle(_handle);
- if (_key != StateKey_NotSet)
- _engine->getScriptManager()->setStateValue(_key, 2);
- if (_sub)
- delete _sub;
- debug(1, "MusicNode: %d destroyed\n", _key);
-}
-
-void MusicNode::setPanTrack(int16 pos) {
- if (!_stereo) {
- _pantrack = true;
- _pantrackPosition = pos;
- setVolume(_volume);
- }
-}
-
-void MusicNode::unsetPanTrack() {
- _pantrack = false;
- setVolume(_volume);
-}
-
-void MusicNode::setFade(int32 time, uint8 target) {
- _crossfadeTarget = target;
- _crossfadeTime = time;
- _crossfade = true;
-}
-
-bool MusicNode::process(uint32 deltaTimeInMillis) {
- if (!_loaded || ! _engine->_mixer->isSoundHandleActive(_handle))
- return stop();
- else {
- uint8 _newvol = _volume;
-
- if (_crossfade) {
- if (_crossfadeTime > 0) {
- if ((int32)deltaTimeInMillis > _crossfadeTime)
- deltaTimeInMillis = _crossfadeTime;
- _newvol += floor(((float)(_crossfadeTarget - _newvol) / (float)_crossfadeTime)) * (float)deltaTimeInMillis;
- _crossfadeTime -= deltaTimeInMillis;
- } else {
- _crossfade = false;
- _newvol = _crossfadeTarget;
- }
- }
-
- if (_pantrack || _volume != _newvol)
- setVolume(_newvol);
-
- if (_sub && _engine->getScriptManager()->getStateValue(StateKey_Subtitles) == 1)
- _sub->process(_engine->_mixer->getSoundElapsedTime(_handle) / 100);
- }
- return false;
-}
-
-void MusicNode::setVolume(uint8 newVolume) {
- if (!_loaded)
- return;
- if (_pantrack) {
- int curX = _engine->getScriptManager()->getStateValue(StateKey_ViewPos);
- curX -= _pantrackPosition;
- int32 _width = _engine->getRenderManager()->getBkgSize().x;
- if (curX < (-_width) / 2)
- curX += _width;
- else if (curX >= _width / 2)
- curX -= _width;
-
- float norm = (float)curX / ((float)_width / 2.0);
- float lvl = fabs(norm);
- if (lvl > 0.5)
- lvl = (lvl - 0.5) * 1.7;
- else
- lvl = 1.0;
-
- float bal = sin(-norm * 3.1415926) * 127.0;
-
- if (_engine->_mixer->isSoundHandleActive(_handle)) {
- _engine->_mixer->setChannelBalance(_handle, bal);
- _engine->_mixer->setChannelVolume(_handle, newVolume * lvl);
- }
- } else {
- if (_engine->_mixer->isSoundHandleActive(_handle)) {
- _engine->_mixer->setChannelBalance(_handle, 0);
- _engine->_mixer->setChannelVolume(_handle, newVolume);
- }
- }
-
- _volume = newVolume;
-}
-
-PanTrackNode::PanTrackNode(ZVision *engine, uint32 key, uint32 slot, int16 pos)
- : SideFX(engine, key, SIDEFX_PANTRACK) {
- _slot = slot;
-
- SideFX *fx = _engine->getScriptManager()->getSideFX(slot);
- if (fx && fx->getType() == SIDEFX_AUDIO) {
- MusicNodeBASE *mus = (MusicNodeBASE *)fx;
- mus->setPanTrack(pos);
- }
-}
-
-PanTrackNode::~PanTrackNode() {
- SideFX *fx = _engine->getScriptManager()->getSideFX(_slot);
- if (fx && fx->getType() == SIDEFX_AUDIO) {
- MusicNodeBASE *mus = (MusicNodeBASE *)fx;
- mus->unsetPanTrack();
- }
-}
-
-MusicMidiNode::MusicMidiNode(ZVision *engine, uint32 key, int8 program, int8 note, int8 volume)
- : MusicNodeBASE(engine, key, SIDEFX_AUDIO) {
- _volume = volume;
- _prog = program;
- _noteNumber = note;
- _pan = 0;
-
- _chan = _engine->getMidiManager()->getFreeChannel();
-
- if (_chan >= 0) {
- _engine->getMidiManager()->setVolume(_chan, _volume);
- _engine->getMidiManager()->setPan(_chan, _pan);
- _engine->getMidiManager()->setProgram(_chan, _prog);
- _engine->getMidiManager()->noteOn(_chan, _noteNumber, _volume);
- }
-
- if (_key != StateKey_NotSet)
- _engine->getScriptManager()->setStateValue(_key, 1);
-}
-
-MusicMidiNode::~MusicMidiNode() {
- if (_chan >= 0) {
- _engine->getMidiManager()->noteOff(_chan);
- }
- if (_key != StateKey_NotSet)
- _engine->getScriptManager()->setStateValue(_key, 2);
-}
-
-void MusicMidiNode::setPanTrack(int16 pos) {
-}
-
-void MusicMidiNode::unsetPanTrack() {
-}
-
-void MusicMidiNode::setFade(int32 time, uint8 target) {
-}
-
-bool MusicMidiNode::process(uint32 deltaTimeInMillis) {
- return false;
-}
-
-void MusicMidiNode::setVolume(uint8 newVolume) {
- if (_chan >= 0) {
- _engine->getMidiManager()->setVolume(_chan, newVolume);
- }
- _volume = newVolume;
-}
-
-} // End of namespace ZVision
diff --git a/engines/zvision/scripting/sidefx/music_node.h b/engines/zvision/scripting/sidefx/music_node.h
deleted file mode 100644
index 3f1ca5c..0000000
--- a/engines/zvision/scripting/sidefx/music_node.h
+++ /dev/null
@@ -1,135 +0,0 @@
-/* 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_MUSIC_NODE_H
-#define ZVISION_MUSIC_NODE_H
-
-#include "audio/mixer.h"
-#include "zvision/scripting/sidefx.h"
-#include "zvision/text/subtitles.h"
-
-namespace Common {
-class String;
-}
-
-namespace ZVision {
-
-class MusicNodeBASE : public SideFX {
-public:
- MusicNodeBASE(ZVision *engine, uint32 key, SideFXType type) : SideFX(engine, key, type) {}
- ~MusicNodeBASE() {}
-
- /**
- * Decrement the timer by the delta time. If the timer is finished, set the status
- * in _globalState and let this node be deleted
- *
- * @param deltaTimeInMillis The number of milliseconds that have passed since last frame
- * @return If true, the node can be deleted after process() finishes
- */
- virtual bool process(uint32 deltaTimeInMillis) = 0;
-
- virtual void setVolume(uint8 volume) = 0;
-
- virtual void setPanTrack(int16 pos) = 0;
- virtual void unsetPanTrack() = 0;
-
- virtual void setFade(int32 time, uint8 target) = 0;
-};
-
-class MusicNode : public MusicNodeBASE {
-public:
- MusicNode(ZVision *engine, uint32 key, Common::String &file, bool loop, int8 volume);
- ~MusicNode();
-
- /**
- * Decrement the timer by the delta time. If the timer is finished, set the status
- * in _globalState and let this node be deleted
- *
- * @param deltaTimeInMillis The number of milliseconds that have passed since last frame
- * @return If true, the node can be deleted after process() finishes
- */
- bool process(uint32 deltaTimeInMillis);
-
- void setVolume(uint8 volume);
-
- void setPanTrack(int16 pos);
- void unsetPanTrack();
-
- void setFade(int32 time, uint8 target);
-
-private:
- bool _pantrack;
- int32 _pantrackPosition;
- int32 _attenuate;
- uint8 _volume;
- bool _loop;
- bool _crossfade;
- uint8 _crossfadeTarget;
- int32 _crossfadeTime;
- bool _stereo;
- Audio::SoundHandle _handle;
- Subtitle *_sub;
- bool _loaded;
-};
-
-// Only used by Zork: Nemesis, for the flute and piano puzzles (tj4e and ve6f, as well as vr)
-class MusicMidiNode : public MusicNodeBASE {
-public:
- MusicMidiNode(ZVision *engine, uint32 key, int8 program, int8 note, int8 volume);
- ~MusicMidiNode();
-
- /**
- * Decrement the timer by the delta time. If the timer is finished, set the status
- * in _globalState and let this node be deleted
- *
- * @param deltaTimeInMillis The number of milliseconds that have passed since last frame
- * @return If true, the node can be deleted after process() finishes
- */
- bool process(uint32 deltaTimeInMillis);
-
- void setVolume(uint8 volume);
-
- void setPanTrack(int16 pos);
- void unsetPanTrack();
-
- void setFade(int32 time, uint8 target);
-
-private:
- int8 _chan;
- int8 _noteNumber;
- int8 _pan;
- int8 _volume;
- int8 _prog;
-};
-
-class PanTrackNode : public SideFX {
-public:
- PanTrackNode(ZVision *engine, uint32 key, uint32 slot, int16 pos);
- ~PanTrackNode();
-
-private:
- uint32 _slot;
-};
-
-} // End of namespace ZVision
-
-#endif
diff --git a/engines/zvision/scripting/sidefx/region_node.cpp b/engines/zvision/scripting/sidefx/region_node.cpp
deleted file mode 100644
index de613d8..0000000
--- a/engines/zvision/scripting/sidefx/region_node.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/* 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/scripting/sidefx/region_node.h"
-
-#include "zvision/zvision.h"
-#include "zvision/scripting/script_manager.h"
-#include "zvision/graphics/render_manager.h"
-
-namespace ZVision {
-
-RegionNode::RegionNode(ZVision *engine, uint32 key, Effect *effect, uint32 delay)
- : SideFX(engine, key, SIDEFX_REGION) {
- _effect = effect;
- _delay = delay;
- _timeLeft = 0;
-}
-
-RegionNode::~RegionNode() {
- _engine->getRenderManager()->deleteEffect(_key);
-}
-
-bool RegionNode::process(uint32 deltaTimeInMillis) {
- _timeLeft -= deltaTimeInMillis;
-
- if (_timeLeft <= 0) {
- _timeLeft = _delay;
- if (_effect)
- _effect->update();
- }
-
- return false;
-}
-
-} // End of namespace ZVision
diff --git a/engines/zvision/scripting/sidefx/region_node.h b/engines/zvision/scripting/sidefx/region_node.h
deleted file mode 100644
index ec716b6..0000000
--- a/engines/zvision/scripting/sidefx/region_node.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* 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_REGION_NODE_H
-#define ZVISION_REGION_NODE_H
-
-#include "graphics/surface.h"
-
-#include "zvision/scripting/sidefx.h"
-#include "zvision/graphics/effect.h"
-
-namespace ZVision {
-
-class ZVision;
-
-class RegionNode : public SideFX {
-public:
- RegionNode(ZVision *engine, uint32 key, Effect *effect, uint32 delay);
- ~RegionNode();
-
- /**
- * Decrement the timer by the delta time. If the timer is finished, set the status
- * in _globalState and let this node be deleted
- *
- * @param deltaTimeInMillis The number of milliseconds that have passed since last frame
- * @return If true, the node can be deleted after process() finishes
- */
- bool process(uint32 deltaTimeInMillis);
-
-private:
- int32 _timeLeft;
- uint32 _delay;
- Effect *_effect;
-};
-
-} // End of namespace ZVision
-
-#endif
diff --git a/engines/zvision/scripting/sidefx/syncsound_node.cpp b/engines/zvision/scripting/sidefx/syncsound_node.cpp
deleted file mode 100644
index eec320b..0000000
--- a/engines/zvision/scripting/sidefx/syncsound_node.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/* 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/scripting/sidefx/syncsound_node.h"
-
-#include "zvision/zvision.h"
-#include "zvision/scripting/script_manager.h"
-#include "zvision/graphics/render_manager.h"
-#include "zvision/sound/zork_raw.h"
-
-#include "common/stream.h"
-#include "common/file.h"
-#include "audio/decoders/wave.h"
-
-namespace ZVision {
-
-SyncSoundNode::SyncSoundNode(ZVision *engine, uint32 key, Common::String &filename, int32 syncto)
- : SideFX(engine, key, SIDEFX_AUDIO) {
- _syncto = syncto;
- _sub = NULL;
-
- Audio::RewindableAudioStream *audioStream = NULL;
-
- if (filename.contains(".wav")) {
- Common::File *file = new Common::File();
- if (_engine->getSearchManager()->openFile(*file, filename)) {
- audioStream = Audio::makeWAVStream(file, DisposeAfterUse::YES);
- }
- } else {
- audioStream = makeRawZorkStream(filename, _engine);
- }
-
- _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, audioStream);
-
- Common::String subname = filename;
- subname.setChar('s', subname.size() - 3);
- subname.setChar('u', subname.size() - 2);
- subname.setChar('b', subname.size() - 1);
-
- if (_engine->getSearchManager()->hasFile(subname))
- _sub = new Subtitle(_engine, subname);
-}
-
-SyncSoundNode::~SyncSoundNode() {
- _engine->_mixer->stopHandle(_handle);
- if (_sub)
- delete _sub;
-}
-
-bool SyncSoundNode::process(uint32 deltaTimeInMillis) {
- if (! _engine->_mixer->isSoundHandleActive(_handle))
- return stop();
- else {
-
- if (_engine->getScriptManager()->getSideFX(_syncto) == NULL)
- return stop();
-
- if (_sub && _engine->getScriptManager()->getStateValue(StateKey_Subtitles) == 1)
- _sub->process(_engine->_mixer->getSoundElapsedTime(_handle) / 100);
- }
- return false;
-}
-
-} // End of namespace ZVision
diff --git a/engines/zvision/scripting/sidefx/syncsound_node.h b/engines/zvision/scripting/sidefx/syncsound_node.h
deleted file mode 100644
index 5961fcc..0000000
--- a/engines/zvision/scripting/sidefx/syncsound_node.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* 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_SYNCSOUND_NODE_H
-#define ZVISION_SYNCSOUND_NODE_H
-
-#include "audio/mixer.h"
-#include "zvision/scripting/sidefx.h"
-#include "zvision/text/subtitles.h"
-
-namespace Common {
-class String;
-}
-
-namespace ZVision {
-class SyncSoundNode : public SideFX {
-public:
- SyncSoundNode(ZVision *engine, uint32 key, Common::String &file, int32 syncto);
- ~SyncSoundNode();
-
- /**
- * Decrement the timer by the delta time. If the timer is finished, set the status
- * in _globalState and let this node be deleted
- *
- * @param deltaTimeInMillis The number of milliseconds that have passed since last frame
- * @return If true, the node can be deleted after process() finishes
- */
- bool process(uint32 deltaTimeInMillis);
-private:
- int32 _syncto;
- Audio::SoundHandle _handle;
- Subtitle *_sub;
-};
-
-} // End of namespace ZVision
-
-#endif
diff --git a/engines/zvision/scripting/sidefx/timer_node.cpp b/engines/zvision/scripting/sidefx/timer_node.cpp
deleted file mode 100644
index 170f6e7..0000000
--- a/engines/zvision/scripting/sidefx/timer_node.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-/* 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/scripting/sidefx/timer_node.h"
-
-#include "zvision/zvision.h"
-#include "zvision/scripting/script_manager.h"
-
-#include "common/stream.h"
-
-namespace ZVision {
-
-TimerNode::TimerNode(ZVision *engine, uint32 key, uint timeInSeconds)
- : SideFX(engine, key, SIDEFX_TIMER) {
- _timeLeft = 0;
-
- if (_engine->getGameId() == GID_NEMESIS)
- _timeLeft = timeInSeconds * 1000;
- else if (_engine->getGameId() == GID_GRANDINQUISITOR)
- _timeLeft = timeInSeconds * 100;
-
- if (_key != StateKey_NotSet)
- _engine->getScriptManager()->setStateValue(_key, 1);
-}
-
-TimerNode::~TimerNode() {
- if (_key != StateKey_NotSet)
- _engine->getScriptManager()->setStateValue(_key, 2);
- int32 timeLeft = _timeLeft / (_engine->getGameId() == GID_NEMESIS ? 1000 : 100);
- if (timeLeft > 0)
- _engine->getScriptManager()->setStateValue(_key, timeLeft); // If timer was stopped by stop or kill
-}
-
-bool TimerNode::process(uint32 deltaTimeInMillis) {
- _timeLeft -= deltaTimeInMillis;
-
- if (_timeLeft <= 0)
- return stop();
-
- return false;
-}
-
-bool TimerNode::stop() {
- if (_key != StateKey_NotSet)
- _engine->getScriptManager()->setStateValue(_key, 2);
- return true;
-}
-
-void TimerNode::serialize(Common::WriteStream *stream) {
- stream->writeUint32BE(MKTAG('T', 'I', 'M', 'R'));
- stream->writeUint32LE(8); // size
- stream->writeUint32LE(_key);
- stream->writeUint32LE(_timeLeft);
-}
-
-void TimerNode::deserialize(Common::SeekableReadStream *stream) {
- _timeLeft = stream->readUint32LE();
-}
-
-} // End of namespace ZVision
diff --git a/engines/zvision/scripting/sidefx/timer_node.h b/engines/zvision/scripting/sidefx/timer_node.h
deleted file mode 100644
index 7a26aff..0000000
--- a/engines/zvision/scripting/sidefx/timer_node.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* 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_TIMER_NODE_H
-#define ZVISION_TIMER_NODE_H
-
-#include "zvision/scripting/sidefx.h"
-
-namespace ZVision {
-
-class ZVision;
-
-class TimerNode : public SideFX {
-public:
- TimerNode(ZVision *engine, uint32 key, uint timeInSeconds);
- ~TimerNode();
-
- /**
- * Decrement the timer by the delta time. If the timer is finished, set the status
- * in _globalState and let this node be deleted
- *
- * @param deltaTimeInMillis The number of milliseconds that have passed since last frame
- * @return If true, the node can be deleted after process() finishes
- */
- bool process(uint32 deltaTimeInMillis);
- void serialize(Common::WriteStream *stream);
- void deserialize(Common::SeekableReadStream *stream);
- inline bool needsSerialization() {
- return true;
- }
-
- bool stop();
-
-private:
- int32 _timeLeft;
-};
-
-} // End of namespace ZVision
-
-#endif
diff --git a/engines/zvision/scripting/sidefx/ttytext_node.cpp b/engines/zvision/scripting/sidefx/ttytext_node.cpp
deleted file mode 100644
index 66a27e9..0000000
--- a/engines/zvision/scripting/sidefx/ttytext_node.cpp
+++ /dev/null
@@ -1,174 +0,0 @@
-/* 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/scripting/sidefx/ttytext_node.h"
-
-#include "zvision/zvision.h"
-#include "zvision/scripting/script_manager.h"
-#include "zvision/graphics/render_manager.h"
-#include "zvision/text/text.h"
-
-#include "common/stream.h"
-#include "common/file.h"
-
-namespace ZVision {
-
-ttyTextNode::ttyTextNode(ZVision *engine, uint32 key, const Common::String &file, const Common::Rect &r, int32 delay) :
- SideFX(engine, key, SIDEFX_TTYTXT),
- _fnt(engine) {
- _delay = delay;
- _r = r;
- _txtpos = 0;
- _nexttime = 0;
- _dx = 0;
- _dy = 0;
-
- Common::File *infile = _engine->getSearchManager()->openFile(file);
- if (infile) {
- while (!infile->eos()) {
- Common::String asciiLine = readWideLine(*infile);
- if (asciiLine.empty()) {
- continue;
- }
- _txtbuf += asciiLine;
- }
-
- delete infile;
- }
- _img.create(_r.width(), _r.height(), _engine->_resourcePixelFormat);
- _style._sharp = true;
- _style.readAllStyle(_txtbuf);
- _style.setFont(_fnt);
- _engine->getScriptManager()->setStateValue(_key, 1);
-}
-
-ttyTextNode::~ttyTextNode() {
- _engine->getScriptManager()->setStateValue(_key, 2);
- _img.free();
-}
-
-bool ttyTextNode::process(uint32 deltaTimeInMillis) {
- _nexttime -= deltaTimeInMillis;
-
- if (_nexttime < 0) {
- if (_txtpos < _txtbuf.size()) {
- if (_txtbuf[_txtpos] == '<') {
- int32 strt = _txtpos;
- int32 endt = 0;
- int16 ret = 0;
- while (_txtbuf[_txtpos] != '>' && _txtpos < _txtbuf.size())
- _txtpos++;
- endt = _txtpos;
- if (strt != -1)
- if ((endt - strt - 1) > 0)
- ret = _style.parseStyle(_txtbuf.c_str() + strt + 1, endt - strt - 1);
-
- if (ret & (TXT_RET_FNTCHG | TXT_RET_FNTSTL | TXT_RET_NEWLN)) {
- if (ret & TXT_RET_FNTCHG)
- _style.setFont(_fnt);
- if (ret & TXT_RET_FNTSTL)
- _style.setFontStyle(_fnt);
-
- if (ret & TXT_RET_NEWLN)
- newline();
- }
-
- if (ret & TXT_RET_HASSTBOX) {
- Common::String buf;
- buf = Common::String::format("%d", _engine->getScriptManager()->getStateValue(_style._statebox));
-
- for (uint8 j = 0; j < buf.size(); j++)
- outchar(buf[j]);
- }
-
- _txtpos++;
- } else {
- int8 charsz = getUtf8CharSize(_txtbuf[_txtpos]);
-
- uint16 chr = readUtf8Char(_txtbuf.c_str() + _txtpos);
-
- if (chr == ' ') {
- uint32 i = _txtpos + charsz;
- uint16 width = _fnt.getCharWidth(chr);
-
- while (i < _txtbuf.size() && _txtbuf[i] != ' ' && _txtbuf[i] != '<') {
-
- int8 chsz = getUtf8CharSize(_txtbuf[i]);
- uint16 uchr = readUtf8Char(_txtbuf.c_str() + _txtpos);
-
- width += _fnt.getCharWidth(uchr);
-
- i += chsz;
- }
-
- if (_dx + width > _r.width())
- newline();
- else
- outchar(chr);
- } else
- outchar(chr);
-
- _txtpos += charsz;
- }
- _nexttime = _delay;
- _engine->getRenderManager()->blitSurfaceToBkg(_img, _r.left, _r.top);
- } else
- return stop();
- }
-
- return false;
-}
-
-void ttyTextNode::scroll() {
- int32 scrl = 0;
- while (_dy - scrl > _r.height() - _fnt.getFontHeight())
- scrl += _fnt.getFontHeight();
- int8 *pixels = (int8 *)_img.getPixels();
- for (uint16 h = scrl; h < _img.h; h++)
- memcpy(pixels + _img.pitch * (h - scrl), pixels + _img.pitch * h, _img.pitch);
-
- _img.fillRect(Common::Rect(0, _img.h - scrl, _img.w, _img.h), 0);
- _dy -= scrl;
-}
-
-void ttyTextNode::newline() {
- _dy += _fnt.getFontHeight();
- _dx = 0;
-}
-
-void ttyTextNode::outchar(uint16 chr) {
- uint32 clr = _engine->_resourcePixelFormat.RGBToColor(_style._red, _style._green, _style._blue);
-
- if (_dx + _fnt.getCharWidth(chr) > _r.width())
- newline();
-
- if (_dy + _fnt.getFontHeight() >= _r.height())
- scroll();
-
- _fnt.drawChar(&_img, chr, _dx, _dy, clr);
-
- _dx += _fnt.getCharWidth(chr);
-}
-
-} // End of namespace ZVision
diff --git a/engines/zvision/scripting/sidefx/ttytext_node.h b/engines/zvision/scripting/sidefx/ttytext_node.h
deleted file mode 100644
index 26d9be8..0000000
--- a/engines/zvision/scripting/sidefx/ttytext_node.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/* 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_TTYTEXT_NODE_H
-#define ZVISION_TTYTEXT_NODE_H
-
-#include "common/rect.h"
-#include "graphics/surface.h"
-
-#include "zvision/scripting/sidefx.h"
-#include "zvision/text/text.h"
-#include "zvision/text/truetype_font.h"
-
-namespace Common {
-class String;
-}
-
-namespace ZVision {
-class ttyTextNode : public SideFX {
-public:
- ttyTextNode(ZVision *engine, uint32 key, const Common::String &file, const Common::Rect &r, int32 delay);
- ~ttyTextNode();
-
- /**
- * Decrement the timer by the delta time. If the timer is finished, set the status
- * in _globalState and let this node be deleted
- *
- * @param deltaTimeInMillis The number of milliseconds that have passed since last frame
- * @return If true, the node can be deleted after process() finishes
- */
- bool process(uint32 deltaTimeInMillis);
-private:
- Common::Rect _r;
-
- cTxtStyle _style;
- StyledTTFont _fnt;
- Common::String _txtbuf;
- uint32 _txtpos;
-
- int32 _delay;
- int32 _nexttime;
- Graphics::Surface _img;
- int16 _dx;
- int16 _dy;
-private:
-
- void newline();
- void scroll();
- void outchar(uint16 chr);
-};
-
-} // End of namespace ZVision
-
-#endif
More information about the Scummvm-git-logs
mailing list