ZVISION: Implement push_toggle control handling

This commit is contained in:
richiesams
2013-08-11 15:12:01 -05:00
parent 269bed7c7d
commit 00a17a66d0
3 changed files with 38 additions and 1 deletions
+35
View File
@@ -102,4 +102,39 @@ void Control::parseTiltControl(ZVision *engine, Common::SeekableReadStream &stre
renderTable->generateRenderTable();
}
void Control::parsePushToggleControl(uint32 key, ZVision *engine, Common::SeekableReadStream &stream) {
Common::Rect hotspot;
Common::String cursorName;
// Loop until we find the closing brace
Common::String line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
while (!line.contains('}')) {
if (line.matchString("*_hotspot*", true)) {
uint x;
uint y;
uint width;
uint height;
sscanf(line.c_str(), "%*[^(](%u,%u,%u,%u)", &x, &y, &width, &height);
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);
}
line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
}
if (!hotspot.isEmpty() && !cursorName.empty()) {
engine->registerMouseEvent(MouseEvent(key, hotspot, cursorName));
}
}
} // End of namespace ZVision
+1
View File
@@ -46,6 +46,7 @@ public:
static void parseFlatControl(ZVision *engine);
static void parsePanoramaControl(ZVision *engine, Common::SeekableReadStream &stream);
static void parseTiltControl(ZVision *engine, Common::SeekableReadStream &stream);
static void parsePushToggleControl(uint32 key, ZVision *engine, Common::SeekableReadStream &stream);
};
} // End of namespace ZVision
+2 -1
View File
@@ -309,7 +309,8 @@ bool ScriptManager::parseControl(Common::String &line, Common::SeekableReadStrea
Common::String controlType(controlTypeBuffer);
if (controlType.equalsIgnoreCase("push_toggle")) {
Control::parsePushToggleControl(key, _engine, stream);
return false;
} else if (controlType.equalsIgnoreCase("flat")) {
Control::parseFlatControl(_engine);
return false;