scummvm/backends/vkeybd/image-map.cpp

75 lines
1.9 KiB
C++
Raw Normal View History

2011-04-16 14:08:33 +02:00
/* ScummVM - Graphic Adventure Engine
2009-10-04 10:31:37 +00:00
*
2011-04-16 14:08:33 +02:00
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
2009-10-04 10:31:37 +00:00
* 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.
*
*/
#include "common/scummsys.h"
2011-04-14 12:41:26 +02:00
2009-10-04 10:31:37 +00:00
#ifdef ENABLE_VKEYBD
2011-05-01 17:49:40 +02:00
#include "common/textconsole.h"
2009-10-04 10:31:37 +00:00
#include "backends/vkeybd/image-map.h"
#include "backends/vkeybd/polygon.h"
namespace Common {
ImageMap::~ImageMap() {
removeAllAreas();
}
2012-01-06 22:56:21 +01:00
Polygon *ImageMap::createArea(const String &id) {
2009-10-04 10:31:37 +00:00
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;
}
2012-01-06 22:56:21 +01:00
void ImageMap::removeArea(const String &id) {
2009-10-04 10:31:37 +00:00
if (!_areas.contains(id))
return;
delete _areas[id];
_areas.erase(id);
}
void ImageMap::removeAllAreas() {
2012-01-06 22:56:21 +01:00
for (AreaMap::iterator it = _areas.begin(); it != _areas.end(); ++it) {
2009-10-04 10:31:37 +00:00
delete it->_value;
}
_areas.clear();
}
String ImageMap::findMapArea(int16 x, int16 y) {
2012-01-06 22:56:21 +01:00
for (AreaMap::iterator it = _areas.begin(); it != _areas.end(); ++it) {
2009-10-04 10:31:37 +00:00
if (it->_value->contains(x, y))
return it->_key;
}
2012-01-06 22:56:21 +01:00
2009-10-04 10:31:37 +00:00
return String();
}
} // End of namespace Common
#endif // #ifdef ENABLE_VKEYBD