aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrichiesams2013-08-18 15:42:45 -0500
committerrichiesams2013-08-18 19:53:05 -0500
commit5eab8a8d77a070b752d5f4e02bad73c5e85dd4a6 (patch)
tree8581c4703730aff04f06a320fc02859cea5109a7
parentd26c814d1e0ed76b4b4440e5798ccd012bd4858d (diff)
downloadscummvm-rg350-5eab8a8d77a070b752d5f4e02bad73c5e85dd4a6.tar.gz
scummvm-rg350-5eab8a8d77a070b752d5f4e02bad73c5e85dd4a6.tar.bz2
scummvm-rg350-5eab8a8d77a070b752d5f4e02bad73c5e85dd4a6.zip
ZVISION: Reimplement PushToggleControl
-rw-r--r--engines/zvision/control.cpp49
-rw-r--r--engines/zvision/control.h12
2 files changed, 51 insertions, 10 deletions
diff --git a/engines/zvision/control.cpp b/engines/zvision/control.cpp
index b55452c876..acc970e167 100644
--- a/engines/zvision/control.cpp
+++ b/engines/zvision/control.cpp
@@ -103,12 +103,15 @@ void Control::parseTiltControl(ZVision *engine, Common::SeekableReadStream &stre
renderTable->generateRenderTable();
}
-void Control::parsePushToggleControl(uint32 key, ZVision *engine, Common::SeekableReadStream &stream) {
- engine->getScriptManager()->setStateValue(key, 0);
- Common::Rect hotspot;
- Common::String cursorName;
-
+//////////////////////////////////////////////////////////////////////////////
+// PushToggleControl
+//////////////////////////////////////////////////////////////////////////////
+
+PushToggleControl::PushToggleControl(uint32 key, Common::SeekableReadStream &stream)
+ : Control() {
+ _event._key = _key = key;
+
// Loop until we find the closing brace
Common::String line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
@@ -121,23 +124,49 @@ void Control::parsePushToggleControl(uint32 key, ZVision *engine, Common::Seekab
uint height;
sscanf(line.c_str(), "%*[^(](%u,%u,%u,%u)", &x, &y, &width, &height);
-
- hotspot = Common::Rect(x, y, x + width, y + height);
+
+ _event._hotspot = Common::Rect(x, y, x + width, y + height);
} else if (line.matchString("cursor*", true)) {
char nameBuffer[25];
sscanf(line.c_str(), "%*[^(](%25[^)])", nameBuffer);
- cursorName = Common::String(nameBuffer);
+ _event._hoverCursor = Common::String(nameBuffer);
}
line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
}
- if (!hotspot.isEmpty() && !cursorName.empty()) {
- engine->registerMouseEvent(MouseEvent(key, hotspot, cursorName));
+ if (_event._hotspot.isEmpty() || _event._hoverCursor.empty()) {
+ warning("Push_toggle cursor %u was parsed incorrectly", &key);
+ }
+}
+
+bool PushToggleControl::enable(ZVision *engine) {
+ if (!_enabled) {
+ engine->registerMouseEvent(_event);
+ _enabled = true;
+ return true;
+ }
+
+ debug("Control %u is already enabled", _key);
+ return false;
+}
+
+bool PushToggleControl::disable(ZVision *engine) {
+ if (_enabled) {
+ engine->removeMouseEvent(_key);
+ _enabled = false;
+ return true;
}
+
+ debug("Control %u is already disabled", _key);
+ return false;
+}
+
+void Control::parsePushToggleControl(uint32 key, ZVision *engine, Common::SeekableReadStream &stream) {
+
}
} // End of namespace ZVision
diff --git a/engines/zvision/control.h b/engines/zvision/control.h
index b374383a45..f17ee7750d 100644
--- a/engines/zvision/control.h
+++ b/engines/zvision/control.h
@@ -25,6 +25,8 @@
#include "common/types.h"
+#include "zvision/mouse_event.h"
+
namespace Common {
class SeekableReadStream;
}
@@ -54,6 +56,16 @@ public:
static void parsePushToggleControl(uint32 key, ZVision *engine, Common::SeekableReadStream &stream);
};
+class PushToggleControl : public Control {
+public:
+ PushToggleControl(uint32 key, Common::SeekableReadStream &stream);
+ bool enable(ZVision *engine);
+ bool disable(ZVision *engine);
+
+private:
+ MouseEvent _event;
+};
+
} // End of namespace ZVision
#endif