[Scummvm-git-logs] scummvm master -> 1037b4ce89e868a054fd3b873b4847f50b9f3115

bluegr noreply at scummvm.org
Wed Nov 25 01:14:16 UTC 2026


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

Summary:
070a927a7a NANCY: NANCY19: Don't warn about changing the scene of an ended stream
441de9bb07 NANCY: NANCY19: Add console commands for script variables
9bcb5d1d89 NANCY: NANCY19: Don't report movies that haven't started as paused
9a9571880e NANCY: NANCY19: Remove a saved value when a script saves nil
51ccf7a61a NANCY: NANCY16: Substitute Courier and italic UI fonts
3cdc7eda9b NANCY: Allow two-digit font numbers in text
7c837961d1 NANCY: NANCY16: Fix the height and alignment of multi-line UI text
d0caec7cef NANCY: NANCY19: Fix the scrolling direction of text
b519a5c949 NANCY: NANCY19: Draw long scrolling text only once
3b3c358bbe NANCY: Merge overlapping dirty rects faster
a6f021acb7 NANCY: NANCY19: Don't redraw pictures that stay on the same pixels
234064e2bb NANCY: NANCY16: Don't redraw panels while the mouse rests on them
134dc1a634 NANCY: NANCY19: Return whether the UI took a sent message
e722b1b667 NANCY: NANCY17: Pause the game while a menu covers it
5cc0bda3e1 NANCY: NANCY19: Redraw only the area particles changed
bcd8f55b0f NANCY: NANCY19: Redraw only the area a Render override changed
c8c35df9d6 NANCY: NANCY16: Redraw only the area of a panel button that changed
1037b4ce89 NANCY: NANCY16: Add a console command that shows or hides UI buttons


Commit: 070a927a7a36f6dd63b27afed24f882c1d9676c9
    https://github.com/scummvm/scummvm/commit/070a927a7a36f6dd63b27afed24f882c1d9676c9
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-25T03:13:45+02:00

Commit Message:
NANCY: NANCY19: Don't warn about changing the scene of an ended stream

A stream can end itself and change its scene in the same frame, like
the phone message in Dossier1 scene 1003. This is expected, so it no
longer logs a warning.

Changed paths:
    engines/nancy/state/scenestream.cpp
    engines/nancy/state/scenestream.h


diff --git a/engines/nancy/state/scenestream.cpp b/engines/nancy/state/scenestream.cpp
index 45428daa4f4..0eb92ad87ea 100644
--- a/engines/nancy/state/scenestream.cpp
+++ b/engines/nancy/state/scenestream.cpp
@@ -506,6 +506,16 @@ SceneStream *SceneStreamManager::find(const Common::String &name) const {
 	return nullptr;
 }
 
+bool SceneStreamManager::hasJustEnded(const Common::String &name) const {
+	for (const SceneStream *stream : _streams) {
+		if (stream && stream->isEnded() && stream->getName().equalsIgnoreCase(name)) {
+			return true;
+		}
+	}
+
+	return false;
+}
+
 void SceneStreamManager::begin(const Common::String &name, const Common::String &sceneName, uint16 frameID, const StreamFlags &flags) {
 	if (find(name)) {
 		// Already running
@@ -642,7 +652,7 @@ void SceneStreamManager::changeScene(const Common::String &name, const SceneChan
 		_running = nullptr;
 		NancySceneState.changeScene(sceneDescription);
 		_running = running;
-	} else {
+	} else if (!hasJustEnded(name)) {
 		warning("Tried to change the scene of stream %s, which is not running", name.c_str());
 	}
 }
@@ -659,7 +669,9 @@ void SceneStreamManager::changeScene(const Common::String &name, const Common::S
 		NancySceneState.changeScene(sceneName, frameID);
 		_running = running;
 #endif
-	} else {
+	} else if (!hasJustEnded(name)) {
+		// A stream can end itself and change its scene in the same frame, like
+		// Dossier1 scene 1003 when its phone message is done
 		warning("Tried to change the scene of stream %s, which is not running", name.c_str());
 	}
 }
diff --git a/engines/nancy/state/scenestream.h b/engines/nancy/state/scenestream.h
index 9bc50a62fe5..9c82b39690a 100644
--- a/engines/nancy/state/scenestream.h
+++ b/engines/nancy/state/scenestream.h
@@ -247,6 +247,8 @@ public:
 
 	// The running stream of that name; null when there is none
 	SceneStream *find(const Common::String &name) const;
+	// Whether a stream of that name ended this frame and hasn't been removed yet
+	bool hasJustEnded(const Common::String &name) const;
 
 	static const char *getMainStreamName();
 	static const char *getUIStreamName();


Commit: 441de9bb070f94403f9378bb88e2acd1eb0a9cad
    https://github.com/scummvm/scummvm/commit/441de9bb070f94403f9378bb88e2acd1eb0a9cad
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-25T03:13:45+02:00

Commit Message:
NANCY: NANCY19: Add console commands for script variables

list_vars shows the variables of the game's scripts and their values,
get_var prints one, and set_var changes one. For example, "set_var
totalScore 500000" sets the score in the Dossier games.

Changed paths:
    engines/nancy/console.cpp
    engines/nancy/console.h


diff --git a/engines/nancy/console.cpp b/engines/nancy/console.cpp
index efeba20d83c..18f13d9062e 100644
--- a/engines/nancy/console.cpp
+++ b/engines/nancy/console.cpp
@@ -19,6 +19,7 @@
  *
  */
 
+#include "common/algorithm.h"
 #include "common/system.h"
 #include "common/events.h"
 #include "common/config-manager.h"
