aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2015-04-22 19:44:57 -0500
committerPaul Gilbert2015-04-22 19:44:57 -0500
commit1ae176f3eb2e392d400095d734895728f0a5eabc (patch)
tree9dd6570d8c52d961ed31f529a70650e83c0df905
parentafbc333696c11a5a10bd6aa1061eded92836c751 (diff)
downloadscummvm-rg350-1ae176f3eb2e392d400095d734895728f0a5eabc.tar.gz
scummvm-rg350-1ae176f3eb2e392d400095d734895728f0a5eabc.tar.bz2
scummvm-rg350-1ae176f3eb2e392d400095d734895728f0a5eabc.zip
SHERLOCK: Fix display of location names on overhead map
-rw-r--r--engines/sherlock/map.cpp74
-rw-r--r--engines/sherlock/map.h3
2 files changed, 77 insertions, 0 deletions
diff --git a/engines/sherlock/map.cpp b/engines/sherlock/map.cpp
index e07dedf7dd..b89b4b29fa 100644
--- a/engines/sherlock/map.cpp
+++ b/engines/sherlock/map.cpp
@@ -113,6 +113,7 @@ int Map::show() {
// Load the entire map
ImageFile bigMap("bigmap.vgs");
+ screen.setPalette(bigMap._palette);
// Load need sprites
setupSprites();
@@ -194,6 +195,10 @@ int Map::show() {
_placesShown = true;
}
+ if (_cursorIndex == 0) {
+ Common::Point pt = events.mousePos();
+ highlightIcon(Common::Point(pt.x - 4 + _bigPos.x, pt.y + _bigPos.y));
+ }
updateMap(false);
}
@@ -322,6 +327,34 @@ void Map::eraseTopLine() {
}
/**
+ * Prints the name of the specified icon
+ */
+void Map::showPlaceName(int idx, bool highlighted) {
+ People &people = *_vm->_people;
+ Screen &screen = *_vm->_screen;
+
+ Common::String name = _locationNames[idx];
+ int width = screen.stringWidth(name);
+
+ if (!_cursorIndex) {
+ saveIcon(people[AL]._imageFrame, _lDrawnPos);
+
+ bool flipped = people[AL]._sequenceNumber == MAP_DOWNLEFT || people[AL]._sequenceNumber == MAP_LEFT
+ || people[AL]._sequenceNumber == MAP_UPLEFT;
+ screen._backBuffer1.transBlitFrom(people[AL]._imageFrame->_frame, _lDrawnPos, flipped);
+ }
+
+ if (highlighted) {
+ int xp = (SHERLOCK_SCREEN_WIDTH - screen.stringWidth(name)) / 2;
+ screen.gPrint(Common::Point(xp + 2, 2), 0, name.c_str());
+ screen.gPrint(Common::Point(xp + 1, 1), 0, name.c_str());
+ screen.gPrint(Common::Point(xp, 0), 12, name.c_str());
+
+ screen.slamArea(xp, 0, screen.stringWidth(name) + 2, 15);
+ }
+}
+
+/**
* Update all on-screen sprites to account for any scrolling of the map
*/
void Map::updateMap(bool flushScreen) {
@@ -473,4 +506,45 @@ void Map::restoreIcon() {
screen._backBuffer1.blitFrom(_iconSave, _savedPos);
}
+/**
+ * Handles highlighting map icons, showing their names
+ */
+void Map::highlightIcon(const Common::Point &pt) {
+ int oldPoint = _point;
+
+ // Iterate through the icon list
+ bool done = false;
+ for (uint idx = 0; idx < _points.size(); ++idx) {
+ const MapEntry &entry = _points[idx];
+
+ // Check whether the mouse is over a given icon
+ if (entry.x != 0 && entry.y != 0) {
+ if (Common::Rect(entry.x - 8, entry.y - 8, entry.x + 9, entry.y + 9).contains(pt)) {
+ done = true;
+
+ if (_point != idx && _vm->readFlags(idx)) {
+ // Changed to a new valid (visible) location
+ eraseTopLine();
+ showPlaceName(idx, true);
+ _point = idx;
+ }
+ }
+ }
+ }
+
+ if (!done) {
+ // No icon was highlighted
+ if (_point != -1) {
+ // No longer highlighting previously highlighted icon, so erase it
+ showPlaceName(_point, false);
+ eraseTopLine();
+ }
+
+ _point = -1;
+ } else if (oldPoint != -1 && oldPoint != _point) {
+ showPlaceName(oldPoint, false);
+ eraseTopLine();
+ }
+}
+
} // End of namespace Sherlock
diff --git a/engines/sherlock/map.h b/engines/sherlock/map.h
index 5b63fe768c..752137e0ba 100644
--- a/engines/sherlock/map.h
+++ b/engines/sherlock/map.h
@@ -76,6 +76,7 @@ private:
void saveTopLine();
void eraseTopLine();
+ void showPlaceName(int idx, bool highlighted);
void updateMap(bool flushScreen);
@@ -83,6 +84,8 @@ private:
void saveIcon(ImageFrame *src, const Common::Point &pt);
void restoreIcon();
+
+ void highlightIcon(const Common::Point &pt);
public:
Map(SherlockEngine *vm);