diff options
author | Paul Gilbert | 2015-07-26 12:23:26 -0400 |
---|---|---|
committer | Paul Gilbert | 2015-07-26 12:23:26 -0400 |
commit | 86a33cf4280aec06a160716ead325342d17a9839 (patch) | |
tree | c9504ffec542ba6ec339bc081dae613de3a01c07 | |
parent | 3217eab5391f9717370d5ae7122d4e4edb3ec2d6 (diff) | |
download | scummvm-rg350-86a33cf4280aec06a160716ead325342d17a9839.tar.gz scummvm-rg350-86a33cf4280aec06a160716ead325342d17a9839.tar.bz2 scummvm-rg350-86a33cf4280aec06a160716ead325342d17a9839.zip |
SHERLOCK: RT: Correct order of precedence of shapes in findBgShape
-rw-r--r-- | engines/sherlock/scalpel/scalpel_scene.cpp | 21 | ||||
-rw-r--r-- | engines/sherlock/scalpel/scalpel_scene.h | 6 | ||||
-rw-r--r-- | engines/sherlock/scene.cpp | 20 | ||||
-rw-r--r-- | engines/sherlock/scene.h | 2 | ||||
-rw-r--r-- | engines/sherlock/tattoo/tattoo_scene.cpp | 55 |
5 files changed, 56 insertions, 48 deletions
diff --git a/engines/sherlock/scalpel/scalpel_scene.cpp b/engines/sherlock/scalpel/scalpel_scene.cpp index 9c36e84969..2f60cebefe 100644 --- a/engines/sherlock/scalpel/scalpel_scene.cpp +++ b/engines/sherlock/scalpel/scalpel_scene.cpp @@ -727,6 +727,27 @@ int ScalpelScene::closestZone(const Common::Point &pt) { return zone; } +int ScalpelScene::findBgShape(const Common::Point &pt) { + if (!_doBgAnimDone) + // New frame hasn't been drawn yet + return -1; + + for (int idx = (int)_bgShapes.size() - 1; idx >= 0; --idx) { + Object &o = _bgShapes[idx]; + if (o._type != INVALID && o._type != NO_SHAPE && o._type != HIDDEN + && o._aType <= PERSON) { + if (o.getNewBounds().contains(pt)) + return idx; + } + else if (o._type == NO_SHAPE) { + if (o.getNoShapeBounds().contains(pt)) + return idx; + } + } + + return -1; +} + } // End of namespace Scalpel } // End of namespace Sherlock diff --git a/engines/sherlock/scalpel/scalpel_scene.h b/engines/sherlock/scalpel/scalpel_scene.h index 62dd1c7a92..8fe3b66b38 100644 --- a/engines/sherlock/scalpel/scalpel_scene.h +++ b/engines/sherlock/scalpel/scalpel_scene.h @@ -89,6 +89,12 @@ public: * A negative playRate can also be specified to play the animation in reverse */ virtual int startCAnim(int cAnimNum, int playRate = 1); + + /** + * Attempts to find a background shape within the passed bounds. If found, + * it will return the shape number, or -1 on failure. + */ + virtual int findBgShape(const Common::Point &pt); }; } // End of namespace Scalpel diff --git a/engines/sherlock/scene.cpp b/engines/sherlock/scene.cpp index 8669d4c092..592c96f527 100644 --- a/engines/sherlock/scene.cpp +++ b/engines/sherlock/scene.cpp @@ -1340,26 +1340,6 @@ Exit *Scene::checkForExit(const Common::Rect &r) { return nullptr; } -int Scene::findBgShape(const Common::Point &pt) { - if (!_doBgAnimDone) - // New frame hasn't been drawn yet - return -1; - - for (int idx = (int)_bgShapes.size() - 1; idx >= 0; --idx) { - Object &o = _bgShapes[idx]; - if (o._type != INVALID && o._type != NO_SHAPE && o._type != HIDDEN - && o._aType <= PERSON) { - if (o.getNewBounds().contains(pt)) - return idx; - } else if (o._type == NO_SHAPE) { - if (o.getNoShapeBounds().contains(pt)) - return idx; - } - } - - return -1; -} - int Scene::checkForZones(const Common::Point &pt, int zoneType) { int matches = 0; diff --git a/engines/sherlock/scene.h b/engines/sherlock/scene.h index 0fbda38fe8..cba4f11029 100644 --- a/engines/sherlock/scene.h +++ b/engines/sherlock/scene.h @@ -289,7 +289,7 @@ public: * Attempts to find a background shape within the passed bounds. If found, * it will return the shape number, or -1 on failure. */ - virtual int findBgShape(const Common::Point &pt); + virtual int findBgShape(const Common::Point &pt) = 0; /** * Synchronize the data for a savegame diff --git a/engines/sherlock/tattoo/tattoo_scene.cpp b/engines/sherlock/tattoo/tattoo_scene.cpp index e40b4d6a9c..2a90a51bec 100644 --- a/engines/sherlock/tattoo/tattoo_scene.cpp +++ b/engines/sherlock/tattoo/tattoo_scene.cpp @@ -724,46 +724,47 @@ void TattooScene::setNPCPath(int npc) { int TattooScene::findBgShape(const Common::Point &pt) { People &people = *_vm->_people; + UserInterface &ui = *_vm->_ui; if (!_doBgAnimDone) // New frame hasn't been drawn yet return -1; - int result = Scene::findBgShape(pt); - if (result == -1) { - if (_labTableScene) { - // Check for SOLID objects in the lab scene - for (int idx = (int)_bgShapes.size() - 1; idx >= 0; --idx) { - Object &o = _bgShapes[idx]; - if (o._type != INVALID && o._type != NO_SHAPE && o._type != HIDDEN && o._aType == SOLID) { - if (o.getNewBounds().contains(pt)) - return idx; - } - } + + for (int idx = (int)_bgShapes.size() - 1; idx >= 0; --idx) { + Object &o = _bgShapes[idx]; + + if (o._type != INVALID && o._type != NO_SHAPE && o._type != HIDDEN && + (o._aType <= PERSON || (ui._menuMode == LAB_MODE && o._aType == SOLID))) { + if (o.getNewBounds().contains(pt)) + return idx; + } else if (o._type == NO_SHAPE) { + if (o.getNoShapeBounds().contains(pt)) + return idx; } + } - // No shape found, so check whether a character is highlighted - for (int idx = 1; idx < MAX_CHARACTERS && result == -1; ++idx) { - Person &person = people[idx]; + // If no shape found, so check whether a character is highlighted + for (int idx = 1; idx < MAX_CHARACTERS; ++idx) { + Person &person = people[idx]; - if (person._type == CHARACTER) { - int scaleVal = getScaleVal(person._position); - Common::Rect charRect; + if (person._type == CHARACTER) { + int scaleVal = getScaleVal(person._position); + Common::Rect charRect; - if (scaleVal == SCALE_THRESHOLD) - charRect = Common::Rect(person.frameWidth(), person.frameHeight()); - else - charRect = Common::Rect(person._imageFrame->sDrawXSize(scaleVal), person._imageFrame->sDrawYSize(scaleVal)); - charRect.moveTo(person._position.x / FIXED_INT_MULTIPLIER, person._position.y / FIXED_INT_MULTIPLIER - - charRect.height()); + if (scaleVal == SCALE_THRESHOLD) + charRect = Common::Rect(person.frameWidth(), person.frameHeight()); + else + charRect = Common::Rect(person._imageFrame->sDrawXSize(scaleVal), person._imageFrame->sDrawYSize(scaleVal)); + charRect.moveTo(person._position.x / FIXED_INT_MULTIPLIER, person._position.y / FIXED_INT_MULTIPLIER + - charRect.height()); - if (charRect.contains(pt)) - result = 1000 + idx; - } + if (charRect.contains(pt)) + return 1000 + idx; } } - return result; + return -1; } void TattooScene::synchronize(Serializer &s) { |