[Scummvm-git-logs] scummvm master -> 6b404187fc9fbf5c6394b9e3006c3ba20e6d0e34
npjg
nathanael.gentrydb8 at gmail.com
Tue Jul 21 19:12:35 UTC 2020
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
6b404187fc DIRECTOR: Move mouse position check to channel
Commit: 6b404187fc9fbf5c6394b9e3006c3ba20e6d0e34
https://github.com/scummvm/scummvm/commit/6b404187fc9fbf5c6394b9e3006c3ba20e6d0e34
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2020-07-21T15:11:34-04:00
Commit Message:
DIRECTOR: Move mouse position check to channel
This permits, for instance, only changing the cursor when we are inside a
bitmapped sprite.
Changed paths:
engines/director/channel.cpp
engines/director/channel.h
engines/director/events.cpp
engines/director/score.cpp
engines/director/score.h
diff --git a/engines/director/channel.cpp b/engines/director/channel.cpp
index a21bf9866e..56bace1918 100644
--- a/engines/director/channel.cpp
+++ b/engines/director/channel.cpp
@@ -148,6 +148,22 @@ bool Channel::isActiveText() {
return false;
}
+bool Channel::isMouseIn(const Common::Point &pos, bool onlyMatte) {
+ Common::Rect bbox = getBbox();
+
+ if (!bbox.contains(pos))
+ return false;
+
+ if (onlyMatte) {
+ if (_sprite->_cast->_type == kCastBitmap) {
+ Graphics::Surface *matte = ((BitmapCastMember *)_sprite->_cast)->getMatte();
+ return matte ? !(*(byte *)(matte->getBasePtr(pos.x - bbox.left, pos.y - bbox.top))) : true;
+ }
+ }
+
+ return true;
+}
+
Common::Rect Channel::getBbox(bool unstretched) {
Common::Rect result(unstretched ? _sprite->_width : _width,
diff --git a/engines/director/channel.h b/engines/director/channel.h
index 3bcd872c7a..33e6a75bb0 100644
--- a/engines/director/channel.h
+++ b/engines/director/channel.h
@@ -45,6 +45,7 @@ public:
bool isDirty(Sprite *nextSprite = nullptr);
bool isEmpty();
bool isActiveText();
+ bool isMouseIn(const Common::Point &pos, bool onlyMatte);
void setWidth(int w);
void setHeight(int h);
diff --git a/engines/director/events.cpp b/engines/director/events.cpp
index fd148c9f66..9770827f77 100644
--- a/engines/director/events.cpp
+++ b/engines/director/events.cpp
@@ -87,7 +87,7 @@ void DirectorEngine::processEvents(bool bufferLingoEvents) {
m->_lastEventTime = g_director->getMacTicks();
m->_lastRollTime = m->_lastEventTime;
- sc->renderCursor(sc->getSpriteIDFromPos(pos));
+ sc->renderCursor(sc->getSpriteIDFromPos(pos, false, true));
if (_currentDraggedChannel) {
if (_currentDraggedChannel->_sprite->_moveable) {
diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index d7433bdbb0..7f4c32c4dd 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -466,11 +466,11 @@ void Score::screenShot() {
newSurface->free();
}
-uint16 Score::getSpriteIDFromPos(Common::Point pos, bool firstActive) {
+uint16 Score::getSpriteIDFromPos(Common::Point pos, bool firstActive, bool onlyMatte) {
int unfocusableSprite = 0;
for (int i = _channels.size() - 1; i >= 0; i--)
- if (_channels[i]->getBbox().contains(pos)) {
+ if (_channels[i]->isMouseIn(pos, onlyMatte)) {
if (!firstActive || _channels[i]->_sprite->isFocusable())
return i;
else if (unfocusableSprite == 0)
diff --git a/engines/director/score.h b/engines/director/score.h
index 3faa0189de..86b6bb2cb8 100644
--- a/engines/director/score.h
+++ b/engines/director/score.h
@@ -88,7 +88,7 @@ public:
int getCurrentLabelNumber();
int getNextLabelNumber(int referenceFrame);
- uint16 getSpriteIDFromPos(Common::Point pos, bool firstActive = false);
+ uint16 getSpriteIDFromPos(Common::Point pos, bool firstActive = false, bool onlyMatte = false);
bool checkSpriteIntersection(uint16 spriteId, Common::Point pos);
Common::List<Channel *> getSpriteIntersections(const Common::Rect &r);
More information about the Scummvm-git-logs
mailing list