Skip to content

Commit

Permalink
ZVISION: Replace disable/enable control functions by call to
Browse files Browse the repository at this point in the history
getStateFlag.
  • Loading branch information
Marisa-Chan committed Oct 25, 2013
1 parent c0a709d commit 6d5e8cb
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 39 deletions.
4 changes: 0 additions & 4 deletions engines/zvision/animation_control.cpp
Expand Up @@ -71,9 +71,6 @@ AnimationControl::~AnimationControl() {
}

bool AnimationControl::process(uint32 deltaTimeInMillis) {
if (!_enabled) {
return false;
}

bool finished = false;

Expand Down Expand Up @@ -253,7 +250,6 @@ bool AnimationControl::process(uint32 deltaTimeInMillis) {
// Then disable the control. DON'T delete it. It can be re-used
if (finished) {
_engine->getScriptManager()->setStateValue(_animationKey, 2);
disable();
_currentLoop = 0;
}

Expand Down
18 changes: 0 additions & 18 deletions engines/zvision/control.cpp
Expand Up @@ -33,24 +33,6 @@

namespace ZVision {

void Control::enable() {
if (!_enabled) {
_enabled = true;
return;
}

debug("Control %u is already enabled", _key);
}

void Control::disable() {
if (_enabled) {
_enabled = false;
return;
}

debug("Control %u is already disabled", _key);
}

void Control::parseFlatControl(ZVision *engine) {
engine->getRenderManager()->getRenderTable()->setRenderState(RenderTable::FLAT);
}
Expand Down
7 changes: 2 additions & 5 deletions engines/zvision/control.h
Expand Up @@ -38,16 +38,14 @@ class ZVision;

class Control {
public:
Control() : _engine(0), _key(0), _enabled(false) {}
Control(ZVision *engine, uint32 key) : _engine(engine), _key(key), _enabled(false) {}
Control() : _engine(0), _key(0) {}
Control(ZVision *engine, uint32 key) : _engine(engine), _key(key) {}
virtual ~Control() {}

uint32 getKey() {
return _key;
}

virtual void enable();
virtual void disable();
virtual void focus() {}
virtual void unfocus() {}
/**
Expand Down Expand Up @@ -131,7 +129,6 @@ class Control {
protected:
ZVision *_engine;
uint32 _key;
bool _enabled;

// Static member functions
public:
Expand Down
12 changes: 4 additions & 8 deletions engines/zvision/lever_control.cpp
Expand Up @@ -191,9 +191,8 @@ void LeverControl::parseLevFile(const Common::String &fileName) {
}

void LeverControl::onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
if (!_enabled) {
if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
return;
}

if (_frameInfo[_currentFrame].hotspot.contains(backgroundImageSpacePos)) {
_mouseIsCaptured = true;
Expand All @@ -202,9 +201,8 @@ void LeverControl::onMouseDown(const Common::Point &screenSpacePos, const Common
}

void LeverControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
if (!_enabled) {
if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
return;
}

if (_mouseIsCaptured) {
_mouseIsCaptured = false;
Expand All @@ -217,9 +215,8 @@ void LeverControl::onMouseUp(const Common::Point &screenSpacePos, const Common::
}

bool LeverControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
if (!_enabled) {
if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
return false;
}

bool cursorWasChanged = false;

Expand Down Expand Up @@ -248,9 +245,8 @@ bool LeverControl::onMouseMove(const Common::Point &screenSpacePos, const Common
}

bool LeverControl::process(uint32 deltaTimeInMillis) {
if (!_enabled) {
if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
return false;
}

if (_isReturning) {
_accumulatedTime += deltaTimeInMillis;
Expand Down
6 changes: 2 additions & 4 deletions engines/zvision/push_toggle_control.cpp
Expand Up @@ -73,19 +73,17 @@ PushToggleControl::~PushToggleControl() {
}

void PushToggleControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
if (!_enabled) {
if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
return;
}

if (_hotspot.contains(backgroundImageSpacePos)) {
_engine->getScriptManager()->setStateValue(_key, 1);
}
}

bool PushToggleControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
if (!_enabled) {
if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
return false;
}

if (_hotspot.contains(backgroundImageSpacePos)) {
_engine->getCursorManager()->changeCursor(_hoverCursor);
Expand Down

0 comments on commit 6d5e8cb

Please sign in to comment.