Skip to content

Commit

Permalink
ZVISION: Rename some scripting classes to better represent what the c…
Browse files Browse the repository at this point in the history
…lasses 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.
  • Loading branch information
RichieSams committed Dec 30, 2014
1 parent 6c3af3c commit 68d3ebd
Show file tree
Hide file tree
Showing 29 changed files with 149 additions and 134 deletions.
2 changes: 1 addition & 1 deletion engines/zvision/graphics/effects/fog.cpp
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions engines/zvision/graphics/effects/fog.h
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion engines/zvision/graphics/effects/light.cpp
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions engines/zvision/graphics/effects/light.h
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion engines/zvision/graphics/effects/wave.cpp
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions engines/zvision/graphics/effects/wave.h
Expand Up @@ -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);
Expand Down
Expand Up @@ -20,8 +20,8 @@
*
*/

#ifndef EFFECT_H_INCLUDED
#define EFFECT_H_INCLUDED
#ifndef GRAPHICS_EFFECT_H_INCLUDED
#define GRAPHICS_EFFECT_H_INCLUDED

#include "common/rect.h"
#include "common/list.h"
Expand All @@ -33,13 +33,13 @@ namespace ZVision {

class ZVision;

class Effect {
class GraphicsEffect {
public:

Effect(ZVision *engine, uint32 key, Common::Rect region, bool ported) : _engine(engine), _key(key), _region(region), _ported(ported) {
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 ~Effect() {}
virtual ~GraphicsEffect() {}

uint32 getKey() {
return _key;
Expand Down Expand Up @@ -80,4 +80,4 @@ typedef Common::List<EffectMapUnit> EffectMap;

} // End of namespace ZVision

#endif // EFFECT_H_INCLUDED
#endif // GRAPHICS_EFFECT_H_INCLUDED
2 changes: 1 addition & 1 deletion engines/zvision/graphics/render_manager.cpp
Expand Up @@ -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);
}

Expand Down
6 changes: 3 additions & 3 deletions engines/zvision/graphics/render_manager.h
Expand Up @@ -31,7 +31,7 @@

#include "graphics/surface.h"

#include "effect.h"
#include "graphics_effect.h"

class OSystem;

Expand Down Expand Up @@ -61,7 +61,7 @@ class RenderManager {
};

typedef Common::HashMap<uint16, OneSubtitle> SubtitleMap;
typedef Common::List<Effect *> EffectsList;
typedef Common::List<GraphicsEffect *> EffectsList;

private:
ZVision *_engine;
Expand Down Expand Up @@ -302,7 +302,7 @@ class RenderManager {
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);
Expand Down
14 changes: 7 additions & 7 deletions engines/zvision/module.mk
Expand Up @@ -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 \
Expand Down
66 changes: 33 additions & 33 deletions engines/zvision/scripting/actions.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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));
}
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down
5 changes: 5 additions & 0 deletions engines/zvision/scripting/control.h
Expand Up @@ -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:

Expand Down

0 comments on commit 68d3ebd

Please sign in to comment.