[Scummvm-git-logs] scummvm master -> 2a664ec3aa80f942edae450b4a69d301541a9935

sev- noreply at scummvm.org
Sat Apr 26 11:37:50 UTC 2025


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

Summary:
2a664ec3aa DIRECTOR: Disable Movie Events while Alert is being shown


Commit: 2a664ec3aa80f942edae450b4a69d301541a9935
    https://github.com/scummvm/scummvm/commit/2a664ec3aa80f942edae450b4a69d301541a9935
Author: Malhar (themalharbdv2046 at gmail.com)
Date: 2025-04-26T19:37:47+08:00

Commit Message:
DIRECTOR: Disable Movie Events while Alert is being shown

Alerts and Message are shown on the screen by ScummVM using GUI dialog
boxes. They may have clickable buttons on them.
In Director, it may happen that the event of clicking or pressing the
button on the GUI dialog box (mouseUp, keyUp) get recorded as a movie
event, which may cause unpredictable change in the lingo script.

Prevent this by disabling all event processing in the Director movie
using a flag _inGuiMessageBox, which is set by the function that calls
the alert or dialog box and cleared once the dialog box dissappears
In this case that is the `b_alert()` function

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


diff --git a/engines/director/events.cpp b/engines/director/events.cpp
index 2954bfde01a..14e4ece7e9d 100644
--- a/engines/director/events.cpp
+++ b/engines/director/events.cpp
@@ -121,6 +121,12 @@ bool Window::processEvent(Common::Event &event) {
 }
 
 bool Movie::processEvent(Common::Event &event) {
+	// When in GUI message box is being shown, movie may record clicking on the message box as a movie event
+	// Make sure that these events (mouseUp, mouseDown) are not recorded in the movie
+	if (_inGuiMessageBox) {
+		return false;
+	}
+
 	Score *sc = getScore();
 	if (sc->getCurrentFrameNum() > sc->getFramesNum()) {
 		warning("processEvents: request to access frame %d of %d", sc->getCurrentFrameNum(), sc->getFramesNum());
diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index da8acc678af..da4d51fe7ec 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -2128,6 +2128,12 @@ void LB::b_voidP(int nargs) {
 // Misc
 ///////////////////
 void LB::b_alert(int nargs) {
+	// Let the movie know not to record mouse and key events
+	// While there is an GUI alert box being shown
+	// It may happen the user clicks on the button on the GUI message and
+	// due to it getting recorded as a movie event, causes unpredictable changes
+	g_director->getCurrentMovie()->_inGuiMessageBox = true;
+
 	Datum d = g_lingo->pop();
 
 	Common::String alert = d.asString();
@@ -2144,6 +2150,9 @@ void LB::b_alert(int nargs) {
 		GUI::MessageDialog dialog(alert.c_str(), _("OK"));
 		dialog.runModal();
 	}
+
+	// Movie can process events as normal now
+	g_director->getCurrentMovie()->_inGuiMessageBox = false;
 }
 
 void LB::b_clearGlobals(int nargs) {
diff --git a/engines/director/movie.h b/engines/director/movie.h
index f78e3dd1a4c..8f59b71a36d 100644
--- a/engines/director/movie.h
+++ b/engines/director/movie.h
@@ -194,6 +194,11 @@ public:
 
 	Common::String _script;
 
+	// A flag to disable the event processing in the Movie
+	// This flag will be set when the user's interaction (mouse and key events like mouseUp, keyUp)  
+	// shouldn't be recorded as movie event, which may cause undesirable change in the lingo script
+	bool _inGuiMessageBox = false;
+
 private:
 	Window *_window;
 	DirectorEngine *_vm;




More information about the Scummvm-git-logs mailing list