diff options
-rw-r--r-- | engines/sherlock/events.cpp | 4 | ||||
-rw-r--r-- | engines/sherlock/events.h | 11 | ||||
-rw-r--r-- | engines/sherlock/screen.cpp | 3 | ||||
-rw-r--r-- | engines/sherlock/tattoo/tattoo_map.cpp | 3 | ||||
-rw-r--r-- | engines/sherlock/tattoo/tattoo_user_interface.cpp | 8 | ||||
-rw-r--r-- | engines/sherlock/tattoo/widget_base.cpp | 8 | ||||
-rw-r--r-- | engines/sherlock/tattoo/widget_verbs.cpp | 12 |
7 files changed, 31 insertions, 18 deletions
diff --git a/engines/sherlock/events.cpp b/engines/sherlock/events.cpp index fdfd77ef74..490d30f698 100644 --- a/engines/sherlock/events.cpp +++ b/engines/sherlock/events.cpp @@ -200,6 +200,10 @@ Common::Point Events::mousePos() const { return g_system->getEventManager()->getMousePos(); } +Common::Point Events::sceneMousePos() const { + return mousePos() + _vm->_screen->_currentScroll; +} + Common::KeyState Events::getKey() { return _pendingKeys.pop(); } diff --git a/engines/sherlock/events.h b/engines/sherlock/events.h index b0dda37607..052698a609 100644 --- a/engines/sherlock/events.h +++ b/engines/sherlock/events.h @@ -129,8 +129,19 @@ public: */ Common::Point mousePos() const; + /** + * Get the current mouse position within the scene, adjusted by the scroll position + */ + Common::Point sceneMousePos() const; + + /** + * Return the current game frame number + */ uint32 getFrameCounter() const { return _frameCounter; } + /** + * Returns true if there's a pending keyboard key + */ bool kbHit() const { return !_pendingKeys.empty(); } /** diff --git a/engines/sherlock/screen.cpp b/engines/sherlock/screen.cpp index 85d8c7ad9d..782869d77e 100644 --- a/engines/sherlock/screen.cpp +++ b/engines/sherlock/screen.cpp @@ -355,7 +355,8 @@ void Screen::slamArea(int16 xp, int16 yp, int16 width, int16 height) { void Screen::slamRect(const Common::Rect &r) { if (r.width() && r.height() > 0) { Common::Rect srcRect = r, destRect = r; - srcRect.translate(_currentScroll.x, _currentScroll.y); + + destRect.translate(-_currentScroll.x, -_currentScroll.y); if (destRect.left < 0) { srcRect.left += -destRect.left; diff --git a/engines/sherlock/tattoo/tattoo_map.cpp b/engines/sherlock/tattoo/tattoo_map.cpp index 943196815b..1a9aed7623 100644 --- a/engines/sherlock/tattoo/tattoo_map.cpp +++ b/engines/sherlock/tattoo/tattoo_map.cpp @@ -305,8 +305,7 @@ void TattooMap::drawMapIcons() { void TattooMap::checkMapNames(bool slamIt) { Events &events = *_vm->_events; - Screen &screen = *_vm->_screen; - Common::Point mapPos = events.mousePos() + screen._currentScroll; + Common::Point mapPos = events.sceneMousePos(); // See if the mouse is pointing at any of the map locations _bgFound = -1; diff --git a/engines/sherlock/tattoo/tattoo_user_interface.cpp b/engines/sherlock/tattoo/tattoo_user_interface.cpp index 2548185ede..7b2ef7206d 100644 --- a/engines/sherlock/tattoo/tattoo_user_interface.cpp +++ b/engines/sherlock/tattoo/tattoo_user_interface.cpp @@ -230,8 +230,7 @@ void TattooUserInterface::handleInput() { TattooEngine &vm = *(TattooEngine *)_vm; Events &events = *_vm->_events; TattooScene &scene = *(TattooScene *)_vm->_scene; - Screen &screen = *_vm->_screen; - Common::Point mousePos = events.mousePos() + screen._currentScroll; + Common::Point mousePos = events.sceneMousePos(); events.pollEventsAndWait(); _keyState.keycode = Common::KEYCODE_INVALID; @@ -532,14 +531,13 @@ void TattooUserInterface::doLabControl() { void TattooUserInterface::displayObjectNames() { Events &events = *_vm->_events; Scene &scene = *_vm->_scene; - Screen &screen = *_vm->_screen; - Common::Point scenePos = events.mousePos() + screen._currentScroll; + Common::Point mousePos = events.sceneMousePos(); _arrowZone = -1; if (_bgFound == -1 || scene._currentScene == 90) { for (uint idx = 0; idx < scene._exits.size() && _arrowZone == -1; ++idx) { Exit &exit = scene._exits[idx]; - if (exit.contains(scenePos)) + if (exit.contains(mousePos)) _arrowZone = idx; } } diff --git a/engines/sherlock/tattoo/widget_base.cpp b/engines/sherlock/tattoo/widget_base.cpp index 10b8ad8dec..d946c46e4c 100644 --- a/engines/sherlock/tattoo/widget_base.cpp +++ b/engines/sherlock/tattoo/widget_base.cpp @@ -141,12 +141,14 @@ Common::String WidgetBase::splitLines(const Common::String &str, Common::StringA } void WidgetBase::restrictToScreen() { + Screen &screen = *_vm->_screen; + if (_bounds.left < 0) _bounds.moveTo(0, _bounds.top); if (_bounds.top < 0) _bounds.moveTo(_bounds.left, 0); - if (_bounds.right > SHERLOCK_SCREEN_WIDTH) - _bounds.moveTo(SHERLOCK_SCREEN_WIDTH - _bounds.width(), _bounds.top); + if (_bounds.right > screen._backBuffer1.w()) + _bounds.moveTo(screen._backBuffer1.w() - _bounds.width(), _bounds.top); if (_bounds.bottom > SHERLOCK_SCREEN_HEIGHT) _bounds.moveTo(_bounds.left, SHERLOCK_SCREEN_HEIGHT - _bounds.height()); } @@ -243,7 +245,7 @@ void WidgetBase::drawScrollBar(int index, int pageSize, int count) { void WidgetBase::handleScrollbarEvents(int index, int pageSize, int count) { Events &events = *_vm->_events; TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui; - Common::Point mousePos = events.mousePos(); + Common::Point mousePos = events.sceneMousePos(); // If they have selected the sollbar, return with the Scroll Bar Still selected if (ui._scrollHighlight == 3) diff --git a/engines/sherlock/tattoo/widget_verbs.cpp b/engines/sherlock/tattoo/widget_verbs.cpp index fff984a3ff..ec18e3ce05 100644 --- a/engines/sherlock/tattoo/widget_verbs.cpp +++ b/engines/sherlock/tattoo/widget_verbs.cpp @@ -38,10 +38,10 @@ WidgetVerbs::WidgetVerbs(SherlockEngine *vm) : WidgetBase(vm) { void WidgetVerbs::load(bool objectsOn) { Events &events = *_vm->_events; + TattooPeople &people = *(TattooPeople *)_vm->_people; Talk &talk = *_vm->_talk; TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui; - TattooPeople &people = *(TattooPeople *)_vm->_people; - Common::Point mousePos = events.mousePos(); + Common::Point mousePos = events.sceneMousePos(); bool isWatson = false; if (talk._talkToAbort) @@ -153,11 +153,9 @@ void WidgetVerbs::handleEvents() { FixedText &fixedText = *_vm->_fixedText; People &people = *_vm->_people; TattooScene &scene = *(TattooScene *)_vm->_scene; - Screen &screen = *_vm->_screen; Talk &talk = *_vm->_talk; TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui; - Common::Point mousePos = events.mousePos(); - Common::Point scenePos = mousePos + screen._currentScroll; + Common::Point mousePos = events.sceneMousePos(); bool noDesc = false; Common::String strLook = fixedText.getText(kFixedText_Look); @@ -183,7 +181,7 @@ void WidgetVerbs::handleEvents() { if (events._rightReleased) { // Reset the selected shape to what was clicked on - ui._bgFound = scene.findBgShape(scenePos); + ui._bgFound = scene.findBgShape(mousePos); ui._personFound = ui._bgFound >= 1000; Object *_bgShape = ui._personFound ? nullptr : &scene._bgShapes[ui._bgFound]; @@ -285,7 +283,7 @@ void WidgetVerbs::handleEvents() { void WidgetVerbs::highlightVerbControls() { Events &events = *_vm->_events; Screen &screen = *_vm->_screen; - Common::Point mousePos = events.mousePos(); + Common::Point mousePos = events.sceneMousePos(); // Get highlighted verb _selector = -1; |