[Scummvm-git-logs] scummvm master -> d27574acae952c1c226b69148b8ea80fdd7a069e

djsrv dservilla at gmail.com
Mon Aug 23 20:10:57 UTC 2021


This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
80b4d55586 DIRECTOR: Make isMouseIn return false for invisible sprites
1a0393bc19 DIRECTOR: Consider buttons to respond to mouse
d27574acae DIRECTOR: Fix mouseUp events


Commit: 80b4d555869dd6f23e459e090208af02303d59b0
    https://github.com/scummvm/scummvm/commit/80b4d555869dd6f23e459e090208af02303d59b0
Author: djsrv (dservilla at gmail.com)
Date: 2021-08-23T16:10:44-04:00

Commit Message:
DIRECTOR: Make isMouseIn return false for invisible sprites

Changed paths:
    engines/director/channel.cpp


diff --git a/engines/director/channel.cpp b/engines/director/channel.cpp
index 07acf6afb2..e545afbf87 100644
--- a/engines/director/channel.cpp
+++ b/engines/director/channel.cpp
@@ -198,8 +198,10 @@ bool Channel::isActiveText() {
 }
 
 bool Channel::isMouseIn(const Common::Point &pos) {
-	Common::Rect bbox = getBbox();
+	if (!_visible)
+		return false;
 
+	Common::Rect bbox = getBbox();
 	if (!bbox.contains(pos))
 		return false;
 


Commit: 1a0393bc19e13b07b5a23f96515fa3bcfab556a4
    https://github.com/scummvm/scummvm/commit/1a0393bc19e13b07b5a23f96515fa3bcfab556a4
Author: djsrv (dservilla at gmail.com)
Date: 2021-08-23T16:10:44-04:00

Commit Message:
DIRECTOR: Consider buttons to respond to mouse

Even without scripts, respondsToMouse and isActive should treat
buttons as if they have scripts since they change visually.

Changed paths:
    engines/director/sprite.cpp


diff --git a/engines/director/sprite.cpp b/engines/director/sprite.cpp
index 95d5d92f75..7e5899143a 100644
--- a/engines/director/sprite.cpp
+++ b/engines/director/sprite.cpp
@@ -160,6 +160,9 @@ bool Sprite::respondsToMouse() {
 	if (_moveable)
 		return true;
 
+	if (_cast && _cast->_type == kCastButton)
+		return true;
+
 	ScriptContext *spriteScript = _movie->getScriptContext(kScoreScript, _scriptId);
 	if (spriteScript && (spriteScript->_eventHandlers.contains(kEventGeneric)
 					  || spriteScript->_eventHandlers.contains(kEventMouseDown)
@@ -175,6 +178,9 @@ bool Sprite::respondsToMouse() {
 }
 
 bool Sprite::isActive() {
+	if (_cast && _cast->_type == kCastButton)
+		return true;
+
 	return _movie->getScriptContext(kScoreScript, _scriptId) != nullptr
 			|| _movie->getScriptContext(kCastScript, _castId) != nullptr;
 }


Commit: d27574acae952c1c226b69148b8ea80fdd7a069e
    https://github.com/scummvm/scummvm/commit/d27574acae952c1c226b69148b8ea80fdd7a069e
Author: djsrv (dservilla at gmail.com)
Date: 2021-08-23T16:10:44-04:00

Commit Message:
DIRECTOR: Fix mouseUp events

Before, the code for setting a button's hilite flag made it so that
mouseUp only ever went to the last sprite that had a mouseDown
event. That is not correct. Whatever sprite the mouse goes up on
gets the event, even if it didn't get the last mouseDown event.

Changed paths:
    engines/director/events.cpp
    engines/director/movie.cpp
    engines/director/movie.h


diff --git a/engines/director/events.cpp b/engines/director/events.cpp
index 0f485a57a4..64d40dc532 100644
--- a/engines/director/events.cpp
+++ b/engines/director/events.cpp
@@ -121,12 +121,8 @@ bool Movie::processEvent(Common::Event &event) {
 			g_director->getCurrentWindow()->setDirty(true);
 			g_director->getCurrentWindow()->addDirtyRect(sc->_channels[_currentHiliteChannelId]->getBbox());
 			_currentHiliteChannelId = 0;
-			_currentHandlingChannelId = 0;
 		}
 
-		if (_currentHandlingChannelId && !sc->_channels[_currentHandlingChannelId]->getBbox().contains(pos))
-			_currentHandlingChannelId = 0;
-
 		// for the list style button, we still have chance to trigger events though button.
 		if (!(g_director->_wm->_mode & Graphics::kWMModeButtonDialogStyle) && g_director->_wm->_mouseDown && g_director->_wm->_hilitingWidget) {
 			if (g_director->getVersion() < 400)
@@ -134,7 +130,6 @@ bool Movie::processEvent(Common::Event &event) {
 			else
 				spriteId = sc->getMouseSpriteIDFromPos(pos);
 
-			_currentHandlingChannelId = spriteId;
 			if (spriteId > 0 && sc->_channels[spriteId]->_sprite->shouldHilite()) {
 				_currentHiliteChannelId = spriteId;
 				g_director->getCurrentWindow()->setDirty(true);
@@ -169,10 +164,10 @@ bool Movie::processEvent(Common::Event &event) {
 			else
 				spriteId = sc->getMouseSpriteIDFromPos(pos);
 
-			// is this variable unused here?
+			// Set `the clickOn` Lingo property.
+			// Even in D4, `the clickOn` uses the old "active" sprite instead of mouse sprite.
 			_currentClickOnSpriteId = sc->getActiveSpriteIDFromPos(pos);
 
-			_currentHandlingChannelId = spriteId;
 			if (spriteId > 0 && sc->_channels[spriteId]->_sprite->shouldHilite()) {
 				_currentHiliteChannelId = spriteId;
 				g_director->_wm->_hilitingWidget = true;
@@ -180,6 +175,10 @@ bool Movie::processEvent(Common::Event &event) {
 				g_director->getCurrentWindow()->addDirtyRect(sc->_channels[_currentHiliteChannelId]->getBbox());
 			}
 
+			CastMember *cast = getCastMember(sc->_channels[spriteId]->_sprite->_castId);
+			if (cast && cast->_type == kCastButton)
+				_mouseDownWasInButton = true;
+
 			_lastEventTime = g_director->getMacTicks();
 			_lastClickTime = _lastEventTime;
 			_lastClickPos = pos;
@@ -200,6 +199,11 @@ bool Movie::processEvent(Common::Event &event) {
 	case Common::EVENT_LBUTTONUP:
 		pos = _window->getMousePos();
 
+		if (g_director->getVersion() < 400)
+			spriteId = sc->getActiveSpriteIDFromPos(pos);
+		else
+			spriteId = sc->getMouseSpriteIDFromPos(pos);
+
 		if (_currentHiliteChannelId && sc->_channels[_currentHiliteChannelId]) {
 			g_director->getCurrentWindow()->setDirty(true);
 			g_director->getCurrentWindow()->addDirtyRect(sc->_channels[_currentHiliteChannelId]->getBbox());
@@ -207,21 +211,26 @@ bool Movie::processEvent(Common::Event &event) {
 
 		g_director->_wm->_hilitingWidget = false;
 
-		debugC(3, kDebugEvents, "event: Button Up @(%d, %d), movie '%s', sprite id: %d", pos.x, pos.y, _macName.c_str(), _currentHandlingChannelId);
+		debugC(3, kDebugEvents, "event: Button Up @(%d, %d), movie '%s', sprite id: %d", pos.x, pos.y, _macName.c_str(), spriteId);
 
 		_currentDraggedChannel = nullptr;
 
-		if (_currentHandlingChannelId) {
-			CastMember *cast = getCastMember(sc->_channels[_currentHandlingChannelId]->_sprite->_castId);
+		// If this is a button cast member, and the last mouse down event was in a button
+		// (any button), flip this button's hilite flag.
+		// Now you might think, "Wait, we don't flip this flag in the mouseDown event.
+		// And why any button??? This doesn't make any sense."
+		// No, it doesn't make sense, but it's what Director does.
+		if (_mouseDownWasInButton) {
+			CastMember *cast = getCastMember(sc->_channels[spriteId]->_sprite->_castId);
 			if (cast && cast->_type == kCastButton)
 				cast->_hilite = !cast->_hilite;
 		}
 
-		queueUserEvent(kEventMouseUp, _currentHandlingChannelId);
+		queueUserEvent(kEventMouseUp, spriteId);
 		sc->renderCursor(pos);
 
 		_currentHiliteChannelId = 0;
-		_currentHandlingChannelId = 0;
+		_mouseDownWasInButton = false;
 		return true;
 
 	case Common::EVENT_KEYDOWN:
diff --git a/engines/director/movie.cpp b/engines/director/movie.cpp
index c98bbedbd8..ff0acf93f9 100644
--- a/engines/director/movie.cpp
+++ b/engines/director/movie.cpp
@@ -63,7 +63,7 @@ Movie::Movie(Window *window) {
 
 	_currentDraggedChannel = nullptr;
 	_currentHiliteChannelId = 0;
-	_currentHandlingChannelId = 0;
+	_mouseDownWasInButton = false;
 
 	_version = 0;
 	_platform = Common::kPlatformMacintosh;
diff --git a/engines/director/movie.h b/engines/director/movie.h
index 510469ec29..d705fac1e0 100644
--- a/engines/director/movie.h
+++ b/engines/director/movie.h
@@ -183,7 +183,7 @@ private:
 	Common::String _script;
 	Common::String _directory;
 
-	uint16 _currentHandlingChannelId;
+	bool _mouseDownWasInButton;
 	Channel *_currentDraggedChannel;
 	Common::Point _draggingSpritePos;
 };




More information about the Scummvm-git-logs mailing list