diff options
author | richiesams | 2013-08-11 15:10:52 -0500 |
---|---|---|
committer | richiesams | 2013-08-11 15:10:52 -0500 |
commit | 269bed7c7d279e0785056a4e5ba1622317402449 (patch) | |
tree | 4ddfbbaf7b959006cb3a0eb4ad2e4789295974a4 | |
parent | 3e8bc76127a66ad631095de94a57c31aabb7d6b4 (diff) | |
download | scummvm-rg350-269bed7c7d279e0785056a4e5ba1622317402449.tar.gz scummvm-rg350-269bed7c7d279e0785056a4e5ba1622317402449.tar.bz2 scummvm-rg350-269bed7c7d279e0785056a4e5ba1622317402449.zip |
ZVISION: Implement mouse event handling
-rw-r--r-- | engines/zvision/events.cpp | 32 | ||||
-rw-r--r-- | engines/zvision/script_manager.cpp | 2 | ||||
-rw-r--r-- | engines/zvision/zvision.h | 7 |
3 files changed, 41 insertions, 0 deletions
diff --git a/engines/zvision/events.cpp b/engines/zvision/events.cpp index 17f48db7fc..79ef0bd6b0 100644 --- a/engines/zvision/events.cpp +++ b/engines/zvision/events.cpp @@ -28,9 +28,19 @@ #include "engines/util.h" #include "zvision/cursor_manager.h" +#include "zvision/render_manager.h" +#include "zvision/mouse_event.h" namespace ZVision { +void ZVision::registerMouseEvent(const MouseEvent &event) { + _mouseEvents.push_back(event); +} + +void ZVision::clearAllMouseEvents() { + _mouseEvents.clear(); +} + void ZVision::processEvents() { while (_eventMan->pollEvent(_event)) { switch (_event.type) { @@ -84,10 +94,32 @@ void ZVision::onMouseDown(const Common::Point &pos) { void ZVision::onMouseUp(const Common::Point &pos) { _cursorManager->cursorDown(false); + + Common::Point imageCoord(_renderManager->convertToImageCoords(pos)); + + for (Common::List<MouseEvent>::iterator iter = _mouseEvents.begin(); iter != _mouseEvents.end(); iter++) { + if (iter->withinHotspot(imageCoord)) { + iter->onClick(this); + } + } } void ZVision::onMouseMove(const Common::Point &pos) { + Common::Point imageCoord(_renderManager->convertToImageCoords(pos)); + + bool isWithinAHotspot = false; + for (Common::List<MouseEvent>::iterator iter = _mouseEvents.begin(); iter != _mouseEvents.end(); iter++) { + if (iter->withinHotspot(imageCoord)) { + _cursorManager->changeCursor(iter->getHoverCursor()); + isWithinAHotspot = true; + } + } + + + if (!isWithinAHotspot) { + _cursorManager->revertToIdle(); + } } void ZVision::onKeyDown(uint keyCode) { diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp index da2a3814dc..03e791720c 100644 --- a/engines/zvision/script_manager.cpp +++ b/engines/zvision/script_manager.cpp @@ -26,6 +26,7 @@ #include "common/hashmap.h" #include "common/debug.h" +#include "zvision/zvision.h" #include "zvision/script_manager.h" #include "zvision/actions.h" #include "zvision/action_node.h" @@ -207,6 +208,7 @@ void ScriptManager::changeLocationIntern() { _activePuzzles.clear(); // We can clear without deleting from the heap because we use SharedPtr _activeControls.clear(); + _engine->clearAllMouseEvents(); // Parse into puzzles and controls Common::String fileName = Common::String::format("%c%c%c%c.scr", _nextLocation.world, _nextLocation.room, _nextLocation.node, _nextLocation.view); diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index 8363fb1672..bf42bf2621 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -33,6 +33,7 @@ #include "zvision/detection.h" #include "zvision/clock.h" +#include "zvision/mouse_event.h" #include "gui/debugger.h" @@ -82,6 +83,9 @@ private: // Clock Clock _clock; + // To store the current mouse events + Common::List<MouseEvent> _mouseEvents; + // To prevent allocation every time we process events Common::Event _event; @@ -99,6 +103,9 @@ public: void playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &destRect = Common::Rect(0, 0, 0, 0), bool skippable = true); + void registerMouseEvent(const MouseEvent &event); + void clearAllMouseEvents(); + void cycleThroughCursors(); private: |