From 6d5e8cb10569eec6b42e41197227ed1652e57900 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 25 Oct 2013 20:42:14 +0000 Subject: [PATCH] ZVISION: Replace disable/enable control functions by call to getStateFlag. --- engines/zvision/animation_control.cpp | 4 ---- engines/zvision/control.cpp | 18 ------------------ engines/zvision/control.h | 7 ++----- engines/zvision/lever_control.cpp | 12 ++++-------- engines/zvision/push_toggle_control.cpp | 6 ++---- 5 files changed, 8 insertions(+), 39 deletions(-) diff --git a/engines/zvision/animation_control.cpp b/engines/zvision/animation_control.cpp index 66eefd7ce6cb..3f9a2e9cc7fe 100644 --- a/engines/zvision/animation_control.cpp +++ b/engines/zvision/animation_control.cpp @@ -71,9 +71,6 @@ AnimationControl::~AnimationControl() { } bool AnimationControl::process(uint32 deltaTimeInMillis) { - if (!_enabled) { - return false; - } bool finished = false; @@ -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; } diff --git a/engines/zvision/control.cpp b/engines/zvision/control.cpp index bcbdabc1432f..034622868130 100644 --- a/engines/zvision/control.cpp +++ b/engines/zvision/control.cpp @@ -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); } diff --git a/engines/zvision/control.h b/engines/zvision/control.h index ab55763a20e5..66fdbfee19fc 100644 --- a/engines/zvision/control.h +++ b/engines/zvision/control.h @@ -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() {} /** @@ -131,7 +129,6 @@ class Control { protected: ZVision *_engine; uint32 _key; - bool _enabled; // Static member functions public: diff --git a/engines/zvision/lever_control.cpp b/engines/zvision/lever_control.cpp index b0f9417042d2..bd2c186ffefc 100644 --- a/engines/zvision/lever_control.cpp +++ b/engines/zvision/lever_control.cpp @@ -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; @@ -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; @@ -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; @@ -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; diff --git a/engines/zvision/push_toggle_control.cpp b/engines/zvision/push_toggle_control.cpp index 21a1c41548d9..2cea5db2d2be 100644 --- a/engines/zvision/push_toggle_control.cpp +++ b/engines/zvision/push_toggle_control.cpp @@ -73,9 +73,8 @@ 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); @@ -83,9 +82,8 @@ void PushToggleControl::onMouseUp(const Common::Point &screenSpacePos, const Com } 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);