aboutsummaryrefslogtreecommitdiff
path: root/engines/zvision/scripting
diff options
context:
space:
mode:
authorMarisa-Chan2014-10-10 16:40:46 +0700
committerMarisa-Chan2014-10-10 16:40:46 +0700
commitcf63da941cf7b7162551f6d660f5dbbda3150239 (patch)
tree930f14ddbbefb64cf8244321e437726cdaa92953 /engines/zvision/scripting
parent2a6c2fdf4532e6f5ba3a2a6f8a0e78db4dcdc635 (diff)
downloadscummvm-rg350-cf63da941cf7b7162551f6d660f5dbbda3150239.tar.gz
scummvm-rg350-cf63da941cf7b7162551f6d660f5dbbda3150239.tar.bz2
scummvm-rg350-cf63da941cf7b7162551f6d660f5dbbda3150239.zip
ZVISION: Action:region and visual effects implemented.
Diffstat (limited to 'engines/zvision/scripting')
-rw-r--r--engines/zvision/scripting/actions.cpp80
-rw-r--r--engines/zvision/scripting/actions.h16
-rw-r--r--engines/zvision/scripting/scr_file_handling.cpp2
-rw-r--r--engines/zvision/scripting/script_manager.h4
-rw-r--r--engines/zvision/scripting/sidefx/region_node.cpp56
-rw-r--r--engines/zvision/scripting/sidefx/region_node.h57
6 files changed, 212 insertions, 3 deletions
diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp
index 399a81d898..839eb1f92c 100644
--- a/engines/zvision/scripting/actions.cpp
+++ b/engines/zvision/scripting/actions.cpp
@@ -34,7 +34,13 @@
#include "zvision/scripting/sidefx/syncsound_node.h"
#include "zvision/scripting/sidefx/animation_node.h"
#include "zvision/scripting/sidefx/ttytext_node.h"
+#include "zvision/scripting/sidefx/region_node.h"
#include "zvision/scripting/controls/titler_control.h"
+#include "zvision/graphics/render_table.h"
+#include "zvision/graphics/effect.h"
+#include "zvision/graphics/effects/fog.h"
+#include "zvision/graphics/effects/light.h"
+#include "zvision/graphics/effects/wave.h"
#include "common/file.h"
@@ -476,6 +482,80 @@ bool ActionQuit::execute() {
return true;
}
+//////////////////////////////////////////////////////////////////////////////
+// ActionRegion
+//////////////////////////////////////////////////////////////////////////////
+
+ActionRegion::ActionRegion(ZVision *engine, int32 slotkey, const Common::String &line) :
+ ResultAction(engine, slotkey) {
+
+ char art[64];
+ char custom[64];
+
+ int32 x1, x2, y1, y2;
+
+ sscanf(line.c_str(), "%s %d %d %d %d %hu %hu %hu %hu %s", art, &x1, &y1, &x2, &y2, &_delay, &_type, &_unk1, &_unk2, custom);
+ _art = Common::String(art);
+ _custom = Common::String(custom);
+ _rect = Common::Rect(x1, y1, x2 + 1, y2 + 1);
+}
+
+ActionRegion::~ActionRegion() {
+ _engine->getScriptManager()->killSideFx(_slotkey);
+}
+
+bool ActionRegion::execute() {
+ if (_engine->getScriptManager()->getSideFX(_slotkey))
+ return true;
+
+ Effect *effct = NULL;
+ switch (_type) {
+ case 0: {
+ uint16 s_x, s_y, frames;
+ double amplitude, waveln, speed;
+ sscanf(_custom.c_str(), "%hu,%hu,%hu,%lf,%lf,%lf,", &s_x, &s_y, &frames, &amplitude, &waveln, &speed);
+ effct = new WaveFx(_engine, _slotkey, _rect, _unk1, frames, s_x, s_y, amplitude, waveln, speed);
+ }
+ break;
+ case 1: {
+ uint16 aX, aY, aD;
+ if (_engine->getRenderManager()->getRenderTable()->getRenderState() == RenderTable::PANORAMA)
+ sscanf(_art.c_str(), "useart[%hu,%hu,%hu]", &aY, &aX, &aD);
+ else
+ sscanf(_art.c_str(), "useart[%hu,%hu,%hu]", &aX, &aY, &aD);
+ int8 minD;
+ int8 maxD;
+ EffectMap *_map = _engine->getRenderManager()->makeEffectMap(Common::Point(aX, aY), aD, _rect, &minD, &maxD);
+ effct = new LightFx(_engine, _slotkey, _rect, _unk1, _map, atoi(_custom.c_str()), minD, maxD);
+ }
+ break;
+ case 9: {
+ int16 dum1;
+ int32 dum2;
+ char buf[64];
+ sscanf(_custom.c_str(), "%hd,%d,%s", &dum1, &dum2, buf);
+ Graphics::Surface tempMask;
+ _engine->getRenderManager()->readImageToSurface(_art, tempMask);
+ if (_rect.width() != tempMask.w)
+ _rect.setWidth(tempMask.w);
+ if (_rect.height() != tempMask.h)
+ _rect.setHeight(tempMask.h);
+
+ EffectMap *_map = _engine->getRenderManager()->makeEffectMap(tempMask, 0);
+ effct = new FogFx(_engine, _slotkey, _rect, _unk1, _map, Common::String(buf));
+ }
+ break;
+ default:
+ break;
+ }
+
+ if (effct) {
+ _engine->getScriptManager()->addSideFX(new RegionNode(_engine, _slotkey, effct, _delay));
+ _engine->getRenderManager()->addEffect(effct);
+ }
+
+ return true;
+}
//////////////////////////////////////////////////////////////////////////////
// ActionRandom
diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h
index de303a7b1b..5e34f6eaf0 100644
--- a/engines/zvision/scripting/actions.h
+++ b/engines/zvision/scripting/actions.h
@@ -317,6 +317,22 @@ public:
bool execute();
};
+class ActionRegion : public ResultAction {
+public:
+ ActionRegion(ZVision *engine, int32 slotkey, const Common::String &line);
+ ~ActionRegion();
+ bool execute();
+
+private:
+ Common::String _art;
+ Common::String _custom;
+ Common::Rect _rect;
+ uint16 _delay;
+ uint16 _type;
+ uint16 _unk1;
+ uint16 _unk2;
+};
+
// TODO: See if this exists in ZGI. It doesn't in ZNem
class ActionUnloadAnimation : public ResultAction {
public:
diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp
index 04378f856f..8140d09a6a 100644
--- a/engines/zvision/scripting/scr_file_handling.cpp
+++ b/engines/zvision/scripting/scr_file_handling.cpp
@@ -266,7 +266,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (act.matchString("random", true)) {
actionList.push_back(new ActionRandom(_engine, slot, args));
} else if (act.matchString("region", true)) {
- // TODO: Implement ActionRegion
+ actionList.push_back(new ActionRegion(_engine, slot, args));
} else if (act.matchString("restore_game", true)) {
// TODO: Implement ActionRestoreGame
} else if (act.matchString("rotate_to", true)) {
diff --git a/engines/zvision/scripting/script_manager.h b/engines/zvision/scripting/script_manager.h
index 4d82f36aea..219cff9f45 100644
--- a/engines/zvision/scripting/script_manager.h
+++ b/engines/zvision/scripting/script_manager.h
@@ -87,9 +87,9 @@ enum StateKey {
StateKey_DebugCheats = 74,
StateKey_JapanFonts = 75,
StateKey_Brightness = 77,
- StateKey_EF9_B = 91,
+ StateKey_EF9_R = 91,
StateKey_EF9_G = 92,
- StateKey_EF9_R = 93,
+ StateKey_EF9_B = 93,
StateKey_EF9_Speed = 94,
StateKey_Inv_Cnt_Slot = 100,
StateKey_Inv_1_Slot = 101,
diff --git a/engines/zvision/scripting/sidefx/region_node.cpp b/engines/zvision/scripting/sidefx/region_node.cpp
new file mode 100644
index 0000000000..de613d8af2
--- /dev/null
+++ b/engines/zvision/scripting/sidefx/region_node.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/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
new file mode 100644
index 0000000000..ec716b6e3e
--- /dev/null
+++ b/engines/zvision/scripting/sidefx/region_node.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/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