[Scummvm-git-logs] scummvm master -> 8b02e0817c3cdcf5a922a9203bb3843854ceee7f

bluegr noreply at scummvm.org
Wed Nov 11 00:35:26 UTC 2026


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

Summary:
77c94e7e97 NANCY: NANCY26: Pause the Xsheet records at the end of their animation
31ede103c9 NANCY: NANCY26: Show the Xsheet records before they first run
bf84511cca NANCY: Stop an esc press that skips something from opening the menu
4672b8bd99 NANCY: NANCY17: Fix sound records that don't change the scene
6475db9300 NANCY: Move the scene time on when a movie is skipped
8b9ca464c0 NANCY: Stop the sounds of a movie when it is skipped
870047a481 NANCY: NANCY19: Redraw script graphics only when shown or hidden
3befe1d00a NANCY: NANCY19: Redraw Override graphics only when they change
14589e62e2 NANCY: NANCY19: Keep movie records in time with their sound
b572d6c937 NANCY: NANCY26: Fix the second line of two-line subtitles
19963c75ac NANCY: NANCY26: Keep the fractions of script points
45fdcb3ad4 NANCY: NANCY19: Replace ScriptPoint with Common::Point32
406524bde2 NANCY: NANCY27: Add Rect:Clamp() and the new Point functions
89c1fd0678 NANCY: NANCY27: Add the sound channels of Nancy27
b4a85959c3 NANCY: NANCY27: Add Game.diags
42e7bdbe95 NANCY: NANCY27: Put away the item in hand when inHand is set to nil
053dea1e23 NANCY: NANCY27: Add Sound:PauseAbandoned() and UnpauseAbandoned()
3b1f81b27c NANCY: NANCY27: Add the Brain
ded14a3efd NANCY: NANCY26: Use the game ID in the header of saved games
4f20476232 NANCY: NANCY26: Keep the state of the Game object in an engine object
8b02e0817c NANCY: NANCY27: Add detection entry


Commit: 77c94e7e97cc802b08412422fdeda74dd1b83786
    https://github.com/scummvm/scummvm/commit/77c94e7e97cc802b08412422fdeda74dd1b83786
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-11T02:33:56+02:00

Commit Message:
NANCY: NANCY26: Pause the Xsheet records at the end of their animation

The video conversations, e.g. Lily's in scene 1200, wait for the
animation of each line to pause itself at its end. Without that, they
got stuck before Nancy's responses were shown.

Changed paths:
    engines/nancy/script/xsheet.cpp


diff --git a/engines/nancy/script/xsheet.cpp b/engines/nancy/script/xsheet.cpp
index 231514b976c..e70bc826188 100644
--- a/engines/nancy/script/xsheet.cpp
+++ b/engines/nancy/script/xsheet.cpp
@@ -22,6 +22,7 @@
 #include "common/textconsole.h"
 
 #include "engines/nancy/graphics.h"
+#include "engines/nancy/nancy.h"
 #include "engines/nancy/resource/xsheetfile.h"
 
 #include "engines/nancy/script/api.h"
