aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMarisa-Chan2014-10-22 11:43:24 +0700
committerMarisa-Chan2014-10-22 11:43:24 +0700
commit0b3a20f645324696e08745a9e8a3fc75e1700cac (patch)
tree19ac59fc6c68951bf41c6547d0a6abc069ef4a80 /engines
parenta65ec38f8ddfb2a856619880d005ccd1a766623a (diff)
downloadscummvm-rg350-0b3a20f645324696e08745a9e8a3fc75e1700cac.tar.gz
scummvm-rg350-0b3a20f645324696e08745a9e8a3fc75e1700cac.tar.bz2
scummvm-rg350-0b3a20f645324696e08745a9e8a3fc75e1700cac.zip
ZVISION: Some push toggles may contain few hotspot zones
Diffstat (limited to 'engines')
-rw-r--r--engines/zvision/scripting/controls/push_toggle_control.cpp21
-rw-r--r--engines/zvision/scripting/controls/push_toggle_control.h5
2 files changed, 19 insertions, 7 deletions
diff --git a/engines/zvision/scripting/controls/push_toggle_control.cpp b/engines/zvision/scripting/controls/push_toggle_control.cpp
index 2f4af0d843..bf74a22051 100644
--- a/engines/zvision/scripting/controls/push_toggle_control.cpp
+++ b/engines/zvision/scripting/controls/push_toggle_control.cpp
@@ -42,6 +42,7 @@ PushToggleControl::PushToggleControl(ZVision *engine, uint32 key, Common::Seekab
Common::String line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
line.toLowercase();
+ _hotspots.clear();
while (!stream.eos() && !line.contains('}')) {
if (line.matchString("*_hotspot*", true)) {
@@ -52,7 +53,7 @@ PushToggleControl::PushToggleControl(ZVision *engine, uint32 key, Common::Seekab
sscanf(line.c_str(), "%*[^(](%u,%u,%u,%u)", &x, &y, &width, &height);
- _hotspot = Common::Rect(x, y, x + width, y + height);
+ _hotspots.push_back(Common::Rect(x, y, x + width + 1, y + height + 1));
} else if (line.matchString("cursor*", true)) {
char nameBuffer[25];
@@ -86,12 +87,13 @@ PushToggleControl::PushToggleControl(ZVision *engine, uint32 key, Common::Seekab
trimCommentsAndWhiteSpace(&line);
}
- if (_hotspot.isEmpty() || _hoverCursor.empty()) {
- warning("Push_toggle cursor %u was parsed incorrectly", key);
+ if (_hotspots.size() == 0 || _hoverCursor.empty()) {
+ warning("Push_toggle %u was parsed incorrectly", key);
}
}
PushToggleControl::~PushToggleControl() {
+ _hotspots.clear();
}
bool PushToggleControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
@@ -101,7 +103,7 @@ bool PushToggleControl::onMouseUp(const Common::Point &screenSpacePos, const Com
if (_event != Common::EVENT_LBUTTONUP)
return false;
- if (_hotspot.contains(backgroundImageSpacePos)) {
+ if (contain(backgroundImageSpacePos)) {
int32 val = _engine->getScriptManager()->getStateValue(_key);
val = (val + 1) % _countTo;
_engine->getScriptManager()->setStateValue(_key, val);
@@ -117,7 +119,7 @@ bool PushToggleControl::onMouseDown(const Common::Point &screenSpacePos, const C
if (_event != Common::EVENT_LBUTTONDOWN)
return false;
- if (_hotspot.contains(backgroundImageSpacePos)) {
+ if (contain(backgroundImageSpacePos)) {
int32 val = _engine->getScriptManager()->getStateValue(_key);
val = (val + 1) % _countTo;
_engine->getScriptManager()->setStateValue(_key, val);
@@ -130,7 +132,7 @@ bool PushToggleControl::onMouseMove(const Common::Point &screenSpacePos, const C
if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
return false;
- if (_hotspot.contains(backgroundImageSpacePos)) {
+ if (contain(backgroundImageSpacePos)) {
_engine->getCursorManager()->changeCursor(_engine->getCursorManager()->getCursorId(_hoverCursor));
return true;
}
@@ -138,4 +140,11 @@ bool PushToggleControl::onMouseMove(const Common::Point &screenSpacePos, const C
return false;
}
+bool PushToggleControl::contain(const Common::Point &point) {
+ for (uint i = 0; i < _hotspots.size(); i++)
+ if (_hotspots[i].contains(point))
+ return true;
+ return false;
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/scripting/controls/push_toggle_control.h b/engines/zvision/scripting/controls/push_toggle_control.h
index 6ba1bd77fa..7b45fb4831 100644
--- a/engines/zvision/scripting/controls/push_toggle_control.h
+++ b/engines/zvision/scripting/controls/push_toggle_control.h
@@ -27,6 +27,7 @@
#include "common/rect.h"
#include "common/events.h"
+#include "common/array.h"
namespace ZVision {
@@ -65,13 +66,15 @@ private:
* The area that will trigger the event
* This is in image space coordinates, NOT screen space
*/
- Common::Rect _hotspot;
+ Common::Array<Common::Rect> _hotspots;
/** The cursor to use when hovering over _hotspot */
Common::String _hoverCursor;
/** Button maximal values count */
uint _countTo;
Common::EventType _event;
+
+ bool contain(const Common::Point &point);
};
} // End of namespace ZVision