diff options
author | Stephen Kennedy | 2008-08-07 16:38:39 +0000 |
---|---|---|
committer | Stephen Kennedy | 2008-08-07 16:38:39 +0000 |
commit | 2645ca48ad9bc219b43ab88cc5b071952297a992 (patch) | |
tree | d1383869820354fb99560d630c0d694535d5ad61 /backends | |
parent | 66e4e3ec1a038bc653bb1c04893c39033ac3fb62 (diff) | |
download | scummvm-rg350-2645ca48ad9bc219b43ab88cc5b071952297a992.tar.gz scummvm-rg350-2645ca48ad9bc219b43ab88cc5b071952297a992.tar.bz2 scummvm-rg350-2645ca48ad9bc219b43ab88cc5b071952297a992.zip |
* Moved VK code into backends/vkeybd
* Moved Keymapper code into backends/keymapper
svn-id: r33681
Diffstat (limited to 'backends')
-rw-r--r-- | backends/events/default/default-events.cpp | 4 | ||||
-rw-r--r-- | backends/keymapper/action.cpp (renamed from backends/common/action.cpp) | 4 | ||||
-rw-r--r-- | backends/keymapper/action.h (renamed from backends/common/action.h) | 0 | ||||
-rw-r--r-- | backends/keymapper/hardware-key.h (renamed from backends/common/hardware-key.h) | 2 | ||||
-rw-r--r-- | backends/keymapper/keymap-manager.cpp (renamed from backends/common/keymap-manager.cpp) | 2 | ||||
-rw-r--r-- | backends/keymapper/keymap-manager.h (renamed from backends/common/keymap-manager.h) | 4 | ||||
-rw-r--r-- | backends/keymapper/keymap.cpp (renamed from backends/common/keymap.cpp) | 4 | ||||
-rw-r--r-- | backends/keymapper/keymap.h (renamed from backends/common/keymap.h) | 2 | ||||
-rw-r--r-- | backends/keymapper/keymapper.cpp (renamed from backends/common/keymapper.cpp) | 2 | ||||
-rw-r--r-- | backends/keymapper/keymapper.h (renamed from backends/common/keymapper.h) | 6 | ||||
-rw-r--r-- | backends/module.mk | 16 | ||||
-rw-r--r-- | backends/platform/sdl/events.cpp | 2 | ||||
-rw-r--r-- | backends/vkeybd/image-map.cpp | 69 | ||||
-rw-r--r-- | backends/vkeybd/image-map.h | 53 | ||||
-rw-r--r-- | backends/vkeybd/polygon.cpp | 55 | ||||
-rw-r--r-- | backends/vkeybd/polygon.h | 114 | ||||
-rw-r--r-- | backends/vkeybd/virtual-keyboard-gui.cpp (renamed from backends/common/virtual-keyboard-gui.cpp) | 6 | ||||
-rw-r--r-- | backends/vkeybd/virtual-keyboard-gui.h (renamed from backends/common/virtual-keyboard-gui.h) | 2 | ||||
-rw-r--r-- | backends/vkeybd/virtual-keyboard-parser.cpp (renamed from backends/common/virtual-keyboard-parser.cpp) | 2 | ||||
-rw-r--r-- | backends/vkeybd/virtual-keyboard-parser.h (renamed from backends/common/virtual-keyboard-parser.h) | 2 | ||||
-rw-r--r-- | backends/vkeybd/virtual-keyboard.cpp (renamed from backends/common/virtual-keyboard.cpp) | 6 | ||||
-rw-r--r-- | backends/vkeybd/virtual-keyboard.h (renamed from backends/common/virtual-keyboard.h) | 2 |
22 files changed, 325 insertions, 34 deletions
diff --git a/backends/events/default/default-events.cpp b/backends/events/default/default-events.cpp index 9bafdd9e4f..026892a050 100644 --- a/backends/events/default/default-events.cpp +++ b/backends/events/default/default-events.cpp @@ -28,8 +28,8 @@ #include "common/system.h" #include "common/config-manager.h" #include "backends/events/default/default-events.h" -#include "backends/common/keymapper.h" -#include "backends/common/virtual-keyboard.h" +#include "backends/keymapper/keymapper.h" +#include "backends/vkeybd/virtual-keyboard.h" #include "engines/engine.h" #include "gui/message.h" diff --git a/backends/common/action.cpp b/backends/keymapper/action.cpp index 49d63fafd4..eefd482de7 100644 --- a/backends/common/action.cpp +++ b/backends/keymapper/action.cpp @@ -23,8 +23,8 @@ * */ -#include "backends/common/action.h" -#include "backends/common/keymap.h" +#include "backends/keymapper/action.h" +#include "backends/keymapper/keymap.h" namespace Common { diff --git a/backends/common/action.h b/backends/keymapper/action.h index d9ecb873b3..d9ecb873b3 100644 --- a/backends/common/action.h +++ b/backends/keymapper/action.h diff --git a/backends/common/hardware-key.h b/backends/keymapper/hardware-key.h index 1442dbd728..40fb2a0cbd 100644 --- a/backends/common/hardware-key.h +++ b/backends/keymapper/hardware-key.h @@ -26,7 +26,7 @@ #ifndef COMMON_HARDWAREKEY #define COMMON_HARDWAREKEY -#include "backends/common/action.h" +#include "backends/keymapper/action.h" namespace Common { diff --git a/backends/common/keymap-manager.cpp b/backends/keymapper/keymap-manager.cpp index 39ad6d061e..c8b4420289 100644 --- a/backends/common/keymap-manager.cpp +++ b/backends/keymapper/keymap-manager.cpp @@ -23,7 +23,7 @@ * */ -#include "backends/common/keymap-manager.h" +#include "backends/keymapper/keymap-manager.h" #include "common/algorithm.h" namespace Common { diff --git a/backends/common/keymap-manager.h b/backends/keymapper/keymap-manager.h index c4db61da02..171da3ac5e 100644 --- a/backends/common/keymap-manager.h +++ b/backends/keymapper/keymap-manager.h @@ -26,8 +26,8 @@ #ifndef COMMON_KEYMAP_MANAGER #define COMMON_KEYMAP_MANAGER -#include "backends/common/hardware-key.h" -#include "backends/common/keymap.h" +#include "backends/keymapper/hardware-key.h" +#include "backends/keymapper/keymap.h" #include "common/hash-str.h" #include "common/hashmap.h" diff --git a/backends/common/keymap.cpp b/backends/keymapper/keymap.cpp index ba6f758caa..3f190dcd48 100644 --- a/backends/common/keymap.cpp +++ b/backends/keymapper/keymap.cpp @@ -23,8 +23,8 @@ * */ -#include "backends/common/keymap.h" -#include "backends/common/hardware-key.h" +#include "backends/keymapper/keymap.h" +#include "backends/keymapper/hardware-key.h" namespace Common { diff --git a/backends/common/keymap.h b/backends/keymapper/keymap.h index d9d928ace9..21904397a1 100644 --- a/backends/common/keymap.h +++ b/backends/keymapper/keymap.h @@ -31,7 +31,7 @@ #include "common/hashmap.h" #include "common/keyboard.h" #include "common/list.h" -#include "backends/common/action.h" +#include "backends/keymapper/action.h" namespace Common { diff --git a/backends/common/keymapper.cpp b/backends/keymapper/keymapper.cpp index 59fb796187..fb1f72e84e 100644 --- a/backends/common/keymapper.cpp +++ b/backends/keymapper/keymapper.cpp @@ -23,7 +23,7 @@ * */ -#include "backends/common/keymapper.h" +#include "backends/keymapper/keymapper.h" #include "common/config-manager.h" namespace Common { diff --git a/backends/common/keymapper.h b/backends/keymapper/keymapper.h index c2113d5ca4..1052903b77 100644 --- a/backends/common/keymapper.h +++ b/backends/keymapper/keymapper.h @@ -29,9 +29,9 @@ #include "common/events.h" #include "common/list.h" #include "common/stack.h" -#include "backends/common/hardware-key.h" -#include "backends/common/keymap.h" -#include "backends/common/keymap-manager.h" +#include "backends/keymapper/hardware-key.h" +#include "backends/keymapper/keymap.h" +#include "backends/keymapper/keymap-manager.h" namespace Common { diff --git a/backends/module.mk b/backends/module.mk index 758dff13b2..49ef78326c 100644 --- a/backends/module.mk +++ b/backends/module.mk @@ -28,13 +28,15 @@ MODULE_OBJS := \ saves/default/default-saves.o \ saves/compressed/compressed-saves.o \ timer/default/default-timer.o \ - common/virtual-keyboard.o \ - common/virtual-keyboard-gui.o \ - common/virtual-keyboard-parser.o \ - common/keymap.o \ - common/keymap-manager.o \ - common/keymapper.o \ - common/action.o \ + keymapper/action.o \ + keymapper/keymap.o \ + keymapper/keymap-manager.o \ + keymapper/keymapper.o \ + vkeybd/image-map.o \ + vkeybd/polygon.o \ + vkeybd/virtual-keyboard.o \ + vkeybd/virtual-keyboard-gui.o \ + vkeybd/virtual-keyboard-parser.o # Include common rules include $(srcdir)/rules.mk diff --git a/backends/platform/sdl/events.cpp b/backends/platform/sdl/events.cpp index 830555e514..3b2baf6aa0 100644 --- a/backends/platform/sdl/events.cpp +++ b/backends/platform/sdl/events.cpp @@ -24,7 +24,7 @@ */ #include "backends/platform/sdl/sdl.h" -#include "backends/common/keymapper.h" +#include "backends/keymapper/keymapper.h" #include "common/util.h" #include "common/events.h" diff --git a/backends/vkeybd/image-map.cpp b/backends/vkeybd/image-map.cpp new file mode 100644 index 0000000000..d97b662c7d --- /dev/null +++ b/backends/vkeybd/image-map.cpp @@ -0,0 +1,69 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "backends/vkeybd/image-map.h" + +namespace Common { + +ImageMap::~ImageMap() { + removeAllAreas(); +} + +Polygon *ImageMap::createArea(const String& id) { + if (_areas.contains(id)) { + warning("Image map already contains an area with target of '%s'", id.c_str()); + return 0; + } + Polygon *p = new Polygon(); + _areas[id] = p; + return p; +} + +void ImageMap::removeArea(const String& id) { + if (!_areas.contains(id)) + return; + delete _areas[id]; + _areas.erase(id); +} + +void ImageMap::removeAllAreas() { + HashMap<String, Polygon*>::iterator it; + for (it = _areas.begin(); it != _areas.end(); it++) { + delete it->_value; + } + _areas.clear(); +} + +String ImageMap::findMapArea(int16 x, int16 y) { + HashMap<String, Polygon*>::iterator it; + for (it = _areas.begin(); it != _areas.end(); it++) { + if (it->_value->contains(x, y)) + return it->_key; + } + return ""; +} + + +} // End of namespace Common diff --git a/backends/vkeybd/image-map.h b/backends/vkeybd/image-map.h new file mode 100644 index 0000000000..ed6feaa26e --- /dev/null +++ b/backends/vkeybd/image-map.h @@ -0,0 +1,53 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#ifndef COMMON_IMAGEMAP_H +#define COMMON_IMAGEMAP_H + +#include "common/hashmap.h" +#include "common/hash-str.h" +#include "backends/vkeybd/polygon.h" + +namespace Common { + +class ImageMap { + +public: + + ~ImageMap(); + + Polygon *createArea(const String& id); + void removeArea(const String& id); + void removeAllAreas(); + String findMapArea(int16 x, int16 y); + +protected: + HashMap<String, Polygon*> _areas; +}; + + +} // End of namespace Common + +#endif diff --git a/backends/vkeybd/polygon.cpp b/backends/vkeybd/polygon.cpp new file mode 100644 index 0000000000..77ef3f0f44 --- /dev/null +++ b/backends/vkeybd/polygon.cpp @@ -0,0 +1,55 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "backends/vkeybd/polygon.h" + +namespace Common { + +bool Polygon::contains(int16 x, int16 y) const { + int yflag0; + int yflag1; + bool inside_flag = false; + unsigned int pt; + + const Point *vtx0 = &_points[_points.size() - 1]; + const Point *vtx1 = &_points[0]; + + yflag0 = (vtx0->y >= y); + for (pt = 0; pt < _points.size(); pt++, vtx1++) { + yflag1 = (vtx1->y >= y); + if (yflag0 != yflag1) { + if (((vtx1->y - y) * (vtx0->x - vtx1->x) >= + (vtx1->x - x) * (vtx0->y - vtx1->y)) == yflag1) { + inside_flag = !inside_flag; + } + } + yflag0 = yflag1; + vtx0 = vtx1; + } + + return inside_flag; +} + +} // end of namespace Common diff --git a/backends/vkeybd/polygon.h b/backends/vkeybd/polygon.h new file mode 100644 index 0000000000..69df2c0ca3 --- /dev/null +++ b/backends/vkeybd/polygon.h @@ -0,0 +1,114 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#ifndef COMMON_POLYGON_H +#define COMMON_POLYGON_H + +#include "common/array.h" +#include "common/rect.h" + +namespace Common { + +struct Polygon { + + + Polygon() {} + Polygon(const Polygon& p) : _points(p._points), _bound(p._bound) {} + Polygon(Array<Point> p) : _points(p) { + if (p.empty()) return; + _bound = Rect(p[0].x, p[0].y, p[0].x, p[0].y); + for (uint i = 1; i < p.size(); i++) { + _bound.extend(Rect(p[i].x, p[i].y, p[i].x, p[i].y)); + } + } + Polygon(Point *p, int n) { + for (int i = 0; i < n; i++) { + addPoint(p[i]); + } + } + virtual ~Polygon() {} + + void addPoint(const Point& p) { + _points.push_back(p); + _bound.extend(Rect(p.x, p.y, p.x, p.y)); + } + + void addPoint(int16 x, int16 y) { + addPoint(Point(x,y)); + } + + uint getPointCount() { + return _points.size(); + } + + /*! @brief check if given position is inside this polygon + + @param x the horizontal position to check + @param y the vertical position to check + + @return true if the given position is inside this polygon, false otherwise + */ + virtual bool contains(int16 x, int16 y) const; + + /*! @brief check if given point is inside this polygon + + @param p the point to check + + @return true if the given point is inside this polygon, false otherwise + */ + virtual bool contains(const Point &p) const { + return contains(p.x, p.y); + } + + virtual void moveTo(int16 x, int16 y) { + int16 dx = x - ((_bound.right + _bound.left) / 2); + int16 dy = y - ((_bound.bottom + _bound.top) / 2); + translate(dx, dy); + } + + virtual void moveTo(const Point &p) { + moveTo(p.x, p.y); + } + + virtual void translate(int16 dx, int16 dy) { + Array<Point>::iterator it; + for (it = _points.begin(); it != _points.end(); it++) { + it->x += dx; + it->y += dy; + } + } + + virtual Rect getBoundingRect() const { + return _bound; + } + +private: + Array<Point> _points; + Rect _bound; +}; + +} // end of namespace Common + +#endif diff --git a/backends/common/virtual-keyboard-gui.cpp b/backends/vkeybd/virtual-keyboard-gui.cpp index ca246a17a1..0dcea70292 100644 --- a/backends/common/virtual-keyboard-gui.cpp +++ b/backends/vkeybd/virtual-keyboard-gui.cpp @@ -23,7 +23,7 @@ * */ -#include "backends/common/virtual-keyboard-gui.h" +#include "backends/vkeybd/virtual-keyboard-gui.h" #include "graphics/cursorman.h" #include "gui/newgui.h" @@ -39,11 +39,9 @@ VirtualKeyboardGUI::VirtualKeyboardGUI(VirtualKeyboard *kbd) { memset(_cursor, 0xFF, sizeof(_cursor)); - _displaying = _needRedraw = _drag = false; + _displaying = _needRedraw = _drag = _drawCaret = _displayEnabled = false; _firstRun = true; - _displayEnabled = false; - _cursorAnimateTimer = 0; } diff --git a/backends/common/virtual-keyboard-gui.h b/backends/vkeybd/virtual-keyboard-gui.h index 10b16f17f7..5836859262 100644 --- a/backends/common/virtual-keyboard-gui.h +++ b/backends/vkeybd/virtual-keyboard-gui.h @@ -26,7 +26,7 @@ #ifndef COMMON_VIRTUAL_KEYBOARD_GUI #define COMMON_VIRTUAL_KEYBOARD_GUI -#include "backends/common/virtual-keyboard.h" +#include "backends/vkeybd/virtual-keyboard.h" #include "common/rect.h" #include "common/system.h" #include "graphics/fontman.h" diff --git a/backends/common/virtual-keyboard-parser.cpp b/backends/vkeybd/virtual-keyboard-parser.cpp index 83f5c6f293..f3d71057b7 100644 --- a/backends/common/virtual-keyboard-parser.cpp +++ b/backends/vkeybd/virtual-keyboard-parser.cpp @@ -23,7 +23,7 @@ * */ -#include "backends/common/virtual-keyboard-parser.h" +#include "backends/vkeybd/virtual-keyboard-parser.h" #include "common/keyboard.h" #include "graphics/imageman.h" diff --git a/backends/common/virtual-keyboard-parser.h b/backends/vkeybd/virtual-keyboard-parser.h index ec6dd6dcec..59a770bdce 100644 --- a/backends/common/virtual-keyboard-parser.h +++ b/backends/vkeybd/virtual-keyboard-parser.h @@ -27,7 +27,7 @@ #define COMMON_VIRTUAL_KEYBOARD_PARSER #include "common/xmlparser.h" -#include "backends/common/virtual-keyboard.h" +#include "backends/vkeybd/virtual-keyboard.h" /** TODO - information about optional attributes and their default values diff --git a/backends/common/virtual-keyboard.cpp b/backends/vkeybd/virtual-keyboard.cpp index 4a125bb727..ae0fd86ee5 100644 --- a/backends/common/virtual-keyboard.cpp +++ b/backends/vkeybd/virtual-keyboard.cpp @@ -23,9 +23,9 @@ * */ -#include "backends/common/virtual-keyboard.h" -#include "backends/common/virtual-keyboard-gui.h" -#include "backends/common/virtual-keyboard-parser.h" +#include "backends/vkeybd/virtual-keyboard.h" +#include "backends/vkeybd/virtual-keyboard-gui.h" +#include "backends/vkeybd/virtual-keyboard-parser.h" #include "graphics/imageman.h" namespace Common { diff --git a/backends/common/virtual-keyboard.h b/backends/vkeybd/virtual-keyboard.h index c5b77aac0f..f15eb4aece 100644 --- a/backends/common/virtual-keyboard.h +++ b/backends/vkeybd/virtual-keyboard.h @@ -31,7 +31,7 @@ class OSystem; #include "common/events.h" #include "common/hashmap.h" #include "common/hash-str.h" -#include "common/image-map.h" +#include "backends/vkeybd/image-map.h" #include "common/keyboard.h" #include "common/list.h" #include "common/str.h" |