@@ -266,6 +267,16 @@ void XsheetRecord::run(double sceneTime, double elapsedTime) {
 	_xsheet.showFrame((uint)_frame);
 
 	if (_hasEnded && !_isPaused) {
+#ifdef ENABLE_NANCY_V5
+		// Nancy26 pauses the record itself, which its scripts see and undo
+		// through localPaused, e.g. the fidgets of the conversations
+		if (g_nancy->getGameType() >= kGameTypeNancy26) {
+			setLocalPaused(true);
+			callFunction("OnPause");
+			return;
+		}
+#endif
+
 		_isPaused = true;
 		callFunction("OnPause");
 	}


Commit: 31ede103c982e106fba0c33ae16a5d4d24386eef
    https://github.com/scummvm/scummvm/commit/31ede103c982e106fba0c33ae16a5d4d24386eef
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-11T02:33:57+02:00

Commit Message:
NANCY: NANCY26: Show the Xsheet records before they first run

In a conversation where Nancy speaks first, e.g. with Lily in scene
1202, the character waits paused until Nancy is done, and was hidden
until then.

Changed paths:
    engines/nancy/script/xsheet.cpp


diff --git a/engines/nancy/script/xsheet.cpp b/engines/nancy/script/xsheet.cpp
index e70bc826188..b7e60685801 100644
--- a/engines/nancy/script/xsheet.cpp
+++ b/engines/nancy/script/xsheet.cpp
@@ -315,7 +315,17 @@ void XsheetRecord::registerGraphics() {
 
 void XsheetRecord::updateGraphics() {
 	_hasShown |= hasStarted();
-	_xsheet.setVisible(isShown() && _hasShown);
+	bool isVisible = isShown() && _hasShown;
+
+#ifdef ENABLE_NANCY_V5
+	// Nancy26 draws the record before it runs as well. The conversations
+	// pause the character until Nancy is done, when she speaks first.
+	if (g_nancy->getGameType() >= kGameTypeNancy26) {
+		isVisible = isShown();
+	}
+#endif
+
+	_xsheet.setVisible(isVisible);
 }
 
 bool XsheetRecord::getField(const Common::String &key) {


Commit: bf84511cca67655cec58d4f7a7d7fd16630531e2
    https://github.com/scummvm/scummvm/commit/bf84511cca67655cec58d4f7a7d7fd16630531e2
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-11T02:34:06+02:00

Commit Message:
NANCY: Stop an esc press that skips something from opening the menu

When esc skips a movie or a line of dialogue, the same press no longer
opens the main menu as well, even when the key is held down. In Nancy19
to Nancy25, the scripts still get esc when it skipped nothing.

Changed paths:
    engines/nancy/input.cpp
    engines/nancy/input.h
    engines/nancy/script/v5/scriptinput.cpp
    engines/nancy/state/scene.cpp
    engines/nancy/state/scene.h


diff --git a/engines/nancy/input.cpp b/engines/nancy/input.cpp
index 8ba99d7b82d..713a7c6716f 100644
--- a/engines/nancy/input.cpp
+++ b/engines/nancy/input.cpp
@@ -45,6 +45,14 @@ void InputManager::processEvents() {
 	while (g_nancy->getEventManager()->pollEvent(event)) {
 		switch (event.type) {
 		case EVENT_KEYDOWN:
+			// A held esc key repeats; once its press was taken away, so are the repeats
+			if (event.kbd.keycode == KEYCODE_ESCAPE) {
+				_isEscEaten &= event.kbdRepeat;
+				if (_isEscEaten) {
+					break;
+				}
+			}
+
 			// Push all keyboard events into an array and let getInput() callers handle them
 			_otherKbdInput.push_back(event.kbd);
 			_inputBeginState = g_nancy->getState();
@@ -164,6 +172,28 @@ NancyInput InputManager::getInput() const {
 	return ret;
 }
 
+// The default keymap of the engines turns esc into a key, next to the menu key
+static void removeEscKeys(Common::Array<Common::KeyState> &keys) {
+	for (uint i = 0; i < keys.size();) {
+		if (keys[i].keycode == Common::KEYCODE_ESCAPE) {
+			keys.remove_at(i);
+		} else {
+			++i;
+		}
+	}
+}
+
+void NancyInput::eatMainMenuKey() {
+	input &= ~kOpenMainMenu;
+	removeEscKeys(otherKbdInput);
+}
+
+void InputManager::eatMainMenuKey() {
+	_inputs &= ~NancyInput::kOpenMainMenu;
+	removeEscKeys(_otherKbdInput);
+	_isEscEaten = true;
+}
+
 void InputManager::forceCleanInput() {
 	_inputs = 0;
 	_otherKbdInput.clear();
diff --git a/engines/nancy/input.h b/engines/nancy/input.h
index 310b9396279..b49ade0616c 100644
--- a/engines/nancy/input.h
+++ b/engines/nancy/input.h
@@ -71,6 +71,9 @@ struct NancyInput {
 	// Consumes just the wheel input, leaving the mouse position and buttons alone,
 	// so a widget that scrolls can still keep updating its hover state
 	void eatMouseWheelInput() { input &= ~kMouseWheel; }
+
+	// Takes away the esc press, which comes both as the menu key and as a key
+	void eatMainMenuKey();
 };
 
 // This class handles collecting events and translating them to a NancyInput object,
@@ -93,12 +96,16 @@ public:
 	InputManager() :
 		_inputs(0),
 		_mouseEnabled(true),
+		_isEscEaten(false),
 		_inputBeginState(NancyState::kNone) {}
 
 	void processEvents();
 
 	NancyInput getInput() const;
 	void forceCleanInput();
+	// Takes away an esc press that skipped something, so nothing else sees it,
+	// in this frame or later ones, until the key gets pressed again
+	void eatMainMenuKey();
 	void setMouseInputEnabled(bool enabled) { _mouseEnabled = enabled; }
 	void setKeymapEnabled(Common::String keymapName, bool enabled);
 	void setVKEnabled(bool enabled);
@@ -111,6 +118,7 @@ private:
 	uint16 _inputs;
 	Common::Array<Common::KeyState> _otherKbdInput;
 	bool _mouseEnabled;
+	bool _isEscEaten;
 	NancyState::NancyState _inputBeginState;
 };
 
diff --git a/engines/nancy/script/v5/scriptinput.cpp b/engines/nancy/script/v5/scriptinput.cpp
index 4277c5130ef..24e7ff34960 100644
--- a/engines/nancy/script/v5/scriptinput.cpp
+++ b/engines/nancy/script/v5/scriptinput.cpp
@@ -473,7 +473,7 @@ namespace State {
 
 // Nancy26's records take care of all the input themselves. Esc opens the menu
 // through them, unless it skips the movies that play or what the characters
-// say; that press then stays away from them until it is let go.
+// say; that press is then taken away from everything.
 void Scene::handleNancy26Input(NancyInput &input) {
 	const bool escPressed = (input.input & NancyInput::kOpenMainMenu) != 0;
 	if (escPressed && !_escHeld && _scriptScene) {
@@ -484,15 +484,13 @@ void Scene::handleNancy26Input(NancyInput &input) {
 			hasSkipped |= _streams.skipSpeech();
 		}
 
-		_isEscSkipping = hasSkipped;
-	} else if (!escPressed) {
-		_isEscSkipping = false;
+		if (hasSkipped) {
+			g_nancy->_input->eatMainMenuKey();
+			input.eatMainMenuKey();
+		}
 	}
 
-	_escHeld = escPressed;
-	if (_isEscSkipping) {
-		input.input &= ~NancyInput::kOpenMainMenu;
-	}
+	_escHeld = (input.input & NancyInput::kOpenMainMenu) != 0;
 
 	Script::handleNancy26Input(input);
 }
diff --git a/engines/nancy/state/scene.cpp b/engines/nancy/state/scene.cpp
index 078ff7861bb..641b993dbc5 100644
--- a/engines/nancy/state/scene.cpp
+++ b/engines/nancy/state/scene.cpp
@@ -2837,12 +2837,14 @@ void Scene::handleInput() {
 
 	// Check if player has pressed esc. While a dialogue line or a cinematic is
 	// playing, esc skips it instead of opening the main menu. Only the initial
-	// press counts, so holding the key down doesn't skip line after line.
+	// press counts, so holding the key down doesn't skip line after line. A
+	// press that skips is taken away, so it can't open the menu afterwards.
 	const bool escPressed = (input.input & NancyInput::kOpenMainMenu) != 0;
 	const bool escJustPressed = escPressed && !_escHeld;
 	_escHeld = escPressed;
 
 	if (escJustPressed) {
+		bool isSkipKey = true;
 		if (_activeConversation) {
 			_activeConversation->skipLine();
 		} else if (_activeMovie) {
@@ -2854,14 +2856,24 @@ void Scene::handleInput() {
 			bool hasSkipped = _scriptScene->skipMovies();
 			hasSkipped |= _streams.skipMovies();
 			if (!hasSkipped) {
-				_scriptScene->skipSpeech();
-				_streams.skipSpeech();
+				hasSkipped = _scriptScene->skipSpeech();
+				hasSkipped |= _streams.skipSpeech();
 			}
+
+			isSkipKey = hasSkipped;
 #endif
 		} else if (g_nancy->getGameType() <= kGameTypeNancy15) {
 			// Nancy16 has no main menu state
 			g_nancy->setState(NancyState::kMainMenu);
 			return;
+		} else {
+			isSkipKey = false;
+		}
+
+		if (isSkipKey) {
+			g_nancy->_input->eatMainMenuKey();
+			input.eatMainMenuKey();
+			_escHeld = false;
 		}
 	}
 
diff --git a/engines/nancy/state/scene.h b/engines/nancy/state/scene.h
index d0e2364b18d..a883f63c0d1 100644
--- a/engines/nancy/state/scene.h
+++ b/engines/nancy/state/scene.h
@@ -596,8 +596,6 @@ private:
 	// Nancy26 makes its UI of records, and hands its records all the input
 	void initNancy26UI();
 	void handleNancy26Input(NancyInput &input);
-
-	bool _isEscSkipping = false;	// the press that skipped stays away from the scripts
 #endif
 
 	uint _inventoryChangeCount = 0;


Commit: 4672b8bd99cc9986658a71500dea29958d4292da
    https://github.com/scummvm/scummvm/commit/4672b8bd99cc9986658a71500dea29958d4292da
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-11T02:34:07+02:00

Commit Message:
NANCY: NANCY17: Fix sound records that don't change the scene

Nancy17 and later mark "no scene change" in their sound records with
32767, which was taken as a scene number. Skipping a cinematic now
stops the speech in these games too, and a looping sound with nothing
else to do ends its record right away, as in Nancy13 to Nancy16.

Changed paths:
    engines/nancy/action/soundrecords.cpp


diff --git a/engines/nancy/action/soundrecords.cpp b/engines/nancy/action/soundrecords.cpp
index bd151116b60..f316ad812a5 100644
--- a/engines/nancy/action/soundrecords.cpp
+++ b/engines/nancy/action/soundrecords.cpp
@@ -261,6 +261,12 @@ void PlaySound::readDataNancy13(Common::SeekableReadStream &stream) {
 	_changeSceneImmediately = stream.readByte();
 	_sceneChange.sceneID = stream.readUint16LE();
 	_sceneChange.continueSceneSound = kContinueSceneSound;	// sounds keep playing into the new scene
+
+	// Nancy17 marks "no scene change" with a different value
+	if (g_nancy->getGameType() >= kGameTypeNancy17 && _sceneChange.sceneID == kNoSceneNancy17) {
+		_sceneChange.sceneID = kNoScene;
+	}
+
 	_afterSoundAction = stream.readByte();	// overlay-refresh control; unused
 
 	// The single event flag became a list of { label, value } pairs.


Commit: 6475db9300ae879d79f4fbfcf45213bcb0dd9835
    https://github.com/scummvm/scummvm/commit/6475db9300ae879d79f4fbfcf45213bcb0dd9835
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-11T02:34:10+02:00

Commit Message:
NANCY: Move the scene time on when a movie is skipped

A skipped movie now adds the time it had left to the time of the scene,
so the records that wait for the end of the movie don't wait any longer.
Fixes skipping the opening cinematic of Nancy18.

Changed paths:
    engines/nancy/action/secondarymovie.cpp
    engines/nancy/state/scene.h


diff --git a/engines/nancy/action/secondarymovie.cpp b/engines/nancy/action/secondarymovie.cpp
index 917829b3f31..5b9859ef31e 100644
--- a/engines/nancy/action/secondarymovie.cpp
+++ b/engines/nancy/action/secondarymovie.cpp
@@ -1552,6 +1552,22 @@ bool PlaySecondaryMovie::skip() {
 		resolveSentinelFrames();
 	}
 
+	// The scene's records wait for times that count the whole movie in, like
+	// the scene change after the opening cinematic of Nancy18
+	if (_decoder.isVideoLoaded() && !_isFinished) {
+		int framesLeft;
+		if (_playDirection == kPlayMovieReverse) {
+			framesLeft = curFrame == -1 ? _lastFrame - _firstFrame + 1 : curFrame - _firstFrame;
+		} else {
+			framesLeft = _lastFrame - curFrame;
+		}
+
+		const int frameCount = _decoder.getFrameCount();
+		if (framesLeft > 0 && frameCount > 0) {
+			NancySceneState.addSceneTime((uint32)((uint64)_decoder.getDuration().msecs() * framesLeft / frameCount));
+		}
+	}
+
 	for (const FlagAtFrame &frameFlag : _frameFlags) {
 		bool isPending;
 		if (_playDirection == kPlayMovieReverse) {
diff --git a/engines/nancy/state/scene.h b/engines/nancy/state/scene.h
index a883f63c0d1..7e2056bacd7 100644
--- a/engines/nancy/state/scene.h
+++ b/engines/nancy/state/scene.h
@@ -288,6 +288,8 @@ public:
 	void requestStateChange(NancyState::NancyState state) { _gameStateRequested = state; }
 	void resetStateToInit() { _state = kInit; }
 
+	// A skipped movie moves the time of the scene on by what was left of it
+	void addSceneTime(uint32 millis) { _timers.sceneTime += millis; }
 	void resetAndStartTimer() { _timers.timerIsActive = true; _timers.timerTime = 0; }
 	void stopTimer() { _timers.timerIsActive = false; _timers.timerTime = 0; }
 


Commit: 8b9ca464c0c254320d96e8f2799813f60fb33457
    https://github.com/scummvm/scummvm/commit/8b9ca464c0c254320d96e8f2799813f60fb33457
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-11T02:34:12+02:00

Commit Message:
NANCY: Stop the sounds of a movie when it is skipped

The sounds that a movie starts as it plays now stop when the movie is
skipped, or cut short by a scene change.

Changed paths:
    engines/nancy/action/actionmanager.cpp
    engines/nancy/action/actionmanager.h
    engines/nancy/action/secondarymovie.cpp
    engines/nancy/action/secondarymovie.h
    engines/nancy/state/scene.cpp
    engines/nancy/state/scene.h


diff --git a/engines/nancy/action/actionmanager.cpp b/engines/nancy/action/actionmanager.cpp
index aed294acf72..9017c76d666 100644
--- a/engines/nancy/action/actionmanager.cpp
+++ b/engines/nancy/action/actionmanager.cpp
@@ -19,6 +19,7 @@
  *
  */
 
+#include "common/algorithm.h"
 #include "common/serializer.h"
 #include "common/stack.h"
 #include "common/config-manager.h"
@@ -870,25 +871,43 @@ void ActionManager::onPause(bool pause) {
 	}
 }
 
+static bool dependsOnFlags(const DependencyRecord &dependency, const Common::Array<int16> &flags) {
+	if (dependency.type == DependencyType::kEvent && Common::find(flags.begin(), flags.end(), dependency.label) != flags.end()) {
+		return true;
+	}
+
+	for (const DependencyRecord &child : dependency.children) {
+		if (dependsOnFlags(child, flags)) {
+			return true;
+		}
+	}
+
+	return false;
+}
+
+// The sounds that the frames of a skipped movie start are a part of it, like
+// its music, and stop with it; so does the speech that plays when it gets skipped.
 // A stopped sound lets its record finish on its own, the same way it would at the
-// end of the line
-void ActionManager::stopSpeechSounds() {
+// end of the line. Sounds that change the scene play out.
+void ActionManager::stopSkippedMovieSounds(const Common::Array<int16> &movieFlags, bool stopsSpeech) {
 	const Common::Array<byte> &speechChannels = g_nancy->getStaticData().soundChannelInfo.speechChannels;
 	bool stoppedCaptionedSound = false;
 
 	for (ActionRecord *record : _records) {
 		PlaySound *sound = dynamic_cast<PlaySound *>(record);
 		if (!sound || !sound->_isActive || sound->_isDone || sound->_state != ActionRecord::kRun ||
-				sound->_sceneChange.sceneID != kNoScene) {
+				sound->_sceneChange.sceneID != kNoScene || !g_nancy->_sound->isSoundPlaying(sound->_sound)) {
 			continue;
 		}
 
-		for (byte channel : speechChannels) {
-			if (sound->_sound.channelID == channel) {
-				g_nancy->_sound->stopSound(sound->_sound);
-				stoppedCaptionedSound |= !sound->_ccText.empty();
-				break;
-			}
+		bool isStopped = dependsOnFlags(sound->_dependencies, movieFlags);
+		if (stopsSpeech && !isStopped) {
+			isStopped = Common::find(speechChannels.begin(), speechChannels.end(), (byte)sound->_sound.channelID) != speechChannels.end();
+		}
+
+		if (isStopped) {
+			g_nancy->_sound->stopSound(sound->_sound);
+			stoppedCaptionedSound |= !sound->_ccText.empty();
 		}
 	}
 
diff --git a/engines/nancy/action/actionmanager.h b/engines/nancy/action/actionmanager.h
index 47b9318dcc3..753658153fb 100644
--- a/engines/nancy/action/actionmanager.h
+++ b/engines/nancy/action/actionmanager.h
@@ -68,7 +68,7 @@ public:
 
 	// Enhancement: stops the lines being spoken by sound records that don't lead to
 	// another scene, after a cinematic got skipped
-	void stopSpeechSounds();
+	void stopSkippedMovieSounds(const Common::Array<int16> &movieFlags, bool stopsSpeech);
 
 	void synchronize(Common::Serializer &serializer);
 
diff --git a/engines/nancy/action/secondarymovie.cpp b/engines/nancy/action/secondarymovie.cpp
index 5b9859ef31e..904d48e894f 100644
--- a/engines/nancy/action/secondarymovie.cpp
+++ b/engines/nancy/action/secondarymovie.cpp
@@ -1539,6 +1539,16 @@ bool PlaySecondaryMovie::isSkippable() {
 		Common::Rect(_decoder.getWidth(), _decoder.getHeight()) == NancySceneState.getViewport().getBounds();
 }
 
+void PlaySecondaryMovie::getCutShortFlags(Common::Array<int16> &labels) const {
+	if (isRandom() || _movieType == kInteractiveMovie || _state != kRun || _isFinished) {
+		return;
+	}
+
+	for (const FlagAtFrame &frameFlag : _frameFlags) {
+		labels.push_back(frameFlag.flagDesc.label);
+	}
+}
+
 bool PlaySecondaryMovie::skip() {
 	if (!isSkippable()) {
 		return false;
@@ -1579,6 +1589,8 @@ bool PlaySecondaryMovie::skip() {
 		if (isPending) {
 			NancySceneState.setEventFlag(frameFlag.flagDesc);
 		}
+
+		NancySceneState.addSkippedMovieFlag(frameFlag.flagDesc.label);
 	}
 
 	g_nancy->_sound->stopSound(_sound);
diff --git a/engines/nancy/action/secondarymovie.h b/engines/nancy/action/secondarymovie.h
index b048a1f9ef7..d09495aaf57 100644
--- a/engines/nancy/action/secondarymovie.h
+++ b/engines/nancy/action/secondarymovie.h
@@ -127,6 +127,10 @@ public:
 	// the player isn't waiting on keep playing. Returns true when skipped.
 	bool skip();
 
+	// Gives the flags that the frames of a cinematic still playing set. A scene
+	// change cuts it short, like a skip, and the sounds they started go with it.
+	void getCutShortFlags(Common::Array<int16> &labels) const;
+
 	Common::Path _videoName;
 	Common::Path _paletteName;
 	Common::Path _bitmapOverlayName;
diff --git a/engines/nancy/state/scene.cpp b/engines/nancy/state/scene.cpp
index 641b993dbc5..266dbeee014 100644
--- a/engines/nancy/state/scene.cpp
+++ b/engines/nancy/state/scene.cpp
@@ -2295,6 +2295,7 @@ void Scene::load(bool fromSaveFile) {
 	}
 
 	_timers.sceneTime = 0;
+	_skippedMovieFlags.clear();
 	g_nancy->_sound->clearListenerPositionOverride();
 	g_nancy->_sound->recalculateSoundEffects();
 
@@ -2390,6 +2391,7 @@ void Scene::loadScriptedScene(bool fromSaveFile) {
 	summary->setBackground(hasBackground ? &_viewport : nullptr);
 
 	_timers.sceneTime = 0;
+	_skippedMovieFlags.clear();
 	g_nancy->_sound->clearListenerPositionOverride();
 
 	// Only numbered scenes are counted, since the others have no number to count
@@ -2474,9 +2476,9 @@ void Scene::run() {
 
 	// The records a skipped cinematic set off have started by now; its dialogue
 	// shouldn't go on without it
-	if (_hasSkippedMovie) {
+	if (_hasSkippedMovie || !_skippedMovieFlags.empty()) {
+		_actionManager.stopSkippedMovieSounds(_skippedMovieFlags, _hasSkippedMovie);
 		_hasSkippedMovie = false;
-		_actionManager.stopSpeechSounds();
 	}
 
 	if (_isLoadingSecondChance) {
@@ -3385,6 +3387,14 @@ void Scene::clearSceneData(bool nextIsNoArt) {
 	// so the pointer must be kept too; otherwise it is cleared to avoid dangling.
 	bool clearActiveMovie = _activeMovie && !_activeMovie->survivesSceneChange(nextIsNoArt);
 
+	if (clearActiveMovie) {
+		Common::Array<int16> cutShortFlags = _skippedMovieFlags;
+		_activeMovie->getCutShortFlags(cutShortFlags);
+		if (!cutShortFlags.empty()) {
+			_actionManager.stopSkippedMovieSounds(cutShortFlags, false);
+		}
+	}
+
 	_actionManager.clearActionRecords(nextIsNoArt);
 
 	if (_lightning) {
diff --git a/engines/nancy/state/scene.h b/engines/nancy/state/scene.h
index 7e2056bacd7..ce79bb8cffd 100644
--- a/engines/nancy/state/scene.h
+++ b/engines/nancy/state/scene.h
@@ -290,6 +290,8 @@ public:
 
 	// A skipped movie moves the time of the scene on by what was left of it
 	void addSceneTime(uint32 millis) { _timers.sceneTime += millis; }
+	// The sounds these flags start belong to a movie that was skipped
+	void addSkippedMovieFlag(int16 label) { _skippedMovieFlags.push_back(label); }
 	void resetAndStartTimer() { _timers.timerIsActive = true; _timers.timerTime = 0; }
 	void stopTimer() { _timers.timerIsActive = false; _timers.timerTime = 0; }
 
@@ -606,6 +608,9 @@ private:
 	// Set when esc skipped a cinematic this frame
 	bool _hasSkippedMovie = false;
 
+	// The flags the frames of the skipped cinematics set, until the scene changes
+	Common::Array<int16> _skippedMovieFlags;
+
 	bool _isLoadingSecondChance = false;
 	Common::String _loadName;
 	bool _isCheatMode = false;


Commit: 870047a48155e3ea9e46388ba65b7a69adcb5926
    https://github.com/scummvm/scummvm/commit/870047a48155e3ea9e46388ba65b7a69adcb5926
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-11T02:34:15+02:00

Commit Message:
NANCY: NANCY19: Redraw script graphics only when shown or hidden

The script records set their graphics visible on every frame, which made
the whole screen get drawn again on every frame. Now a graphic is only
drawn again when it gets shown or hidden.

Changed paths:
    engines/nancy/renderobject.cpp
    engines/nancy/renderobject.h
    engines/nancy/script/records.cpp
    engines/nancy/script/v5/textrecord.cpp
    engines/nancy/script/v5/widgets.cpp
    engines/nancy/script/xsheet.cpp


diff --git a/engines/nancy/renderobject.cpp b/engines/nancy/renderobject.cpp
index c5e94df3cbb..0692325292f 100644
--- a/engines/nancy/renderobject.cpp
+++ b/engines/nancy/renderobject.cpp
@@ -86,7 +86,11 @@ void RenderObject::moveTo(const Common::Rect &bounds) {
 	_hasMoved = true;
 }
 
-void RenderObject::setVisible(bool visible) {
+void RenderObject::setVisible(bool visible, bool forceRedraw) {
+	if (!forceRedraw && visible == _isVisible) {
+		return;
+	}
+
 	_isVisible = visible;
 	_needsRedraw = true;
 }
diff --git a/engines/nancy/renderobject.h b/engines/nancy/renderobject.h
index f815800b335..0aef55e4bb7 100644
--- a/engines/nancy/renderobject.h
+++ b/engines/nancy/renderobject.h
@@ -60,7 +60,8 @@ public:
 
 	void moveTo(const Common::Point &position);
 	void moveTo(const Common::Rect &bounds);
-	void setVisible(bool visible);
+	// Without forceRedraw, an object that stays shown or hidden isn't drawn again
+	void setVisible(bool visible, bool forceRedraw = true);
 	void setTransparent(bool isTransparent);
 	bool isVisible() const { return _isVisible; }
 
diff --git a/engines/nancy/script/records.cpp b/engines/nancy/script/records.cpp
index 458b00fd4c7..1f644a575c2 100644
--- a/engines/nancy/script/records.cpp
+++ b/engines/nancy/script/records.cpp
@@ -1400,10 +1400,10 @@ void OverlayRecord::updateGraphics() {
 	}
 
 	_graphic.setClipRect(getScreenClip());
-	_graphic.setVisible(isShown() && _hasPicture);
+	_graphic.setVisible(isShown() && _hasPicture, false);
 
 	if (_hasAttachment) {
-		_attachment.setVisible(_isAttachmentDrawn);
+		_attachment.setVisible(_isAttachmentDrawn, false);
 		_isAttachmentDrawn = false;
 	}
 }
@@ -1727,7 +1727,7 @@ void AnimOverlayRecord::updateGraphics() {
 	}
 
 	_graphic.setClipRect(getScreenClip());
-	_graphic.setVisible(isShown() && _isVisible && _hasPicture);
+	_graphic.setVisible(isShown() && _isVisible && _hasPicture, false);
 }
 
 // anim:Play() and anim:Pause(), for the records that play something
@@ -2236,7 +2236,7 @@ void TextRecord::registerGraphics() {
 }
 
 void TextRecord::updateGraphics() {
-	_graphic.setVisible(isActive());
+	_graphic.setVisible(isActive(), false);
 
 	if (_isDirty) {
 		_isDirty = false;
@@ -2535,7 +2535,7 @@ void MovieRecord::updateGraphics() {
 	}
 
 	_graphic.setClipRect(getScreenClip());
-	_graphic.setVisible(isShown() && _isVisible && !isSeeThrough());
+	_graphic.setVisible(isShown() && _isVisible && !isSeeThrough(), false);
 }
 
 void MovieRecord::describeState(Common::Array<Common::String> &lines) const {
diff --git a/engines/nancy/script/v5/textrecord.cpp b/engines/nancy/script/v5/textrecord.cpp
index 9153f920d4b..42e2e519b3d 100644
--- a/engines/nancy/script/v5/textrecord.cpp
+++ b/engines/nancy/script/v5/textrecord.cpp
@@ -115,7 +115,7 @@ void BitmapTextRecord::registerGraphics() {
 
 void BitmapTextRecord::updateGraphics() {
 	_graphic.setClipRect(getScreenClip());
-	_graphic.setVisible(isShown());
+	_graphic.setVisible(isShown(), false);
 
 	if (_isDirty || hasAlphaChanged()) {
 		_isDirty = false;
diff --git a/engines/nancy/script/v5/widgets.cpp b/engines/nancy/script/v5/widgets.cpp
index 21413b3a386..ae197c463ff 100644
--- a/engines/nancy/script/v5/widgets.cpp
+++ b/engines/nancy/script/v5/widgets.cpp
@@ -1019,7 +1019,7 @@ static uint32 toSurfaceColor(const Graphics::ManagedSurface &surface, uint32 arg
 
 void EditBoxRecord::updateGraphics() {
 	_graphic.setClipRect(getScreenClip());
-	_graphic.setVisible(isShown());
+	_graphic.setVisible(isShown(), false);
 
 	const bool isFocused = hasFocus();
 	if (isFocused != _hadFocus) {
diff --git a/engines/nancy/script/xsheet.cpp b/engines/nancy/script/xsheet.cpp
index b7e60685801..0179106697b 100644
--- a/engines/nancy/script/xsheet.cpp
+++ b/engines/nancy/script/xsheet.cpp
@@ -174,7 +174,7 @@ void XSheet::parkFreeRunning() {
 
 void XSheet::setVisible(bool isVisible) {
 	for (Tree *tree : _trees) {
-		tree->graphic.setVisible(isVisible);
+		tree->graphic.setVisible(isVisible, false);
 	}
 }
 


Commit: 3befe1d00a095b4427af5737d6356f006acdd6b2
    https://github.com/scummvm/scummvm/commit/3befe1d00a095b4427af5737d6356f006acdd6b2
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-11T02:34:18+02:00

Commit Message:
NANCY: NANCY19: Redraw Override graphics only when they change

Overrides draw through their Render function on every frame, and the
result was drawn to the screen every time. Now it is only drawn when it
differs from the previous frame. This fixes the slow mouse in the Load,
Options and Extras screens of Nancy26 and Nancy27, which darken the
whole screen this way.

Changed paths:
    engines/nancy/script/records.cpp
    engines/nancy/script/records.h


diff --git a/engines/nancy/script/records.cpp b/engines/nancy/script/records.cpp
index 1f644a575c2..68ef5a57511 100644
--- a/engines/nancy/script/records.cpp
+++ b/engines/nancy/script/records.cpp
@@ -1103,7 +1103,9 @@ void OverrideRecord::onZChanged() {
 
 // An override draws by having its "Render" function called every frame, which
 // draws through the "Draw" object. Here that goes onto a picture as large as
-// the viewport, which is started over every frame.
+// the viewport, which is started over every frame. The picture is only shown
+// again when it changed: the menus darken all the screen behind them, and
+// drawing all of it every frame made them slow.
 void OverrideRecord::updateGraphics() {
 	lua_State *L = getLua();
 
@@ -1113,7 +1115,7 @@ void OverrideRecord::updateGraphics() {
 
 	if (!hasRender || !isShown()) {
 		if (_canvas) {
-			_canvas->setVisible(false);
+			_canvas->setVisible(false, false);
 		}
 
 		return;
@@ -1128,19 +1130,27 @@ void OverrideRecord::updateGraphics() {
 		_canvas = new RecordGraphic();
 		_canvas->init();
 		_canvas->_drawSurface.create(bounds.width(), bounds.height(), g_nancy->_graphics->getTransparentPixelFormat());
+		_canvas->_drawSurface.clear(0);
 		_canvas->moveTo(bounds);
 		_canvas->setScriptZ(getZ(), getContext());
 		_canvas->registerGraphics();
+		_renderSurface.create(bounds.width(), bounds.height(), _canvas->_drawSurface.format);
 	}
 
-	_canvas->_drawSurface.clear(0);
+	_renderSurface.clear(0);
 
-	s_drawTarget = &_canvas->_drawSurface;
+	s_drawTarget = &_renderSurface;
 	callFunction("Render");
 	s_drawTarget = nullptr;
 
-	_canvas->setVisible(true);
-	_canvas->setNeedsRedraw(true);
+	Graphics::ManagedSurface &shown = _canvas->_drawSurface;
+	const uint32 size = shown.pitch * shown.h;
+	if (memcmp(shown.getPixels(), _renderSurface.getPixels(), size) != 0) {
+		memcpy(shown.getPixels(), _renderSurface.getPixels(), size);
+		_canvas->setNeedsRedraw(true);
+	}
+
+	_canvas->setVisible(true, false);
 }
 
 // this:Done()
diff --git a/engines/nancy/script/records.h b/engines/nancy/script/records.h
index d89cf171a9b..62a2050771f 100644
--- a/engines/nancy/script/records.h
+++ b/engines/nancy/script/records.h
@@ -250,7 +250,9 @@ protected:
 	bool setField(const Common::String &key) override;
 
 private:
-	// What the "Render" function draws on, for the records that have one
+	// What the "Render" function draws on, for the records that have one, and
+	// what it shows
+	Graphics::ManagedSurface _renderSurface;
 	RecordGraphic *_canvas = nullptr;
 
 	Common::String _messagingName;	// Nancy22, from SetMessagingName


Commit: 14589e62e262fde73f9762fa61cef86917fb6c07
    https://github.com/scummvm/scummvm/commit/14589e62e262fde73f9762fa61cef86917fb6c07
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-11T02:34:21+02:00

Commit Message:
NANCY: NANCY19: Keep movie records in time with their sound

Movie records now play by the game time instead of the system clock.
When a movie falls behind, it decodes the frames it missed without
showing them, up to two per update. The time before the first update
of a movie doesn't count, as it can be long when a scene has just
loaded. This fixes the first video of the Nancy27 video call running
ahead of its voice, and the Nancy26 logo rushing through its frames.

Changed paths:
    engines/nancy/movieplayer.cpp
    engines/nancy/movieplayer.h
    engines/nancy/script/records.cpp
    engines/nancy/script/records.h


diff --git a/engines/nancy/movieplayer.cpp b/engines/nancy/movieplayer.cpp
index 0527ae41b0c..47edcd79d55 100644
--- a/engines/nancy/movieplayer.cpp
+++ b/engines/nancy/movieplayer.cpp
@@ -315,6 +315,8 @@ void MoviePlayer::playRange(int first, int last) {
 	_rangePlaying = (first != last);
 	_frameMillis = getFrameMillis();
 	_nextFrameTime = g_system->getMillis() + _frameMillis;
+	_playedMillis = 0.0;
+	_nextPlayedFrame = _frameMillis;
 }
 
 bool MoviePlayer::update() {
@@ -339,6 +341,32 @@ bool MoviePlayer::update() {
 		_nextFrameTime = now + _frameMillis;
 	}
 
+	return showNextFrame();
+}
+
+// Every frame is due at its own time from the start. A movie that is late
+// decodes a frame it missed without showing it, so it stays in time with its
+// sound even when the game draws fewer frames than the movie has. It doesn't
+// catch up on more than that at once: when decoding takes longer than the
+// frames last, each update would have more of them to decode than the last.
+bool MoviePlayer::advance(double elapsedMillis) {
+	if (!_rangePlaying || !_decoder) {
+		return false;
+	}
+
+	_playedMillis += elapsedMillis;
+
+	static const int kMaxFramesPerAdvance = 2;
+	int numShown = 0;
+	while (numShown < kMaxFramesPerAdvance && _playedMillis >= _nextPlayedFrame && showNextFrame()) {
+		_nextPlayedFrame += _frameMillis;
+		++numShown;
+	}
+
+	return numShown > 0;
+}
+
+bool MoviePlayer::showNextFrame() {
 	if (_decoder->endOfVideo() ||
 			(_step > 0 && _decoder->getCurFrame() >= _rangeLast) ||
 			(_step < 0 && _decoder->getCurFrame() <= _rangeLast)) {
diff --git a/engines/nancy/movieplayer.h b/engines/nancy/movieplayer.h
index 7c75419f709..0e071eb1a99 100644
--- a/engines/nancy/movieplayer.h
+++ b/engines/nancy/movieplayer.h
@@ -110,6 +110,9 @@ public:
 	void goToFrame(int frameNr);				// show a single still frame
 	void playRange(int first, int last);		// begin timed playback (reverse if last < first)
 	bool update();								// advance; true if the shown frame changed
+	// Advances by the time that went by in the game, which stops while the
+	// movie isn't run. A movie that falls behind skips frames to catch up.
+	bool advance(double elapsedMillis);
 	bool isRangePlaying() const { return _rangePlaying; }
 	int getCurrentFrame() const { return getCurFrame(); }
 	void drawFrame(Graphics::ManagedSurface &dst, const Common::Point &pos) const;
@@ -142,6 +145,7 @@ private:
 	uint _cacheFillNext = 0;
 
 	double getFrameMillis() const;
+	bool showNextFrame();
 
 	// Simple frame-range player state. _currentSurface points at the decoder's
 	// last-decoded frame (owned by it, valid until the next decode).
@@ -150,6 +154,8 @@ private:
 	int _step = 1;
 	bool _rangePlaying = false;
 	double _nextFrameTime = 0.0;	// when the next frame is due, in milliseconds
+	double _playedMillis = 0.0;		// how long advance() has played the range
+	double _nextPlayedFrame = 0.0;	// when advance() shows the next frame
 	double _frameMillis = 1000.0 / 15.0;
 };
 
diff --git a/engines/nancy/script/records.cpp b/engines/nancy/script/records.cpp
index 68ef5a57511..70d17843d15 100644
--- a/engines/nancy/script/records.cpp
+++ b/engines/nancy/script/records.cpp
@@ -2438,6 +2438,7 @@ void MovieRecord::applyPosition() {
 void MovieRecord::runOnce() {
 	_player.playRange(_firstFrame, _lastFrame);
 	drawFrame();
+	_hasJustStarted = true;
 }
 
 // A movie that plays through and ends; one that loops forever never does. One
@@ -2459,6 +2460,11 @@ bool MovieRecord::isSkippable() const {
 }
 
 void MovieRecord::run(double sceneTime, double elapsedTime) {
+	// The frame that starts a movie went by before it, and can be a long one
+	// when the scene just loaded. The movie would skip ahead of its sound.
+	const double playedTime = _hasJustStarted ? 0.0 : elapsedTime;
+	_hasJustStarted = false;
+
 	// A movie that is being skipped moves on by one frame every time it runs, so
 	// the scripts that wait for one of its frames still see it. The frames on the
 	// way aren't decoded, and neither is the last one: a skipped movie ends, which
@@ -2494,7 +2500,7 @@ void MovieRecord::run(double sceneTime, double elapsedTime) {
 
 	_skipFrame = -1;
 
-	if (_player.update()) {
+	if (_player.advance(playedTime * 1000.0)) {
 		drawFrame();
 	}
 
diff --git a/engines/nancy/script/records.h b/engines/nancy/script/records.h
index 62a2050771f..3ee9906dd33 100644
--- a/engines/nancy/script/records.h
+++ b/engines/nancy/script/records.h
@@ -512,6 +512,7 @@ private:
 	bool _hasCalledOnPause = false;
 	bool _isPaused = false;
 	bool _isVisible = true;
+	bool _hasJustStarted = false;
 	double _endTime = 0.0;
 };
 


Commit: b572d6c937ce8bad0b48b2a934b96f0d3d98315c
    https://github.com/scummvm/scummvm/commit/b572d6c937ce8bad0b48b2a934b96f0d3d98315c
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-11T02:34:23+02:00

Commit Message:
NANCY: NANCY26: Fix the second line of two-line subtitles

The first line of a text took its height from the default font, not from
the font set by the tags at its start. Subtitles have room for two lines
of their own font, so their second line was cut off in Nancy26 and
Nancy27.

Changed paths:
    engines/nancy/script/v5/bitmaptext.cpp


diff --git a/engines/nancy/script/v5/bitmaptext.cpp b/engines/nancy/script/v5/bitmaptext.cpp
index 5b46ad9029f..4510ccdeb3d 100644
--- a/engines/nancy/script/v5/bitmaptext.cpp
+++ b/engines/nancy/script/v5/bitmaptext.cpp
@@ -231,8 +231,12 @@ void BitmapText::layout(const Common::String &text, int width, int height, int o
 
 		if (!isEnd && text[pos] == '<' && readStyleTag(text, pos, style, isNewLine)) {
 			if (!isNewLine) {
+				// The tags before the first letter set the line up, its height too,
+				// which was taken from the font before them
 				if (line.letters.empty()) {
 					line.align = style.horizontalAlign;
+					face = getFace(findFont(style.fontID), style.isBold, style.isItalic);
+					line.height = face ? face->height : 0;
 				}
 
 				continue;


Commit: 19963c75ace87c00a5dcc26a98f6ba8b2c492572
    https://github.com/scummvm/scummvm/commit/19963c75ace87c00a5dcc26a98f6ba8b2c492572
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-11T02:34:36+02:00

Commit Message:
NANCY: NANCY26: Keep the fractions of script points

>From Nancy26 on, script points keep the fractions of their coordinates.
For example, the center of a rect can be half a pixel in, and a point
multiplied by a number no longer truncates the number first. Earlier
games still drop the fractions. Graphics are still drawn at whole
pixels.

Changed paths:
    engines/nancy/script/mathtypes.cpp
    engines/nancy/script/types.cpp
    engines/nancy/script/types.h
    engines/nancy/script/v5/messaging.cpp


diff --git a/engines/nancy/script/mathtypes.cpp b/engines/nancy/script/mathtypes.cpp
index 71de6d55ef4..28d76976feb 100644
--- a/engines/nancy/script/mathtypes.cpp
+++ b/engines/nancy/script/mathtypes.cpp
@@ -833,12 +833,12 @@ static ScriptVector readTransformInput(lua_State *L, int index) {
 		return getFlatVector(*vector);
 	}
 
-	ScriptPoint point;
-	if (!readPoint(L, index, point)) {
+	double x, y;
+	if (!readPointCoordinates(L, index, x, y)) {
 		luaL_argerror(L, index, "Expected a Vector, a Point, a table with x and y, or two numbers");
 	}
 
-	return ScriptVector(point.x, point.y, 0.0);
+	return ScriptVector(x, y, 0.0);
 }
 
 static int matrixTransformCoord(lua_State *L) {
diff --git a/engines/nancy/script/types.cpp b/engines/nancy/script/types.cpp
index 8d598019d83..fb52ee93dd5 100644
--- a/engines/nancy/script/types.cpp
+++ b/engines/nancy/script/types.cpp
@@ -19,6 +19,7 @@
  *
  */
 
+#include "engines/nancy/nancy.h"
 #include "engines/nancy/script/luabind.h"
 #include "engines/nancy/script/mathtypes.h"
 #include "engines/nancy/script/types.h"
@@ -33,6 +34,18 @@ static const char *const kPointHelperType = "ND.PointHelper";
 static const char *const kColorType = "ND.Color";
 static const char *const kColorHelperType = "ND.ColorHelper";
 
+// What a script point holds
+struct PointValue {
+	float x = 0.0f;
+	float y = 0.0f;
+
+	PointValue() {}
+	PointValue(double px, double py) : x((float)px), y((float)py) {}
+};
+
+static bool hasFractionalPoints();
+static void pushPointValue(lua_State *L, const PointValue &point);
+
 Common::Rect ScriptRect::toRect() const {
 	if (isEmpty()) {
 		return Common::Rect();
@@ -133,7 +146,12 @@ static int rectIndex(lua_State *L) {
 	} else if (key == "height") {
 		lua_pushinteger(L, rect.height());
 	} else if (key == "center") {
-		pushPoint(L, ScriptPoint(rect.left + rect.width() / 2, rect.top + rect.height() / 2));
+		// From Nancy26 on, the middle of a rect can be half a pixel in
+		if (hasFractionalPoints()) {
+			pushPointValue(L, PointValue(rect.left + rect.width() * 0.5f, rect.top + rect.height() * 0.5f));
+		} else {
+			pushPoint(L, ScriptPoint(rect.left + rect.width() / 2, rect.top + rect.height() / 2));
+		}
 	} else if (key == "centerV") {
 		// Not rounded, unlike "center"
 		ScriptVector center;
@@ -328,15 +346,37 @@ static const luaL_Reg kRectHelperFunctions[] = {
 
 // Point
 
-void pushPoint(lua_State *L, const ScriptPoint &point) {
+// The coordinates of points can have fractions from Nancy26 on. Before that,
+// numbers lose theirs when they become coordinates.
+static bool hasFractionalPoints() {
+	return g_nancy->getGameType() >= kGameTypeNancy26;
+}
+
+static double checkCoordinate(lua_State *L, int index) {
+	return hasFractionalPoints() ? luaL_checknumber(L, index) : luaL_checkint(L, index);
+}
+
+static void pushPointValue(lua_State *L, const PointValue &point) {
 	pushValue(L, kPointType, point);
 }
 
-static ScriptPoint &checkPoint(lua_State *L, int index) {
-	return *(ScriptPoint *)checkUserData(L, index, kPointType);
+void pushPoint(lua_State *L, const ScriptPoint &point) {
+	pushPointValue(L, PointValue(point.x, point.y));
+}
+
+static PointValue &checkPoint(lua_State *L, int index) {
+	return *(PointValue *)checkUserData(L, index, kPointType);
 }
 
 bool readPoint(lua_State *L, int index, ScriptPoint &point) {
+	// A point's own coordinates lose their fractions on the way to the screen
+	const PointValue *value = (const PointValue *)testUserData(L, index, kPointType);
+	if (value) {
+		point.x = (int32)value->x;
+		point.y = (int32)value->y;
+		return true;
+	}
+
 	int type = lua_type(L, index);
 	if (type != LUA_TUSERDATA && type != LUA_TTABLE) {
 		return false;
@@ -356,31 +396,63 @@ bool readPoint(lua_State *L, int index, ScriptPoint &point) {
 	return hasBoth;
 }
 
+bool readPointCoordinates(lua_State *L, int index, double &x, double &y) {
+	const PointValue *value = (const PointValue *)testUserData(L, index, kPointType);
+	if (value) {
+		x = value->x;
+		y = value->y;
+		return true;
+	}
+
+	ScriptPoint point;
+	if (!readPoint(L, index, point)) {
+		return false;
+	}
+
+	x = point.x;
+	y = point.y;
+	return true;
+}
+
+bool copyPoint(lua_State *from, int index, lua_State *to) {
+	const PointValue *value = (const PointValue *)testUserData(from, index, kPointType);
+	if (value) {
+		pushPointValue(to, *value);
+		return true;
+	}
+
+	ScriptPoint point;
+	if (lua_isuserdata(from, index) && readPoint(from, index, point)) {
+		pushPoint(to, point);
+		return true;
+	}
+
+	return false;
+}
+
 // Point:New(x, y), or Point:New(place) in Nancy20
 static int pointNew(lua_State *L) {
-	ScriptPoint point;
+	PointValue point;
 	if (lua_gettop(L) == 2) {
 		double x, y;
 		checkPlaceArguments(L, 2, x, y);
-		point.x = (int32)x;
-		point.y = (int32)y;
+		point = hasFractionalPoints() ? PointValue(x, y) : PointValue((int32)x, (int32)y);
 	} else {
-		point.x = luaL_checkint(L, 2);
-		point.y = luaL_checkint(L, 3);
+		point = PointValue(checkCoordinate(L, 2), checkCoordinate(L, 3));
 	}
 
-	pushPoint(L, point);
+	pushPointValue(L, point);
 	return 1;
 }
 
 static int pointIndex(lua_State *L) {
-	const ScriptPoint &point = checkPoint(L, 1);
+	const PointValue &point = checkPoint(L, 1);
 	Common::String key = luaL_checkstring(L, 2);
 
 	if (key == "x") {
-		lua_pushinteger(L, point.x);
+		lua_pushnumber(L, point.x);
 	} else if (key == "y") {
-		lua_pushinteger(L, point.y);
+		lua_pushnumber(L, point.y);
 	} else {
 		return indexFunctions(L);
 	}
@@ -389,13 +461,13 @@ static int pointIndex(lua_State *L) {
 }
 
 static int pointNewIndex(lua_State *L) {
-	ScriptPoint &point = checkPoint(L, 1);
+	PointValue &point = checkPoint(L, 1);
 	Common::String key = luaL_checkstring(L, 2);
 
 	if (key == "x") {
-		point.x = luaL_checkint(L, 3);
+		point.x = (float)checkCoordinate(L, 3);
 	} else if (key == "y") {
-		point.y = luaL_checkint(L, 3);
+		point.y = (float)checkCoordinate(L, 3);
 	} else {
 		return luaL_error(L, "Object %s does not have field '%s'", kPointType, key.c_str());
 	}
@@ -404,52 +476,62 @@ static int pointNewIndex(lua_State *L) {
 }
 
 static int pointEquals(lua_State *L) {
-	const ScriptPoint &a = checkPoint(L, 1);
-	const ScriptPoint &b = checkPoint(L, 2);
+	const PointValue &a = checkPoint(L, 1);
+	const PointValue &b = checkPoint(L, 2);
 	lua_pushboolean(L, a.x == b.x && a.y == b.y);
 	return 1;
 }
 
 static int pointAdd(lua_State *L) {
-	const ScriptPoint &a = checkPoint(L, 1);
-	const ScriptPoint &b = checkPoint(L, 2);
-	pushPoint(L, ScriptPoint(a.x + b.x, a.y + b.y));
+	const PointValue &a = checkPoint(L, 1);
+	const PointValue &b = checkPoint(L, 2);
+	pushPointValue(L, PointValue(a.x + b.x, a.y + b.y));
 	return 1;
 }
 
 static int pointSubtract(lua_State *L) {
-	const ScriptPoint &a = checkPoint(L, 1);
-	const ScriptPoint &b = checkPoint(L, 2);
-	pushPoint(L, ScriptPoint(a.x - b.x, a.y - b.y));
+	const PointValue &a = checkPoint(L, 1);
+	const PointValue &b = checkPoint(L, 2);
+	pushPointValue(L, PointValue(a.x - b.x, a.y - b.y));
 	return 1;
 }
 
-// Either side can be a number, which multiplies both coordinates
-static ScriptPoint checkPointFactor(lua_State *L, int index) {
+// Either side can be a number, which multiplies both coordinates.
+// Before Nancy26, the number is truncated first.
+static void checkPointFactor(lua_State *L, int index, float &x, float &y) {
 	if (lua_isnumber(L, index)) {
-		const int32 factor = (int32)lua_tonumber(L, index);
-		return ScriptPoint(factor, factor);
+		const double factor = lua_tonumber(L, index);
+		x = y = hasFractionalPoints() ? (float)factor : (float)(int32)factor;
+		return;
 	}
 
-	return checkPoint(L, index);
+	const PointValue &point = checkPoint(L, index);
+	x = point.x;
+	y = point.y;
 }
 
 static int pointMultiply(lua_State *L) {
-	const ScriptPoint a = checkPointFactor(L, 1);
-	const ScriptPoint b = checkPointFactor(L, 2);
-	pushPoint(L, ScriptPoint(a.x * b.x, a.y * b.y));
+	float ax, ay, bx, by;
+	checkPointFactor(L, 1, ax, ay);
+	checkPointFactor(L, 2, bx, by);
+	pushPointValue(L, PointValue(ax * bx, ay * by));
 	return 1;
 }
 
 static int pointNegate(lua_State *L) {
-	const ScriptPoint &point = checkPoint(L, 1);
-	pushPoint(L, ScriptPoint(-point.x, -point.y));
+	const PointValue &point = checkPoint(L, 1);
+	pushPointValue(L, PointValue(-point.x, -point.y));
 	return 1;
 }
 
 static int pointToString(lua_State *L) {
-	const ScriptPoint &point = checkPoint(L, 1);
-	lua_pushstring(L, Common::String::format("P(%d, %d)", point.x, point.y).c_str());
+	const PointValue &point = checkPoint(L, 1);
+	if (hasFractionalPoints()) {
+		lua_pushstring(L, Common::String::format("<%f, %f>", point.x, point.y).c_str());
+	} else {
+		lua_pushstring(L, Common::String::format("P(%d, %d)", (int32)point.x, (int32)point.y).c_str());
+	}
+
 	return 1;
 }
 
@@ -469,7 +551,7 @@ static const luaL_Reg kPointFunctions[] = {
 // Point.origin is a new point every time, since scripts can change points
 static int pointHelperIndex(lua_State *L) {
 	if (lua_type(L, 2) == LUA_TSTRING && strcmp(lua_tostring(L, 2), "origin") == 0) {
-		pushPoint(L, ScriptPoint(0, 0));
+		pushPointValue(L, PointValue(0.0, 0.0));
 		return 1;
 	}
 
diff --git a/engines/nancy/script/types.h b/engines/nancy/script/types.h
index 88fe80db9be..6eeb4a7e403 100644
--- a/engines/nancy/script/types.h
+++ b/engines/nancy/script/types.h
@@ -84,6 +84,13 @@ void pushPoint(lua_State *L, const ScriptPoint &point);
 // Returns false when the value has neither.
 bool readPoint(lua_State *L, int index, ScriptPoint &point);
 
+// The same, keeping the fractions a point can have from Nancy26 on
+bool readPointCoordinates(lua_State *L, int index, double &x, double &y);
+
+// Pushes a copy of a point, or of something else with an x and a y, onto
+// another Lua state. Returns false when the value has neither.
+bool copyPoint(lua_State *from, int index, lua_State *to);
+
 // Colors are 0xAARRGGBB
 void pushColor(lua_State *L, uint32 argb);
 uint32 *testColor(lua_State *L, int index);
diff --git a/engines/nancy/script/v5/messaging.cpp b/engines/nancy/script/v5/messaging.cpp
index a2630d98476..eb93f6a1b46 100644
--- a/engines/nancy/script/v5/messaging.cpp
+++ b/engines/nancy/script/v5/messaging.cpp
@@ -145,9 +145,7 @@ void copyValue(lua_State *from, int index, lua_State *to) {
 		return;
 	}
 
-	ScriptPoint point;
-	if (lua_isuserdata(from, index) && readPoint(from, index, point)) {
-		pushPoint(to, point);
+	if (copyPoint(from, index, to)) {
 		return;
 	}
 


Commit: 45fdcb3ad4c62ff42734a5695673fc5da124535f
    https://github.com/scummvm/scummvm/commit/45fdcb3ad4c62ff42734a5695673fc5da124535f
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-11T02:34:41+02:00

Commit Message:
NANCY: NANCY19: Replace ScriptPoint with Common::Point32

Changed paths:
    engines/nancy/script/bootapi.cpp
    engines/nancy/script/gameapi.cpp
    engines/nancy/script/record.cpp
    engines/nancy/script/record.h
    engines/nancy/script/records.cpp
    engines/nancy/script/records.h
    engines/nancy/script/ref.cpp
    engines/nancy/script/scenecontext.cpp
    engines/nancy/script/scenecontext.h
    engines/nancy/script/types.cpp
    engines/nancy/script/types.h
    engines/nancy/script/uiapi.cpp
    engines/nancy/script/v5/bootobjects.cpp
    engines/nancy/script/v5/scriptinput.cpp
    engines/nancy/script/v5/scriptinput.h
    engines/nancy/script/v5/widgets.cpp
    engines/nancy/script/v5/widgets.h


diff --git a/engines/nancy/script/bootapi.cpp b/engines/nancy/script/bootapi.cpp
index e7df9d871a0..a24dcdeb75d 100644
--- a/engines/nancy/script/bootapi.cpp
+++ b/engines/nancy/script/bootapi.cpp
@@ -416,13 +416,13 @@ static void readCursor(lua_State *L, int cursorTable, ScriptBootData::Cursor &cu
 			hasAll = false;
 		}
 
-		ScriptPoint hotspot;
+		Common::Point32 hotspot;
 		if (pushField(L, cursorTable, kHotspotNames[i])) {
 			if (!readPoint(L, -1, hotspot)) {
 				hasAll = false;
 			}
 
-			cursor.hotspots[i] = hotspot.toPoint();
+			cursor.hotspots[i] = Common::Point(hotspot.x, hotspot.y);
 			lua_pop(L, 1);
 		} else {
 			hasAll = false;
diff --git a/engines/nancy/script/gameapi.cpp b/engines/nancy/script/gameapi.cpp
index 229eea2abb2..35c9ec7dbd2 100644
--- a/engines/nancy/script/gameapi.cpp
+++ b/engines/nancy/script/gameapi.cpp
@@ -269,9 +269,9 @@ static int cursorIndex(lua_State *L) {
 
 	if (key == "activePoint") {
 		// Where the mouse is in the viewport, while it is in there
-		ScriptPoint point;
+		Common::Point32 point;
 		if (!SceneContext::getViewportMouse(g_nancy->_input->getInput(), point)) {
-			point = ScriptPoint(-1, -1);
+			point = Common::Point32(-1, -1);
 		}
 
 		pushPoint(L, point);
@@ -280,12 +280,12 @@ static int cursorIndex(lua_State *L) {
 
 	if (key == "activeUIPoint") {
 		// Where the mouse is on the screen
-		pushPoint(L, ScriptPoint(g_nancy->_input->getInput().mousePos));
+		pushPoint(L, Common::Point32(g_nancy->_input->getInput().mousePos));
 		return 1;
 	}
 
 	if (key == "inViewport") {
-		ScriptPoint point;
+		Common::Point32 point;
 		lua_pushboolean(L, SceneContext::getViewportMouse(g_nancy->_input->getInput(), point));
 		return 1;
 	}
@@ -335,7 +335,7 @@ static int cursorNewIndex(lua_State *L) {
 
 // Cursor:MoveTo(point), Nancy21: puts the mouse at a place in the viewport
 static int cursorMoveTo(lua_State *L) {
-	ScriptPoint point;
+	Common::Point32 point;
 	if (!readPoint(L, 2, point)) {
 		return luaL_argerror(L, 2, "expected a point");
 	}
diff --git a/engines/nancy/script/record.cpp b/engines/nancy/script/record.cpp
index 70156dafa78..19b918ab0e0 100644
--- a/engines/nancy/script/record.cpp
+++ b/engines/nancy/script/record.cpp
@@ -529,7 +529,7 @@ int Record::setScriptField() {
 	return 0;
 }
 
-void Record::sendMouseMove(const ScriptPoint &point, bool inViewport) {
+void Record::sendMouseMove(const Common::Point32 &point, bool inViewport) {
 	if (!isActive()) {
 		return;
 	}
@@ -546,7 +546,7 @@ void Record::sendMouseMove(const ScriptPoint &point, bool inViewport) {
 	}
 }
 
-bool Record::sendChangeCursor(const ScriptPoint &point, bool inViewport, uint &cursorType, bool &isHot) {
+bool Record::sendChangeCursor(const Common::Point32 &point, bool inViewport, uint &cursorType, bool &isHot) {
 	if (!isActive()) {
 		return false;
 	}
@@ -570,7 +570,7 @@ bool Record::sendChangeCursor(const ScriptPoint &point, bool inViewport, uint &c
 	return hasCursor;
 }
 
-bool Record::sendMouseEvent(RecordEvent event, const ScriptPoint &point, bool inViewport) {
+bool Record::sendMouseEvent(RecordEvent event, const Common::Point32 &point, bool inViewport) {
 	if (!isActive()) {
 		return false;
 	}
@@ -594,7 +594,7 @@ bool Record::sendMouseEvent(RecordEvent event, const ScriptPoint &point, bool in
 }
 
 // Only the records made of script functions handle mouse wheel events
-void Record::sendMouseScroll(const ScriptPoint &point, bool inViewport, int notches) {
+void Record::sendMouseScroll(const Common::Point32 &point, bool inViewport, int notches) {
 	if (!isActive() || !isScripted()) {
 		return;
 	}
@@ -800,7 +800,7 @@ static int recordRun(lua_State *L) {
 static int recordOnMouseMove(lua_State *L) {
 	Record *record = checkRecord(L, 1);
 
-	ScriptPoint point;
+	Common::Point32 point;
 	if (!readPoint(L, 2, point)) {
 		return luaL_argerror(L, 2, "Single parameter must be a Point or a table with x and y fields");
 	}
@@ -813,7 +813,7 @@ static int recordOnMouseMove(lua_State *L) {
 static int recordChangeCursor(lua_State *L) {
 	Record *record = checkRecord(L, 1);
 
-	ScriptPoint point;
+	Common::Point32 point;
 	if (!readPoint(L, 2, point)) {
 		return luaL_argerror(L, 2, "Single parameter must be a Point or a table with x and y fields");
 	}
@@ -833,7 +833,7 @@ static int recordOnMouseEvent(lua_State *L) {
 	const RecordEvent event = (RecordEvent)lua_tointeger(L, lua_upvalueindex(1));
 	Record *record = checkRecord(L, 1);
 
-	ScriptPoint point;
+	Common::Point32 point;
 	if (!readPoint(L, 2, point)) {
 		return luaL_argerror(L, 2, "Single parameter must be a Point or a table with x and y fields");
 	}
diff --git a/engines/nancy/script/record.h b/engines/nancy/script/record.h
index dcd93396f1e..a7919c9d92d 100644
--- a/engines/nancy/script/record.h
+++ b/engines/nancy/script/record.h
@@ -187,11 +187,11 @@ public:
 	// the function a script gave the record for it, or to what the kind of
 	// record does by itself. Positions are in the coordinates of the viewport.
 	// A click, a key and the cursor are up to the first record that takes them.
-	void sendMouseMove(const ScriptPoint &point, bool inViewport);
-	bool sendChangeCursor(const ScriptPoint &point, bool inViewport, uint &cursorType, bool &isHot);
-	bool sendMouseEvent(RecordEvent event, const ScriptPoint &point, bool inViewport);
+	void sendMouseMove(const Common::Point32 &point, bool inViewport);
+	bool sendChangeCursor(const Common::Point32 &point, bool inViewport, uint &cursorType, bool &isHot);
+	bool sendMouseEvent(RecordEvent event, const Common::Point32 &point, bool inViewport);
 	bool sendKeyEvent(RecordEvent event, Common::KeyCode key);
-	void sendMouseScroll(const ScriptPoint &point, bool inViewport, int notches);
+	void sendMouseScroll(const Common::Point32 &point, bool inViewport, int notches);
 
 	// Where the record puts what it shows, for the kinds that show something,
 	// after the nodes it is under moved it
@@ -257,7 +257,7 @@ public:
 	// point is in the coordinates of the screen. A button is 0 for the left one
 	// and 1 for the right one.
 	virtual bool isMouseRegion() const { return false; }
-	virtual bool hitTest(const ScriptPoint &point) const { return false; }
+	virtual bool hitTest(const Common::Point32 &point) const { return false; }
 	virtual void setMouseOver(bool isOver) {}
 	virtual bool pressRegion(int button) { return false; }	// returns whether it took the click
 	virtual void releaseRegion(int button) {}
@@ -265,7 +265,7 @@ public:
 
 	// Nancy26: the mouse wheel turned while the mouse was at the point, in the
 	// coordinates of the screen. Returns whether the record took it.
-	virtual bool scrollRegion(const ScriptPoint &point, int notches) { return false; }
+	virtual bool scrollRegion(const Common::Point32 &point, int notches) { return false; }
 
 	// Nancy26: whether the keys go no further than this record
 	virtual bool capturesKeys() const { return false; }
@@ -343,9 +343,9 @@ protected:
 	// by itself: Run, Render, and everything the player does
 	virtual bool isScripted() const { return false; }
 
-	virtual void onMouseMove(const ScriptPoint &point, bool inViewport) {}
-	virtual bool getCursor(const ScriptPoint &point, bool inViewport, uint &cursorType, bool &isHot) { return false; }
-	virtual bool onMouseEvent(RecordEvent event, const ScriptPoint &point, bool inViewport) { return false; }
+	virtual void onMouseMove(const Common::Point32 &point, bool inViewport) {}
+	virtual bool getCursor(const Common::Point32 &point, bool inViewport, uint &cursorType, bool &isHot) { return false; }
+	virtual bool onMouseEvent(RecordEvent event, const Common::Point32 &point, bool inViewport) { return false; }
 
 	// Whether the kind of record has a "transform", and what to do when it changes
 	virtual bool hasTransform() const { return false; }
diff --git a/engines/nancy/script/records.cpp b/engines/nancy/script/records.cpp
index 70d17843d15..45c8c08e154 100644
--- a/engines/nancy/script/records.cpp
+++ b/engines/nancy/script/records.cpp
@@ -561,7 +561,7 @@ void SummaryRecord::setFrame(uint frame) {
 	}
 }
 
-SummaryRecord::Turn SummaryRecord::getTurnAt(const ScriptPoint &point, bool inViewport) const {
+SummaryRecord::Turn SummaryRecord::getTurnAt(const Common::Point32 &point, bool inViewport) const {
 	// Only a background with several frames can be turned around in
 	if (_numFrames <= 1 || !inViewport) {
 		return kNoTurn;
@@ -570,7 +570,7 @@ SummaryRecord::Turn SummaryRecord::getTurnAt(const ScriptPoint &point, bool inVi
 	const ScriptBootData *boot = GetEngineData(ScriptBootData);
 	assert(boot);
 
-	const Common::Point place = point.toPoint();
+	const Common::Point place(point.x, point.y);
 	if (_canRotate && boot->leftNodeHotspot.contains(place)) {
 		return canTurn(kTurnLeft) ? kTurnLeft : kNoTurn;
 	} else if (_canRotate && boot->rightNodeHotspot.contains(place)) {
@@ -592,7 +592,7 @@ bool SummaryRecord::canTurn(Turn turn) const {
 	return turn == kTurnLeft ? _frame + 1 < _numFrames : _frame > 0;
 }
 
-void SummaryRecord::onMouseMove(const ScriptPoint &point, bool inViewport) {
+void SummaryRecord::onMouseMove(const Common::Point32 &point, bool inViewport) {
 	// The view turns by itself while the mouse stays on a side, after a first wait
 	Turn turn = getTurnAt(point, inViewport);
 	if (turn == kTurnAround) {
@@ -606,7 +606,7 @@ void SummaryRecord::onMouseMove(const ScriptPoint &point, bool inViewport) {
 	_turn = turn;
 }
 
-bool SummaryRecord::getCursor(const ScriptPoint &point, bool inViewport, uint &cursorType, bool &isHot) {
+bool SummaryRecord::getCursor(const Common::Point32 &point, bool inViewport, uint &cursorType, bool &isHot) {
 	const ScriptBootData *boot = GetEngineData(ScriptBootData);
 	assert(boot);
 
@@ -634,7 +634,7 @@ bool SummaryRecord::getCursor(const ScriptPoint &point, bool inViewport, uint &c
 	return true;
 }
 
-bool SummaryRecord::onMouseEvent(RecordEvent event, const ScriptPoint &point, bool inViewport) {
+bool SummaryRecord::onMouseEvent(RecordEvent event, const Common::Point32 &point, bool inViewport) {
 	switch (event) {
 	case kEventRightDown:
 		_isTurningFast = true;
@@ -852,7 +852,7 @@ void NavLogicRecord::run(double sceneTime, double elapsedTime) {
 
 // The mouse is taken back to where the hotspot was before the transform, so a
 // turned hotspot is turned with its picture
-bool NavLogicRecord::isOver(const ScriptPoint &point) const {
+bool NavLogicRecord::isOver(const Common::Point32 &point) const {
 	double x = point.x;
 	double y = point.y;
 	getTransform().inverse().transformPoint(x, y);
@@ -882,7 +882,7 @@ bool NavLogicRecord::isOver(const ScriptPoint &point) const {
 
 // A hotspot that is held down tells its scripts when the mouse leaves it and
 // comes back, with OnUp and OnDown
-void NavLogicRecord::onMouseMove(const ScriptPoint &point, bool inViewport) {
+void NavLogicRecord::onMouseMove(const Common::Point32 &point, bool inViewport) {
 	const bool wasMouseOver = _isMouseOver;
 	_isMouseOver = inViewport && isOver(point);
 
@@ -893,7 +893,7 @@ void NavLogicRecord::onMouseMove(const ScriptPoint &point, bool inViewport) {
 	}
 }
 
-bool NavLogicRecord::getCursor(const ScriptPoint &point, bool inViewport, uint &cursorType, bool &isHot) {
+bool NavLogicRecord::getCursor(const Common::Point32 &point, bool inViewport, uint &cursorType, bool &isHot) {
 	if (!_hasCursor || !isOver(point)) {
 		return false;
 	}
@@ -903,7 +903,7 @@ bool NavLogicRecord::getCursor(const ScriptPoint &point, bool inViewport, uint &
 	return true;
 }
 
-bool NavLogicRecord::onMouseEvent(RecordEvent event, const ScriptPoint &point, bool inViewport) {
+bool NavLogicRecord::onMouseEvent(RecordEvent event, const Common::Point32 &point, bool inViewport) {
 	if (_isPressedAndReleased) {
 		const RecordEvent downEvent = _isRightClick ? kEventRightDown : kEventLeftDown;
 		const RecordEvent upEvent = _isRightClick ? kEventRightUp : kEventLeftUp;
diff --git a/engines/nancy/script/records.h b/engines/nancy/script/records.h
index 3ee9906dd33..2ef66e2755b 100644
--- a/engines/nancy/script/records.h
+++ b/engines/nancy/script/records.h
@@ -120,15 +120,15 @@ protected:
 	bool getField(const Common::String &key) override;
 	bool setField(const Common::String &key) override;
 
-	void onMouseMove(const ScriptPoint &point, bool inViewport) override;
-	bool getCursor(const ScriptPoint &point, bool inViewport, uint &cursorType, bool &isHot) override;
-	bool onMouseEvent(RecordEvent event, const ScriptPoint &point, bool inViewport) override;
+	void onMouseMove(const Common::Point32 &point, bool inViewport) override;
+	bool getCursor(const Common::Point32 &point, bool inViewport, uint &cursorType, bool &isHot) override;
+	bool onMouseEvent(RecordEvent event, const Common::Point32 &point, bool inViewport) override;
 
 private:
 	enum Turn { kNoTurn, kTurnLeft, kTurnRight, kTurnAround };
 
 	// The side of the node the mouse is on
-	Turn getTurnAt(const ScriptPoint &point, bool inViewport) const;
+	Turn getTurnAt(const Common::Point32 &point, bool inViewport) const;
 	bool canTurn(Turn turn) const;
 	void setFrame(uint frame);
 	void playTheme();
@@ -179,9 +179,9 @@ protected:
 	bool getField(const Common::String &key) override;
 	bool setField(const Common::String &key) override;
 
-	void onMouseMove(const ScriptPoint &point, bool inViewport) override;
-	bool getCursor(const ScriptPoint &point, bool inViewport, uint &cursorType, bool &isHot) override;
-	bool onMouseEvent(RecordEvent event, const ScriptPoint &point, bool inViewport) override;
+	void onMouseMove(const Common::Point32 &point, bool inViewport) override;
+	bool getCursor(const Common::Point32 &point, bool inViewport, uint &cursorType, bool &isHot) override;
+	bool onMouseEvent(RecordEvent event, const Common::Point32 &point, bool inViewport) override;
 
 private:
 	struct Flag {
@@ -192,7 +192,7 @@ private:
 	void readScene(int valueIndex);
 	void readCursor(int valueIndex);
 	void readRef(int valueIndex);
-	bool isOver(const ScriptPoint &point) const;
+	bool isOver(const Common::Point32 &point) const;
 	void trigger();
 
 	Common::String _sceneName;
diff --git a/engines/nancy/script/ref.cpp b/engines/nancy/script/ref.cpp
index 72990493f93..055517c7d52 100644
--- a/engines/nancy/script/ref.cpp
+++ b/engines/nancy/script/ref.cpp
@@ -134,8 +134,8 @@ static bool addRefLayer(ScriptRef &ref, const Common::String &imageName, const C
 	return true;
 }
 
-static ScriptPoint checkPlace(lua_State *L, int index) {
-	ScriptPoint point;
+static Common::Point32 checkPlace(lua_State *L, int index) {
+	Common::Point32 point;
 	if (!readPoint(L, index, point)) {
 		luaL_argerror(L, index, "Single parameter must be a Point, a Vector or a table with x and y fields");
 	}
@@ -239,7 +239,7 @@ static int refRemove(lua_State *L) {
 // ref:At(place), Nancy20, the color there
 static int refAt(lua_State *L) {
 	const ScriptRef *ref = checkRef(L, 1);
-	const ScriptPoint place = checkPlace(L, 2);
+	const Common::Point32 place = checkPlace(L, 2);
 
 	uint32 pixel = 0;
 	ref->getPixel(place.x, place.y, pixel);
@@ -250,7 +250,7 @@ static int refAt(lua_State *L) {
 // ref:IsAt(place, color)
 static int refIsAt(lua_State *L) {
 	const ScriptRef *ref = checkRef(L, 1);
-	const ScriptPoint place = checkPlace(L, 2);
+	const Common::Point32 place = checkPlace(L, 2);
 	const uint32 color = checkColor(L, 3);
 
 	uint32 pixel;
@@ -261,7 +261,7 @@ static int refIsAt(lua_State *L) {
 // ref:IsOpaqueAt(place)
 static int refIsOpaqueAt(lua_State *L) {
 	const ScriptRef *ref = checkRef(L, 1);
-	const ScriptPoint place = checkPlace(L, 2);
+	const Common::Point32 place = checkPlace(L, 2);
 
 	uint32 pixel;
 	lua_pushboolean(L, ref->getPixel(place.x, place.y, pixel) && (pixel >> 24) != 0);
@@ -270,7 +270,7 @@ static int refIsOpaqueAt(lua_State *L) {
 
 // How much of the square of the given size around a place passes a test, from 0 to 1.
 // The places that have no pixel count as failing it.
-static double getAreaShare(const ScriptRef *ref, const ScriptPoint &place, int size, bool testColor, uint32 color) {
+static double getAreaShare(const ScriptRef *ref, const Common::Point32 &place, int size, bool testColor, uint32 color) {
 	if (size <= 0) {
 		return 0.0;
 	}
@@ -298,7 +298,7 @@ static double getAreaShare(const ScriptRef *ref, const ScriptPoint &place, int s
 // ref:IsInArea(place, color, size)
 static int refIsInArea(lua_State *L) {
 	const ScriptRef *ref = checkRef(L, 1);
-	const ScriptPoint place = checkPlace(L, 2);
+	const Common::Point32 place = checkPlace(L, 2);
 	const uint32 color = checkColor(L, 3);
 	const int size = luaL_checkint(L, 4);
 
@@ -309,7 +309,7 @@ static int refIsInArea(lua_State *L) {
 // ref:IsOpaqueInArea(place, size)
 static int refIsOpaqueInArea(lua_State *L) {
 	const ScriptRef *ref = checkRef(L, 1);
-	const ScriptPoint place = checkPlace(L, 2);
+	const Common::Point32 place = checkPlace(L, 2);
 	const int size = luaL_checkint(L, 3);
 
 	lua_pushnumber(L, getAreaShare(ref, place, size, false, 0));
diff --git a/engines/nancy/script/scenecontext.cpp b/engines/nancy/script/scenecontext.cpp
index ff253ceb374..6f5aceb757a 100644
--- a/engines/nancy/script/scenecontext.cpp
+++ b/engines/nancy/script/scenecontext.cpp
@@ -476,7 +476,7 @@ void SceneContext::renderAttachment() {
 	const VIEW *viewport = GetEngineData(VIEW);
 	assert(viewport);
 
-	ScriptPoint mouse;
+	Common::Point32 mouse;
 	getViewportMouse(g_nancy->_input->getInput(), mouse);
 
 	ScriptMatrix transform;
@@ -608,7 +608,7 @@ void SceneContext::applyGraphNodeChanges() {
 	}
 }
 
-bool SceneContext::getViewportMouse(const NancyInput &input, ScriptPoint &point) {
+bool SceneContext::getViewportMouse(const NancyInput &input, Common::Point32 &point) {
 	const UI::Viewport &viewport = NancySceneState.getViewport();
 	const Common::Rect screenPosition = viewport.getScreenPosition();
 
@@ -624,7 +624,7 @@ bool SceneContext::getViewportMouse(const NancyInput &input, ScriptPoint &point)
 // which leaves the turning around in the background for when nothing else
 // takes a click.
 // Only clicks and keys can be taken; the rest goes to every record.
-void SceneContext::sendMouseEvent(int event, const ScriptPoint &point, bool inViewport) {
+void SceneContext::sendMouseEvent(int event, const Common::Point32 &point, bool inViewport) {
 	const bool canBeTaken = event == kEventLeftClick || event == kEventRightClick;
 
 	for (Record *record : _inputOrder) {
@@ -656,7 +656,7 @@ static const MoveKey kMoveKeys[] = {
 };
 
 void SceneContext::handleInput(NancyInput &input) {
-	ScriptPoint point;
+	Common::Point32 point;
 	const bool inViewport = getViewportMouse(input, point);
 
 	for (Record *record : _inputOrder) {
diff --git a/engines/nancy/script/scenecontext.h b/engines/nancy/script/scenecontext.h
index 16d35cd1d90..3a11c2b5877 100644
--- a/engines/nancy/script/scenecontext.h
+++ b/engines/nancy/script/scenecontext.h
@@ -185,7 +185,7 @@ public:
 	bool describeManager(const Common::String &name, Common::String &text);
 
 	// Where the mouse is in the viewport. Returns whether it is inside of it.
-	static bool getViewportMouse(const NancyInput &input, ScriptPoint &point);
+	static bool getViewportMouse(const NancyInput &input, Common::Point32 &point);
 
 private:
 	bool callSceneFunction(const char *name, int numArgs);
@@ -198,7 +198,7 @@ private:
 	void renderAttachment();
 	bool hasSkippableRecord() const;
 	void pushSceneFunctions();
-	void sendMouseEvent(int event, const ScriptPoint &point, bool inViewport);
+	void sendMouseEvent(int event, const Common::Point32 &point, bool inViewport);
 	void sendKeyEvent(int event, Common::KeyCode key);
 
 	Common::String _streamName;
diff --git a/engines/nancy/script/types.cpp b/engines/nancy/script/types.cpp
index fb52ee93dd5..d9f2405c619 100644
--- a/engines/nancy/script/types.cpp
+++ b/engines/nancy/script/types.cpp
@@ -70,8 +70,8 @@ ScriptRect &checkRect(lua_State *L, int index) {
 }
 
 // The functions that take a place accept either a point or two numbers
-static ScriptPoint checkPointArguments(lua_State *L, int index) {
-	ScriptPoint point;
+static Common::Point32 checkPointArguments(lua_State *L, int index) {
+	Common::Point32 point;
 
 	if (lua_gettop(L) == index) {
 		if (!readPoint(L, index, point)) {
@@ -150,7 +150,7 @@ static int rectIndex(lua_State *L) {
 		if (hasFractionalPoints()) {
 			pushPointValue(L, PointValue(rect.left + rect.width() * 0.5f, rect.top + rect.height() * 0.5f));
 		} else {
-			pushPoint(L, ScriptPoint(rect.left + rect.width() / 2, rect.top + rect.height() / 2));
+			pushPoint(L, Common::Point32(rect.left + rect.width() / 2, rect.top + rect.height() / 2));
 		}
 	} else if (key == "centerV") {
 		// Not rounded, unlike "center"
@@ -161,15 +161,15 @@ static int rectIndex(lua_State *L) {
 		pushVector(L, center);
 	} else if (key == "size") {
 		// Nancy22: the width and the height as a point
-		pushPoint(L, ScriptPoint(rect.width(), rect.height()));
+		pushPoint(L, Common::Point32(rect.width(), rect.height()));
 	} else if (key == "leftTop") {
-		pushPoint(L, ScriptPoint(rect.left, rect.top));
+		pushPoint(L, Common::Point32(rect.left, rect.top));
 	} else if (key == "rightTop") {
-		pushPoint(L, ScriptPoint(rect.right, rect.top));
+		pushPoint(L, Common::Point32(rect.right, rect.top));
 	} else if (key == "leftBottom") {
-		pushPoint(L, ScriptPoint(rect.left, rect.bottom));
+		pushPoint(L, Common::Point32(rect.left, rect.bottom));
 	} else if (key == "rightBottom") {
-		pushPoint(L, ScriptPoint(rect.right, rect.bottom));
+		pushPoint(L, Common::Point32(rect.right, rect.bottom));
 	} else {
 		return indexFunctions(L);
 	}
@@ -208,7 +208,7 @@ static int rectEquals(lua_State *L) {
 static int rectContains(lua_State *L) {
 	const ScriptRect &rect = checkRect(L, 1);
 
-	ScriptPoint point;
+	Common::Point32 point;
 	if (!readPoint(L, 2, point)) {
 		return luaL_error(L, "Single parameter must be a Point, a Vector or a table with x and y fields");
 	}
@@ -219,7 +219,7 @@ static int rectContains(lua_State *L) {
 
 static int rectOffset(lua_State *L) {
 	ScriptRect rect = checkRect(L, 1);
-	ScriptPoint offset = checkPointArguments(L, 2);
+	Common::Point32 offset = checkPointArguments(L, 2);
 	rect.translate(offset.x, offset.y);
 	pushRect(L, rect);
 	return 1;
@@ -242,7 +242,7 @@ static int rectIntersect(lua_State *L) {
 
 static int rectCenteredOn(lua_State *L) {
 	ScriptRect rect = checkRect(L, 1);
-	ScriptPoint center = checkPointArguments(L, 2);
+	Common::Point32 center = checkPointArguments(L, 2);
 	rect.translate(center.x - (rect.left + rect.width() / 2), center.y - (rect.top + rect.height() / 2));
 	pushRect(L, rect);
 	return 1;
@@ -360,7 +360,7 @@ static void pushPointValue(lua_State *L, const PointValue &point) {
 	pushValue(L, kPointType, point);
 }
 
-void pushPoint(lua_State *L, const ScriptPoint &point) {
+void pushPoint(lua_State *L, const Common::Point32 &point) {
 	pushPointValue(L, PointValue(point.x, point.y));
 }
 
@@ -368,7 +368,7 @@ static PointValue &checkPoint(lua_State *L, int index) {
 	return *(PointValue *)checkUserData(L, index, kPointType);
 }
 
-bool readPoint(lua_State *L, int index, ScriptPoint &point) {
+bool readPoint(lua_State *L, int index, Common::Point32 &point) {
 	// A point's own coordinates lose their fractions on the way to the screen
 	const PointValue *value = (const PointValue *)testUserData(L, index, kPointType);
 	if (value) {
@@ -404,7 +404,7 @@ bool readPointCoordinates(lua_State *L, int index, double &x, double &y) {
 		return true;
 	}
 
-	ScriptPoint point;
+	Common::Point32 point;
 	if (!readPoint(L, index, point)) {
 		return false;
 	}
@@ -421,7 +421,7 @@ bool copyPoint(lua_State *from, int index, lua_State *to) {
 		return true;
 	}
 
-	ScriptPoint point;
+	Common::Point32 point;
 	if (lua_isuserdata(from, index) && readPoint(from, index, point)) {
 		pushPoint(to, point);
 		return true;
@@ -684,7 +684,7 @@ void registerTypes(lua_State *L) {
 	registerGlobal(L, "Point", kPointHelperType, kPointHelperFunctions);
 
 	luaL_getmetatable(L, kPointHelperType);
-	pushPoint(L, ScriptPoint());
+	pushPoint(L, Common::Point32());
 	lua_setfield(L, -2, "origin");
 	lua_pop(L, 1);
 
diff --git a/engines/nancy/script/types.h b/engines/nancy/script/types.h
index 6eeb4a7e403..855797e92f4 100644
--- a/engines/nancy/script/types.h
+++ b/engines/nancy/script/types.h
@@ -61,28 +61,17 @@ struct ScriptRect {
 	Common::Rect toRect() const;
 };
 
-struct ScriptPoint {
-	int32 x = 0;
-	int32 y = 0;
-
-	ScriptPoint() {}
-	ScriptPoint(int32 px, int32 py) : x(px), y(py) {}
-	ScriptPoint(const Common::Point &point) : x(point.x), y(point.y) {}
-
-	Common::Point toPoint() const { return Common::Point(x, y); }
-};
-
 void registerTypes(lua_State *L);
 
 void pushRect(lua_State *L, const ScriptRect &rect);
 ScriptRect *testRect(lua_State *L, int index);		// null when it is something else
 ScriptRect &checkRect(lua_State *L, int index);
 
-void pushPoint(lua_State *L, const ScriptPoint &point);
+void pushPoint(lua_State *L, const Common::Point32 &point);
 
 // Reads anything that has an x and a y: a point, a vector or a table.
 // Returns false when the value has neither.
-bool readPoint(lua_State *L, int index, ScriptPoint &point);
+bool readPoint(lua_State *L, int index, Common::Point32 &point);
 
 // The same, keeping the fractions a point can have from Nancy26 on
 bool readPointCoordinates(lua_State *L, int index, double &x, double &y);
diff --git a/engines/nancy/script/uiapi.cpp b/engines/nancy/script/uiapi.cpp
index 80f7866f4e3..0010a46b093 100644
--- a/engines/nancy/script/uiapi.cpp
+++ b/engines/nancy/script/uiapi.cpp
@@ -215,7 +215,7 @@ static void readRectField(lua_State *L, int tableIndex, const char *name, Script
 	}
 }
 
-static void readPointField(lua_State *L, int tableIndex, const char *name, ScriptPoint &point) {
+static void readPointField(lua_State *L, int tableIndex, const char *name, Common::Point32 &point) {
 	if (pushField(L, tableIndex, name)) {
 		if (!readPoint(L, -1, point)) {
 			luaL_error(L, "field %s must be a point", name);
@@ -504,7 +504,7 @@ static int panelAddButton(lua_State *L) {
 	writeControl(L, 2, kAlignCenter, data);
 	writeOverlay(L, 2, "foregroundOverlay", data);
 
-	ScriptPoint pressedOffset;
+	Common::Point32 pressedOffset;
 	readPointField(L, 2, "pressedOffset", pressedOffset);
 	data.writeSint32LE(pressedOffset.x);
 	data.writeSint32LE(pressedOffset.y);
@@ -661,7 +661,7 @@ static int newPanel(lua_State *L, byte kind) {
 	int32 initialState = UI::NDUI::kStartVisible;
 	int32 primaryOrder = 0;
 	int32 secondaryOrder = 0;
-	ScriptPoint spacing;
+	Common::Point32 spacing;
 	ScriptRect margins;
 	uint32 color = 0;
 
diff --git a/engines/nancy/script/v5/bootobjects.cpp b/engines/nancy/script/v5/bootobjects.cpp
index 02ac09e38da..50d2f38a68d 100644
--- a/engines/nancy/script/v5/bootobjects.cpp
+++ b/engines/nancy/script/v5/bootobjects.cpp
@@ -68,13 +68,13 @@ static void readNancy26Cursor(lua_State *L, int cursorTable, ScriptBootData::Cur
 	cursor.sources[0] = cursor.sources[1] = checkRect(L, -1).toRect();
 	lua_pop(L, 1);
 
-	ScriptPoint hotspot;
+	Common::Point32 hotspot;
 	if (pushField(L, cursorTable, "activePt")) {
 		readPoint(L, -1, hotspot);
 		lua_pop(L, 1);
 	}
 
-	cursor.hotspots[0] = cursor.hotspots[1] = hotspot.toPoint();
+	cursor.hotspots[0] = cursor.hotspots[1] = Common::Point(hotspot.x, hotspot.y);
 }
 
 int createNancy26Cursors(lua_State *L, ScriptBootData &boot) {
@@ -83,13 +83,13 @@ int createNancy26Cursors(lua_State *L, ScriptBootData &boot) {
 	readField(L, 2, "leftNode", boot.leftNodeCursorName);
 	readField(L, 2, "uturnNode", boot.uturnNodeCursorName);
 
-	ScriptPoint offset;
+	Common::Point32 offset;
 	if (pushField(L, 2, "invOffset")) {
 		readPoint(L, -1, offset);
 		lua_pop(L, 1);
 	}
 
-	boot.itemCursorOffset = offset.toPoint();
+	boot.itemCursorOffset = Common::Point(offset.x, offset.y);
 
 	Common::Array<Common::String> names;
 	getSortedKeys(L, 2, names);
diff --git a/engines/nancy/script/v5/scriptinput.cpp b/engines/nancy/script/v5/scriptinput.cpp
index 24e7ff34960..c48d66356b8 100644
--- a/engines/nancy/script/v5/scriptinput.cpp
+++ b/engines/nancy/script/v5/scriptinput.cpp
@@ -43,13 +43,13 @@ static const uint32 kDoubleClickTime = 500;	// milliseconds
 static const int kDoubleClickDistance = 4;
 
 struct InputState {
-	ScriptPoint mouse;
+	Common::Point32 mouse;
 	bool hasMouse = false;
 	Record *hovered = nullptr;
 	Record *pressed[2] = { nullptr, nullptr };
 
 	uint32 lastClickTime[2] = { 0, 0 };
-	ScriptPoint lastClickPoint[2];
+	Common::Point32 lastClickPoint[2];
 	bool isDoubleClick[2] = { false, false };
 
 	uint16 heldMoveKeys = 0;
@@ -62,7 +62,7 @@ static InputState &getState() {
 	return s_state;
 }
 
-const ScriptPoint &getScriptMousePoint() {
+const Common::Point32 &getScriptMousePoint() {
 	return getState().mouse;
 }
 
@@ -386,10 +386,10 @@ static const MoveKey kMoveKeys[] = {
 void handleNancy26Input(NancyInput &input) {
 	InputState &state = getState();
 
-	const ScriptPoint oldMouse = state.mouse;
+	const Common::Point32 oldMouse = state.mouse;
 	state.hasMouse = input.mousePos.x >= 0;
 	if (state.hasMouse) {
-		state.mouse = ScriptPoint(input.mousePos);
+		state.mouse = Common::Point32(input.mousePos);
 	}
 
 	state.isDoubleClick[0] = state.isDoubleClick[1] = false;
diff --git a/engines/nancy/script/v5/scriptinput.h b/engines/nancy/script/v5/scriptinput.h
index 8d465dfa1c9..aa30c69b19a 100644
--- a/engines/nancy/script/v5/scriptinput.h
+++ b/engines/nancy/script/v5/scriptinput.h
@@ -41,7 +41,7 @@ class Record;
 void handleNancy26Input(NancyInput &input);
 
 // Where the mouse is, in screen coordinates
-const ScriptPoint &getScriptMousePoint();
+const Common::Point32 &getScriptMousePoint();
 
 // Whether a button was just clicked twice in a row; 0 is the left one
 bool isDoubleClick(int button);
diff --git a/engines/nancy/script/v5/widgets.cpp b/engines/nancy/script/v5/widgets.cpp
index ae197c463ff..84c526bf6a9 100644
--- a/engines/nancy/script/v5/widgets.cpp
+++ b/engines/nancy/script/v5/widgets.cpp
@@ -128,7 +128,7 @@ void HotspotRecord::readTable(int tableIndex) {
 	}
 }
 
-bool HotspotRecord::hitTest(const ScriptPoint &point) const {
+bool HotspotRecord::hitTest(const Common::Point32 &point) const {
 	double x = point.x;
 	double y = point.y;
 	getTransform().inverse().transformPoint(x, y);
@@ -348,7 +348,7 @@ void SinkRecord::readTable(int tableIndex) {
 	}
 }
 
-bool SinkRecord::hitTest(const ScriptPoint &point) const {
+bool SinkRecord::hitTest(const Common::Point32 &point) const {
 	double x = point.x;
 	double y = point.y;
 	getTransform().inverse().transformPoint(x, y);
@@ -665,8 +665,8 @@ void SliderRecord::readTable(int tableIndex) {
 }
 
 // The knob is as large as the part of the picture it shows
-static ScriptPoint getOverlaySize(Record *overlay) {
-	ScriptPoint size;
+static Common::Point32 getOverlaySize(Record *overlay) {
+	Common::Point32 size;
 	if (!overlay) {
 		return size;
 	}
@@ -676,21 +676,21 @@ static ScriptPoint getOverlaySize(Record *overlay) {
 	lua_getfield(L, -1, "source");
 	const ScriptRect *source = testRect(L, -1);
 	if (source) {
-		size = ScriptPoint(source->width(), source->height());
+		size = Common::Point32(source->width(), source->height());
 	}
 
 	lua_pop(L, 2);
 	return size;
 }
 
-ScriptPoint SliderRecord::getKnobMax() const {
-	const ScriptPoint knobSize = getOverlaySize(_knobOverlay);
-	return ScriptPoint(MAX<int>(0, _knobArea.width() - knobSize.x), MAX<int>(0, _knobArea.height() - knobSize.y));
+Common::Point32 SliderRecord::getKnobMax() const {
+	const Common::Point32 knobSize = getOverlaySize(_knobOverlay);
+	return Common::Point32(MAX<int>(0, _knobArea.width() - knobSize.x), MAX<int>(0, _knobArea.height() - knobSize.y));
 }
 
-void SliderRecord::setKnobPos(const ScriptPoint &pos, bool callsScripts) {
-	const ScriptPoint knobMax = getKnobMax();
-	const ScriptPoint newPos(CLIP<int>(pos.x, 0, knobMax.x), CLIP<int>(pos.y, 0, knobMax.y));
+void SliderRecord::setKnobPos(const Common::Point32 &pos, bool callsScripts) {
+	const Common::Point32 knobMax = getKnobMax();
+	const Common::Point32 newPos(CLIP<int>(pos.x, 0, knobMax.x), CLIP<int>(pos.y, 0, knobMax.y));
 
 	const bool hasMoved = newPos.x != _knobPos.x || newPos.y != _knobPos.y;
 	_knobPos = newPos;
@@ -706,7 +706,7 @@ void SliderRecord::placeKnob() {
 		return;
 	}
 
-	const ScriptPoint knobSize = getOverlaySize(_knobOverlay);
+	const Common::Point32 knobSize = getOverlaySize(_knobOverlay);
 	ScriptRect dest(0, 0, knobSize.x, knobSize.y);
 	dest.translate(_knobArea.left + _knobPos.x, _knobArea.top + _knobPos.y);
 
@@ -721,16 +721,16 @@ void SliderRecord::onHotspotDown(int button) {
 		return;
 	}
 
-	const ScriptPoint mouse = getScriptMousePoint();
-	const ScriptPoint knobSize = getOverlaySize(_knobOverlay);
+	const Common::Point32 mouse = getScriptMousePoint();
+	const Common::Point32 knobSize = getOverlaySize(_knobOverlay);
 	const ScriptRect knob(_knobArea.left + _knobPos.x, _knobArea.top + _knobPos.y,
 		_knobArea.left + _knobPos.x + knobSize.x, _knobArea.top + _knobPos.y + knobSize.y);
 
 	if (knob.contains(mouse.x, mouse.y)) {
-		_dragOffset = ScriptPoint(mouse.x - knob.left, mouse.y - knob.top);
+		_dragOffset = Common::Point32(mouse.x - knob.left, mouse.y - knob.top);
 	} else {
-		_dragOffset = ScriptPoint(knobSize.x / 2, knobSize.y / 2);
-		setKnobPos(ScriptPoint(mouse.x - _knobArea.left - _dragOffset.x, mouse.y - _knobArea.top - _dragOffset.y), true);
+		_dragOffset = Common::Point32(knobSize.x / 2, knobSize.y / 2);
+		setKnobPos(Common::Point32(mouse.x - _knobArea.left - _dragOffset.x, mouse.y - _knobArea.top - _dragOffset.y), true);
 	}
 
 	_isDragging = true;
@@ -749,12 +749,12 @@ void SliderRecord::run(double sceneTime, double elapsedTime) {
 	ClipTransformerRecord::run(sceneTime, elapsedTime);
 
 	if (_isDragging) {
-		const ScriptPoint mouse = getScriptMousePoint();
-		setKnobPos(ScriptPoint(mouse.x - _knobArea.left - _dragOffset.x, mouse.y - _knobArea.top - _dragOffset.y), true);
+		const Common::Point32 mouse = getScriptMousePoint();
+		setKnobPos(Common::Point32(mouse.x - _knobArea.left - _dragOffset.x, mouse.y - _knobArea.top - _dragOffset.y), true);
 	}
 }
 
-bool SliderRecord::scrollRegion(const ScriptPoint &point, int notches) {
+bool SliderRecord::scrollRegion(const Common::Point32 &point, int notches) {
 	if (!isNodeEnabled() || (_scrollAmount.x == 0 && _scrollAmount.y == 0)) {
 		return false;
 	}
@@ -763,7 +763,7 @@ bool SliderRecord::scrollRegion(const ScriptPoint &point, int notches) {
 		return false;
 	}
 
-	setKnobPos(ScriptPoint(_knobPos.x - notches * _scrollAmount.x, _knobPos.y - notches * _scrollAmount.y), true);
+	setKnobPos(Common::Point32(_knobPos.x - notches * _scrollAmount.x, _knobPos.y - notches * _scrollAmount.y), true);
 	return true;
 }
 
@@ -795,7 +795,7 @@ bool SliderRecord::getField(const Common::String &key) {
 	} else if (key == "knobMax") {
 		pushPoint(L, getKnobMax());
 	} else if (key == "percent") {
-		const ScriptPoint knobMax = getKnobMax();
+		const Common::Point32 knobMax = getKnobMax();
 		pushVector(L, ScriptVector(knobMax.x > 0 ? (double)_knobPos.x / knobMax.x : 0.0,
 			knobMax.y > 0 ? (double)_knobPos.y / knobMax.y : 0.0, 0.0));
 	} else {
@@ -809,7 +809,7 @@ bool SliderRecord::setField(const Common::String &key) {
 	lua_State *L = getLua();
 
 	if (key == "knobPos") {
-		ScriptPoint pos;
+		Common::Point32 pos;
 		readPoint(L, 3, pos);
 		setKnobPos(pos, false);
 	} else if (key == "scrollArea") {
@@ -911,7 +911,7 @@ void EditBoxRecord::registerGraphics() {
 	_graphic.registerGraphics();
 }
 
-bool EditBoxRecord::hitTest(const ScriptPoint &point) const {
+bool EditBoxRecord::hitTest(const Common::Point32 &point) const {
 	double x = point.x;
 	double y = point.y;
 	getTransform().inverse().transformPoint(x, y);
diff --git a/engines/nancy/script/v5/widgets.h b/engines/nancy/script/v5/widgets.h
index 56f3542e21a..147bfc93e8a 100644
--- a/engines/nancy/script/v5/widgets.h
+++ b/engines/nancy/script/v5/widgets.h
@@ -52,7 +52,7 @@ public:
 	void setWidget(WidgetRecord *widget) { _widget = widget; }
 
 	bool isMouseRegion() const override { return true; }
-	bool hitTest(const ScriptPoint &point) const override;
+	bool hitTest(const Common::Point32 &point) const override;
 	void setMouseOver(bool isOver) override;
 	bool pressRegion(int button) override;
 	void releaseRegion(int button) override;
@@ -112,7 +112,7 @@ public:
 	RecordType getType() const override { return kRecordSink; }
 
 	bool isMouseRegion() const override { return _handlesMouse; }
-	bool hitTest(const ScriptPoint &point) const override;
+	bool hitTest(const Common::Point32 &point) const override;
 	bool pressRegion(int button) override { return true; }
 	bool getRegionCursor(uint &cursorType, bool &isHot) const override;
 	bool capturesKeys() const override { return _handlesKeys; }
@@ -193,7 +193,7 @@ public:
 	void onHotspotUp(int button, bool isOver) override;
 
 	// The wheel moves the knob while the mouse is in the scroll area
-	bool scrollRegion(const ScriptPoint &point, int notches) override;
+	bool scrollRegion(const Common::Point32 &point, int notches) override;
 
 protected:
 	void readTable(int tableIndex) override;
@@ -204,16 +204,16 @@ protected:
 
 private:
 	// How far the knob can go across and down
-	ScriptPoint getKnobMax() const;
-	void setKnobPos(const ScriptPoint &pos, bool callsScripts);
+	Common::Point32 getKnobMax() const;
+	void setKnobPos(const Common::Point32 &pos, bool callsScripts);
 	void placeKnob();
 
 	Record *_knobOverlay = nullptr;
 	ScriptRect _knobArea;
 	ScriptRect _scrollArea;
-	ScriptPoint _scrollAmount;
-	ScriptPoint _knobPos;
-	ScriptPoint _dragOffset;	// from the knob to the mouse, while dragged
+	Common::Point32 _scrollAmount;
+	Common::Point32 _knobPos;
+	Common::Point32 _dragOffset;	// from the knob to the mouse, while dragged
 	bool _isDragging = false;
 };
 
@@ -229,7 +229,7 @@ public:
 	~EditBoxRecord() override;
 
 	bool isMouseRegion() const override { return true; }
-	bool hitTest(const ScriptPoint &point) const override;
+	bool hitTest(const Common::Point32 &point) const override;
 	bool pressRegion(int button) override;
 	bool getRegionCursor(uint &cursorType, bool &isHot) const override;
 	bool handleKey(Common::KeyCode key, uint16 ascii) override;


Commit: 406524bde20451a90566d3146b49dfa312c89341
    https://github.com/scummvm/scummvm/commit/406524bde20451a90566d3146b49dfa312c89341
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-11T02:34:43+02:00

Commit Message:
NANCY: NANCY27: Add Rect:Clamp() and the new Point functions

Nancy27 adds Rect:Clamp(), which gives the nearest point inside a rect,
dividing points, and Point:Rounded() and Point:Floored().

Changed paths:
    engines/nancy/script/types.cpp


diff --git a/engines/nancy/script/types.cpp b/engines/nancy/script/types.cpp
index d9f2405c619..8d4b65d2ba7 100644
--- a/engines/nancy/script/types.cpp
+++ b/engines/nancy/script/types.cpp
@@ -217,6 +217,16 @@ static int rectContains(lua_State *L) {
 	return 1;
 }
 
+// Rect:Clamp(point) and Rect:Clamp(x, y), Nancy27: the nearest point of the
+// rect, right and bottom edges included
+static int rectClamp(lua_State *L) {
+	const ScriptRect &rect = checkRect(L, 1);
+	const Common::Point32 point = checkPointArguments(L, 2);
+	pushPoint(L, Common::Point32(CLIP<int32>(point.x, rect.left, MAX(rect.left, rect.right)),
+								 CLIP<int32>(point.y, rect.top, MAX(rect.top, rect.bottom))));
+	return 1;
+}
+
 static int rectOffset(lua_State *L) {
 	ScriptRect rect = checkRect(L, 1);
 	Common::Point32 offset = checkPointArguments(L, 2);
@@ -325,6 +335,7 @@ static const luaL_Reg kRectFunctions[] = {
 	{ "__newindex", rectNewIndex },
 	{ "__eq", rectEquals },
 	{ "Contains", rectContains },
+	{ "Clamp", rectClamp },
 	{ "Offset", rectOffset },
 	{ "Intersect", rectIntersect },
 	{ "CenteredOn", rectCenteredOn },
@@ -496,7 +507,7 @@ static int pointSubtract(lua_State *L) {
 	return 1;
 }
 
-// Either side can be a number, which multiplies both coordinates.
+// Either side can be a number, which multiplies or divides both coordinates.
 // Before Nancy26, the number is truncated first.
 static void checkPointFactor(lua_State *L, int index, float &x, float &y) {
 	if (lua_isnumber(L, index)) {
@@ -518,6 +529,33 @@ static int pointMultiply(lua_State *L) {
 	return 1;
 }
 
+// Nancy27
+static int pointDivide(lua_State *L) {
+	float ax, ay, bx, by;
+	checkPointFactor(L, 1, ax, ay);
+	checkPointFactor(L, 2, bx, by);
+	pushPointValue(L, PointValue(ax / bx, ay / by));
+	return 1;
+}
+
+// Halves go away from zero
+static double roundCoordinate(float value) {
+	return value > 0.0f ? floor(value + 0.5) : ceil(value - 0.5);
+}
+
+// Point:Rounded() and Point:Floored(), Nancy27
+static int pointRounded(lua_State *L) {
+	const PointValue &point = checkPoint(L, 1);
+	pushPointValue(L, PointValue(roundCoordinate(point.x), roundCoordinate(point.y)));
+	return 1;
+}
+
+static int pointFloored(lua_State *L) {
+	const PointValue &point = checkPoint(L, 1);
+	pushPointValue(L, PointValue(floor(point.x), floor(point.y)));
+	return 1;
+}
+
 static int pointNegate(lua_State *L) {
 	const PointValue &point = checkPoint(L, 1);
 	pushPointValue(L, PointValue(-point.x, -point.y));
@@ -541,10 +579,13 @@ static const luaL_Reg kPointFunctions[] = {
 	{ "__eq", pointEquals },
 	{ "__add", pointAdd },
 	{ "__mul", pointMultiply },
+	{ "__div", pointDivide },
 	{ "__sub", pointSubtract },
 	{ "__unm", pointNegate },
 	{ "__tostring", pointToString },
 	{ "__concat", concatToStrings },
+	{ "Rounded", pointRounded },
+	{ "Floored", pointFloored },
 	{ nullptr, nullptr }
 };
 


Commit: 89c1fd06783addb4d80f2842b309f3bca206f40a
    https://github.com/scummvm/scummvm/commit/89c1fd06783addb4d80f2842b309f3bca206f40a
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-11T02:34:44+02:00

Commit Message:
NANCY: NANCY27: Add the sound channels of Nancy27

Nancy27 has no global sound channels, and has three more phone channels

Changed paths:
    engines/nancy/script/gameapi.cpp


diff --git a/engines/nancy/script/gameapi.cpp b/engines/nancy/script/gameapi.cpp
index 35c9ec7dbd2..3e8a0688971 100644
--- a/engines/nancy/script/gameapi.cpp
+++ b/engines/nancy/script/gameapi.cpp
@@ -1125,6 +1125,18 @@ static const SoundChannelName kNancy24SoundChannelNames[] = {
 	{ "AllGlobal", kChannelAllGlobal }
 };
 
+// Nancy27 has no global channels, and has three more phone channels
+static const SoundChannelName kNancy27SoundChannelNames[] = {
+	{ "Theme", 0 }, { "UIMusic", 1 }, { "EngineMusic", 2 },
+	{ "Ambient1", 3 }, { "Ambient2", 4 }, { "Ambient3", 5 }, { "Ambient4", 6 },
+	{ "Ambient5", 7 }, { "Ambient6", 8 }, { "Ambient7", 9 }, { "Ambient8", 10 },
+	{ "FX1", 11 }, { "FX2", 12 }, { "FX3", 13 }, { "FX4", 14 }, { "FX5", 15 }, { "FX6", 16 }, { "FX7", 17 }, { "FX8", 18 },
+	{ "InvFX", 19 }, { "PhoneFX", 20 }, { "PhoneFX2", 21 }, { "PhoneFX3", 22 }, { "PhoneFX4", 23 }, { "UIFX", 24 }, { "EngineFX", 25 },
+	{ "NPCVoice", 26 }, { "PlayerVoice", 27 }, { "UIVoice", 28 }, { "EngineVoice", 29 },
+	{ "All", kChannelAll }, { "AllExceptTheme", kChannelAllExceptTheme }, { "AllMusic", kChannelAllMusic },
+	{ "AllFX", kChannelAllFX }, { "AllAmbient", kChannelAllAmbient }, { "AllVoice", kChannelAllVoice }
+};
+
 // Where the channels of each kind begin, and the end of the last kind
 struct SoundChannelLayout {
 	uint16 firstMusic;
@@ -1138,15 +1150,18 @@ struct SoundChannelLayout {
 static const SoundChannelLayout kSoundChannelLayout = { 0, 6, 6, 14, 24, kNumSoundChannels };
 static const SoundChannelLayout kNancy22SoundChannelLayout = { 0, 3, 8, 16, 26, kNumSoundChannels };
 static const SoundChannelLayout kNancy24SoundChannelLayout = { 0, 3, 6, 14, 26, kNumSoundChannels };
+static const SoundChannelLayout kNancy27SoundChannelLayout = { 0, 3, 3, 11, 26, kNumSoundChannels };
 
 static const SoundChannelLayout &getSoundChannelLayout() {
 	if (g_nancy->getGameType() <= kGameTypeNancy21) {
 		return kSoundChannelLayout;
 	} else if (g_nancy->getGameType() <= kGameTypeNancy23) {
 		return kNancy22SoundChannelLayout;
+	} else if (g_nancy->getGameType() <= kGameTypeNancy26) {
+		return kNancy24SoundChannelLayout;
 	}
 
-	return kNancy24SoundChannelLayout;
+	return kNancy27SoundChannelLayout;
 }
 
 void pushSoundChannel(lua_State *L, uint16 channel) {
@@ -1182,7 +1197,14 @@ bool isVoicePlaying() {
 }
 
 static bool findSoundChannel(const char *name, uint16 &result) {
-	if (g_nancy->getGameType() >= kGameTypeNancy24) {
+	if (g_nancy->getGameType() >= kGameTypeNancy27) {
+		for (const SoundChannelName &channel : kNancy27SoundChannelNames) {
+			if (scumm_stricmp(channel.name, name) == 0) {
+				result = channel.channel;
+				return true;
+			}
+		}
+	} else if (g_nancy->getGameType() >= kGameTypeNancy24) {
 		for (const SoundChannelName &channel : kNancy24SoundChannelNames) {
 			if (scumm_stricmp(channel.name, name) == 0) {
 				result = channel.channel;


Commit: b4a85959c364999206d204a79a71d7ae524052f5
    https://github.com/scummvm/scummvm/commit/b4a85959c364999206d204a79a71d7ae524052f5
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-11T02:34:46+02:00

Commit Message:
NANCY: NANCY27: Add Game.diags

Nancy27 scripts read and set Game.diags, a setting of the cheat tools,
which is now kept.

Changed paths:
    engines/nancy/script/v5/gamefunctions.cpp


diff --git a/engines/nancy/script/v5/gamefunctions.cpp b/engines/nancy/script/v5/gamefunctions.cpp
index a8f34f151b7..975f22d1d09 100644
--- a/engines/nancy/script/v5/gamefunctions.cpp
+++ b/engines/nancy/script/v5/gamefunctions.cpp
@@ -177,6 +177,7 @@ static int keyIndex(lua_State *L) {
 // What the cheat tools switch on
 static bool s_isCheatMode = false;
 static bool s_isFastConvo = false;
+static bool s_showsDiagnostics = false;	// Nancy27
 
 // How many times a new game began since the game was started
 static uint s_numRestarts = 0;
@@ -351,6 +352,8 @@ static bool pushGameField(lua_State *L, const Common::String &key) {
 		lua_pushboolean(L, s_isFastConvo);
 	} else if (key == "cheatMode") {
 		lua_pushboolean(L, s_isCheatMode);
+	} else if (key == "diags") {
+		lua_pushboolean(L, s_showsDiagnostics);
 	} else if (key == "needsSave") {
 		lua_pushboolean(L, true);
 	} else if (key == "restarts") {
@@ -378,6 +381,8 @@ static int gameNewIndex(lua_State *L) {
 		s_isCheatMode = lua_toboolean(L, 3) != 0;
 	} else if (key == "fastConvo") {
 		s_isFastConvo = lua_toboolean(L, 3) != 0;
+	} else if (key == "diags") {
+		s_showsDiagnostics = lua_toboolean(L, 3) != 0;
 	} else {
 		return luaL_error(L, "Field %s is not settable on Game ", key.c_str());
 	}


Commit: 42e7bdbe95367945f8f7e103d12bf32c64856a4f
    https://github.com/scummvm/scummvm/commit/42e7bdbe95367945f8f7e103d12bf32c64856a4f
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-11T02:34:49+02:00

Commit Message:
NANCY: NANCY27: Put away the item in hand when inHand is set to nil

Nancy27 scripts put away the item in hand by setting Inventory.inHand
to nil, as well as to an empty name.

Changed paths:
    engines/nancy/script/v5/gamefunctions.cpp


diff --git a/engines/nancy/script/v5/gamefunctions.cpp b/engines/nancy/script/v5/gamefunctions.cpp
index 975f22d1d09..5523da1cd7e 100644
--- a/engines/nancy/script/v5/gamefunctions.cpp
+++ b/engines/nancy/script/v5/gamefunctions.cpp
@@ -528,14 +528,15 @@ static bool pushInventoryField(lua_State *L, const Common::String &key) {
 	return true;
 }
 
-// Inventory.inHand = name, or "" to put it away
+// Inventory.inHand = name, or "" to put it away. Nancy27 also puts it away
+// with nil.
 static int inventoryNewIndex(lua_State *L) {
 	const Common::String key = luaL_checkstring(L, 2);
 	if (key != "inHand") {
 		return luaL_error(L, "Inventory does not have a settable field %s", key.c_str());
 	}
 
-	const Common::String name = luaL_checkstring(L, 3);
+	const Common::String name = lua_isnil(L, 3) ? "" : luaL_checkstring(L, 3);
 	const int16 heldItem = name.empty() ? -1 : checkItem(L, 3).id;
 	if (heldItem != NancySceneState.getHeldItem()) {
 		NancySceneState.setHeldItem(heldItem);


Commit: 053dea1e23deb8ccd306439c5d8e6f636a03bdad
    https://github.com/scummvm/scummvm/commit/053dea1e23deb8ccd306439c5d8e6f636a03bdad
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-11T02:34:52+02:00

Commit Message:
NANCY: NANCY27: Add Sound:PauseAbandoned() and UnpauseAbandoned()

Nancy27 pauses the sounds that keep playing after their records are
gone while its UI is shown, and resumes them when the UI is closed.
Channels that started another sound in the meantime are left alone.

Changed paths:
    engines/nancy/script/records.cpp
    engines/nancy/script/records.h
    engines/nancy/script/v5/gamefunctions.cpp


diff --git a/engines/nancy/script/records.cpp b/engines/nancy/script/records.cpp
index 45c8c08e154..aed36e30b1f 100644
--- a/engines/nancy/script/records.cpp
+++ b/engines/nancy/script/records.cpp
@@ -2056,6 +2056,16 @@ static int soundStopIfPlaying(lua_State *L) {
 	return 0;
 }
 
+bool SoundRecord::getPlayingChannel(uint16 &channel) const {
+	if (!_isPlaying || g_nancy->_sound->getChannelSerial(_channel) != _channelSerial ||
+			!g_nancy->_sound->isSoundPlaying(_channel)) {
+		return false;
+	}
+
+	channel = _channel;
+	return true;
+}
+
 void SoundRecord::stopIfPlaying() {
 	if (_isPlaying && g_nancy->_sound->getChannelSerial(_channel) == _channelSerial) {
 		g_nancy->_sound->stopSound(_sound);
diff --git a/engines/nancy/script/records.h b/engines/nancy/script/records.h
index 2ef66e2755b..376f186b232 100644
--- a/engines/nancy/script/records.h
+++ b/engines/nancy/script/records.h
@@ -371,6 +371,9 @@ public:
 	bool skipSpeech() override;
 	void stopIfPlaying();
 
+	// The channel the sound of the record plays on, while it does
+	bool getPlayingChannel(uint16 &channel) const;
+
 protected:
 	void readTable(int tableIndex) override;
 	void runOnce() override;
diff --git a/engines/nancy/script/v5/gamefunctions.cpp b/engines/nancy/script/v5/gamefunctions.cpp
index 5523da1cd7e..7015992a169 100644
--- a/engines/nancy/script/v5/gamefunctions.cpp
+++ b/engines/nancy/script/v5/gamefunctions.cpp
@@ -29,9 +29,12 @@
 #include "engines/nancy/enginedata.h"
 #include "engines/nancy/graphics.h"
 #include "engines/nancy/nancy.h"
+#include "engines/nancy/sound.h"
 
 #include "engines/nancy/script/api.h"
 #include "engines/nancy/script/luabind.h"
+#include "engines/nancy/script/records.h"
+#include "engines/nancy/script/scenecontext.h"
 #include "engines/nancy/script/types.h"
 
 #include "engines/nancy/script/v5/gamefunctions.h"
@@ -602,6 +605,75 @@ static int soundSetGroupVolume(lua_State *L) {
 	return 0;
 }
 
+// Sound:PauseAbandoned() and Sound:UnpauseAbandoned(), Nancy27: pause and
+// resume the sounds that went on playing after their records were gone, as
+// the UI pops up over the game and goes away again
+
+struct PausedChannel {
+	uint16 channel;
+	uint32 serial;
+};
+
+static Common::Array<PausedChannel> s_pausedAbandonedChannels;
+
+static void addPlayingChannels(const SceneContext *context, Common::Array<bool> &isOwned) {
+	if (!context) {
+		return;
+	}
+
+	for (const Record *record : context->getRecords()) {
+		uint16 channel;
+		if (record->getType() == kRecordSound && ((const SoundRecord *)record)->getPlayingChannel(channel) && channel < isOwned.size()) {
+			isOwned[channel] = true;
+		}
+	}
+}
+
+static int soundPauseAbandoned(lua_State *L) {
+	Common::Array<bool> isOwned;
+	isOwned.resize(g_nancy->getStaticData().soundChannelInfo.numChannels, false);
+
+	Common::Array<State::SceneStream *> streams;
+	NancySceneState.getStreams().getDrawOrder(streams);
+	for (const State::SceneStream *stream : streams) {
+		addPlayingChannels(stream ? stream->getScriptScene() : NancySceneState.getScriptScene(), isOwned);
+	}
+
+	for (uint16 i = 0; i < isOwned.size(); ++i) {
+		if (isOwned[i] || !g_nancy->_sound->isSoundPlaying(i)) {
+			continue;
+		}
+
+		bool isPaused = false;
+		for (const PausedChannel &paused : s_pausedAbandonedChannels) {
+			isPaused = isPaused || paused.channel == i;
+		}
+
+		if (!isPaused) {
+			g_nancy->_sound->pauseSound(i, true);
+
+			PausedChannel paused;
+			paused.channel = i;
+			paused.serial = g_nancy->_sound->getChannelSerial(i);
+			s_pausedAbandonedChannels.push_back(paused);
+		}
+	}
+
+	return 0;
+}
+
+// A channel that got another sound in the meantime is left alone
+static int soundUnpauseAbandoned(lua_State *L) {
+	for (const PausedChannel &paused : s_pausedAbandonedChannels) {
+		if (g_nancy->_sound->getChannelSerial(paused.channel) == paused.serial) {
+			g_nancy->_sound->pauseSound(paused.channel, false);
+		}
+	}
+
+	s_pausedAbandonedChannels.clear();
+	return 0;
+}
+
 // Scene:IsStreamRunning(stream)
 static int sceneIsStreamRunning(lua_State *L) {
 	const char *streamName = luaL_checkstring(L, 2);
@@ -651,6 +723,8 @@ void registerNancy26GameAPI(lua_State *L) {
 	static const luaL_Reg kSoundFunctions[] = {
 		{ "GetGroupVolume", soundGetGroupVolume },
 		{ "SetGroupVolume", soundSetGroupVolume },
+		{ "PauseAbandoned", soundPauseAbandoned },
+		{ "UnpauseAbandoned", soundUnpauseAbandoned },
 		{ nullptr, nullptr }
 	};
 


Commit: 3b1f81b27cb9f3bf5cbfc1b5fb045c5424df75ad
    https://github.com/scummvm/scummvm/commit/3b1f81b27cb9f3bf5cbfc1b5fb045c5424df75ad
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-11T02:34:54+02:00

Commit Message:
NANCY: NANCY27: Add the Brain

The Brain is a set of named true/false conditions in Nancy27, which its
Brain_SC script sets up in a Lua state of its own. The other scripts
read them through the Brain global. Some conditions are worked out
every time they are read. Others keep their last result until a script
asks for an update, and that result is saved with the game.

Changed paths:
  A engines/nancy/script/v5/brain.cpp
  A engines/nancy/script/v5/brain.h
    engines/nancy/module.mk
    engines/nancy/puzzledata.cpp
    engines/nancy/puzzledata.h
    engines/nancy/script/v5/bootobjects.cpp
    engines/nancy/script/v5/gamefunctions.cpp


diff --git a/engines/nancy/module.mk b/engines/nancy/module.mk
index 5e27336fde8..5d3cb646956 100644
--- a/engines/nancy/module.mk
+++ b/engines/nancy/module.mk
@@ -242,6 +242,7 @@ ifdef ENABLE_NANCY_V5
 MODULE_OBJS += \
   script/v5/bitmaptext.o \
   script/v5/bootobjects.o \
+  script/v5/brain.o \
   script/v5/cliptransformer.o \
   script/v5/gamefunctions.o \
   script/v5/messaging.o \
diff --git a/engines/nancy/puzzledata.cpp b/engines/nancy/puzzledata.cpp
index 50f925aa5c5..f10923b8f68 100644
--- a/engines/nancy/puzzledata.cpp
+++ b/engines/nancy/puzzledata.cpp
@@ -1089,6 +1089,29 @@ void ScriptSavedData::synchronize(Common::Serializer &ser) {
 	}
 }
 
+void BrainData::synchronize(Common::Serializer &ser) {
+	uint16 numResults = results.size();
+	ser.syncAsUint16LE(numResults);
+
+	Common::Array<Common::String> names;
+	if (ser.isSaving()) {
+		for (auto &entry : results) {
+			names.push_back(entry._key);
+		}
+	} else {
+		results.clear();
+		names.resize(numResults);
+	}
+
+	for (Common::String &name : names) {
+		ser.syncString(name);
+
+		byte result = results.getValOrDefault(name, false) ? 1 : 0;
+		ser.syncAsByte(result);
+		results.setVal(name, result != 0);
+	}
+}
+
 void ScriptPictureData::synchronize(Common::Serializer &ser) {
 	uint16 numPictures = pictures.size();
 	ser.syncAsUint16LE(numPictures);
@@ -1165,6 +1188,8 @@ PuzzleData *makePuzzleData(const uint32 tag) {
 		return new ScriptSavedData();
 	case ScriptJournalData::getTag():
 		return new ScriptJournalData();
+	case BrainData::getTag():
+		return new BrainData();
 	case ScriptPictureData::getTag():
 		return new ScriptPictureData();
 	case StreamData::getTag():
diff --git a/engines/nancy/puzzledata.h b/engines/nancy/puzzledata.h
index 66f91936af2..5021512c726 100644
--- a/engines/nancy/puzzledata.h
+++ b/engines/nancy/puzzledata.h
@@ -743,6 +743,15 @@ struct ScriptSavedData : public PuzzleData {
 	Common::HashMap<Common::String, Common::Array<byte>, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> values;
 };
 
+// Nancy27. The results of the conditions of the Brain that are only worked out
+// again when the scripts ask for it
+struct BrainData : public PuzzleData {
+	static constexpr uint32 getTag() { return MKTAG('B', 'R', 'N', 'S'); }
+	virtual void synchronize(Common::Serializer &ser);
+
+	Common::HashMap<Common::String, bool, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> results;
+};
+
 // Nancy21. The pictures the camera of the cell phone took, as PNG files, which
 // the scripts show from the "LOADSAVE" tree
 struct ScriptPictureData : public PuzzleData {
diff --git a/engines/nancy/script/v5/bootobjects.cpp b/engines/nancy/script/v5/bootobjects.cpp
index 50d2f38a68d..578c879446b 100644
--- a/engines/nancy/script/v5/bootobjects.cpp
+++ b/engines/nancy/script/v5/bootobjects.cpp
@@ -27,6 +27,7 @@
 #include "engines/nancy/script/types.h"
 
 #include "engines/nancy/script/v5/bootobjects.h"
+#include "engines/nancy/script/v5/brain.h"
 
 #include "engines/nancy/ui/ndui/button.h"
 
@@ -322,6 +323,10 @@ void NancyEngine::bootNancy26Data(ScriptBootData *boot, EVNT *flags, INVD *inven
 	runRequiredScript("AutotextBoot", bootTables);
 	runRequiredScript("BuildNumber", bootTables);
 
+	if (getGameType() >= kGameTypeNancy27) {
+		_engineData.setVal("BrainLogic", new Script::BrainLogic());
+	}
+
 	Script::BootTables textTables;
 	textTables.texts = autotext;
 	for (const Common::String &name : boot->textFileNames) {
diff --git a/engines/nancy/script/v5/brain.cpp b/engines/nancy/script/v5/brain.cpp
new file mode 100644
index 00000000000..ce3a0a5663f
--- /dev/null
+++ b/engines/nancy/script/v5/brain.cpp
@@ -0,0 +1,258 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/textconsole.h"
+
+#include "engines/nancy/nancy.h"
+#include "engines/nancy/puzzledata.h"
+#include "engines/nancy/script/luabind.h"
+#include "engines/nancy/script/luastate.h"
+#include "engines/nancy/script/v5/brain.h"
+#include "engines/nancy/state/scene.h"
+
+namespace Nancy {
+namespace Script {
+
+static const char *const kBrainInitType = "ND.BrainInit";
+
+BrainLogic::BrainLogic() : _lua(new LuaState()) {
+	static const luaL_Reg kBrainInitFunctions[] = {
+		{ "__index", indexFunctions },
+		{ "Create", brainInitCreate },
+		{ nullptr, nullptr }
+	};
+
+	// The BrainInit global holds the Brain that BrainInit:Create adds to
+	lua_State *L = _lua->get();
+	registerType(L, kBrainInitType, kBrainInitFunctions);
+	pushValue(L, kBrainInitType, this);
+	lua_setglobal(L, "BrainInit");
+
+	_isLoading = true;
+	const bool isLoaded = _lua->runScript("Brain_SC");
+	_isLoading = false;
+
+	if (!isLoaded) {
+		error("Failed to load boot script Brain_SC");
+	}
+}
+
+BrainLogic::~BrainLogic() {
+	delete _lua;
+}
+
+// BrainInit:Create({ { name, isAutoUpdated, function }, ... }). The names
+// end in "_BR".
+int BrainLogic::brainInitCreate(lua_State *L) {
+	BrainLogic *brain = *(BrainLogic **)checkUserData(L, 1, kBrainInitType);
+	luaL_checktype(L, 2, LUA_TTABLE);
+	if (!brain->_isLoading) {
+		return luaL_error(L, "BrainInit:Create can only be called by Brain_SC");
+	}
+
+	const int numEntries = (int)lua_objlen(L, 2);
+	for (int i = 1; i <= numEntries; ++i) {
+		lua_rawgeti(L, 2, i);
+		luaL_checktype(L, -1, LUA_TTABLE);
+
+		lua_rawgeti(L, -1, 1);
+		lua_rawgeti(L, -2, 2);
+		lua_rawgeti(L, -3, 3);
+		if (!lua_isstring(L, -3) || !lua_isboolean(L, -2)) {
+			return luaL_error(L, "Entry %d of the Brain does not have enough fields", i);
+		}
+
+		if (!lua_isfunction(L, -1)) {
+			return luaL_error(L, "Entry %d of the Brain has no logic function", i);
+		}
+
+		Logic logic;
+		logic.name = lua_tostring(L, -3);
+		logic.isAutoUpdated = lua_toboolean(L, -2) != 0;
+
+		if (!logic.name.hasSuffix("_BR")) {
+			warning("Logic %s of the Brain is not properly tagged", logic.name.c_str());
+			lua_pop(L, 4);
+			continue;
+		}
+
+		if (brain->findLogic(logic.name)) {
+			warning("Name %s appears more than once in the Brain", logic.name.c_str());
+			lua_pop(L, 4);
+			continue;
+		}
+
+		logic.functionRef = luaL_ref(L, LUA_REGISTRYINDEX);
+		brain->_logic.push_back(logic);
+		lua_pop(L, 3);
+	}
+
+	return 0;
+}
+
+const BrainLogic::Logic *BrainLogic::findLogic(const Common::String &name) const {
+	for (const Logic &logic : _logic) {
+		if (logic.name.equalsIgnoreCase(name)) {
+			return &logic;
+		}
+	}
+
+	return nullptr;
+}
+
+// Runs the function of a condition, and keeps the result of one that isn't
+// updated automatically. A function that fails changes nothing.
+bool BrainLogic::evaluate(const Logic &logic, bool &value) {
+	lua_State *L = _lua->get();
+	lua_rawgeti(L, LUA_REGISTRYINDEX, logic.functionRef);
+	const Common::String what = Common::String::format("Function for %s failed", logic.name.c_str());
+	if (!LuaState::call(L, 0, 1, what.c_str())) {
+		return false;
+	}
+
+	value = lua_toboolean(L, -1) != 0;
+	lua_pop(L, 1);
+
+	if (!logic.isAutoUpdated) {
+		BrainData *data = (BrainData *)NancySceneState.getPuzzleData(BrainData::getTag());
+		data->results.setVal(logic.name, value);
+	}
+
+	return true;
+}
+
+bool BrainLogic::getValue(const Common::String &name, bool &value) {
+	const Logic *logic = findLogic(name);
+	if (!logic) {
+		return false;
+	}
+
+	value = false;
+	if (!logic->isAutoUpdated) {
+		const BrainData *data = (const BrainData *)NancySceneState.getPuzzleData(BrainData::getTag());
+		if (data->results.tryGetVal(logic->name, value)) {
+			return true;
+		}
+	}
+
+	evaluate(*logic, value);
+	return true;
+}
+
+bool BrainLogic::isAutoUpdated(const Common::String &name) const {
+	const Logic *logic = findLogic(name);
+	return logic && logic->isAutoUpdated;
+}
+
+void BrainLogic::update(const Common::String &name) {
+	const Logic *logic = findLogic(name);
+	bool value;
+	if (logic) {
+		evaluate(*logic, value);
+	}
+}
+
+// The cheat menu sets the conditions that keep their results
+void BrainLogic::overrideValue(const Common::String &name, bool value) {
+	const Logic *logic = findLogic(name);
+	if (logic && !logic->isAutoUpdated) {
+		BrainData *data = (BrainData *)NancySceneState.getPuzzleData(BrainData::getTag());
+		data->results.setVal(logic->name, value);
+	}
+}
+
+void BrainLogic::getNames(Common::Array<Common::String> &names) const {
+	for (const Logic &logic : _logic) {
+		names.push_back(logic.name);
+	}
+}
+
+static BrainLogic &getBrain(lua_State *L) {
+	BrainLogic *brain = (BrainLogic *)const_cast<EngineData *>(g_nancy->getEngineData("BrainLogic"));
+	if (!brain) {
+		luaL_error(L, "The game has no Brain");
+	}
+
+	return *brain;
+}
+
+// Brain:AllNames(): an array of the names of all conditions
+static int brainAllNames(lua_State *L) {
+	Common::Array<Common::String> names;
+	getBrain(L).getNames(names);
+
+	lua_createtable(L, names.size(), 0);
+	for (uint i = 0; i < names.size(); ++i) {
+		lua_pushstring(L, names[i].c_str());
+		lua_rawseti(L, -2, i + 1);
+	}
+
+	return 1;
+}
+
+static int brainIsAutoUpdated(lua_State *L) {
+	lua_pushboolean(L, getBrain(L).isAutoUpdated(luaL_checkstring(L, 2)));
+	return 1;
+}
+
+static int brainUpdate(lua_State *L) {
+	getBrain(L).update(luaL_checkstring(L, 2));
+	return 0;
+}
+
+static int brainOverrideFromCheat(lua_State *L) {
+	getBrain(L).overrideValue(luaL_checkstring(L, 2), lua_toboolean(L, 3) != 0);
+	return 0;
+}
+
+// Brain.<name>: the result of a condition
+static int brainIndex(lua_State *L) {
+	const char *name = luaL_checkstring(L, 2);
+
+	bool value;
+	if (getBrain(L).getValue(name, value)) {
+		lua_pushboolean(L, value);
+		return 1;
+	}
+
+	indexFunctions(L);
+	if (lua_isnil(L, -1)) {
+		return luaL_error(L, "There is no logic for %s", name);
+	}
+
+	return 1;
+}
+
+void registerBrainAPI(lua_State *L) {
+	static const luaL_Reg kBrainFunctions[] = {
+		{ "__index", brainIndex },
+		{ "AllNames", brainAllNames },
+		{ "IsAutoUpdated", brainIsAutoUpdated },
+		{ "Update", brainUpdate },
+		{ "OverrideFromCheat", brainOverrideFromCheat },
+		{ nullptr, nullptr }
+	};
+
+	registerGlobal(L, "Brain", "ND.Brain", kBrainFunctions);
+}
+
+} // End of namespace Script
+} // End of namespace Nancy
diff --git a/engines/nancy/script/v5/brain.h b/engines/nancy/script/v5/brain.h
new file mode 100644
index 00000000000..655fa3b6712
--- /dev/null
+++ b/engines/nancy/script/v5/brain.h
@@ -0,0 +1,78 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NANCY_SCRIPT_V5_BRAIN_H
+#define NANCY_SCRIPT_V5_BRAIN_H
+
+#include "common/array.h"
+#include "common/str.h"
+
+#include "engines/nancy/enginedata.h"
+
+struct lua_State;
+
+namespace Nancy {
+namespace Script {
+
+class LuaState;
+
+// Nancy27. The conditions Brain_SC gives names to ("Hum_Ready_BR"), which
+// scripts read as booleans through the Brain global. Each one is a function
+// that keeps running in a Lua state of its own for the whole game. Those that
+// aren't updated automatically keep their last result, which is saved with
+// the game, until a script asks for it to be worked out again.
+class BrainLogic : public EngineData {
+public:
+	BrainLogic();
+	~BrainLogic() override;
+
+	// Returns false when there is no condition of that name
+	bool getValue(const Common::String &name, bool &value);
+	bool isAutoUpdated(const Common::String &name) const;
+	void update(const Common::String &name);
+	void overrideValue(const Common::String &name, bool value);
+
+	void getNames(Common::Array<Common::String> &names) const;
+
+private:
+	struct Logic {
+		Common::String name;
+		bool isAutoUpdated = true;
+		int functionRef = 0;
+	};
+
+	static int brainInitCreate(lua_State *L);
+
+	const Logic *findLogic(const Common::String &name) const;
+	bool evaluate(const Logic &logic, bool &value);
+
+	LuaState *_lua;
+	Common::Array<Logic> _logic;
+	bool _isLoading = false;	// BrainInit:Create only works while Brain_SC runs
+};
+
+// The Brain global of the scene scripts
+void registerBrainAPI(lua_State *L);
+
+} // End of namespace Script
+} // End of namespace Nancy
+
+#endif // NANCY_SCRIPT_V5_BRAIN_H
diff --git a/engines/nancy/script/v5/gamefunctions.cpp b/engines/nancy/script/v5/gamefunctions.cpp
index 7015992a169..7cd9690cafe 100644
--- a/engines/nancy/script/v5/gamefunctions.cpp
+++ b/engines/nancy/script/v5/gamefunctions.cpp
@@ -36,6 +36,7 @@
 #include "engines/nancy/script/records.h"
 #include "engines/nancy/script/scenecontext.h"
 #include "engines/nancy/script/types.h"
+#include "engines/nancy/script/v5/brain.h"
 
 #include "engines/nancy/script/v5/gamefunctions.h"
 #include "engines/nancy/script/v5/scriptinput.h"
@@ -744,6 +745,8 @@ void registerNancy26GameAPI(lua_State *L) {
 	addFunctions(L, "ND.Sound", kSoundFunctions);
 	addFunctions(L, "ND.Scene", kSceneFunctions);
 	addFunctions(L, "ND.Log", kLogFunctions);
+
+	registerBrainAPI(L);
 }
 
 } // End of namespace Script


Commit: ded14a3efd4b9926bf4a9f54e8c5d07db7f520a5
    https://github.com/scummvm/scummvm/commit/ded14a3efd4b9926bf4a9f54e8c5d07db7f520a5
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-11T02:34:56+02:00

Commit Message:
NANCY: NANCY26: Use the game ID in the header of saved games

Nancy26 and Nancy27 have no boot script that gives a name for the
header of their saved games, so use the game ID (e.g. "nancy27").

Changed paths:
    engines/nancy/nancy.cpp
    engines/nancy/script/v5/bootobjects.cpp


diff --git a/engines/nancy/nancy.cpp b/engines/nancy/nancy.cpp
index 64ed8dca884..19e772a0e9d 100644
--- a/engines/nancy/nancy.cpp
+++ b/engines/nancy/nancy.cpp
@@ -970,8 +970,13 @@ void NancyEngine::bootScriptedGameEngine() {
 	_staticData.numItems = inventory->items.size();
 	_staticData.numEventFlags = (uint16)(kNumGenericEventFlags + flags->numRecords);
 
-	// Saved games get matched against the name of the game
-	const Common::String &saveName = boot->saveFolderName.empty() ? boot->defaultSaveName : boot->saveFolderName;
+	// The name of the game goes into the header of saved games
+	Common::String saveName = boot->saveFolderName.empty() ? boot->defaultSaveName : boot->saveFolderName;
+	if (saveName.empty()) {
+		// Nancy26 and later give no name, so the ID of the game stands in
+		saveName = getGameId();
+	}
+
 	Common::strlcpy((char *)bootSummary->header, saveName.c_str(), sizeof(bootSummary->header));
 	bootSummary->firstScene.sceneID = 0;
 
diff --git a/engines/nancy/script/v5/bootobjects.cpp b/engines/nancy/script/v5/bootobjects.cpp
index 578c879446b..51a62847a88 100644
--- a/engines/nancy/script/v5/bootobjects.cpp
+++ b/engines/nancy/script/v5/bootobjects.cpp
@@ -346,8 +346,6 @@ void NancyEngine::bootNancy26Data(ScriptBootData *boot, EVNT *flags, INVD *inven
 	boot->rightNodeHotspot = Common::Rect(width - 47, 0, width, height - 80);
 	boot->uturnNodeHotspot = Common::Rect(0, height - 80, width, height);
 
-	boot->defaultSaveName = "Tomb";
-
 	// The scripts every scene starts with
 	static const char *const kIncludeFiles[] = { "Math_SC", "Fader_SC", "string_SC", "ScriptingShortcuts_SC" };
 	for (const char *name : kIncludeFiles) {


Commit: 4f204762321c978e67017cbb37729a3c8468acad
    https://github.com/scummvm/scummvm/commit/4f204762321c978e67017cbb37729a3c8468acad
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-11T02:34:59+02:00

Commit Message:
NANCY: NANCY26: Keep the state of the Game object in an engine object

The cheat settings, the number of restarts and the sounds that
Sound:PauseAbandoned() paused were static globals. They are now kept in
a ScriptGameState, which lives as long as the engine.

Changed paths:
    engines/nancy/script/v5/bootobjects.cpp
    engines/nancy/script/v5/gamefunctions.cpp
    engines/nancy/script/v5/gamefunctions.h


diff --git a/engines/nancy/script/v5/bootobjects.cpp b/engines/nancy/script/v5/bootobjects.cpp
index 51a62847a88..a8156e4b15c 100644
--- a/engines/nancy/script/v5/bootobjects.cpp
+++ b/engines/nancy/script/v5/bootobjects.cpp
@@ -28,6 +28,7 @@
 
 #include "engines/nancy/script/v5/bootobjects.h"
 #include "engines/nancy/script/v5/brain.h"
+#include "engines/nancy/script/v5/gamefunctions.h"
 
 #include "engines/nancy/ui/ndui/button.h"
 
@@ -300,6 +301,8 @@ static void runRequiredScript(const char *name, const Script::BootTables &tables
 // is left over from the earlier games; the exe never runs it. What it set
 // is fixed in the exe instead.
 void NancyEngine::bootNancy26Data(ScriptBootData *boot, EVNT *flags, INVD *inventory, ENVS *environments, VIEW *viewport, CVTX *autotext) {
+	_engineData.setVal("ScriptGameState", new Script::ScriptGameState());
+
 	Script::BootTables flagTables;
 	flagTables.flags = flags;
 	runRequiredScript("Flags", flagTables);
diff --git a/engines/nancy/script/v5/gamefunctions.cpp b/engines/nancy/script/v5/gamefunctions.cpp
index 7cd9690cafe..3f5a95b5a73 100644
--- a/engines/nancy/script/v5/gamefunctions.cpp
+++ b/engines/nancy/script/v5/gamefunctions.cpp
@@ -178,13 +178,11 @@ static int keyIndex(lua_State *L) {
 
 // Game
 
-// What the cheat tools switch on
-static bool s_isCheatMode = false;
-static bool s_isFastConvo = false;
-static bool s_showsDiagnostics = false;	// Nancy27
-
-// How many times a new game began since the game was started
-static uint s_numRestarts = 0;
+static ScriptGameState &getGameState() {
+	ScriptGameState *state = (ScriptGameState *)const_cast<EngineData *>(g_nancy->getEngineData("ScriptGameState"));
+	assert(state);
+	return *state;
+}
 
 // The saved games the scripts made by themselves, the second chances, which
 // the dialog for loading leaves out. ScummVM's saves have no place for that, so
@@ -308,7 +306,7 @@ static int gameAllSaves(lua_State *L) {
 }
 
 static int gameNew(lua_State *L) {
-	++s_numRestarts;
+	++getGameState().numRestarts;
 	getSaveManager(L).requestNewGame();
 	return 0;
 }
@@ -353,15 +351,15 @@ static bool pushGameField(lua_State *L, const Common::String &key) {
 		const ScriptBootData *boot = GetEngineData(ScriptBootData);
 		lua_pushstring(L, boot ? boot->buildNumber.c_str() : "");
 	} else if (key == "fastConvo") {
-		lua_pushboolean(L, s_isFastConvo);
+		lua_pushboolean(L, getGameState().isFastConvo);
 	} else if (key == "cheatMode") {
-		lua_pushboolean(L, s_isCheatMode);
+		lua_pushboolean(L, getGameState().isCheatMode);
 	} else if (key == "diags") {
-		lua_pushboolean(L, s_showsDiagnostics);
+		lua_pushboolean(L, getGameState().showsDiagnostics);
 	} else if (key == "needsSave") {
 		lua_pushboolean(L, true);
 	} else if (key == "restarts") {
-		lua_pushinteger(L, s_numRestarts);
+		lua_pushinteger(L, getGameState().numRestarts);
 	} else {
 		return false;
 	}
@@ -382,11 +380,11 @@ static int gameNewIndex(lua_State *L) {
 	const Common::String key = luaL_checkstring(L, 2);
 
 	if (key == "cheatMode") {
-		s_isCheatMode = lua_toboolean(L, 3) != 0;
+		getGameState().isCheatMode = lua_toboolean(L, 3) != 0;
 	} else if (key == "fastConvo") {
-		s_isFastConvo = lua_toboolean(L, 3) != 0;
+		getGameState().isFastConvo = lua_toboolean(L, 3) != 0;
 	} else if (key == "diags") {
-		s_showsDiagnostics = lua_toboolean(L, 3) != 0;
+		getGameState().showsDiagnostics = lua_toboolean(L, 3) != 0;
 	} else {
 		return luaL_error(L, "Field %s is not settable on Game ", key.c_str());
 	}
@@ -610,13 +608,6 @@ static int soundSetGroupVolume(lua_State *L) {
 // resume the sounds that went on playing after their records were gone, as
 // the UI pops up over the game and goes away again
 
-struct PausedChannel {
-	uint16 channel;
-	uint32 serial;
-};
-
-static Common::Array<PausedChannel> s_pausedAbandonedChannels;
-
 static void addPlayingChannels(const SceneContext *context, Common::Array<bool> &isOwned) {
 	if (!context) {
 		return;
@@ -640,23 +631,24 @@ static int soundPauseAbandoned(lua_State *L) {
 		addPlayingChannels(stream ? stream->getScriptScene() : NancySceneState.getScriptScene(), isOwned);
 	}
 
+	Common::Array<ScriptGameState::PausedChannel> &pausedChannels = getGameState().pausedAbandonedChannels;
 	for (uint16 i = 0; i < isOwned.size(); ++i) {
 		if (isOwned[i] || !g_nancy->_sound->isSoundPlaying(i)) {
 			continue;
 		}
 
 		bool isPaused = false;
-		for (const PausedChannel &paused : s_pausedAbandonedChannels) {
+		for (const ScriptGameState::PausedChannel &paused : pausedChannels) {
 			isPaused = isPaused || paused.channel == i;
 		}
 
 		if (!isPaused) {
 			g_nancy->_sound->pauseSound(i, true);
 
-			PausedChannel paused;
+			ScriptGameState::PausedChannel paused;
 			paused.channel = i;
 			paused.serial = g_nancy->_sound->getChannelSerial(i);
-			s_pausedAbandonedChannels.push_back(paused);
+			pausedChannels.push_back(paused);
 		}
 	}
 
@@ -665,13 +657,14 @@ static int soundPauseAbandoned(lua_State *L) {
 
 // A channel that got another sound in the meantime is left alone
 static int soundUnpauseAbandoned(lua_State *L) {
-	for (const PausedChannel &paused : s_pausedAbandonedChannels) {
+	Common::Array<ScriptGameState::PausedChannel> &pausedChannels = getGameState().pausedAbandonedChannels;
+	for (const ScriptGameState::PausedChannel &paused : pausedChannels) {
 		if (g_nancy->_sound->getChannelSerial(paused.channel) == paused.serial) {
 			g_nancy->_sound->pauseSound(paused.channel, false);
 		}
 	}
 
-	s_pausedAbandonedChannels.clear();
+	pausedChannels.clear();
 	return 0;
 }
 
diff --git a/engines/nancy/script/v5/gamefunctions.h b/engines/nancy/script/v5/gamefunctions.h
index 5206ea8805c..6d1375b25d4 100644
--- a/engines/nancy/script/v5/gamefunctions.h
+++ b/engines/nancy/script/v5/gamefunctions.h
@@ -22,11 +22,35 @@
 #ifndef NANCY_SCRIPT_V5_GAMEFUNCTIONS_H
 #define NANCY_SCRIPT_V5_GAMEFUNCTIONS_H
 
+#include "common/array.h"
+
+#include "engines/nancy/enginedata.h"
+
 struct lua_State;
 
 namespace Nancy {
 namespace Script {
 
+// Nancy26. What the Game and Sound objects of the scripts keep while the game
+// runs, across new games
+struct ScriptGameState : public EngineData {
+	// What the cheat tools switch on
+	bool isCheatMode = false;
+	bool isFastConvo = false;
+	bool showsDiagnostics = false;	// Nancy27
+
+	// How many times a new game began since the game was started
+	uint numRestarts = 0;
+
+	// Nancy27. The channels Sound:PauseAbandoned() paused, and the sounds on them
+	struct PausedChannel {
+		uint16 channel;
+		uint32 serial;
+	};
+
+	Common::Array<PausedChannel> pausedAbandonedChannels;
+};
+
 // What Nancy26 adds to the objects of the earlier games: the saved games and
 // settings in Game, the inventory by the names of the items, Flags:All(),
 // Key:IsDown(), the volume of the groups of sounds and more. Fields that mean


Commit: 8b02e0817c3cdcf5a922a9203bb3843854ceee7f
    https://github.com/scummvm/scummvm/commit/8b02e0817c3cdcf5a922a9203bb3843854ceee7f
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-11T02:35:00+02:00

Commit Message:
NANCY: NANCY27: Add detection entry

Marked as unstable, as the game now starts

Changed paths:
    engines/nancy/detection_tables.h


diff --git a/engines/nancy/detection_tables.h b/engines/nancy/detection_tables.h
index 6caa8ad4fd6..26c445c5020 100644
--- a/engines/nancy/detection_tables.h
+++ b/engines/nancy/detection_tables.h
@@ -920,6 +920,14 @@ static const ADGameDescription gameDescriptions[] = {
 		ADGF_UNSTABLE | ADGF_DROPPLATFORM,
 		NANCY_GUIOPTIONS
 	},
+	{ // MD5 by bluegr
+		"nancy27", nullptr,
+		AD_ENTRY1s("ciftree.dat", "3fad2155442ea49861fe00d4050a8a8e", 202097045),
+		Common::EN_ANY,
+		Common::kPlatformWindows,
+		ADGF_UNSTABLE | ADGF_DROPPLATFORM,
+		NANCY_GUIOPTIONS
+	},
 
 	// Do not delete
 	AD_TABLE_END_MARKER




More information about the Scummvm-git-logs mailing list