[Scummvm-git-logs] scummvm master -> 4eb06084a8449d8c8e5060d8611bd101c6b39cee

sev- noreply at scummvm.org
Wed Sep 17 21:23:12 UTC 2025


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

Summary:
6368d7aa08 DIRECTOR: LINGO: Queues all behavior events for D6+
4eb06084a8 DIRECTOR: LINGO: Further work on behavior support


Commit: 6368d7aa08e2ede65351c6acdd1fe8439d99b8d2
    https://github.com/scummvm/scummvm/commit/6368d7aa08e2ede65351c6acdd1fe8439d99b8d2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2025-09-17T23:22:58+02:00

Commit Message:
DIRECTOR: LINGO: Queues all behavior events for D6+

Changed paths:
    engines/director/lingo/lingo-events.cpp
    engines/director/lingo/lingo.h


diff --git a/engines/director/lingo/lingo-events.cpp b/engines/director/lingo/lingo-events.cpp
index 49bcfff8244..dfce905877a 100644
--- a/engines/director/lingo/lingo-events.cpp
+++ b/engines/director/lingo/lingo-events.cpp
@@ -383,6 +383,15 @@ void Movie::queueEvent(Common::Queue<LingoEvent> &queue, LEvent event, int targe
 	int oldQueueSize = queue.size();
 
 	uint16 channelId = 0;
+	uint16 pointedSpriteId = 0;
+
+	// In D6+ there are multiple behavors per sprite, find the sprite
+	if (g_director->getVersion() >= 600) {
+		if (targetId == 0)
+			pointedSpriteId = _score->getActiveSpriteIDFromPos(pos);
+		else
+			pointedSpriteId = targetId;
+	}
 
 	/* When an event occurs the message [...] is first sent to a
 	 * primary event handler: [... if exists it is executed] and the
@@ -482,7 +491,24 @@ void Movie::queueEvent(Common::Queue<LingoEvent> &queue, LEvent event, int targe
 		case kEventBeginSprite:
 		case kEventMouseEnter:
 		case kEventMouseLeave:
-			queue.push(LingoEvent(event, eventId, kSpriteHandler, false, pos, channelId));
+			if (_vm->getVersion() >= 600) {
+				if (pointedSpriteId != 0) {
+					Sprite *sprite = _score->getSpriteById(pointedSpriteId);
+					if (sprite) {
+						// Generate event for each behavior, and pass through for all but the last one.
+						// This is to allow multiple behaviors on a single sprite to each have a
+						// chance to handle the event.
+						for (int i = 0; i < sprite->_behaviors.size(); i++) {
+							bool passThrough = (i != sprite->_behaviors.size() - 1);
+							queue.push(LingoEvent(event, eventId, kSpriteHandler, passThrough, pos, channelId, i));
+						}
+					}
+				} else {
+					// We have no sprite under the mouse, no SpriteHandler to queue.
+				}
+			} else {
+				queue.push(LingoEvent(event, eventId, kSpriteHandler, false, pos, channelId));
+			}
 			queue.push(LingoEvent(event, eventId, kCastHandler, false, pos, channelId));
 			// fall through
 
diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h
index 387f6bb4308..20c9e0d8c6e 100644
--- a/engines/director/lingo/lingo.h
+++ b/engines/director/lingo/lingo.h
@@ -271,8 +271,9 @@ struct LingoEvent {
 	uint16 channelId;
 	CastMemberID scriptId;
 	Common::Point mousePos;
+	int behaviorIndex = -1;
 
-	LingoEvent (LEvent e, int ei, ScriptType st, bool pass, CastMemberID si = CastMemberID(), Common::Point mp = Common::Point(-1, -1)) {
+	LingoEvent(LEvent e, int ei, ScriptType st, bool pass, CastMemberID si = CastMemberID(), Common::Point mp = Common::Point(-1, -1), int bi = -1) {
 		event = e;
 		eventId = ei;
 		eventHandlerSourceType = kNoneHandler;
@@ -281,9 +282,10 @@ struct LingoEvent {
 		channelId = 0;
 		scriptId = si;
 		mousePos = mp;
+		behaviorIndex = bi;
 	}
 
-	LingoEvent (LEvent e, int ei, EventHandlerSourceType ehst, bool pass, Common::Point mp = Common::Point(-1, -1), uint16 ci = 0) {
+	LingoEvent(LEvent e, int ei, EventHandlerSourceType ehst, bool pass, Common::Point mp = Common::Point(-1, -1), uint16 ci = 0, int bi = -1) {
 		event = e;
 		eventId = ei;
 		eventHandlerSourceType = ehst;
@@ -292,6 +294,7 @@ struct LingoEvent {
 		channelId = ci;
 		scriptId = CastMemberID();
 		mousePos = mp;
+		behaviorIndex = bi;
 	}
 };
 


Commit: 4eb06084a8449d8c8e5060d8611bd101c6b39cee
    https://github.com/scummvm/scummvm/commit/4eb06084a8449d8c8e5060d8611bd101c6b39cee
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2025-09-17T23:22:58+02:00

Commit Message:
DIRECTOR: LINGO: Further work on behavior support

Now we find out the relevant behavior, though for the complex ones
we need to instantiate it (and it goes into 'the scriptInstanceList'
and pass the parameters represented in 'initializerParams', which
is a string, so need to call 'value()' over it

Changed paths:
    engines/director/lingo/lingo-events.cpp
    engines/director/sprite.cpp


diff --git a/engines/director/lingo/lingo-events.cpp b/engines/director/lingo/lingo-events.cpp
index dfce905877a..29d2e24cbb3 100644
--- a/engines/director/lingo/lingo-events.cpp
+++ b/engines/director/lingo/lingo-events.cpp
@@ -233,6 +233,7 @@ void Movie::resolveScriptEvent(LingoEvent &event) {
 		{
 			CastMemberID scriptId;
 			bool immediate = false;
+			Common::String initializerParams;
 			// mouseUp events seem to check the frame script ID from the original mouseDown event
 			if ((event.event == kEventMouseUp) || (event.event == kEventRightMouseUp)) {
 				scriptId = _currentMouseDownSpriteScriptID;
@@ -243,9 +244,27 @@ void Movie::resolveScriptEvent(LingoEvent &event) {
 				Frame *currentFrame = _score->_currentFrame;
 				assert(currentFrame != nullptr);
 				Sprite *sprite = _score->getSpriteById(event.channelId);
-				if (!sprite || !sprite->_scriptId.member)
+				if (!sprite)
 					return;
-				scriptId = sprite->_scriptId;
+
+				if (_vm->getVersion() >= 600) {
+					if (event.behaviorIndex >= 0) {
+						scriptId = sprite->_behaviors[event.behaviorIndex].memberID;
+						initializerParams = sprite->_behaviors[event.behaviorIndex].initializerParams;
+						warning("ID: %s, initializerParams: '%s'", scriptId.asString().c_str(), initializerParams.c_str());
+
+						// TODO: instantiate the behavior script as a child and set its properties
+						// according to the list in initializerParams
+					} else {
+						return;
+					}
+				} else {
+					if (!sprite->_scriptId.member)
+						return;
+
+					scriptId = sprite->_scriptId;
+				}
+
 				immediate = sprite->_immediate;
 			}
 
@@ -387,10 +406,11 @@ void Movie::queueEvent(Common::Queue<LingoEvent> &queue, LEvent event, int targe
 
 	// In D6+ there are multiple behavors per sprite, find the sprite
 	if (g_director->getVersion() >= 600) {
-		if (targetId == 0)
-			pointedSpriteId = _score->getActiveSpriteIDFromPos(pos);
-		else
+		if (targetId == 0) {
+			pointedSpriteId = _score->getMouseSpriteIDFromPos(pos);
+		} else {
 			pointedSpriteId = targetId;
+		}
 	}
 
 	/* When an event occurs the message [...] is first sent to a
diff --git a/engines/director/sprite.cpp b/engines/director/sprite.cpp
index c048fb541cd..c17eb8b3ec7 100644
--- a/engines/director/sprite.cpp
+++ b/engines/director/sprite.cpp
@@ -335,6 +335,12 @@ bool Sprite::respondsToMouse() {
 	if (_cast && _cast->_type == kCastButton)
 		return true;
 
+	// TODO: Check if we need to check against individual events like below
+	if (g_director->getVersion() >= 600) {
+		if (_behaviors.size() > 0)
+			return true;
+	}
+
 	ScriptContext *spriteScript = _movie->getScriptContext(kScoreScript, _scriptId);
 	if (spriteScript && (spriteScript->_eventHandlers.contains(kEventGeneric)
 					  || spriteScript->_eventHandlers.contains(kEventMouseDown)




More information about the Scummvm-git-logs mailing list