diff options
author | richiesams | 2013-08-26 14:03:25 -0500 |
---|---|---|
committer | richiesams | 2013-08-28 16:44:19 -0500 |
commit | 52af1f7f1019ddb2f95d1cff034d58f3cffd224a (patch) | |
tree | 7f4e4be8a68e51ffefcf8cf00f4ce6cb28d9239a | |
parent | 5e1215837ae29899dbb759a55b3de10b3dc0bee8 (diff) | |
download | scummvm-rg350-52af1f7f1019ddb2f95d1cff034d58f3cffd224a.tar.gz scummvm-rg350-52af1f7f1019ddb2f95d1cff034d58f3cffd224a.tar.bz2 scummvm-rg350-52af1f7f1019ddb2f95d1cff034d58f3cffd224a.zip |
ZVISION: Bake ActionNode and MouseEvent into Control
This makes memory management a lot easier as well as removes the need for
multiple lists that point to the same objects. However, there will be quite a few Controls
that don't need all the functionality of ActionNode and MouseEvent, so the default
implementations are No Op.
-rw-r--r-- | engines/zvision/action_node.h | 11 | ||||
-rw-r--r-- | engines/zvision/control.h | 39 | ||||
-rw-r--r-- | engines/zvision/mouse_event.h | 71 |
3 files changed, 38 insertions, 83 deletions
diff --git a/engines/zvision/action_node.h b/engines/zvision/action_node.h index 9a5ca0be0b..9df06c750f 100644 --- a/engines/zvision/action_node.h +++ b/engines/zvision/action_node.h @@ -29,17 +29,6 @@ namespace ZVision { class ZVision; -class ActionNode { -public: - virtual ~ActionNode() {} - /** - * Processes the node given the deltaTime since last frame - * - * @param deltaTimeInMillis The number of milliseconds that have passed since last frame - * @return If true, the node can be deleted after process() finishes - */ - virtual bool process(uint32 deltaTimeInMillis) = 0; -}; class TimerNode : public ActionNode { public: diff --git a/engines/zvision/control.h b/engines/zvision/control.h index 616589f055..8d4ea9f65d 100644 --- a/engines/zvision/control.h +++ b/engines/zvision/control.h @@ -25,8 +25,10 @@ #include "common/types.h" + namespace Common { class SeekableReadStream; +struct Point; } namespace ZVision { @@ -35,12 +37,47 @@ class ZVision; class Control { public: - Control() : _enabled(false) {} + Control() : _engine(0), _key(0), _enabled(false) {} + Control(ZVision *engine, uint32 key) : _engine(engine), _key(key), _enabled(false) {} virtual ~Control() {} virtual bool enable() = 0; virtual bool disable() = 0; + uint32 getKey() { return _key; } + + /** + * Called when LeftMouse is pushed. Default is NOP. + * + * @param screenSpacePos The position of the mouse in screen space + * @param backgroundImageSpacePos The position of the mouse in background image space + */ + virtual void onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {} + /** + * Called when LeftMouse is lifted. Default is NOP. + * + * @param screenSpacePos The position of the mouse in screen space + * @param backgroundImageSpacePos The position of the mouse in background image space + */ + virtual void onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {} + /** + * Called on every MouseMove. Default is NOP. + * + * @param screenSpacePos The position of the mouse in screen space + * @param backgroundImageSpacePos The position of the mouse in background image space + * @return Was the cursor changed? + */ + virtual bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { return false; } + /** + * Processes the node given the deltaTime since last frame. Default is NOP. + * + * @param deltaTimeInMillis The number of milliseconds that have passed since last frame + * @return If true, the node can be deleted after process() finishes + */ + virtual bool process(uint32 deltaTimeInMillis) { return false; } + protected: + ZVision * _engine; + uint32 _key; bool _enabled; // Static member functions diff --git a/engines/zvision/mouse_event.h b/engines/zvision/mouse_event.h deleted file mode 100644 index fe81adaf19..0000000000 --- a/engines/zvision/mouse_event.h +++ /dev/null @@ -1,71 +0,0 @@ -/* 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_MOUSE_EVENT_H -#define ZVISION_MOUSE_EVENT_H - -#include "common/types.h" -#include "common/rect.h" -#include "common/str.h" - -namespace ZVision { - -class ZVision; - -class MouseEvent { -public: - MouseEvent() : _key(0) {} - MouseEvent(uint32 key) : _key(key) {} - virtual ~MouseEvent() {} - -public: - uint32 _key; - -public: - /** - * Called when LeftMouse is pushed. - * - * @param screenSpacePos The position of the mouse in screen space - * @param backgroundImageSpacePos The position of the mouse in background image space - */ - virtual void onMouseDown(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos) = 0; - /** - * Called when LeftMouse is lifted. - * - * @param screenSpacePos The position of the mouse in screen space - * @param backgroundImageSpacePos The position of the mouse in background image space - */ - virtual void onMouseUp(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos) = 0; - /** - * Called on every MouseMove. - * - * @param screenSpacePos The position of the mouse in screen space - * @param backgroundImageSpacePos The position of the mouse in background image space - * @return Was the cursor changed? - */ - virtual bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point backgroundImageSpacePos) = 0; -}; - -} // End of namespace ZVision - -#endif |