diff options
author | Paul Gilbert | 2015-07-10 08:23:12 -0400 |
---|---|---|
committer | Paul Gilbert | 2015-07-10 08:23:12 -0400 |
commit | 8c00644cf269d788ee7ebfc291373e049257ba23 (patch) | |
tree | 3dc5e78b90bc8edec45157e30e95ecd6e389f064 /engines | |
parent | 138ec332d2190fcc44707c7d14114f85b1813f7c (diff) | |
download | scummvm-rg350-8c00644cf269d788ee7ebfc291373e049257ba23.tar.gz scummvm-rg350-8c00644cf269d788ee7ebfc291373e049257ba23.tar.bz2 scummvm-rg350-8c00644cf269d788ee7ebfc291373e049257ba23.zip |
SHERLOCK: RT: Fix interacting with characters
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sherlock/scene.cpp | 10 | ||||
-rw-r--r-- | engines/sherlock/scene.h | 18 | ||||
-rw-r--r-- | engines/sherlock/tattoo/tattoo_scene.cpp | 33 | ||||
-rw-r--r-- | engines/sherlock/tattoo/tattoo_scene.h | 6 |
4 files changed, 48 insertions, 19 deletions
diff --git a/engines/sherlock/scene.cpp b/engines/sherlock/scene.cpp index 2f8762e7bd..e56561fb5f 100644 --- a/engines/sherlock/scene.cpp +++ b/engines/sherlock/scene.cpp @@ -1338,7 +1338,7 @@ Exit *Scene::checkForExit(const Common::Rect &r) { return nullptr; } -int Scene::findBgShape(const Common::Rect &r) { +int Scene::findBgShape(const Common::Point &pt) { if (!_doBgAnimDone) // New frame hasn't been drawn yet return -1; @@ -1347,10 +1347,10 @@ int Scene::findBgShape(const Common::Rect &r) { Object &o = _bgShapes[idx]; if (o._type != INVALID && o._type != NO_SHAPE && o._type != HIDDEN && o._aType <= PERSON) { - if (r.intersects(o.getNewBounds())) + if (o.getNewBounds().contains(pt)) return idx; } else if (o._type == NO_SHAPE) { - if (r.intersects(o.getNoShapeBounds())) + if (o.getNoShapeBounds().contains(pt)) return idx; } } @@ -1358,10 +1358,6 @@ int Scene::findBgShape(const Common::Rect &r) { return -1; } -int Scene::findBgShape(const Common::Point &pt) { - return findBgShape(Common::Rect(pt.x, pt.y, pt.x + 1, pt.y + 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 8ae6327ce2..0fbda38fe8 100644 --- a/engines/sherlock/scene.h +++ b/engines/sherlock/scene.h @@ -270,18 +270,6 @@ public: int toggleObject(const Common::String &name); /** - * Attempts to find a background shape within the passed bounds. If found, - * it will return the shape number, or -1 on failure. - */ - int findBgShape(const Common::Rect &r); - - /** - * Attempts to find a background shape within the passed bounds. If found, - * it will return the shape number, or -1 on failure. - */ - int findBgShape(const Common::Point &pt); - - /** * Checks to see if the given position in the scene belongs to a given zone type. * If it is, the zone is activated and used just like a TAKL zone or aFLAG_SET zone. */ @@ -298,6 +286,12 @@ public: virtual int closestZone(const Common::Point &pt) = 0; /** + * 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); + + /** * Synchronize the data for a savegame */ virtual void synchronize(Serializer &s); diff --git a/engines/sherlock/tattoo/tattoo_scene.cpp b/engines/sherlock/tattoo/tattoo_scene.cpp index f8ca2651c6..badc58d86f 100644 --- a/engines/sherlock/tattoo/tattoo_scene.cpp +++ b/engines/sherlock/tattoo/tattoo_scene.cpp @@ -708,6 +708,39 @@ void TattooScene::setNPCPath(int npc) { talk.talkTo(pathFile); } +int TattooScene::findBgShape(const Common::Point &pt) { + People &people = *_vm->_people; + + if (!_doBgAnimDone) + // New frame hasn't been drawn yet + return -1; + + int result = Scene::findBgShape(pt); + if (result == -1) { + // 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 (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 (charRect.contains(pt)) + result = 1000 + idx; + } + } + } + + return result; +} + void TattooScene::synchronize(Serializer &s) { TattooEngine &vm = *(TattooEngine *)_vm; Scene::synchronize(s); diff --git a/engines/sherlock/tattoo/tattoo_scene.h b/engines/sherlock/tattoo/tattoo_scene.h index 695fef3d49..432233f501 100644 --- a/engines/sherlock/tattoo/tattoo_scene.h +++ b/engines/sherlock/tattoo/tattoo_scene.h @@ -132,6 +132,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 Tattoo |