@@ -71,6 +72,9 @@ NancyConsole::NancyConsole() : GUI::Debugger() {
 	registerCmd("script_export", WRAP_METHOD(NancyConsole, Cmd_scriptExport));
 	registerCmd("list_managers", WRAP_METHOD(NancyConsole, Cmd_listManagers));
 	registerCmd("cheat_mode", WRAP_METHOD(NancyConsole, Cmd_cheatMode));
+	registerCmd("list_vars", WRAP_METHOD(NancyConsole, Cmd_listVars));
+	registerCmd("get_var", WRAP_METHOD(NancyConsole, Cmd_getVar));
+	registerCmd("set_var", WRAP_METHOD(NancyConsole, Cmd_setVar));
 #endif
 	registerCmd("actionrecord_export", WRAP_METHOD(NancyConsole, Cmd_actionRecordExport));
 	registerCmd("scan_ar_type", WRAP_METHOD(NancyConsole, Cmd_scanForActionRecordType));
@@ -805,6 +809,96 @@ bool NancyConsole::Cmd_listRecords(int argc, const char **argv) {
 	return true;
 }
 
+// The whole numbers that the scripts of Nancy19 and later keep in VarTable; null
+// outside of a scene and in the older games
+static ScriptValueData *getScriptValues() {
+	if (g_nancy->getGameType() < kGameTypeNancy19 || g_nancy->getState() != NancyState::kScene) {
+		return nullptr;
+	}
+
+	return (ScriptValueData *)NancySceneState.getPuzzleData(ScriptValueData::getTag());
+}
+
+bool NancyConsole::Cmd_listVars(int argc, const char **argv) {
+	if (argc != 1) {
+		debugPrintf("Lists the variables of the scripts of Nancy19 and later, with their values.\n");
+		debugPrintf("Nancy1New and later name all of theirs. The older games only have the\n");
+		debugPrintf("ones their scripts have set so far.\n");
+		debugPrintf("Usage: %s\n", argv[0]);
+		return true;
+	}
+
+	const ScriptValueData *values = getScriptValues();
+	if (!values) {
+		debugPrintf("Script variables are only available in a scene of Nancy19 and later\n");
+		return true;
+	}
+
+	Common::Array<Common::String> names;
+	if (g_nancy->getGameType() >= kGameTypeNancy1New) {
+		const ScriptBootData *boot = GetEngineData(ScriptBootData);
+		for (const auto &name : boot->valueNames) {
+			names.push_back(name._key);
+		}
+	} else {
+		for (const auto &value : values->values) {
+			names.push_back(value._key);
+		}
+	}
+
+	Common::sort(names.begin(), names.end());
+	for (const Common::String &name : names) {
+		debugPrintf("%s = %d\n", name.c_str(), values->values.getValOrDefault(name, 0));
+	}
+
+	return true;
+}
+
+bool NancyConsole::Cmd_getVar(int argc, const char **argv) {
+	if (argc != 2) {
+		debugPrintf("Prints a variable of the scripts of Nancy19 and later.\n");
+		debugPrintf("Usage: %s <name>\n", argv[0]);
+		return true;
+	}
+
+	const ScriptValueData *values = getScriptValues();
+	if (!values) {
+		debugPrintf("Script variables are only available in a scene of Nancy19 and later\n");
+		return true;
+	}
+
+	debugPrintf("%s = %d\n", argv[1], values->values.getValOrDefault(argv[1], 0));
+	return true;
+}
+
+bool NancyConsole::Cmd_setVar(int argc, const char **argv) {
+	if (argc != 3) {
+		debugPrintf("Sets a variable of the scripts of Nancy19 and later.\n");
+		debugPrintf("Usage: %s <name> <value>\n", argv[0]);
+		debugPrintf("For example, %s totalScore 500000 sets the score of the Dossier games.\n", argv[0]);
+		return true;
+	}
+
+	ScriptValueData *values = getScriptValues();
+	if (!values) {
+		debugPrintf("Script variables are only available in a scene of Nancy19 and later\n");
+		return true;
+	}
+
+	// Nancy1New and later name all their variables in their boot scripts
+	if (g_nancy->getGameType() >= kGameTypeNancy1New) {
+		const ScriptBootData *boot = GetEngineData(ScriptBootData);
+		if (!boot->valueNames.contains(argv[1])) {
+			debugPrintf("This game has no variable named %s\n", argv[1]);
+			return true;
+		}
+	}
+
+	values->values.setVal(argv[1], atoi(argv[2]));
+	debugPrintf("%s = %d\n", argv[1], values->values.getVal(argv[1]));
+	return true;
+}
+
 // Nancy20: the cheat mode of the original, which the scripts ask for with
 // Game.cheatMode. It turns on views made for debugging the puzzles, like the
 // physics shapes of the Nancy22 driving game (Q).
diff --git a/engines/nancy/console.h b/engines/nancy/console.h
index 5e2a92705cc..f45f6821a06 100644
--- a/engines/nancy/console.h
+++ b/engines/nancy/console.h
@@ -61,6 +61,9 @@ private:
 	bool Cmd_scriptExport(int argc, const char **argv);
 	bool Cmd_listManagers(int argc, const char **argv);
 	bool Cmd_cheatMode(int argc, const char **argv);
+	bool Cmd_listVars(int argc, const char **argv);
+	bool Cmd_getVar(int argc, const char **argv);
+	bool Cmd_setVar(int argc, const char **argv);
 #endif
 	bool Cmd_actionRecordExport(int argc, const char **argv);
 	bool Cmd_scanForActionRecordType(int argc, const char **argv);


Commit: 9bcb5d1d891b9f1e90cb8cea308e70b57e35a599
    https://github.com/scummvm/scummvm/commit/9bcb5d1d891b9f1e90cb8cea308e70b57e35a599
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-25T03:13:46+02:00

Commit Message:
NANCY: NANCY19: Don't report movies that haven't started as paused

Up to Nancy20, a movie only counts as paused once a script pauses it
or it stops on its last frame. The last scene of Dossier1 (3010)
relies on this: it showed the light beam from the start, without the
wooden pillars that should cover it

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


diff --git a/engines/nancy/script/records.cpp b/engines/nancy/script/records.cpp
index ef40b1b61bc..7e42750621f 100644
--- a/engines/nancy/script/records.cpp
+++ b/engines/nancy/script/records.cpp
@@ -3355,7 +3355,13 @@ bool MovieRecord::getField(const Common::String &key) {
 	} else if (key == "Pause") {
 		lua_pushcfunction(L, moviePause);
 	} else if (key == "paused") {
-		lua_pushboolean(L, _isPaused || !_player.isRangePlaying());
+		// Up to Nancy20, a movie that hasn't started yet isn't paused: Dossier1
+		// scene 3010 shows its pillars until a light movie stops on its last frame
+		if (g_nancy->getGameType() < kGameTypeNancyDossier2) {
+			lua_pushboolean(L, _isPaused || _hasCalledOnPause);
+		} else {
+			lua_pushboolean(L, _isPaused || !_player.isRangePlaying());
+		}
 	} else if (key == "pauseOnLastFrame") {
 		lua_pushboolean(L, _pausesOnLastFrame);
 	} else if (key == "visible") {


Commit: 9a9571880edc81fa7cb7c9255a0b5ce2367280f1
    https://github.com/scummvm/scummvm/commit/9a9571880edc81fa7cb7c9255a0b5ce2367280f1
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-25T03:13:46+02:00

Commit Message:
NANCY: NANCY19: Remove a saved value when a script saves nil

Save:Data with nil now removes the value. Dossier1 uses this to clear
the player's name when leaving the arcade games.

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


diff --git a/engines/nancy/script/gameapi.cpp b/engines/nancy/script/gameapi.cpp
index 68b6644da45..9b30e01fe77 100644
--- a/engines/nancy/script/gameapi.cpp
+++ b/engines/nancy/script/gameapi.cpp
@@ -935,12 +935,19 @@ static int saveData(lua_State *L) {
 	const char *name = luaL_checkstring(L, 2);
 	lua_settop(L, 3);
 
+	ScriptSavedData *saved = (ScriptSavedData *)NancySceneState.getPuzzleData(ScriptSavedData::getTag());
+
+	// Saving nil removes the value: Dossier1 looks for a player's name that way
+	if (lua_isnil(L, 3)) {
+		saved->values.erase(name);
+		return 0;
+	}
+
 	Common::Array<byte> packed;
 	if (!writeSavedValue(L, 3, packed, 0)) {
 		return luaL_error(L, "Save:Data can only save tables, numbers, booleans, strings and nils");
 	}
 
-	ScriptSavedData *saved = (ScriptSavedData *)NancySceneState.getPuzzleData(ScriptSavedData::getTag());
 	saved->values.setVal(name, packed);
 	return 0;
 }


Commit: 51ccf7a61abdbd3198dd58fcc618ac9da66392fd
    https://github.com/scummvm/scummvm/commit/51ccf7a61abdbd3198dd58fcc618ac9da66392fd
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-25T03:13:47+02:00

Commit Message:
NANCY: NANCY16: Substitute Courier and italic UI fonts

Courier is now replaced with Liberation Mono, which has the same fixed
width, and fonts with "Italic" in their name get an italic substitute.
The end credits of Dossier1 use both.

Changed paths:
    engines/nancy/font.cpp


diff --git a/engines/nancy/font.cpp b/engines/nancy/font.cpp
index 154eee55c59..5dab7826bda 100644
--- a/engines/nancy/font.cpp
+++ b/engines/nancy/font.cpp
@@ -220,10 +220,15 @@ void Font::setSystemFont(const Common::String &name, const Common::String &faceN
 		debugC(1, kDebugEngine, "Could not load font file %s", fileName.toString().c_str());
 	}
 
-	// None of the Windows fonts the game asks for (Tahoma, Arial, Lucida Handwriting)
-	// ship with ScummVM, so they all get replaced with the same sans-serif font
+	// None of the Windows fonts the game asks for (Tahoma, Arial, Courier, Lucida
+	// Handwriting) ship with ScummVM. Courier gets a font of the same fixed width,
+	// and the rest the same sans-serif font, italic when the name says so.
 	const int32 kBoldWeight = 700;
-	const char *substitute = weight >= kBoldWeight ? "LiberationSans-Bold.ttf" : "LiberationSans-Regular.ttf";
+	const bool isBold = weight >= kBoldWeight;
+	const bool isItalic = faceName.hasSuffixIgnoreCase("Italic");
+	const char *style = isBold ? (isItalic ? "BoldItalic" : "Bold") : (isItalic ? "Italic" : "Regular");
+	const Common::String substitute = Common::String::format("Liberation%s-%s.ttf",
+		faceName.hasPrefixIgnoreCase("Courier") ? "Mono" : "Sans", style);
 	_systemFont.reset(Graphics::loadTTFFontFromArchive(substitute, height, Graphics::kTTFSizeModeCell), DisposeAfterUse::YES);
 #endif
 


Commit: 3cdc7eda9b51095a313ec188f3d464e25e408f09
    https://github.com/scummvm/scummvm/commit/3cdc7eda9b51095a313ec188f3d464e25e408f09
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-25T03:13:47+02:00

Commit Message:
NANCY: Allow two-digit font numbers in text

Text tags can now select fonts above 9. The end credits of Dossier1
use font 27, so they were drawn in the wrong font. A tag for a font
the game doesn't have is ignored, with a warning.

Changed paths:
    engines/nancy/misc/hypertext.cpp


diff --git a/engines/nancy/misc/hypertext.cpp b/engines/nancy/misc/hypertext.cpp
index 5a8f8222682..edb74873a9a 100644
--- a/engines/nancy/misc/hypertext.cpp
+++ b/engines/nancy/misc/hypertext.cpp
@@ -244,20 +244,28 @@ void HypertextParser::drawAllText(const Common::Rect &textBounds, uint leftOffse
 
 					metaInfo.push({MetaInfo::kColor, numNonSpaceChars, (byte)(curToken[1] - '0')});
 					continue;
-				case 'f' :
+				case 'f' : {
 					// Font token
-					// This selects a specific font ID for the following text
-					if (curToken.size() != 2) {
+					// This selects a specific font ID for the following text. The credits
+					// of Dossier1 are in font 27.
+					if (curToken.size() != 2 && !(curToken.size() == 3 && Common::isDigit(curToken[2]))) {
 						break;
 					}
 
+					const uint fontID = atoi(curToken.c_str() + 1);
+					if (!g_nancy->_graphics->getFont(fontID)) {
+						warning("Text tag <%s> selects a font that doesn't exist", curToken.c_str());
+						continue;
+					}
+
 					// A font set before any text also applies to word wrapping
 					if (numNonSpaceChars == 0) {
-						curFontID = curToken[1] - '0';
+						curFontID = fontID;
 					}
 
-					metaInfo.push({MetaInfo::kFont, numNonSpaceChars, (byte)(curToken[1] - '0')});
+					metaInfo.push({MetaInfo::kFont, numNonSpaceChars, (byte)fontID});
 					continue;
+				}
 				case 'j' : {
 					// Justification: <jl>, <jr> or <jc>
 					if (curToken.size() != 2) {


Commit: 7c837961d11f735b358bf665f482adb4d85cfff7
    https://github.com/scummvm/scummvm/commit/7c837961d11f735b358bf665f482adb4d85cfff7
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-25T03:13:47+02:00

Commit Message:
NANCY: NANCY16: Fix the height and alignment of multi-line UI text

Text height now uses the real line spacing of its font. Text that
isn't wrapped but has line breaks now gets its full height, and each
line is aligned by itself. The last line of the Dossier1 credits was
cut off without this.

Changed paths:
    engines/nancy/misc/hypertext.cpp
    engines/nancy/misc/hypertext.h
    engines/nancy/ui/ndui/element.cpp
    engines/nancy/ui/ndui/element.h


diff --git a/engines/nancy/misc/hypertext.cpp b/engines/nancy/misc/hypertext.cpp
index edb74873a9a..b643b55b595 100644
--- a/engines/nancy/misc/hypertext.cpp
+++ b/engines/nancy/misc/hypertext.cpp
@@ -580,6 +580,7 @@ void HypertextParser::drawAllText(const Common::Rect &textBounds, uint leftOffse
 
 			// Record the height of the text currently drawn. Used for textbox scrolling
 			_drawnTextHeight = (_numDrawnLines - 1) * lineStep(font) + _imageVerticalOffset;
+			_lastLineStep = lineStep(font);
 		}
 
 		// Draw the footer image(s)
diff --git a/engines/nancy/misc/hypertext.h b/engines/nancy/misc/hypertext.h
index fcfbf697dc5..3023d7f046e 100644
--- a/engines/nancy/misc/hypertext.h
+++ b/engines/nancy/misc/hypertext.h
@@ -40,6 +40,7 @@ public:
 		_highlightBackgroundColor(0),
 		_numDrawnLines(0),
 		_drawnTextHeight(0),
+		_lastLineStep(0),
 		_needsTextRedraw(false),
 		_defaultTextColor(0),
 		_imageVerticalOffset(0) {}
@@ -97,6 +98,7 @@ protected:
 
 	uint16 _numDrawnLines;
 	uint16 _drawnTextHeight;
+	uint16 _lastLineStep;	// How far apart the lines of the font drawn last are
 	bool _needsTextRedraw;
 
 	// Otherwise a line is as long as its text, and may run past the right of the bounds
diff --git a/engines/nancy/ui/ndui/element.cpp b/engines/nancy/ui/ndui/element.cpp
index 787d12284a0..a2904dd9c90 100644
--- a/engines/nancy/ui/ndui/element.cpp
+++ b/engines/nancy/ui/ndui/element.cpp
@@ -83,14 +83,14 @@ public:
 		return 0;
 	}
 
-	// The number of lines the text gets wrapped into
-	uint countLines(const Common::String &text, int width, uint fontID) {
+	// The height of the text when it gets wrapped to a width
+	int measureHeight(const Common::String &text, int width, uint fontID) {
 		_fullSurface.create(width, 1, g_nancy->_graphics->getTransparentPixelFormat());
 		addTextLine(text);
 		drawAllText(Common::Rect(width, 1), 0, fontID, fontID);
 
 		// Every text gets an empty line after it
-		return _numDrawnLines - 1;
+		return (_numDrawnLines - 1) * _lastLineStep;
 	}
 };
 
@@ -264,7 +264,15 @@ int Element::measureTextHeight(const Common::String &text, int width) const {
 	}
 
 	ElementText layout;
-	return layout.countLines(text, width, (uint)fontID) * getFontHeight();
+	return layout.measureHeight(text, width, (uint)fontID);
+}
+
+int Element::getDrawnTextHeight(const Common::String &text, int width) const {
+	if (_wordWrap) {
+		return measureTextHeight(text, width);
+	}
+
+	return text.contains("<n>") ? measureTextHeight(text, kSingleLineWidth) : getFontHeight();
 }
 
 const Graphics::Font *Element::getSystemFont() const {
@@ -292,18 +300,23 @@ void Element::drawText(Graphics::ManagedSurface &surface, const Common::String &
 	// in the rect. Wrapped text is aligned up and down in the rect like it. Text
 	// isn't cut off by a rect that is too low for it: the goal of Lights, Camera,
 	// Curses has two lines in the height of one.
-	const int textHeight = _wordWrap ? measureTextHeight(text, dest.width()) : getFontHeight();
+	const int textHeight = getDrawnTextHeight(text, dest.width());
+	const bool hasSeveralLines = !_wordWrap && text.contains("<n>");
 	ElementText layout;
 	const int renderHeight = MAX<int>(dest.height(), textHeight);
 	const Graphics::ManagedSurface &rendered = layout.render(text, _wordWrap ? dest.width() : kSingleLineWidth, renderHeight, (uint)fontID,
 		colorChannelToByte(color[1]), colorChannelToByte(color[2]), colorChannelToByte(color[3]),
-		_wordWrap ? _horizontalAlignment : (int32)ElementText::kAlignLeft, state);
+		_wordWrap || hasSeveralLines ? _horizontalAlignment : (int32)ElementText::kAlignLeft, state);
 
 	int left = dest.left;
 	int width = rendered.w;
 	int top = dest.top;
 	if (!_wordWrap) {
-		width = layout.getDrawnWidth();
+		// Each of several lines is aligned by itself, in the whole width laid out
+		if (!hasSeveralLines) {
+			width = layout.getDrawnWidth();
+		}
+
 		if (_horizontalAlignment == ElementText::kAlignCenter) {
 			left += (dest.width() - width) / 2;
 		} else if (_horizontalAlignment == ElementText::kAlignRight) {
diff --git a/engines/nancy/ui/ndui/element.h b/engines/nancy/ui/ndui/element.h
index 514eba6fea4..fe5be5963a6 100644
--- a/engines/nancy/ui/ndui/element.h
+++ b/engines/nancy/ui/ndui/element.h
@@ -64,6 +64,9 @@ public:
 
 	// The height the text takes up when it gets wrapped to the given width
 	int measureTextHeight(const Common::String &text, int width) const;
+	// The height the text takes up when drawn, which also goes for text that isn't
+	// wrapped but has several lines
+	int getDrawnTextHeight(const Common::String &text, int width) const;
 	const Graphics::Font *getSystemFont() const;
 	void setTextureName(const Common::String &textureName) { _textureName = textureName; }
 


Commit: d0caec7cef6e46f1945391136a73930719d17c1a
    https://github.com/scummvm/scummvm/commit/d0caec7cef6e46f1945391136a73930719d17c1a
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-25T03:13:48+02:00

Commit Message:
NANCY: NANCY19: Fix the scrolling direction of text

Scripts use the opposite sign for the scroll offset and speed of text,
where a positive offset moves the text down. The end credits of
Dossier1 scrolled the wrong way without this.

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 7e42750621f..f8003b52d34 100644
--- a/engines/nancy/script/records.cpp
+++ b/engines/nancy/script/records.cpp
@@ -2812,6 +2812,9 @@ void TextRecord::readTable(int tableIndex) {
 
 	readField(L, tableIndex, "yOffset", _yOffset);
 	readField(L, tableIndex, "yVelocity", _yVelocity);
+	// Scripts use the opposite sign for yOffset and yVelocity
+	_yOffset = -_yOffset;
+	_yVelocity = -_yVelocity;
 	readField(L, tableIndex, "useAutotext", _usesAutotext);
 	readField(L, tableIndex, "revealAll", _revealsAll);
 
@@ -2985,9 +2988,9 @@ bool TextRecord::getField(const Common::String &key) {
 	if (key == "onScreen") {
 		pushRect(L, _dest);
 	} else if (key == "yOffset") {
-		lua_pushnumber(L, _yOffset);
+		lua_pushnumber(L, -_yOffset);
 	} else if (key == "yVelocity") {
-		lua_pushnumber(L, _yVelocity);
+		lua_pushnumber(L, -_yVelocity);
 	} else if (key == "RevealNext") {
 		lua_pushcfunction(L, textRevealNext);
 	} else {
@@ -3006,10 +3009,10 @@ bool TextRecord::setField(const Common::String &key) {
 	} else if (key == "text") {
 		setText(luaL_checkstring(L, 3));
 	} else if (key == "yOffset") {
-		_yOffset = luaL_checknumber(L, 3);
+		_yOffset = -luaL_checknumber(L, 3);
 		_isDirty = true;
 	} else if (key == "yVelocity") {
-		_yVelocity = luaL_checknumber(L, 3);
+		_yVelocity = -luaL_checknumber(L, 3);
 	} else {
 		return false;
 	}
diff --git a/engines/nancy/script/records.h b/engines/nancy/script/records.h
index 56e2ce6ce4b..6fcb87138d0 100644
--- a/engines/nancy/script/records.h
+++ b/engines/nancy/script/records.h
@@ -560,6 +560,8 @@ private:
 	bool _isDirty = true;
 
 	ScriptRect _dest;
+	// How far the text is scrolled up. Scripts use the opposite sign: a
+	// positive offset moves the text down.
 	double _yOffset = 0.0;
 	double _yVelocity = 0.0;	// per second
 


Commit: b519a5c949443d8a46087cbfb3dc5795f6e804ed
    https://github.com/scummvm/scummvm/commit/b519a5c949443d8a46087cbfb3dc5795f6e804ed
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-25T03:13:48+02:00

Commit Message:
NANCY: NANCY19: Draw long scrolling text only once

The end credits of Dossier1 are one long text that scrolls up. It was
drawn in full on every frame, which slowed the game down. Now it is
drawn once and only the visible part is copied. The credits also run
until their last line has scrolled away, measured by the drawn height.

Changed paths:
    engines/nancy/script/records.cpp
    engines/nancy/script/records.h
    engines/nancy/ui/ndui/element.cpp


diff --git a/engines/nancy/script/records.cpp b/engines/nancy/script/records.cpp
index f8003b52d34..3c3c38f7c4b 100644
--- a/engines/nancy/script/records.cpp
+++ b/engines/nancy/script/records.cpp
@@ -2875,6 +2875,7 @@ void TextRecord::applyDest() {
 	if (_graphic._drawSurface.w != width || _graphic._drawSurface.h != height) {
 		_graphic._drawSurface.create(width, height, g_nancy->_graphics->getTransparentPixelFormat());
 		_isDirty = true;
+		_isScrollingTextDirty = true;
 	}
 
 	_graphic.moveTo(getTransformedDest(_dest, getTransform(), width, height));
@@ -2890,6 +2891,7 @@ void TextRecord::setText(const Common::String &text) {
 	_numRevealed = 0;
 	_shownText = _revealsAll ? _text : Common::String();
 	_isDirty = true;
+	_isScrollingTextDirty = true;
 }
 
 bool TextRecord::revealNext() {
@@ -2916,12 +2918,14 @@ bool TextRecord::revealNext() {
 	_shownText += _text.substr(_numRevealed, end - _numRevealed);
 	_numRevealed = end;
 	_isDirty = true;
+	_isScrollingTextDirty = true;
 	return true;
 }
 
 void TextRecord::run(double sceneTime, double elapsedTime) {
 	if (_element.blend(UI::NDUI::kStateNormal, (float)elapsedTime, kTextBlendRate)) {
 		_isDirty = true;
+		_isScrollingTextDirty = true;
 	}
 
 	if (_yVelocity == 0.0) {
@@ -2933,7 +2937,7 @@ void TextRecord::run(double sceneTime, double elapsedTime) {
 
 	// A text that moves is done once it has left its place
 	const Common::Rect dest = _dest.toRect();
-	const int textHeight = _element.measureTextHeight(_shownText, dest.width());
+	const int textHeight = _isScrollingTextDirty ? _element.getDrawnTextHeight(_shownText, dest.width()) : _scrollingText.h;
 	if ((_yOffset > textHeight && _yVelocity > 0.0) || (_yOffset < -dest.height() && _yVelocity < 0.0)) {
 		finish();
 	}
@@ -2954,15 +2958,49 @@ void TextRecord::updateGraphics() {
 	if (_isDirty) {
 		_isDirty = false;
 
-		Common::Rect area(_graphic._drawSurface.w, _graphic._drawSurface.h);
-		area.translate(0, -(int)_yOffset);
-
 		_graphic._drawSurface.clear(0);
-		_element.drawText(_graphic._drawSurface, _shownText, area, false);
+		if (!drawScrollingText()) {
+			Common::Rect area(_graphic._drawSurface.w, _graphic._drawSurface.h);
+			area.translate(0, -(int)_yOffset);
+			_element.drawText(_graphic._drawSurface, _shownText, area, false);
+		}
+
 		_graphic.setNeedsRedraw(true);
 	}
 }
 
+// Returns false for a text that fits in the record, which gets drawn as usual
+bool TextRecord::drawScrollingText() {
+	if (_yVelocity == 0.0) {
+		return false;
+	}
+
+	const int width = _graphic._drawSurface.w;
+	const int height = _graphic._drawSurface.h;
+	if (_isScrollingTextDirty) {
+		_isScrollingTextDirty = false;
+
+		const int textHeight = MAX<int>(_element.getDrawnTextHeight(_shownText, width), 1);
+		_scrollingText.create(width, textHeight, _graphic._drawSurface.format);
+		_scrollingText.clear(0);
+		if (textHeight > height) {
+			_element.drawText(_scrollingText, _shownText, Common::Rect(width, textHeight), false);
+		}
+	}
+
+	if (_scrollingText.h <= height) {
+		return false;
+	}
+
+	const int scroll = (int)_yOffset;
+	const Common::Rect source(0, MAX<int>(scroll, 0), width, MIN<int>(scroll + height, _scrollingText.h));
+	if (source.top < source.bottom) {
+		_graphic._drawSurface.copyRectToSurface(_scrollingText.rawSurface(), 0, source.top - scroll, source);
+	}
+
+	return true;
+}
+
 bool TextRecord::prepareReset() {
 	_dest = _initialDest;
 	_yOffset = _initialYOffset;
diff --git a/engines/nancy/script/records.h b/engines/nancy/script/records.h
index 6fcb87138d0..e02dd66b0d0 100644
--- a/engines/nancy/script/records.h
+++ b/engines/nancy/script/records.h
@@ -554,11 +554,17 @@ protected:
 private:
 	void setText(const Common::String &text);
 	void applyDest();
+	bool drawScrollingText();
 
 	UI::NDUI::Element _element;
 	RecordGraphic _graphic;
 	bool _isDirty = true;
 
+	// A text taller than the record, like the credits, is drawn once and then
+	// only the part that shows gets copied
+	Graphics::ManagedSurface _scrollingText;
+	bool _isScrollingTextDirty = true;
+
 	ScriptRect _dest;
 	// How far the text is scrolled up. Scripts use the opposite sign: a
 	// positive offset moves the text down.
diff --git a/engines/nancy/ui/ndui/element.cpp b/engines/nancy/ui/ndui/element.cpp
index a2904dd9c90..98c60a5dd5f 100644
--- a/engines/nancy/ui/ndui/element.cpp
+++ b/engines/nancy/ui/ndui/element.cpp
@@ -340,11 +340,10 @@ void Element::drawText(Graphics::ManagedSurface &surface, const Common::String &
 				continue;
 			}
 
-			for (int x = 0; x < width; ++x) {
+			const int firstX = MAX<int>(0, -(left + offset));
+			const int endX = MIN<int>(width, surface.w - (left + offset));
+			for (int x = firstX; x < endX; ++x) {
 				int destX = left + x + offset;
-				if (destX < 0 || destX >= surface.w) {
-					continue;
-				}
 
 				byte a, r, g, b;
 				rendered.format.colorToARGB(rendered.getPixel(x, y), a, r, g, b);


Commit: 3b3c358bbef9e69891ebd6848453b96cd9bcc4f1
    https://github.com/scummvm/scummvm/commit/3b3c358bbef9e69891ebd6848453b96cd9bcc4f1
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-25T03:13:48+02:00

Commit Message:
NANCY: Merge overlapping dirty rects faster

Overlapping dirty rects are merged so that no area gets drawn twice.
After each merge, the old loop started over from the first rect. With
the many small rects of particles, this slowed the game down. Now each
rect takes in all the rects it overlaps before the loop moves on.

Changed paths:
    engines/nancy/graphics.cpp


diff --git a/engines/nancy/graphics.cpp b/engines/nancy/graphics.cpp
index 153d5ebe056..9f420846ff4 100644
--- a/engines/nancy/graphics.cpp
+++ b/engines/nancy/graphics.cpp
@@ -245,21 +245,24 @@ bool GraphicsManager::isInLayer(const RenderObject &object, Layer layer) const {
 void GraphicsManager::filterDirtyRects(Common::List<Common::Rect> &rects) {
 	// Rects that overlap are merged into one. An area that gets drawn twice would
 	// have the objects with an alpha channel blended onto it twice.
-	bool hasMerged;
-	do {
-		hasMerged = false;
-
-		for (auto outer = rects.begin(); outer != rects.end() && !hasMerged; ++outer) {
-			for (auto inner = rects.begin(); inner != rects.end(); ++inner) {
+	// A rect is done once it overlaps no other. One that grows later on checks
+	// all the rects again, including the ones that were done.
+	for (auto outer = rects.begin(); outer != rects.end(); ++outer) {
+		bool hasGrown;
+		do {
+			hasGrown = false;
+
+			for (auto inner = rects.begin(); inner != rects.end();) {
 				if (inner != outer && outer->intersects(*inner)) {
 					outer->extend(*inner);
-					rects.erase(inner);
-					hasMerged = true;
-					break;
+					inner = rects.erase(inner);
+					hasGrown = true;
+				} else {
+					++inner;
 				}
 			}
-		}
-	} while (hasMerged);
+		} while (hasGrown);
+	}
 }
 
 // Perform the actual drawing. This checks for cases where something would be fully obscured,


Commit: a6f021acb73d07038357986177b553fa55b9f82c
    https://github.com/scummvm/scummvm/commit/a6f021acb73d07038357986177b553fa55b9f82c
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-25T03:13:49+02:00

Commit Message:
NANCY: NANCY19: Don't redraw pictures that stay on the same pixels

Scripts can move a picture by less than a pixel per frame, like the
pieces of the Dossier1 DataMine puzzle. Each of these moves redrew the
picture, even though it looked the same until it reached another whole
pixel. This made the puzzle slow. Such moves now only store the new
position.

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 3c3c38f7c4b..8405b34ce97 100644
--- a/engines/nancy/script/records.cpp
+++ b/engines/nancy/script/records.cpp
@@ -2097,6 +2097,19 @@ bool OverlayRecord::setPicture(const Common::String &imageName) {
 	return true;
 }
 
+// Scripts can move a picture by less than a pixel per frame, like the pieces of
+// the Dossier1 DataMine puzzle. A plain picture only looks different once it
+// reaches another whole pixel. From Nancy26 on, records can also have an alpha.
+bool OverlayRecord::staysOnSamePixels(const ScriptRect &dest) {
+	if (g_nancy->getGameType() >= kGameTypeNancy26 || _modColor != kNoModColor) {
+		return false;
+	}
+
+	const ScriptMatrix transform = getTransform();
+	return transform.isTranslation() &&
+		getTransformedDest(dest, transform, 0, 0) == getTransformedDest(_dest, transform, 0, 0);
+}
+
 bool OverlayRecord::setField(const Common::String &key) {
 	lua_State *L = getLua();
 
@@ -2120,7 +2133,11 @@ bool OverlayRecord::setField(const Common::String &key) {
 				return true;
 			}
 
+			const bool isOnSamePixels = staysOnSamePixels(dest);
 			_dest = dest;
+			if (isOnSamePixels) {
+				return true;
+			}
 		}
 	} else if (key == "source") {
 		const ScriptRect source = checkRect(L, 3);
diff --git a/engines/nancy/script/records.h b/engines/nancy/script/records.h
index e02dd66b0d0..8a4d50267f6 100644
--- a/engines/nancy/script/records.h
+++ b/engines/nancy/script/records.h
@@ -323,6 +323,7 @@ private:
 	void readDest(int index);
 	void readDestTable(Common::Array<ScriptRect> &dests);
 	void applyRects();
+	bool staysOnSamePixels(const ScriptRect &dest);
 	bool setPicture(const Common::String &imageName);
 
 #ifdef ENABLE_NANCY_V5


Commit: 234064e2bbf003468cc6e0a7633185740f7b44e7
    https://github.com/scummvm/scummvm/commit/234064e2bbf003468cc6e0a7633185740f7b44e7
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-25T03:13:49+02:00

Commit Message:
NANCY: NANCY16: Don't redraw panels while the mouse rests on them

Each frame the mouse was over a control, the whole panel got redrawn.
With a large panel such as the Exit menu of the Dossier1 arcade, the
mouse cursor became choppy. Panels are now redrawn on clicks and wheel
moves, and list boxes redraw when the hovered item changes.

Changed paths:
    engines/nancy/ui/ndui/listbox.cpp
    engines/nancy/ui/ndui/panel.cpp


diff --git a/engines/nancy/ui/ndui/listbox.cpp b/engines/nancy/ui/ndui/listbox.cpp
index 44ea533cc03..d200ba8dc79 100644
--- a/engines/nancy/ui/ndui/listbox.cpp
+++ b/engines/nancy/ui/ndui/listbox.cpp
@@ -174,7 +174,11 @@ void ListBox::draw(Graphics::ManagedSurface &surface, const Common::Point &offse
 
 void ListBox::onMouseHover(const Common::Point &pos) {
 	Common::Rect text = getTextBounds();
-	_hovered = (pos.x >= text.left && pos.x < text.right) ? getItemAt(pos) : -1;
+	const int hovered = (pos.x >= text.left && pos.x < text.right) ? getItemAt(pos) : -1;
+	if (hovered != _hovered) {
+		_hovered = hovered;
+		_panel->setDirty();
+	}
 }
 
 bool ListBox::onMouseDown(const Common::Point &pos) {
diff --git a/engines/nancy/ui/ndui/panel.cpp b/engines/nancy/ui/ndui/panel.cpp
index 0dcd497f2ea..8fc805548d3 100644
--- a/engines/nancy/ui/ndui/panel.cpp
+++ b/engines/nancy/ui/ndui/panel.cpp
@@ -929,6 +929,12 @@ bool Panel::handleInput(NancyInput &input, bool canHover, bool &isOverControl) {
 		isOverControl = true;
 		hovered->onMouseHover(pos);
 
+		// Resting the mouse on a control changes nothing by itself, and redrawing
+		// a large panel every frame slows down the game
+		if ((input.input & NancyInput::kLeftMouseButtonDown) || notches) {
+			_isDirty = true;
+		}
+
 		if ((input.input & NancyInput::kLeftMouseButtonDown) && hovered->onMouseDown(pos)) {
 			_capture = hovered;
 		}
@@ -936,8 +942,6 @@ bool Panel::handleInput(NancyInput &input, bool canHover, bool &isOverControl) {
 		if (notches && hovered->onWheel(notches)) {
 			notches = 0;
 		}
-
-		_isDirty = true;
 	} else if (_enabled && (input.input & NancyInput::kLeftMouseButtonUp)) {
 		// A click on the panel itself reports no value
 		_background->fireEvents(kEventClicked, false, -1, getName());


Commit: 134dc1a634d5264e3f720fc7ffb952264c5f1c0a
    https://github.com/scummvm/scummvm/commit/134dc1a634d5264e3f720fc7ffb952264c5f1c0a
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-25T03:13:49+02:00

Commit Message:
NANCY: NANCY19: Return whether the UI took a sent message

Message:Send returned false for every message that went to the UI.
The dialog that dims the screen stops disabling panels at the first
message that wasn't taken, so the panels under the Dossier1 arcade
menu still reacted to the mouse.

Changed paths:
    engines/nancy/script/gameapi.cpp
    engines/nancy/ui/ndui/manager.cpp
    engines/nancy/ui/ndui/manager.h


diff --git a/engines/nancy/script/gameapi.cpp b/engines/nancy/script/gameapi.cpp
index 9b30e01fe77..3e22c18e48a 100644
--- a/engines/nancy/script/gameapi.cpp
+++ b/engines/nancy/script/gameapi.cpp
@@ -2016,7 +2016,7 @@ static const luaL_Reg kSceneFunctions[] = {
 };
 
 // Hands a message to the scene or the record it is for, or else to the UI.
-// Returns whether a scene or a record took it.
+// Returns whether any of them took it.
 static bool deliverMessage(lua_State *L, const char *actionName, UI::NDUI::Action &action) {
 	// The targets that answer do so to the control whose event is being handled
 	UI::NDUI::Manager *ui = NancySceneState.getNDUI();
@@ -2049,7 +2049,9 @@ static bool deliverMessage(lua_State *L, const char *actionName, UI::NDUI::Actio
 	}
 
 	if (!hasReceiver && ui) {
-		ui->takeAction(action);
+		// Scripts go by whether the UI took it: the dialog that dims the screen
+		// stops disabling panels at the first one that didn't
+		wasTaken = ui->takeAction(action);
 	}
 
 	return wasTaken;
diff --git a/engines/nancy/ui/ndui/manager.cpp b/engines/nancy/ui/ndui/manager.cpp
index d926aada510..245d6e49135 100644
--- a/engines/nancy/ui/ndui/manager.cpp
+++ b/engines/nancy/ui/ndui/manager.cpp
@@ -163,19 +163,20 @@ void Manager::updateTooltip(const Common::Point &mousePos) {
 	_tooltipWindow.setVisible(show);
 }
 
-void Manager::takeAction(const Action &action) {
+bool Manager::takeAction(const Action &action) {
 	if (action.target.hasPrefixIgnoreCase("Engine_")) {
 		takeEngineAction(action);
-		return;
+		return true;
 	}
 
 	for (Panel *panel : _panels) {
 		if (panel->takeAction(action)) {
-			return;
+			return true;
 		}
 	}
 
 	debugC(1, kDebugEngine, "Unhandled NDUI action %d on \"%s\" from \"%s\"", action.type, action.target.c_str(), action.sender.c_str());
+	return false;
 }
 
 void Manager::takeAction(int32 type, const Common::String &target, double value) {
diff --git a/engines/nancy/ui/ndui/manager.h b/engines/nancy/ui/ndui/manager.h
index 4f573bb90d7..43b68c67c67 100644
--- a/engines/nancy/ui/ndui/manager.h
+++ b/engines/nancy/ui/ndui/manager.h
@@ -136,7 +136,8 @@ public:
 	const Common::String &getEventSender() const { return _eventSender; }
 	void setEventSender(const Common::String &sender) { _eventSender = sender; }
 
-	void takeAction(const Action &action);
+	// Returns whether anything took the action
+	bool takeAction(const Action &action);
 	void takeAction(int32 type, const Common::String &target, double value);
 	void takeAction(int32 type, const Common::String &target, const Common::String &text);
 	void handleInput(NancyInput &input);


Commit: e722b1b6673d3c5326e9a76577750643c8a17a91
    https://github.com/scummvm/scummvm/commit/e722b1b6673d3c5326e9a76577750643c8a17a91
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-25T03:13:50+02:00

Commit Message:
NANCY: NANCY17: Pause the game while a menu covers it

The dialog that dims the screen, like the Exit menu of the Dossier1
arcade, disables the game window. The original pauses the game then:
its scripts and the in-game time stop, sounds and movies pause, and the
game behind the menu gets no input. Up to Nancy20, the total play time
stops too. NDUI panels use the system clock for their timing.

Changed paths:
    engines/nancy/state/scene.cpp
    engines/nancy/state/scene.h
    engines/nancy/state/scenestream.cpp
    engines/nancy/state/scenestream.h
    engines/nancy/ui/ndui/listbox.cpp
    engines/nancy/ui/ndui/manager.cpp
    engines/nancy/ui/ndui/panel.cpp
    engines/nancy/ui/ndui/saveload.cpp


diff --git a/engines/nancy/state/scene.cpp b/engines/nancy/state/scene.cpp
index 52a5c41e7f5..cbc5bab607e 100644
--- a/engines/nancy/state/scene.cpp
+++ b/engines/nancy/state/scene.cpp
@@ -2459,7 +2459,7 @@ void Scene::loadScriptedScene(bool fromSaveFile) {
 void Scene::processMainStream() {
 #ifdef ENABLE_NANCY_V4
 	if (_scriptScene) {
-		_scriptScene->run(_frameSeconds);
+		_scriptScene->run(_isGamePaused ? 0.0 : _frameSeconds);
 
 		if (_isProfileChangePending && _scriptScene->getTime() > 0.0) {
 			finishProfileChange();
@@ -2539,6 +2539,23 @@ void Scene::finishProfileChange() {
 }
 #endif
 
+double Scene::getStreamFrameSeconds(const Common::String &streamName) const {
+	return _isGamePaused && !streamName.equalsIgnoreCase(SceneStreamManager::getUIStreamName()) ? 0.0 : _frameSeconds;
+}
+
+void Scene::setGamePaused(bool isPaused) {
+	if (isPaused != _isGamePaused) {
+		_isGamePaused = isPaused;
+		g_nancy->_sound->pauseAllSounds(isPaused);
+
+		// The movies of later games run on the time of their stream
+		if (g_nancy->getGameType() <= kGameTypeNancy18) {
+			_actionManager.onPause(isPaused);
+			_streams.onPause(isPaused);
+		}
+	}
+}
+
 void Scene::run() {
 	if (_gameStateRequested != NancyState::kNone) {
 		g_nancy->setState(_gameStateRequested);
@@ -2546,7 +2563,14 @@ void Scene::run() {
 		return;
 	}
 
-	Time currentPlayTime = g_nancy->getTotalPlayTime();
+	// Up to Nancy20, a pause stops the clock of the whole game. Later games
+	// stop what runs in the game window, and the in-game time.
+	const bool isClockStopped = _isGamePaused && g_nancy->getGameType() <= kGameTypeNancy20;
+	if (isClockStopped) {
+		g_nancy->setTotalPlayTime(_timers.lastTotalTime.getTotalMilliseconds());
+	}
+
+	Time currentPlayTime = isClockStopped ? _timers.lastTotalTime : Time(g_nancy->getTotalPlayTime());
 	Time deltaTime = currentPlayTime - _timers.lastTotalTime;
 	_timers.lastTotalTime = currentPlayTime;
 
@@ -2561,8 +2585,11 @@ void Scene::run() {
 	// so any flags they fire this frame are visible to record dependencies
 	tickSoftwareTimers(deltaTime.getTotalMilliseconds());
 
-	// Calculate the in-game time (playerTime)
-	if (currentPlayTime > _timers.playerTimeNextMinute) {
+	// Calculate the in-game time (playerTime). It stands still while a menu has
+	// paused the game, and the rest of the minute is kept for later.
+	if (_isGamePaused) {
+		_timers.playerTimeNextMinute += deltaTime;
+	} else if (currentPlayTime > _timers.playerTimeNextMinute) {
 		auto *bootSummary = GetEngineData(BSUM);
 		assert(bootSummary);
 
@@ -3029,6 +3056,11 @@ void Scene::handleInput() {
 		_cellPhonePopup.handleInput(input);
 	}
 
+	// What is behind the menu that paused the game doesn't get the input
+	if (_isGamePaused) {
+		return;
+	}
+
 	if (g_nancy->getGameType() <= kGameTypeNancy15) {
 		_textbox.handleInput(input);
 	}
@@ -3332,6 +3364,9 @@ void Scene::initUI() {
 	auto *pcui = GetEngineData(PCUI);
 	assert(pcui);
 
+	// The menu that paused the game goes away with the old UI
+	setGamePaused(false);
+
 	delete _ndui;
 	_ndui = new UI::NDUI::Manager();
 
diff --git a/engines/nancy/state/scene.h b/engines/nancy/state/scene.h
index 2af2f495fd7..06421c01f37 100644
--- a/engines/nancy/state/scene.h
+++ b/engines/nancy/state/scene.h
@@ -347,6 +347,13 @@ public:
 	void processMainStream();
 	double getFrameSeconds() const { return _frameSeconds; }
 
+	// How long the last frame took for a stream: no time passes for the game
+	// while a menu has paused it, but the UI stream of later games keeps going
+	double getStreamFrameSeconds(const Common::String &streamName) const;
+
+	// Stops the game and its sounds, while a menu covers it
+	void setGamePaused(bool isPaused);
+
 	SceneChangeDescription &getSceneInfo() { return _streams.getRunning() ? _streams.getRunning()->getSceneInfo() : _sceneState.currentScene; }
 	const SceneChangeDescription &getMainSceneInfo() const { return _sceneState.currentScene; }
 
@@ -606,6 +613,7 @@ private:
 	Common::String _nextScriptSceneName;
 #endif
 	double _frameSeconds = 0.0;	// how long the last frame took
+	bool _isGamePaused = false;
 	Action::PlaySecondaryMovie *_activeMovie;
 	Action::ConversationSound *_activeConversation;
 
diff --git a/engines/nancy/state/scenestream.cpp b/engines/nancy/state/scenestream.cpp
index 0eb92ad87ea..7eea5fd984a 100644
--- a/engines/nancy/state/scenestream.cpp
+++ b/engines/nancy/state/scenestream.cpp
@@ -102,7 +102,7 @@ bool SceneStream::loadNextScene() {
 void SceneStream::processRecords() {
 #ifdef ENABLE_NANCY_V4
 	if (_scriptScene) {
-		_scriptScene->run(NancySceneState.getFrameSeconds());
+		_scriptScene->run(NancySceneState.getStreamFrameSeconds(getName()));
 		return;
 	}
 #endif
@@ -741,6 +741,14 @@ static void returnViewedItem(const Common::String &streamName) {
 	}
 }
 
+void SceneStreamManager::onPause(bool isPaused) {
+	for (SceneStream *stream : _streams) {
+		if (stream) {
+			stream->onPause(isPaused);
+		}
+	}
+}
+
 void SceneStreamManager::process() {
 	if (_streams.empty()) {
 		NancySceneState.processMainStream();
diff --git a/engines/nancy/state/scenestream.h b/engines/nancy/state/scenestream.h
index 9c82b39690a..b538066df2a 100644
--- a/engines/nancy/state/scenestream.h
+++ b/engines/nancy/state/scenestream.h
@@ -104,6 +104,7 @@ public:
 
 	// Nancy19: the scripts of the scene store what they keep in a saved game
 	void onSave();
+	void onPause(bool isPaused) { _actionManager.onPause(isPaused); }
 
 	// Nancy19: hands a message to the scene. Returns false when it isn't for it.
 	bool receiveMessage(const Script::Message &message, bool &wasTaken);
@@ -232,6 +233,7 @@ public:
 	SceneStream *getRunning() const { return _running; }
 
 	void process();
+	void onPause(bool isPaused);
 	bool handleInput(NancyInput &input, bool beforeMainStream);
 
 	void clear();
diff --git a/engines/nancy/ui/ndui/listbox.cpp b/engines/nancy/ui/ndui/listbox.cpp
index d200ba8dc79..8cdb369f41d 100644
--- a/engines/nancy/ui/ndui/listbox.cpp
+++ b/engines/nancy/ui/ndui/listbox.cpp
@@ -19,6 +19,8 @@
  *
  */
 
+#include "common/system.h"
+
 #include "engines/nancy/graphics.h"
 #include "engines/nancy/nancy.h"
 #include "engines/nancy/util.h"
@@ -195,7 +197,7 @@ bool ListBox::onMouseDown(const Common::Point &pos) {
 	// A second click on the same item, shortly after the first
 	static const uint32 kDoubleClickTime = 500;
 
-	const uint32 now = g_nancy->getTotalPlayTime();
+	const uint32 now = g_system->getMillis();
 	const bool isDoubleClick = item == _lastClicked && now - _lastClickTime <= kDoubleClickTime;
 	_lastClicked = isDoubleClick ? -1 : item;
 	_lastClickTime = now;
diff --git a/engines/nancy/ui/ndui/manager.cpp b/engines/nancy/ui/ndui/manager.cpp
index 245d6e49135..132d38f5fe9 100644
--- a/engines/nancy/ui/ndui/manager.cpp
+++ b/engines/nancy/ui/ndui/manager.cpp
@@ -22,6 +22,7 @@
 #include "common/debug.h"
 #include "common/events.h"
 #include "common/memstream.h"
+#include "common/system.h"
 
 #include "engines/nancy/nancy.h"
 #include "engines/nancy/resource/resource.h"
@@ -128,7 +129,7 @@ void Manager::setHoveredTooltip(const Control *control, Tooltip *tooltip) {
 }
 
 void Manager::updateTooltip(const Common::Point &mousePos) {
-	const uint32 now = g_nancy->getTotalPlayTime();
+	const uint32 now = g_system->getMillis();
 
 	if (_hoveredControl != _tooltipControl) {
 		// Another control starts over
diff --git a/engines/nancy/ui/ndui/panel.cpp b/engines/nancy/ui/ndui/panel.cpp
index 8fc805548d3..593c5d1dd9d 100644
--- a/engines/nancy/ui/ndui/panel.cpp
+++ b/engines/nancy/ui/ndui/panel.cpp
@@ -26,6 +26,7 @@
 
 #include "common/algorithm.h"
 #include "common/memstream.h"
+#include "common/system.h"
 
 #include "engines/nancy/ui/ndui/panel.h"
 #include "engines/nancy/ui/ndui/control.h"
@@ -823,7 +824,8 @@ int Panel::getCheckedRadioIndex(const Common::String &group) const {
 }
 
 void Panel::updateGraphics() {
-	uint32 now = g_nancy->getTotalPlayTime();
+	// Not the play time: up to Nancy20, it stops while a menu pauses the game
+	uint32 now = g_system->getMillis();
 	if (_lastUpdateTime == 0) {
 		_lastUpdateTime = now;
 	}
diff --git a/engines/nancy/ui/ndui/saveload.cpp b/engines/nancy/ui/ndui/saveload.cpp
index 65ece2cb291..7bc4f9e2fe0 100644
--- a/engines/nancy/ui/ndui/saveload.cpp
+++ b/engines/nancy/ui/ndui/saveload.cpp
@@ -681,6 +681,15 @@ void Manager::onGameWindowAction(const Action &action) {
 	case kActionSetValue:
 		ConfMan.setInt("matte_color", (int)action.value);
 		applyMatteColor();
+		break;
+	case kActionEnable:
+	case kActionDisable:
+		// The dialog that dims the screen disables the game window, which pauses
+		// the game. Nancy16 does nothing for it.
+		if (g_nancy->getGameType() >= kGameTypeNancy17) {
+			NancySceneState.setGamePaused(action.type == kActionDisable);
+		}
+
 		break;
 	case kActionQuery: {
 		const Graphics::PixelFormat &format = g_nancy->_graphics->getTransparentPixelFormat();


Commit: 5cc0bda3e1a2c70c2be6f8a7fb3777e6a2af9622
    https://github.com/scummvm/scummvm/commit/5cc0bda3e1a2c70c2be6f8a7fb3777e6a2af9622
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-25T03:13:50+02:00

Commit Message:
NANCY: NANCY19: Redraw only the area particles changed

Particles are drawn on a transparent picture as large as the viewport.
Each frame redrew all of it, along with everything under it, which
slowed games with particles down. Now only the area the particles
were in and the area they are in now get redrawn. The particles also
stop redrawing while the game is paused.

Changed paths:
    engines/nancy/graphics.cpp
    engines/nancy/renderobject.cpp
    engines/nancy/renderobject.h
    engines/nancy/script/particles.cpp


diff --git a/engines/nancy/graphics.cpp b/engines/nancy/graphics.cpp
index 9f420846ff4..e5d82dbf7b4 100644
--- a/engines/nancy/graphics.cpp
+++ b/engines/nancy/graphics.cpp
@@ -164,6 +164,8 @@ void GraphicsManager::draw(bool updateScreen) {
 
 		if (current.needsRedraw()) {
 			const Common::Rect &drawnPosition = current.getDrawnScreenPosition();
+			Common::Rect changed = current.getChangedArea();
+			changed.translate(current.getScreenPosition().left, current.getScreenPosition().top);
 			if (current.isVisible()) {
 				if (!drawnPosition.isEmpty() && drawnPosition != current.getScreenPosition()) {
 					// Object moved to a new location on screen, update the previous one
@@ -171,14 +173,15 @@ void GraphicsManager::draw(bool updateScreen) {
 				}
 
 				// Redraw the current location
-				addDirtyRect(current, current.getScreenPosition());
+				addDirtyRect(current, changed.isEmpty() ? current.getScreenPosition() : changed);
 			} else if (!drawnPosition.isEmpty()) {
 				// Object just turned invisible, redraw the last location. An object
 				// that stays invisible has nothing to clean up, however often it changes.
-				addDirtyRect(current, drawnPosition);
+				addDirtyRect(current, changed.isEmpty() ? drawnPosition : changed);
 			}
 		}
 
+		current.clearChangedArea();
 		current.setDrawnScreenPosition(current.isVisible() ? current.getScreenPosition() : Common::Rect());
 		current.setNeedsRedraw(false);
 		current.setHasMoved(false);
diff --git a/engines/nancy/renderobject.cpp b/engines/nancy/renderobject.cpp
index 5c3e32775f2..c4fd2c013e0 100644
--- a/engines/nancy/renderobject.cpp
+++ b/engines/nancy/renderobject.cpp
@@ -164,6 +164,14 @@ void RenderObject::setPalette(const byte *colors, uint paletteStart, uint palett
 	}
 }
 
+void RenderObject::addChangedArea(const Common::Rect &area) {
+	if (_changedArea.isEmpty()) {
+		_changedArea = area;
+	} else if (!area.isEmpty()) {
+		_changedArea.extend(area);
+	}
+}
+
 Common::Rect RenderObject::getScreenPosition() const {
 	return convertPositionToScreen(_screenPosition);
 }
diff --git a/engines/nancy/renderobject.h b/engines/nancy/renderobject.h
index f4a36cade3f..7a67acbab64 100644
--- a/engines/nancy/renderobject.h
+++ b/engines/nancy/renderobject.h
@@ -86,6 +86,13 @@ public:
 	bool needsRedraw() const { return _needsRedraw; }
 	void setNeedsRedraw(bool needsRedraw) { _needsRedraw = needsRedraw; }
 
+	// The part of the picture that changed, for a large one that is mostly
+	// transparent. Only that part of the screen gets drawn again; when it's
+	// empty, all of the object does.
+	void addChangedArea(const Common::Rect &area);
+	const Common::Rect &getChangedArea() const { return _changedArea; }
+	void clearChangedArea() { _changedArea = Common::Rect(); }
+
 	void setHasMoved(bool hasMoved) { _hasMoved = hasMoved; }
 
 	// Nancy16 scales the game up to fit the screen; these objects get drawn at the
@@ -151,6 +158,7 @@ public:
 
 protected:
 	bool _needsRedraw;
+	Common::Rect _changedArea;
 	bool _isVisible;
 	bool _hasMoved;
 	bool _isNativeResolution = false;
diff --git a/engines/nancy/script/particles.cpp b/engines/nancy/script/particles.cpp
index c9ef900e76f..f8daa66e2ea 100644
--- a/engines/nancy/script/particles.cpp
+++ b/engines/nancy/script/particles.cpp
@@ -1290,6 +1290,15 @@ void registerParticleAPI(lua_State *L) {
 	registerType(L, kParticleStageType, kParticleStageFunctions);
 }
 
+// The picture of the particles is as large as the viewport and mostly transparent.
+// Only the areas they were in and are in now get drawn again.
+static void showCanvas(RecordGraphic &canvas, const Common::Rect &previousArea, const Common::Rect &drawnArea) {
+	canvas.setVisible(true, false);
+	canvas.addChangedArea(previousArea);
+	canvas.addChangedArea(drawnArea);
+	canvas.setNeedsRedraw(!canvas.getChangedArea().isEmpty());
+}
+
 // The particles are drawn on a picture as large as the viewport, which is
 // started over every frame
 void ParticleRecord::registerGraphics() {
@@ -1301,7 +1310,8 @@ void ParticleRecord::registerGraphics() {
 void ParticleRecord::updateGraphics() {
 	if (!isShown() || _count == 0) {
 		if (_canvas) {
-			_canvas->setVisible(false);
+			_canvas->addChangedArea(_drawnArea);
+			_canvas->setVisible(false, false);
 		}
 
 		return;
@@ -1333,13 +1343,13 @@ void ParticleRecord::updateGraphics() {
 		_canvas->_drawSurface.fillRect(_drawnArea, 0);
 	}
 
+	const Common::Rect previousArea = _drawnArea;
 	_drawnArea = Common::Rect();
 	for (uint i = 0; i < _count; ++i) {
 		drawParticle(_particles[(_first + i) % _particles.size()], transform, _drawnArea);
 	}
 
-	_canvas->setVisible(true);
-	_canvas->setNeedsRedraw(true);
+	showCanvas(*_canvas, previousArea, _drawnArea);
 }
 
 // Where a corner of a particle ends up in the viewport. Returns false when it is
@@ -1681,6 +1691,8 @@ void ParticleEmitterRecord::runStage(const Stage &stage, double sceneTime, doubl
 // What is left over of a particle a frame goes on to the next. A frame makes no
 // more than a tenth of the particles of a second.
 void ParticleEmitterRecord::run(double sceneTime, double elapsedTime) {
+	const uint numParticles = _particles.size();
+
 	if (_frequency > 0.0) {
 		const double due = (elapsedTime + _emitClock) * _frequency;
 		const int count = (int)floor(due);
@@ -1709,7 +1721,10 @@ void ParticleEmitterRecord::run(double sceneTime, double elapsedTime) {
 		++i;
 	}
 
-	_isDirty = true;
+	// Nothing moves while the game is paused
+	if (elapsedTime != 0.0 || _particles.size() != numParticles) {
+		_isDirty = true;
+	}
 }
 
 void ParticleEmitterRecord::onZChanged() {
@@ -1729,7 +1744,8 @@ void ParticleEmitterRecord::registerGraphics() {
 void ParticleEmitterRecord::updateGraphics() {
 	if (!isShown() || _particles.empty()) {
 		if (_canvas) {
-			_canvas->setVisible(false);
+			_canvas->addChangedArea(_drawnArea);
+			_canvas->setVisible(false, false);
 		}
 
 		return;
@@ -1760,6 +1776,7 @@ void ParticleEmitterRecord::updateGraphics() {
 		_canvas->_drawSurface.fillRect(_drawnArea, 0);
 	}
 
+	const Common::Rect previousArea = _drawnArea;
 	_drawnArea = Common::Rect();
 	_canvas->setMasked(isMasked());
 
@@ -1793,8 +1810,7 @@ void ParticleEmitterRecord::updateGraphics() {
 		drawParticleQuad(_canvas->_drawSurface, _image, particle, place * transform, false, _drawnArea);
 	}
 
-	_canvas->setVisible(true);
-	_canvas->setNeedsRedraw(true);
+	showCanvas(*_canvas, previousArea, _drawnArea);
 }
 
 bool ParticleEmitterRecord::getField(const Common::String &key) {


Commit: bcd8f55b0f14c9f20703c8e469135dc1db5d2b02
    https://github.com/scummvm/scummvm/commit/bcd8f55b0f14c9f20703c8e469135dc1db5d2b02
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-25T03:13:50+02:00

Commit Message:
NANCY: NANCY19: Redraw only the area a Render override changed

Scripts with a Render function draw on a transparent picture as large
as the viewport. When anything on it changed, all of it was redrawn,
along with everything under it, which slowed the game down. Now only
the area that differs from the last frame gets redrawn.

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


diff --git a/engines/nancy/script/records.cpp b/engines/nancy/script/records.cpp
index 8405b34ce97..eee8338f111 100644
--- a/engines/nancy/script/records.cpp
+++ b/engines/nancy/script/records.cpp
@@ -1217,6 +1217,46 @@ void OverrideRecord::onZChanged() {
 	}
 }
 
+// The smallest rect around the pixels that differ between two pictures of the
+// same size and 32 bit format. Empty when they are the same.
+static Common::Rect findChangedArea(const Graphics::ManagedSurface &a, const Graphics::ManagedSurface &b) {
+	const uint rowSize = a.w * 4;
+
+	int top = 0;
+	while (top < a.h && memcmp(a.getBasePtr(0, top), b.getBasePtr(0, top), rowSize) == 0) {
+		++top;
+	}
+
+	if (top == a.h) {
+		return Common::Rect();
+	}
+
+	int bottom = a.h;
+	while (memcmp(a.getBasePtr(0, bottom - 1), b.getBasePtr(0, bottom - 1), rowSize) == 0) {
+		--bottom;
+	}
+
+	int left = a.w;
+	int right = 0;
+	for (int y = top; y < bottom; ++y) {
+		const uint32 *rowA = (const uint32 *)a.getBasePtr(0, y);
+		const uint32 *rowB = (const uint32 *)b.getBasePtr(0, y);
+		for (int x = 0; x < left; ++x) {
+			if (rowA[x] != rowB[x]) {
+				left = x;
+			}
+		}
+
+		for (int x = a.w - 1; x >= right; --x) {
+			if (rowA[x] != rowB[x]) {
+				right = x + 1;
+			}
+		}
+	}
+
+	return Common::Rect(left, top, right, bottom);
+}
+
 // 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 picture is only shown
@@ -1268,9 +1308,10 @@ void OverrideRecord::updateGraphics() {
 	}
 
 	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);
+	const Common::Rect changed = findChangedArea(shown, _renderSurface);
+	if (!changed.isEmpty()) {
+		memcpy(shown.getPixels(), _renderSurface.getPixels(), shown.pitch * shown.h);
+		_canvas->addChangedArea(changed);
 		_canvas->setNeedsRedraw(true);
 	}
 


Commit: c8c35df9d6c4d68f391e85e5d09ac51324e812e9
    https://github.com/scummvm/scummvm/commit/c8c35df9d6c4d68f391e85e5d09ac51324e812e9
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-25T03:13:51+02:00

Commit Message:
NANCY: NANCY16: Redraw only the area of a panel button that changed

A button that fades in and out of its hover color made the whole panel
redraw on every frame of the fade. With a large panel, like the Exit
menu of the Dossier1 arcade, this made the mouse cursor choppy. Now
only the button's own area is redrawn, unless the button has text or
is pressed in, which can reach past its bounds.

Changed paths:
    engines/nancy/ui/ndui/button.h
    engines/nancy/ui/ndui/control.h
    engines/nancy/ui/ndui/panel.cpp
    engines/nancy/ui/ndui/panel.h


diff --git a/engines/nancy/ui/ndui/button.h b/engines/nancy/ui/ndui/button.h
index ab3a966ef58..cc4c018f6ab 100644
--- a/engines/nancy/ui/ndui/button.h
+++ b/engines/nancy/ui/ndui/button.h
@@ -35,6 +35,8 @@ public:
 	Button(Panel *panel) : Control(panel) {}
 
 	bool update(float seconds) override;
+	// Text can reach past the bounds, and so does a button that is pressed in
+	bool isDrawnInBounds() const override { return _text.empty() && !_isPressed; }
 	void draw(Graphics::ManagedSurface &surface, const Common::Point &offset) const override;
 
 	bool containsPoint(const Common::Point &pos) const override { return _bounds.contains(pos); }
diff --git a/engines/nancy/ui/ndui/control.h b/engines/nancy/ui/ndui/control.h
index 9557a132093..49baa769510 100644
--- a/engines/nancy/ui/ndui/control.h
+++ b/engines/nancy/ui/ndui/control.h
@@ -58,6 +58,11 @@ public:
 
 	// The area the control draws to, which can reach past its bounds
 	virtual Common::Rect getDrawBounds() const { return _bounds; }
+
+	// Whether a change of its colors shows inside getDrawBounds() only, so the
+	// rest of the panel doesn't have to be drawn again
+	virtual bool isDrawnInBounds() const { return false; }
+
 	virtual void onMouseHover(const Common::Point &pos) {}
 	virtual bool onMouseDown(const Common::Point &pos) { return false; }
 	virtual void onMouseMove(const Common::Point &pos) {}
diff --git a/engines/nancy/ui/ndui/panel.cpp b/engines/nancy/ui/ndui/panel.cpp
index 593c5d1dd9d..c363292bfd1 100644
--- a/engines/nancy/ui/ndui/panel.cpp
+++ b/engines/nancy/ui/ndui/panel.cpp
@@ -841,14 +841,61 @@ void Panel::updateGraphics() {
 		control->fireEvents(kEventUpdate, false, 0, control->getName());
 	}
 
-	bool changed = _background->update(seconds);
+	bool isAllChanged = _background->update(seconds) || _isDirty;
+	Common::Rect changedArea;
 	for (Control *control : _controls) {
-		changed |= control->update(seconds);
+		if (!control->update(seconds)) {
+			continue;
+		}
+
+		if (!control->isDrawnInBounds()) {
+			isAllChanged = true;
+			continue;
+		}
+
+		Common::Rect bounds = control->getDrawBounds();
+		bounds.translate(0, -_scrollOffset);
+		if (changedArea.isEmpty()) {
+			changedArea = bounds;
+		} else {
+			changedArea.extend(bounds);
+		}
 	}
 
-	if (changed || _isDirty) {
+	if (isAllChanged) {
 		redraw();
+	} else if (!changedArea.isEmpty()) {
+		redrawArea(changedArea);
+	}
+}
+
+// A button fading in and out of its hover color only needs its own area drawn
+void Panel::redrawArea(const Common::Rect &area) {
+	const Common::Rect clipped = area.findIntersectingRect(Common::Rect(_drawSurface.w, _drawSurface.h));
+	if (clipped.isEmpty()) {
+		return;
+	}
+
+	Graphics::ManagedSurface target(_drawSurface, clipped);
+	target.clear(0);
+
+	const Common::Point offset(-clipped.left, -clipped.top);
+	if (_backgroundColor >> 24) {
+		Common::Rect background = _background->_bounds;
+		background.translate(offset.x, offset.y);
+		background.clip(Common::Rect(target.w, target.h));
+		if (!background.isEmpty()) {
+			target.fillRect(background, argbToColor(target.format, _backgroundColor));
+		}
 	}
+
+	_background->draw(target, offset);
+	for (Control *control : _controls) {
+		control->draw(target, Common::Point(offset.x, offset.y - _scrollOffset));
+	}
+
+	addChangedArea(clipped);
+	_needsRedraw = true;
 }
 
 void Panel::redraw() {
diff --git a/engines/nancy/ui/ndui/panel.h b/engines/nancy/ui/ndui/panel.h
index 83a632f1e65..5624772c1f9 100644
--- a/engines/nancy/ui/ndui/panel.h
+++ b/engines/nancy/ui/ndui/panel.h
@@ -148,6 +148,7 @@ private:
 	void setCollapsed(bool isCollapsed);
 	void fireEvent(int32 eventType, double value = 0.0);
 	void redraw();
+	void redrawArea(const Common::Rect &area);
 	Control *getControlAt(const Common::Point &pos) const;
 	void showItem(int16 itemID, bool show);
 	void cycleFocus();


Commit: 1037b4ce89e868a054fd3b873b4847f50b9f3115
    https://github.com/scummvm/scummvm/commit/1037b4ce89e868a054fd3b873b4847f50b9f3115
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-25T03:13:51+02:00

Commit Message:
NANCY: NANCY16: Add a console command that shows or hides UI buttons

Nancy16 and later games store which buttons of the user interface are
shown or enabled in saved games. The new ui_control command shows,
hides, enables or disables a control by name, for example,
"ui_control ShowPaperDoll show"

Changed paths:
    engines/nancy/console.cpp
    engines/nancy/console.h


diff --git a/engines/nancy/console.cpp b/engines/nancy/console.cpp
index 18f13d9062e..06aecbedb14 100644
--- a/engines/nancy/console.cpp
+++ b/engines/nancy/console.cpp
@@ -44,6 +44,8 @@
 
 #include "engines/nancy/action/actionrecord.h"
 
+#include "engines/nancy/ui/ndui/manager.h"
+
 #ifdef ENABLE_NANCY_V4
 #include "engines/nancy/script/record.h"
 #include "engines/nancy/script/scenecontext.h"
@@ -93,6 +95,7 @@ NancyConsole::NancyConsole() : GUI::Debugger() {
 	registerCmd("set_difficulty", WRAP_METHOD(NancyConsole, Cmd_setDifficulty));
 	registerCmd("sound_info", WRAP_METHOD(NancyConsole, Cmd_soundInfo));
 	registerCmd("debug_hotspots", WRAP_METHOD(NancyConsole, Cmd_showHotspots));
+	registerCmd("ui_control", WRAP_METHOD(NancyConsole, Cmd_uiControl));
 }
 
 NancyConsole::~NancyConsole() {}
@@ -1642,6 +1645,46 @@ bool NancyConsole::Cmd_setInventory(int argc, const char **argv) {
 	return cmdExit(0, nullptr);
 }
 
+// Saved games keep which UI controls are shown, so this can repair a saved game
+// made while a control was stuck
+bool NancyConsole::Cmd_uiControl(int argc, const char **argv) {
+	if (argc != 3) {
+		debugPrintf("Shows, hides, enables or disables a control of the UI (Nancy16 and later).\n");
+		debugPrintf("Save the game afterwards to keep the change.\n");
+		debugPrintf("Usage: %s <name> show|hide|enable|disable\n", argv[0]);
+		debugPrintf("For example, %s ShowPaperDoll show brings back the outfit button of Nancy18.\n", argv[0]);
+		return true;
+	}
+
+	if (g_nancy->getState() != NancyState::kScene || !NancySceneState.getNDUI()) {
+		debugPrintf("The UI is only available in a scene of Nancy16 and later\n");
+		return true;
+	}
+
+	const Common::String command = argv[2];
+	UI::NDUI::Action action;
+	action.target = argv[1];
+	if (command.equalsIgnoreCase("show")) {
+		action.type = UI::NDUI::kActionShow;
+	} else if (command.equalsIgnoreCase("hide")) {
+		action.type = UI::NDUI::kActionHide;
+	} else if (command.equalsIgnoreCase("enable")) {
+		action.type = UI::NDUI::kActionEnable;
+	} else if (command.equalsIgnoreCase("disable")) {
+		action.type = UI::NDUI::kActionDisable;
+	} else {
+		debugPrintf("Invalid action %s\n", argv[2]);
+		return true;
+	}
+
+	if (!NancySceneState.getNDUI()->takeAction(action)) {
+		debugPrintf("The UI has no control named %s\n", argv[1]);
+		return true;
+	}
+
+	return cmdExit(0, nullptr);
+}
+
 bool NancyConsole::Cmd_holdItem(int argc, const char **argv) {
 	if (g_nancy->getState() != NancyState::kScene) {
 		debugPrintf("Not in the kScene state\n");
diff --git a/engines/nancy/console.h b/engines/nancy/console.h
index f45f6821a06..1854f198fa8 100644
--- a/engines/nancy/console.h
+++ b/engines/nancy/console.h
@@ -82,6 +82,7 @@ private:
 	bool Cmd_setDifficulty(int argc, const char **argv);
 	bool Cmd_soundInfo(int argc, const char **argv);
 	bool Cmd_showHotspots(int argc, const char **argv);
+	bool Cmd_uiControl(int argc, const char **argv);
 
 	void printInventoryItem(uint itemID);
 




More information about the Scummvm-git-logs mailing list