diff options
author | Stephen Kennedy | 2008-07-07 21:10:58 +0000 |
---|---|---|
committer | Stephen Kennedy | 2008-07-07 21:10:58 +0000 |
commit | 641e3d752e9fc3b631474773a815b019f8d507e7 (patch) | |
tree | e9d477999b603e56787437cd56178294893ab856 /backends | |
parent | 43c0fb8d895654394ac3a047947d15703a4557fa (diff) | |
download | scummvm-rg350-641e3d752e9fc3b631474773a815b019f8d507e7.tar.gz scummvm-rg350-641e3d752e9fc3b631474773a815b019f8d507e7.tar.bz2 scummvm-rg350-641e3d752e9fc3b631474773a815b019f8d507e7.zip |
MILESTONE: bitmap showing with key color transparency implemented!
- SurfaceKeyColored class handles blitting of keycolor transparency data
- ImageMap tested - Rect and Polygon areas seem to be working as expected
svn-id: r32950
Diffstat (limited to 'backends')
-rw-r--r-- | backends/common/virtual-keyboard-parser.cpp | 36 | ||||
-rw-r--r-- | backends/common/virtual-keyboard-parser.h | 5 | ||||
-rw-r--r-- | backends/common/virtual-keyboard.cpp | 49 |
3 files changed, 55 insertions, 35 deletions
diff --git a/backends/common/virtual-keyboard-parser.cpp b/backends/common/virtual-keyboard-parser.cpp index 9c2adb4dc2..e1eef3505c 100644 --- a/backends/common/virtual-keyboard-parser.cpp +++ b/backends/common/virtual-keyboard-parser.cpp @@ -40,6 +40,9 @@ VirtualKeyboardParser::VirtualKeyboardParser(VirtualKeyboard *kbd) : XMLParser() _callbacks["layout"] = &VirtualKeyboardParser::parserCallback_Layout; _callbacks["map"] = &VirtualKeyboardParser::parserCallback_Map; _callbacks["area"] = &VirtualKeyboardParser::parserCallback_Area; + + _closedCallbacks["keyboard"] = &VirtualKeyboardParser::parserCallback_KeyboardClosed; + _closedCallbacks["mode"] = &VirtualKeyboardParser::parserCallback_ModeClosed; } bool VirtualKeyboardParser::keyCallback(Common::String keyName) { @@ -49,6 +52,13 @@ bool VirtualKeyboardParser::keyCallback(Common::String keyName) { return (this->*(_callbacks[_activeKey.top()->name]))(); } +bool VirtualKeyboardParser::closedKeyCallback(Common::String keyName) { + if (!_closedCallbacks.contains(_activeKey.top()->name)) + return true; + + return (this->*(_closedCallbacks[_activeKey.top()->name]))(); +} + bool VirtualKeyboardParser::parserCallback_Keyboard() { ParserNode *kbdNode = getActiveNode(); @@ -59,7 +69,6 @@ bool VirtualKeyboardParser::parserCallback_Keyboard() { if (_kbdParsed) return parserError("Only a single keyboard element is allowed"); - _kbdParsed = true; if (!kbdNode->values.contains("initial_mode")) return parserError("Keyboard element must contain initial_mode attribute"); @@ -89,6 +98,13 @@ bool VirtualKeyboardParser::parserCallback_Keyboard() { return true; } +bool VirtualKeyboardParser::parserCallback_KeyboardClosed() { + _kbdParsed = true; + if (!_keyboard->_initialMode) + return parserError("Initial mode of keyboard pack not defined"); + return true; +} + bool VirtualKeyboardParser::parserCallback_Mode() { ParserNode *modeNode = getActiveNode(); @@ -146,6 +162,12 @@ bool VirtualKeyboardParser::parserCallback_Mode() { return true; } +bool VirtualKeyboardParser::parserCallback_ModeClosed() { + if (!_mode->image) + return parserError("'%s' layout missing from '%s' mode", _mode->resolution.c_str(), _mode->name.c_str()); + return true; +} + bool VirtualKeyboardParser::parserCallback_Event() { ParserNode *evtNode = getActiveNode(); @@ -262,15 +284,14 @@ bool VirtualKeyboardParser::parserCallback_Area() { Common::String shape = areaNode->values["shape"]; if (shape == "rect") { + Common::Rect *rect = _mode->imageMap.createRectArea(areaNode->values["target"]); int x1, y1, x2, y2; if (!parseIntegerKey(areaNode->values["coords"].c_str(), 4, &x1, &y1, &x2, &y2)) return parserError("Invalid coords for rect area"); - - Common::Rect rect(x1, y1, x2, y2); - _mode->imageMap.addRectMapArea(rect, areaNode->values["target"]); + rect->left = x1; rect->top = y1; rect->right = x2; rect->bottom = y2; } else if (shape == "poly") { Common::StringTokenizer tok (areaNode->values["coords"], ", "); - Common::Polygon poly; + Common::Polygon *poly = _mode->imageMap.createPolygonArea(areaNode->values["target"]); for (Common::String st = tok.nextToken(); !st.empty(); st = tok.nextToken()) { int x, y; if (sscanf(st.c_str(), "%d", &x) != 1) @@ -278,11 +299,10 @@ bool VirtualKeyboardParser::parserCallback_Area() { st = tok.nextToken(); if (sscanf(st.c_str(), "%d", &y) != 1) return parserError("Invalid coords for polygon area"); - poly.addPoint(x, y); + poly->addPoint(x, y); } - if (poly.getPointCount() < 3) + if (poly->getPointCount() < 3) return parserError("Invalid coords for polygon area"); - _mode->imageMap.addPolygonMapArea(poly, areaNode->values["target"]); } else return parserError("Area shape '%s' not known", shape.c_str()); diff --git a/backends/common/virtual-keyboard-parser.h b/backends/common/virtual-keyboard-parser.h index 4423ae7b35..98ec5cd0b7 100644 --- a/backends/common/virtual-keyboard-parser.h +++ b/backends/common/virtual-keyboard-parser.h @@ -49,6 +49,7 @@ protected: bool _kbdParsed; bool keyCallback(Common::String keyName); + bool closedKeyCallback(Common::String keyName); void cleanup() { _mode = 0; _kbdParsed = _modeParsed = false; @@ -62,7 +63,11 @@ protected: bool parserCallback_Map(); bool parserCallback_Area(); + bool parserCallback_KeyboardClosed(); + bool parserCallback_ModeClosed(); + Common::HashMap<Common::String, ParserCallback, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> _callbacks; + Common::HashMap<Common::String, ParserCallback, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> _closedCallbacks; }; } // end of namespace GUI diff --git a/backends/common/virtual-keyboard.cpp b/backends/common/virtual-keyboard.cpp index f45769940a..e87d10ab3c 100644 --- a/backends/common/virtual-keyboard.cpp +++ b/backends/common/virtual-keyboard.cpp @@ -28,6 +28,7 @@ #include "common/config-manager.h" #include "common/events.h" #include "graphics/imageman.h" +#include "graphics/surface-keycolored.h" #include "common/unzip.h" namespace Common { @@ -101,24 +102,10 @@ bool VirtualKeyboard::loadKeyboardPack(Common::String packName) { return false; } - if (!_parser->parse()) - return false; - - if (!_initialMode) - warning("Initial mode of keyboard pack not defined"); - - ModeMap::iterator it; - for (it = _modes.begin(); it != _modes.end(); it++) { - // if no image then it means layout tag for the - // required resolution was missing from the mode tag. - if (!it->_value.image) { - warning("'%s' layout missing from '%s' mode", it->_value.resolution.c_str(), it->_value.name.c_str()); - return false; - } - } - - _loaded = true; - return true; + _loaded = _parser->parse(); + if (_loaded) + printf("Keyboard pack '%s' loaded successfully!\n", packName.c_str()); + return _loaded; } void VirtualKeyboard::reposition() @@ -159,10 +146,11 @@ void VirtualKeyboard::processClick(int16 x, int16 y) if (x < 0 || x > _currentMode->image->w) return; if (y < 0 || y > _currentMode->image->h) return; - Common::MapArea *area = _currentMode->imageMap.findMapArea(x, y); - if (!area) return; - if (!_currentMode->events.contains(area->getTarget())) return; - Event evt = _currentMode->events[area->getTarget()]; + Common::String area = _currentMode->imageMap.findMapArea(x, y); + if (area.empty()) return; + printf("Map area found! - %s\n", area.c_str()); + if (!_currentMode->events.contains(area)) return; + Event evt = _currentMode->events[area]; switch (evt.type) { case kEventKey: @@ -214,6 +202,7 @@ void VirtualKeyboard::runLoop() { while (_displaying) { if (_needRedraw) redraw(); + _system->updateScreen(); Common::Event event; while (eventMan->pollEvent(event)) { switch (event.type) { @@ -238,12 +227,18 @@ void VirtualKeyboard::runLoop() { } void VirtualKeyboard::redraw() { + Graphics::SurfaceKeyColored surf; + + surf.create(_system->getOverlayWidth(), _system->getOverlayHeight(), sizeof(OverlayColor)); + + _system->grabOverlay((OverlayColor*)surf.pixels, surf.w); + + surf.blit(_currentMode->image, _pos.x, _pos.y, _system->RGBToColor(0xff, 0, 0xff)); + _system->copyRectToOverlay((OverlayColor*)surf.pixels, surf.w, 0, 0, surf.w, surf.h); + + surf.free(); + _needRedraw = false; - _system->clearOverlay(); - _system->copyRectToOverlay((OverlayColor*)_currentMode->image->pixels, - _currentMode->image->w, _pos.x, _pos.y, - _currentMode->image->w, _currentMode->image->h); - _system->updateScreen(); } bool VirtualKeyboard::pollEvent(Common::Event &event) { |