diff options
Diffstat (limited to 'engines/zvision')
-rw-r--r-- | engines/zvision/push_toggle_control.cpp | 46 | ||||
-rw-r--r-- | engines/zvision/push_toggle_control.h | 22 | ||||
-rw-r--r-- | engines/zvision/scr_file_handling.cpp | 2 |
3 files changed, 23 insertions, 47 deletions
diff --git a/engines/zvision/push_toggle_control.cpp b/engines/zvision/push_toggle_control.cpp index 9e68bdb8be..be038e767a 100644 --- a/engines/zvision/push_toggle_control.cpp +++ b/engines/zvision/push_toggle_control.cpp @@ -33,8 +33,7 @@ namespace ZVision { PushToggleControl::PushToggleControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream) - : MouseEvent(key), - _engine(engine) { + : Control(engine, key) { // Loop until we find the closing brace Common::String line = stream.readLine(); trimCommentsAndWhiteSpace(&line); @@ -66,39 +65,24 @@ PushToggleControl::PushToggleControl(ZVision *engine, uint32 key, Common::Seekab } } - bool PushToggleControl::enable() { - if (!_enabled) { - _engine->registerMouseEvent(this); - _enabled = true; - return true; - } - - debug("Control %u is already enabled", _key); - return false; - } - - bool PushToggleControl::disable() { - if (_enabled) { - _engine->removeMouseEvent(_key); - _enabled = false; - return true; - } - - debug("Control %u is already disabled", _key); - return false; - } +PushToggleControl::~PushToggleControl() { + // Clear the state value back to 0 + _engine->getScriptManager()->setStateValue(_key, 0); +} - void PushToggleControl::onMouseDown(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos) { +void PushToggleControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { + if (_hotspot.contains(backgroundImageSpacePos)) { _engine->getScriptManager()->setStateValue(_key, 1); } +} - bool PushToggleControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos) { - if (_hotspot.contains(backgroundImageSpacePos)) { - _engine->getCursorManager()->changeCursor(_hoverCursor); - return true; - } - - return false; +bool PushToggleControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { + if (_hotspot.contains(backgroundImageSpacePos)) { + _engine->getCursorManager()->changeCursor(_hoverCursor); + return true; } + return false; +} + } // End of namespace ZVision diff --git a/engines/zvision/push_toggle_control.h b/engines/zvision/push_toggle_control.h index 9384a43d93..8ab6f619bb 100644 --- a/engines/zvision/push_toggle_control.h +++ b/engines/zvision/push_toggle_control.h @@ -25,32 +25,25 @@ #include "common/types.h" +#include "common/rect.h" + #include "zvision/control.h" -#include "zvision/mouse_event.h" namespace ZVision { -class PushToggleControl : public Control, public MouseEvent { +class PushToggleControl : public Control { public: PushToggleControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream); - bool enable(); - bool disable(); + ~PushToggleControl(); /** - * Called when LeftMouse is pushed. Calls ScriptManager::setStateValue(_key, 1); - * - * @param screenSpacePos The position of the mouse in screen space - * @param backgroundImageSpacePos The position of the mouse in background image space - */ - void onMouseDown(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos); - /** - * Called when LeftMouse is lifted. Does nothing + * Called when LeftMouse is lifted. Calls ScriptManager::setStateValue(_key, 1); * * @param screenSpacePos The position of the mouse in screen space * @param backgroundImageSpacePos The position of the mouse in background image space */ - void onMouseUp(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos) {} + void onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos); /** * Called on every MouseMove. Tests if the mouse is inside _hotspot, and if so, sets the cursor. * @@ -59,10 +52,9 @@ public: * @param backgroundImageSpacePos The position of the mouse in background image space * @return Was the cursor changed? */ - bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos); + bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos); private: - ZVision * _engine; /** * The area that will trigger the event * This is in image space coordinates, NOT screen space diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index c4aed70ac5..212d7140b0 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -279,7 +279,7 @@ void ScriptManager::parseControl(Common::String &line, Common::SeekableReadStrea Common::String controlType(controlTypeBuffer); if (controlType.equalsIgnoreCase("push_toggle")) { - _activeControls[key] = new PushToggleControl(_engine, key, stream); + _activeControls.push_back(new PushToggleControl(_engine, key, stream)); return; } else if (controlType.equalsIgnoreCase("flat")) { Control::parseFlatControl(_engine); |