[Scummvm-git-logs] scummvm master -> 91c72a6e3dd1b3db40a2b203fe55cffd539365e7
bluegr
noreply at scummvm.org
Fri Nov 20 02:05:01 UTC 2026
This automated email contains information about 13 new commits which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
07273eaaa4 NANCY: NANCY19: Give the input to the frontmost stream first
bd276d663e NANCY: NANCY19: Draw each stream in a layer of its own
b1d4f317bb NANCY: NANCY19: Keep the order of records that share a z order
c60fb06350 NANCY: DOSSIER1: Put new items last in the inventory
9e81a58c67 NANCY: NDUI: Center wrapped text up and down in its rect
a14463b2bd NANCY: DOSSIER1: Scroll tall backgrounds up and down
2bfb8566b8 NANCY: DOSSIER1: Run the OnSceneEnd script
909d70fd92 NANCY: DOSSIER1: Show the score after loading a game
b7f6029ddc NANCY: Blend transparent pixels onto black ones
614110a041 NANCY: NANCY16: Smooth NDUI pictures drawn at another size
680ee8c611 NANCY: DOSSIER1: Keep the music of the area playing
c409955baa NANCY: Remove blitAlpha32
91c72a6e3d NANCY: DOSSIER1: Speed up drawing under the flashlight
Commit: 07273eaaa4cad072a7fc711f0755b1afd64bfa0f
https://github.com/scummvm/scummvm/commit/07273eaaa4cad072a7fc711f0755b1afd64bfa0f
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-20T04:04:19+02:00
Commit Message:
NANCY: NANCY19: Give the input to the frontmost stream first
In Lights, Camera, Curses, the journal opens the map in a stream in
front of it, but the journal's click blocker took every click. The
streams now get the input from the frontmost one back.
Changed paths:
engines/nancy/state/scenestream.cpp
diff --git a/engines/nancy/state/scenestream.cpp b/engines/nancy/state/scenestream.cpp
index 3afdfe853f4..d82554ac3df 100644
--- a/engines/nancy/state/scenestream.cpp
+++ b/engines/nancy/state/scenestream.cpp
@@ -773,10 +773,13 @@ void SceneStreamManager::process() {
// Returns whether a stream kept the input to itself
bool SceneStreamManager::handleInput(NancyInput &input, bool beforeMainStream) {
- const Common::Array<SceneStream *> streams = _streams;
+ // The frontmost stream gets the input first, so one that takes it keeps it
+ // from the ones behind: the map of Lights, Camera, Curses from the journal
+ // that opens it. Streams at the same z go in the order they began.
+ Common::Array<SceneStream *> streams;
bool isBeforeMainStream = true;
- for (SceneStream *stream : streams) {
+ for (SceneStream *stream : _streams) {
if (!stream) {
isBeforeMainStream = false;
continue;
@@ -793,6 +796,15 @@ bool SceneStreamManager::handleInput(NancyInput &input, bool beforeMainStream) {
continue;
}
+ uint i = 0;
+ while (i < streams.size() && streams[i]->getZOffset() >= stream->getZOffset()) {
+ ++i;
+ }
+
+ streams.insert_at(i, stream);
+ }
+
+ for (SceneStream *stream : streams) {
_running = stream;
stream->handleInput(input);
_running = nullptr;
Commit: bd276d663e785d43aab64577272607bd680ea998
https://github.com/scummvm/scummvm/commit/bd276d663e785d43aab64577272607bd680ea998
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-20T04:04:21+02:00
Commit Message:
NANCY: NANCY19: Draw each stream in a layer of its own
Nancy19 to Nancy20 draw each stream as a whole layer, in front of or
behind the others, e.g. the journal of Lights, Camera, Curses covers
the scene behind it. A stream that doesn't take the input is drawn
with the main stream, whichever stream began it. The UI is in front.
Changed paths:
engines/nancy/graphics.cpp
engines/nancy/renderobject.cpp
engines/nancy/renderobject.h
engines/nancy/script/gameapi.cpp
engines/nancy/script/records.cpp
engines/nancy/script/records.h
engines/nancy/state/scenestream.cpp
engines/nancy/ui/ndui/panel.cpp
diff --git a/engines/nancy/graphics.cpp b/engines/nancy/graphics.cpp
index c0f0d5d4bd7..c547eb26b57 100644
--- a/engines/nancy/graphics.cpp
+++ b/engines/nancy/graphics.cpp
@@ -1109,7 +1109,11 @@ Common::Rect GraphicsManager::getDrawnPosition(const RenderObject &object) const
}
int GraphicsManager::objectComparator(const void *a, const void *b) {
- if (((const RenderObject*)a)->getZOrder() < ((const RenderObject*)b)->getZOrder()) {
+ if (((const RenderObject*)a)->getLayer() < ((const RenderObject*)b)->getLayer()) {
+ return -1;
+ } else if (((const RenderObject*)a)->getLayer() > ((const RenderObject*)b)->getLayer()) {
+ return 1;
+ } else if (((const RenderObject*)a)->getZOrder() < ((const RenderObject*)b)->getZOrder()) {
return -1;
} else if (((const RenderObject*)a)->getZOrder() > ((const RenderObject*)b)->getZOrder()) {
return 1;
diff --git a/engines/nancy/renderobject.cpp b/engines/nancy/renderobject.cpp
index 626de4761c0..1f7b4498d3b 100644
--- a/engines/nancy/renderobject.cpp
+++ b/engines/nancy/renderobject.cpp
@@ -49,6 +49,16 @@ void RenderObject::setZOrder(uint16 z) {
g_nancy->_graphics->reorderObject(this);
}
+void RenderObject::setLayer(int32 layer) {
+ if (_layer == layer) {
+ return;
+ }
+
+ _layer = layer;
+ _needsRedraw = true;
+ g_nancy->_graphics->reorderObject(this);
+}
+
void RenderObject::init() {
_previousScreenPosition = _screenPosition;
}
diff --git a/engines/nancy/renderobject.h b/engines/nancy/renderobject.h
index c82831e3bd2..57a08288dca 100644
--- a/engines/nancy/renderobject.h
+++ b/engines/nancy/renderobject.h
@@ -117,6 +117,13 @@ public:
// scripts draw in the order they were made. 0 for everything else.
uint32 getTieOrder() const { return _tieOrder; }
void setTieOrder(uint32 order) { _tieOrder = order; }
+
+ // What comes before the z order: Nancy19 to Nancy20 draw each stream in a
+ // layer of its own. The UI is in front of all of them.
+ static const int32 kUILayer = 0x7FFFFFFF;
+ int32 getLayer() const { return _layer; }
+ void setLayer(int32 layer);
+
// Also moves the object in the draw order, so changing the z of a registered
// object takes effect without re-registering it
void setZOrder(uint16 z);
@@ -140,6 +147,7 @@ protected:
bool _isMasked = false;
uint16 _z;
uint32 _tieOrder = 0;
+ int32 _layer = 0;
Common::Rect _drawnScreenPosition;
Common::Rect _previousScreenPosition;
Common::Rect _screenPosition;
diff --git a/engines/nancy/script/gameapi.cpp b/engines/nancy/script/gameapi.cpp
index 0dc724722fc..cf76bc9b1f6 100644
--- a/engines/nancy/script/gameapi.cpp
+++ b/engines/nancy/script/gameapi.cpp
@@ -1710,12 +1710,13 @@ static bool readStreamLifetime(const Common::String &lifetime, State::StreamFlag
return true;
}
-// A stream that keeps the input goes in front of the frontmost stream, and any
-// other one shares the z of the stream that began it. Nancy19 to Nancy20 keep
-// the streams in an order of their own, where it goes a step in front; from
-// Resorting to Danger on, it goes 10 in front. 10 is more than the z of a
-// record spans, so it covers the scenes behind it, e.g. the journal of Lights,
-// Camera, Curses or the scrapbook of Nancy25.
+// A stream that keeps the input goes in front of the frontmost stream. Nancy19
+// to Nancy20 keep the streams in an order of their own, where it goes a step in
+// front and any other one goes with the main stream, and draw each place there
+// as a layer, e.g. the journal of Lights, Camera, Curses over the scene behind
+// it. From Resorting to Danger on, it goes 10 in front, which is more than the
+// z of a record spans there, e.g. the scrapbook of Nancy25, and any other
+// stream shares the z of the stream that began it.
static int32 getCapturingStreamZOffset() {
const State::SceneStreamManager &streams = NancySceneState.getStreams();
return streams.getFrontZOffset() + 10 - streams.getRunningZOffset();
diff --git a/engines/nancy/script/records.cpp b/engines/nancy/script/records.cpp
index d3e2c5d8663..48adf14ad97 100644
--- a/engines/nancy/script/records.cpp
+++ b/engines/nancy/script/records.cpp
@@ -194,10 +194,20 @@ Record *makeRecord(RecordType type, SceneContext &context) {
static const double kBackgroundScriptZ = -5.0;
static const int kBackgroundZ = 6;
-// Scripts tell apart z values as close as 0.001, and every stream is one step
-// closer than the one that began it
+// Scripts tell apart z values as close as 0.001
static const double kStepsPerScriptZ = 1000.0;
+// Nancy19 to Nancy20 keep the streams in an order of their own, and draw the
+// records of each z there together, sorted by their z: the z of a stream is a
+// layer of what is drawn. Later games add it to the z of the records.
+static bool hasStreamLayers() {
+ return g_nancy->getGameType() < kGameTypeNancyDossier2;
+}
+
+int32 RecordGraphic::getScriptLayer(int32 zOffset) {
+ return hasStreamLayers() ? zOffset : 0;
+}
+
uint16 RecordGraphic::getScriptZOrder(double z, int32 zOffset) {
#ifdef ENABLE_NANCY_V5
if (g_nancy->getGameType() >= kGameTypeNancy26) {
@@ -205,6 +215,10 @@ uint16 RecordGraphic::getScriptZOrder(double z, int32 zOffset) {
}
#endif
+ if (hasStreamLayers()) {
+ zOffset = 0;
+ }
+
const double steps = (z - kBackgroundScriptZ + zOffset) * kStepsPerScriptZ;
return (uint16)CLIP<int>(kBackgroundZ + (int)floor(steps + 0.5), 0, kMaxScriptZOrder);
}
@@ -240,6 +254,8 @@ void RecordGraphic::setScriptZ(double z, const SceneContext &context, uint32 rec
g_nancy->_graphics->reorderObject(this);
}
+ setLayer(getScriptLayer(context.getZOffset()));
+
setZOrder(getScriptZOrder(z, context.getZOffset()));
setViewTransform(context.getViewTransform());
}
@@ -1740,6 +1756,7 @@ void OverlayRecord::renderNow() {
_hasAttachment = true;
_attachment.init();
_attachment.setVisible(false);
+ _attachment.setLayer(RenderObject::kUILayer);
_attachment.setZOrder(kAttachmentZ);
_attachment.registerGraphics();
}
diff --git a/engines/nancy/script/records.h b/engines/nancy/script/records.h
index 06ca6f368d5..133ef493a0b 100644
--- a/engines/nancy/script/records.h
+++ b/engines/nancy/script/records.h
@@ -79,6 +79,7 @@ public:
// The z order of a script z in a stream that is the given steps in front
static uint16 getScriptZOrder(double z, int32 zOffset);
static uint16 getBackgroundZOrder(int32 zOffset);
+ static int32 getScriptLayer(int32 zOffset);
// The highest z order of what the records draw
static const int kMaxScriptZOrder = 59000;
diff --git a/engines/nancy/state/scenestream.cpp b/engines/nancy/state/scenestream.cpp
index d82554ac3df..048e5962058 100644
--- a/engines/nancy/state/scenestream.cpp
+++ b/engines/nancy/state/scenestream.cpp
@@ -240,6 +240,7 @@ void SceneStream::loadBackground(const Common::Path &videoFile) {
_background->setZOrder(_background->getZOrder() + _zOffset);
#ifdef ENABLE_NANCY_V4
if (_scriptScene) {
+ _background->setLayer(Script::RecordGraphic::getScriptLayer(_scriptScene->getZOffset()));
_background->setZOrder(Script::RecordGraphic::getBackgroundZOrder(_scriptScene->getZOffset()));
}
#endif
@@ -510,7 +511,15 @@ void SceneStreamManager::begin(const Common::String &name, const Common::String
return;
}
- int32 zOffset = flags.zOffset + (_running ? _running->getZOffset() : 0);
+ // Nancy19 to Nancy20 put a stream that doesn't take the input with the main
+ // stream, whichever stream began it
+ const GameType gameType = g_nancy->getGameType();
+ const bool isWithMainStream = gameType >= kGameTypeNancy19 && gameType < kGameTypeNancyDossier2 && !flags.capturesInput;
+ int32 zOffset = flags.zOffset;
+ if (_running && !isWithMainStream) {
+ zOffset += _running->getZOffset();
+ }
+
SceneStream *stream = new SceneStream(name, flags, zOffset);
stream->changeScene(sceneName, frameID);
diff --git a/engines/nancy/ui/ndui/panel.cpp b/engines/nancy/ui/ndui/panel.cpp
index 376a5393ca2..0dcd497f2ea 100644
--- a/engines/nancy/ui/ndui/panel.cpp
+++ b/engines/nancy/ui/ndui/panel.cpp
@@ -44,6 +44,7 @@ namespace NDUI {
static const int kInvButtonFirstID = 10;
Panel::Panel(Manager *manager, uint16 z, byte kind) : RenderObject(z), _manager(manager), _kind(kind) {
+ _layer = kUILayer;
setNativeResolution(true);
}
Commit: b1d4f317bb471472a35e246e61988f0db58c02d1
https://github.com/scummvm/scummvm/commit/b1d4f317bb471472a35e246e61988f0db58c02d1
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-20T04:04:24+02:00
Commit Message:
NANCY: NANCY19: Keep the order of records that share a z order
The z order clamps very near and very far z values to one value, so
records far behind the background (Lights, Camera, Curses scene 6221)
were mixed up with it. In Nancy19 to Nancy20, records with the same z
order are now sorted by their exact z, as the original does.
Changed paths:
engines/nancy/graphics.cpp
engines/nancy/renderobject.cpp
engines/nancy/renderobject.h
engines/nancy/script/records.cpp
engines/nancy/script/records.h
engines/nancy/state/scene.cpp
engines/nancy/state/scenestream.cpp
diff --git a/engines/nancy/graphics.cpp b/engines/nancy/graphics.cpp
index c547eb26b57..d594f04f321 100644
--- a/engines/nancy/graphics.cpp
+++ b/engines/nancy/graphics.cpp
@@ -1117,6 +1117,10 @@ int GraphicsManager::objectComparator(const void *a, const void *b) {
return -1;
} else if (((const RenderObject*)a)->getZOrder() > ((const RenderObject*)b)->getZOrder()) {
return 1;
+ } else if (((const RenderObject*)a)->getExactZ() < ((const RenderObject*)b)->getExactZ()) {
+ return -1;
+ } else if (((const RenderObject*)a)->getExactZ() > ((const RenderObject*)b)->getExactZ()) {
+ return 1;
} else if (((const RenderObject*)a)->getTieOrder() < ((const RenderObject*)b)->getTieOrder()) {
return -1;
} else if (((const RenderObject*)a)->getTieOrder() > ((const RenderObject*)b)->getTieOrder()) {
diff --git a/engines/nancy/renderobject.cpp b/engines/nancy/renderobject.cpp
index 1f7b4498d3b..7abf43ebce0 100644
--- a/engines/nancy/renderobject.cpp
+++ b/engines/nancy/renderobject.cpp
@@ -49,6 +49,18 @@ void RenderObject::setZOrder(uint16 z) {
g_nancy->_graphics->reorderObject(this);
}
+const double RenderObject::kNoExactZ = -1e300;
+
+void RenderObject::setExactZ(double z) {
+ if (_exactZ == z) {
+ return;
+ }
+
+ _exactZ = z;
+ _needsRedraw = true;
+ g_nancy->_graphics->reorderObject(this);
+}
+
void RenderObject::setLayer(int32 layer) {
if (_layer == layer) {
return;
diff --git a/engines/nancy/renderobject.h b/engines/nancy/renderobject.h
index 57a08288dca..cefe8c51976 100644
--- a/engines/nancy/renderobject.h
+++ b/engines/nancy/renderobject.h
@@ -124,6 +124,13 @@ public:
int32 getLayer() const { return _layer; }
void setLayer(int32 layer);
+ // Nancy19 to Nancy20: the z of a record of the scripts, which tells apart the
+ // records the z order can't, e.g. the many farther than the background.
+ // Everything else is farther than all records of its z order.
+ static const double kNoExactZ;
+ double getExactZ() const { return _exactZ; }
+ void setExactZ(double z);
+
// Also moves the object in the draw order, so changing the z of a registered
// object takes effect without re-registering it
void setZOrder(uint16 z);
@@ -148,6 +155,7 @@ protected:
uint16 _z;
uint32 _tieOrder = 0;
int32 _layer = 0;
+ double _exactZ = kNoExactZ;
Common::Rect _drawnScreenPosition;
Common::Rect _previousScreenPosition;
Common::Rect _screenPosition;
diff --git a/engines/nancy/script/records.cpp b/engines/nancy/script/records.cpp
index 48adf14ad97..ed11a07ca7b 100644
--- a/engines/nancy/script/records.cpp
+++ b/engines/nancy/script/records.cpp
@@ -208,6 +208,10 @@ int32 RecordGraphic::getScriptLayer(int32 zOffset) {
return hasStreamLayers() ? zOffset : 0;
}
+double RecordGraphic::getBackgroundExactZ() {
+ return hasStreamLayers() ? kBackgroundScriptZ : RenderObject::kNoExactZ;
+}
+
uint16 RecordGraphic::getScriptZOrder(double z, int32 zOffset) {
#ifdef ENABLE_NANCY_V5
if (g_nancy->getGameType() >= kGameTypeNancy26) {
@@ -255,6 +259,9 @@ void RecordGraphic::setScriptZ(double z, const SceneContext &context, uint32 rec
}
setLayer(getScriptLayer(context.getZOffset()));
+ if (hasStreamLayers()) {
+ setExactZ(z);
+ }
setZOrder(getScriptZOrder(z, context.getZOffset()));
setViewTransform(context.getViewTransform());
diff --git a/engines/nancy/script/records.h b/engines/nancy/script/records.h
index 133ef493a0b..ec657b1e081 100644
--- a/engines/nancy/script/records.h
+++ b/engines/nancy/script/records.h
@@ -80,6 +80,7 @@ public:
static uint16 getScriptZOrder(double z, int32 zOffset);
static uint16 getBackgroundZOrder(int32 zOffset);
static int32 getScriptLayer(int32 zOffset);
+ static double getBackgroundExactZ();
// The highest z order of what the records draw
static const int kMaxScriptZOrder = 59000;
diff --git a/engines/nancy/state/scene.cpp b/engines/nancy/state/scene.cpp
index 67be0f01ea6..cf039ba1aa5 100644
--- a/engines/nancy/state/scene.cpp
+++ b/engines/nancy/state/scene.cpp
@@ -2381,6 +2381,8 @@ void Scene::loadScriptedScene(bool fromSaveFile) {
_viewport.setZOrder(Script::RecordGraphic::getBackgroundZOrder(_scriptScene->getZOffset()));
}
+ _viewport.setExactZ(Script::RecordGraphic::getBackgroundExactZ());
+
g_nancy->_graphics->suppressNextDraw();
debugC(0, kDebugScene, "Loading new scene %s, frame %i", sceneName.c_str(), _sceneState.nextScene.frameID);
diff --git a/engines/nancy/state/scenestream.cpp b/engines/nancy/state/scenestream.cpp
index 048e5962058..45428daa4f4 100644
--- a/engines/nancy/state/scenestream.cpp
+++ b/engines/nancy/state/scenestream.cpp
@@ -241,6 +241,7 @@ void SceneStream::loadBackground(const Common::Path &videoFile) {
#ifdef ENABLE_NANCY_V4
if (_scriptScene) {
_background->setLayer(Script::RecordGraphic::getScriptLayer(_scriptScene->getZOffset()));
+ _background->setExactZ(Script::RecordGraphic::getBackgroundExactZ());
_background->setZOrder(Script::RecordGraphic::getBackgroundZOrder(_scriptScene->getZOffset()));
}
#endif
Commit: c60fb063509fc3b04e702325f96fb9018982e220
https://github.com/scummvm/scummvm/commit/c60fb063509fc3b04e702325f96fb9018982e220
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-20T04:04:26+02:00
Commit Message:
NANCY: DOSSIER1: Put new items last in the inventory
Lights, Camera, Curses adds each item after the others and makes its
button when the item is first shown, so the scripts number the
buttons in inventory order. After loading a game, the buttons are now
shown in the order of the list, in this game and Resorting to Danger.
Changed paths:
engines/nancy/script/bootapi.cpp
engines/nancy/state/scene.cpp
engines/nancy/ui/ndui/enginehandlers.cpp
diff --git a/engines/nancy/script/bootapi.cpp b/engines/nancy/script/bootapi.cpp
index 8dac15c5eab..83b9c28e341 100644
--- a/engines/nancy/script/bootapi.cpp
+++ b/engines/nancy/script/bootapi.cpp
@@ -370,6 +370,11 @@ static int inventoryCreate(lua_State *L) {
s_tables->boot->inventoryImageName = Common::Path(imageName);
+ // Lights, Camera, Curses has no addToFront, and puts new items last
+ if (g_nancy->getGameType() == kGameTypeNancyDossier1) {
+ s_tables->boot->isInventoryAddedToFront = false;
+ }
+
Common::Array<Common::String> names;
getSortedKeys(L, 2, names);
diff --git a/engines/nancy/state/scene.cpp b/engines/nancy/state/scene.cpp
index cf039ba1aa5..057be0d38cb 100644
--- a/engines/nancy/state/scene.cpp
+++ b/engines/nancy/state/scene.cpp
@@ -1482,11 +1482,15 @@ bool Scene::changePlayerCharacter(uint characterIndex) {
}
void Scene::showInventoryButtons() {
- // The most recent items come first
+ // Each item shown goes first, or last in the games that put new items last,
+ // so the buttons come out in the order of the list
const Common::Array<int16> &order = _inventoryBox.getOrder();
- for (int i = (int)order.size() - 1; i >= 0; --i) {
- if (order[i] != -1 && _flags.items[order[i]] == g_nancy->_true) {
- _ndui->showInventoryItem(order[i], true);
+ const ScriptBootData *scriptBoot = (const ScriptBootData *)g_nancy->getEngineData("ScriptBootData");
+ const bool isAddedLast = scriptBoot && !scriptBoot->isInventoryAddedToFront;
+ for (uint i = 0; i < order.size(); ++i) {
+ const int16 id = isAddedLast ? order[i] : order[order.size() - 1 - i];
+ if (id != -1 && _flags.items[id] == g_nancy->_true) {
+ _ndui->showInventoryItem(id, true);
}
}
}
diff --git a/engines/nancy/ui/ndui/enginehandlers.cpp b/engines/nancy/ui/ndui/enginehandlers.cpp
index 83db02c5853..09640c65b18 100644
--- a/engines/nancy/ui/ndui/enginehandlers.cpp
+++ b/engines/nancy/ui/ndui/enginehandlers.cpp
@@ -332,8 +332,13 @@ void Manager::onSceneChange(uint16 sceneID) {
void Manager::createItemButtons() {
Panel *panel = findPanel("InvDialog");
- // Nancy19 makes them one at a time, with the script of the panel
+ // Nancy19 makes them one at a time, with the script of the panel. Lights,
+ // Camera, Curses makes each one when its item is first shown.
if (panel && g_nancy->getGameType() >= kGameTypeNancy19) {
+ if (g_nancy->getGameType() == kGameTypeNancyDossier1) {
+ return;
+ }
+
const INVD *items = GetEngineData(INVD);
assert(items);
@@ -372,6 +377,16 @@ void Manager::createItemButtons() {
}
void Manager::showInventoryItem(int16 itemID, bool show) {
+ // The scripts of Lights, Camera, Curses number the buttons as they get them,
+ // which is where the items are in the inventory
+ if (show && g_nancy->getGameType() == kGameTypeNancyDossier1 && !findItemButton(itemID)) {
+ Panel *panel = findPanel("InvDialog");
+ const INVD *items = GetEngineData(INVD);
+ if (panel && items && itemID >= 0 && (uint)itemID < items->items.size()) {
+ panel->addItemButton(items->items[itemID]);
+ }
+ }
+
takeAction(show ? kActionShowItem : kActionHideItem, "InvDialog", (double)itemID);
}
Commit: 9e81a58c67fa37118cfab2a472b96a630fadfc44
https://github.com/scummvm/scummvm/commit/9e81a58c67fa37118cfab2a472b96a630fadfc44
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-20T04:04:28+02:00
Commit Message:
NANCY: NDUI: Center wrapped text up and down in its rect
Text that wraps is now centered or bottom-aligned in its rect like
single lines, and isn't cut off. The goal text of Lights, Camera,
Curses shows two lines in the height of one.
Changed paths:
engines/nancy/ui/ndui/element.cpp
diff --git a/engines/nancy/ui/ndui/element.cpp b/engines/nancy/ui/ndui/element.cpp
index fd3f881f6e3..4e257d02127 100644
--- a/engines/nancy/ui/ndui/element.cpp
+++ b/engines/nancy/ui/ndui/element.cpp
@@ -234,9 +234,12 @@ void Element::drawText(Graphics::ManagedSurface &surface, const Common::String &
}
// Text kept on a single line is laid out as wide as it gets, and then aligned
- // in the rect. It isn't cut off by a rect that is too low for it.
+ // 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();
ElementText layout;
- const int renderHeight = _wordWrap ? dest.height() : MAX<int>(dest.height(), getFontHeight());
+ 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);
@@ -251,13 +254,12 @@ void Element::drawText(Graphics::ManagedSurface &surface, const Common::String &
} else if (_horizontalAlignment == ElementText::kAlignRight) {
left = dest.right - width;
}
+ }
- int lineHeight = getFontHeight();
- if (_verticalAlignment == kAlignVCenter) {
- top += (dest.height() - lineHeight) / 2;
- } else if (_verticalAlignment == kAlignBottom) {
- top += dest.height() - lineHeight;
- }
+ if (_verticalAlignment == kAlignVCenter) {
+ top += (dest.height() - textHeight) / 2;
+ } else if (_verticalAlignment == kAlignBottom) {
+ top += dest.height() - textHeight;
}
// The text gets blended in with the color's alpha. The shadow is the same shape
Commit: a14463b2bd078cfc9752bf0bbe88d9eaae6233ae
https://github.com/scummvm/scummvm/commit/a14463b2bd078cfc9752bf0bbe88d9eaae6233ae
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-20T04:04:29+02:00
Commit Message:
NANCY: DOSSIER1: Scroll tall backgrounds up and down
Scene 2400 of Lights, Camera, Curses has a background taller than the
viewport, which its summary scrolls up and down. The records are
placed by their own transforms, so the scroll no longer moves them or
the mouse.
Changed paths:
engines/nancy/renderobject.cpp
engines/nancy/renderobject.h
engines/nancy/script/records.cpp
engines/nancy/script/records.h
engines/nancy/script/scenecontext.cpp
engines/nancy/ui/viewport.h
diff --git a/engines/nancy/renderobject.cpp b/engines/nancy/renderobject.cpp
index 7abf43ebce0..5c3e32775f2 100644
--- a/engines/nancy/renderobject.cpp
+++ b/engines/nancy/renderobject.cpp
@@ -165,19 +165,24 @@ void RenderObject::setPalette(const byte *colors, uint paletteStart, uint palett
}
Common::Rect RenderObject::getScreenPosition() const {
- if (isViewportRelative()) {
- return NancySceneState.getViewport().convertViewportToScreen(_screenPosition);
- } else {
- return _screenPosition;
- }
+ return convertPositionToScreen(_screenPosition);
}
Common::Rect RenderObject::getPreviousScreenPosition() const {
- if (isViewportRelative()) {
- return NancySceneState.getViewport().convertViewportToScreen(_previousScreenPosition);
- } else {
- return _previousScreenPosition;
+ return convertPositionToScreen(_previousScreenPosition);
+}
+
+Common::Rect RenderObject::convertPositionToScreen(const Common::Rect &position) const {
+ if (!isViewportRelative()) {
+ return position;
+ }
+
+ const UI::Viewport &viewport = NancySceneState.getViewport();
+ Common::Rect ret = position;
+ if (!isMovedByViewportScroll()) {
+ ret.translate(0, viewport.getCurVerticalScroll());
}
+ return viewport.convertViewportToScreen(ret);
}
// Convert a rectangle from screen space to local (to _drawSurface) space.
@@ -190,8 +195,9 @@ Common::Rect RenderObject::convertToLocal(const Common::Rect &screen) const {
Common::Rect viewportScreenPos = NancySceneState.getViewport().getScreenPosition();
offset.x -= viewportScreenPos.left;
offset.y -= viewportScreenPos.top;
- uint viewportScroll = NancySceneState.getViewport().getCurVerticalScroll();
- offset.y += viewportScroll;
+ if (isMovedByViewportScroll()) {
+ offset.y += NancySceneState.getViewport().getCurVerticalScroll();
+ }
}
offset.x -= _screenPosition.left;
@@ -236,8 +242,9 @@ Common::Rect RenderObject::convertToScreen(const Common::Rect &rect) const {
Common::Rect viewportScreenPos = NancySceneState.getViewport().getScreenPosition();
offset.x += viewportScreenPos.left;
offset.y += viewportScreenPos.top;
- uint viewportScroll = NancySceneState.getViewport().getCurVerticalScroll();
- offset.y -= viewportScroll;
+ if (isMovedByViewportScroll()) {
+ offset.y -= NancySceneState.getViewport().getCurVerticalScroll();
+ }
}
offset.x += _screenPosition.left;
diff --git a/engines/nancy/renderobject.h b/engines/nancy/renderobject.h
index cefe8c51976..f4a36cade3f 100644
--- a/engines/nancy/renderobject.h
+++ b/engines/nancy/renderobject.h
@@ -140,6 +140,10 @@ public:
// Needed for proper handling of objects inside the viewport
virtual bool isViewportRelative() const { return false; }
+ // Whether an object in the viewport moves with its vertical scroll. The
+ // records of the scripts are placed by their transforms instead.
+ virtual bool isMovedByViewportScroll() const { return true; }
+
// The zoom the object gets drawn with, if any. It belongs to whoever set it.
const ViewTransform *getViewTransform() const { return _viewTransform; }
void setViewTransform(const ViewTransform *viewTransform) { _viewTransform = viewTransform; }
@@ -161,6 +165,9 @@ protected:
Common::Rect _screenPosition;
Common::Rect _clipRect;
const ViewTransform *_viewTransform = nullptr;
+
+private:
+ Common::Rect convertPositionToScreen(const Common::Rect &position) const;
};
} // End of namespace Nancy
diff --git a/engines/nancy/script/records.cpp b/engines/nancy/script/records.cpp
index ed11a07ca7b..ef077ec4e5f 100644
--- a/engines/nancy/script/records.cpp
+++ b/engines/nancy/script/records.cpp
@@ -649,6 +649,14 @@ void SummaryRecord::onTransformChanged() {
const ScriptMatrix transform = getTransform();
_background->setHorizontalScroll(MAX<int>(0, (int)-transform.m[3][0]));
+
+ // A background taller than the viewport, like the one of Dossier1 scene
+ // 2400, scrolls down as far as the transform moves it up
+ const int verticalScroll = (int)-transform.m[3][1];
+ if (verticalScroll > 0 || _background->getCurVerticalScroll() != 0) {
+ const int maxScroll = (int)_background->getFullFrameHeight() - (int)_background->getScreenPositionRaw().height();
+ _background->setVerticalScroll(CLIP<int>(verticalScroll, 0, MAX<int>(maxScroll, 0)));
+ }
}
void SummaryRecord::setFrame(uint frame) {
diff --git a/engines/nancy/script/records.h b/engines/nancy/script/records.h
index ec657b1e081..56e2ce6ce4b 100644
--- a/engines/nancy/script/records.h
+++ b/engines/nancy/script/records.h
@@ -93,6 +93,7 @@ protected:
// Nancy26 has the viewport at the top left of the screen, and lets records
// draw on all of it, the UI along the bottom included
bool isViewportRelative() const override;
+ bool isMovedByViewportScroll() const override { return false; }
};
// Shows a part of an image where the record's transform places it. The part
diff --git a/engines/nancy/script/scenecontext.cpp b/engines/nancy/script/scenecontext.cpp
index f1412f7f33b..41da46f9de0 100644
--- a/engines/nancy/script/scenecontext.cpp
+++ b/engines/nancy/script/scenecontext.cpp
@@ -649,10 +649,10 @@ bool SceneContext::getViewportMouse(const NancyInput &input, Common::Point32 &po
const UI::Viewport &viewport = NancySceneState.getViewport();
const Common::Rect screenPosition = viewport.getScreenPosition();
- const Common::Rect local = viewport.convertScreenToViewport(
- Common::Rect(input.mousePos.x, input.mousePos.y, input.mousePos.x + 1, input.mousePos.y + 1));
- point.x = local.left;
- point.y = local.top;
+ // The scroll of a background higher than the viewport only picks the part
+ // of it that shows; the records are placed by their transforms
+ point.x = input.mousePos.x - viewport.getScreenPositionRaw().left;
+ point.y = input.mousePos.y - viewport.getScreenPositionRaw().top;
return screenPosition.contains(input.mousePos);
}
diff --git a/engines/nancy/ui/viewport.h b/engines/nancy/ui/viewport.h
index afdaf354f40..7559f4eefdf 100644
--- a/engines/nancy/ui/viewport.h
+++ b/engines/nancy/ui/viewport.h
@@ -73,6 +73,7 @@ public:
void enableFrameCache() { _decoder.enableFrameCache(); }
uint16 getCurFrame() const { return _currentFrame; }
uint16 getCurVerticalScroll() const { return _drawSurface.getOffsetFromOwner().y; }
+ uint16 getFullFrameHeight() const { return _fullFrame.h; }
uint16 getMaxScroll() const;
// The currently-visible scene background, in viewport-local coords. Used by
Commit: 2bfb8566b8bffe3fe3a63a81e2b46fa9957ce12e
https://github.com/scummvm/scummvm/commit/2bfb8566b8bffe3fe3a63a81e2b46fa9957ce12e
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-20T04:04:30+02:00
Commit Message:
NANCY: DOSSIER1: Run the OnSceneEnd script
Lights, Camera, Curses runs its OnSceneEnd script when a scene of the
main stream ends, and when the game is left, unless the stream is
paused. The script saves the player's profile, which is now done at
once, in place of the save the port made on quitting.
Changed paths:
engines/nancy/nancy.cpp
engines/nancy/script/api.h
engines/nancy/script/gameapi.cpp
engines/nancy/script/scenecontext.h
engines/nancy/state/scene.cpp
engines/nancy/state/scene.h
engines/nancy/ui/ndui/manager.h
diff --git a/engines/nancy/nancy.cpp b/engines/nancy/nancy.cpp
index 069d4d59f1e..04618a22591 100644
--- a/engines/nancy/nancy.cpp
+++ b/engines/nancy/nancy.cpp
@@ -568,7 +568,7 @@ Common::Error NancyEngine::run() {
if (shouldQuit()) {
#ifdef ENABLE_NANCY_V4
if (State::Scene::hasInstance() && _gameFlow.curState == NancyState::kScene) {
- NancySceneState.saveProfileOnQuit();
+ NancySceneState.runSceneEndScript();
}
#endif
diff --git a/engines/nancy/script/api.h b/engines/nancy/script/api.h
index e5f27e6e8ea..35fe6c70cd6 100644
--- a/engines/nancy/script/api.h
+++ b/engines/nancy/script/api.h
@@ -82,9 +82,6 @@ int16 checkInventoryItem(lua_State *L, int index);
// Player, Scene, Sound, Cursor...
void registerGameAPI(lua_State *L);
-// Lights, Camera, Curses: what Save:Data(name, text) does, for the engine
-void saveDataString(const Common::String &name, const Common::String &text);
-
// Flags go by name. Both return false when there is no flag of that name.
bool setFlagByName(const Common::String &name, bool value);
bool getFlagByName(const Common::String &name, bool &value);
diff --git a/engines/nancy/script/gameapi.cpp b/engines/nancy/script/gameapi.cpp
index cf76bc9b1f6..68b6644da45 100644
--- a/engines/nancy/script/gameapi.cpp
+++ b/engines/nancy/script/gameapi.cpp
@@ -945,18 +945,6 @@ static int saveData(lua_State *L) {
return 0;
}
-void saveDataString(const Common::String &name, const Common::String &text) {
- Common::Array<byte> packed;
- packed.push_back(kSavedString);
- writeSavedUint32(packed, text.size());
- for (uint i = 0; i < text.size(); ++i) {
- packed.push_back((byte)text[i]);
- }
-
- ScriptSavedData *saved = (ScriptSavedData *)NancySceneState.getPuzzleData(ScriptSavedData::getTag());
- saved->values.setVal(name, packed);
-}
-
// Load:Data(name), which gives nil for a name nothing was saved under
static int loadData(lua_State *L) {
const char *name = luaL_checkstring(L, 2);
diff --git a/engines/nancy/script/scenecontext.h b/engines/nancy/script/scenecontext.h
index 63ef8ff6edd..ca1436b0f98 100644
--- a/engines/nancy/script/scenecontext.h
+++ b/engines/nancy/script/scenecontext.h
@@ -120,6 +120,11 @@ public:
// records get paused or go on at the start of the next frame.
void requestStreamPause(bool isPaused) { _streamPauseRequest = isPaused ? kRequestPause : kRequestResume; }
+ // Whether the stream is paused, or is about to be
+ bool isPausedByScript() const {
+ return _streamPauseRequest == kRequestNone ? _isStreamPausedByScript : _streamPauseRequest == kRequestPause;
+ }
+
#ifdef ENABLE_NANCY_V5
// Nancy26: the stream of the scene was put at another place among the
// others, so everything it draws goes elsewhere
diff --git a/engines/nancy/state/scene.cpp b/engines/nancy/state/scene.cpp
index 057be0d38cb..a4cfb9b711c 100644
--- a/engines/nancy/state/scene.cpp
+++ b/engines/nancy/state/scene.cpp
@@ -49,7 +49,6 @@
#include "engines/nancy/misc/specialeffect.h"
#include "engines/nancy/misc/viewportfader.h"
#include "engines/nancy/ui/ndui/manager.h"
-#include "engines/nancy/ui/ndui/panel.h"
#ifdef ENABLE_NANCY_V4
#include "engines/nancy/script/api.h"
#include "engines/nancy/script/records.h"
@@ -1771,8 +1770,11 @@ void Scene::synchronize(Common::Serializer &ser) {
if (g_nancy->getGameType() >= kGameTypeNancyDossier1) {
ser.syncString(_scriptSceneName);
- // The scene gets loaded again below, from nextScene and this name
- _nextScriptSceneName = _scriptSceneName;
+ // The scene gets loaded again below, from nextScene and this name. A save
+ // made as the scene changes leaves the name of the next scene alone.
+ if (ser.isLoading()) {
+ _nextScriptSceneName = _scriptSceneName;
+ }
}
#endif
@@ -2347,6 +2349,10 @@ void Scene::load(bool fromSaveFile) {
// Nancy19 scenes are Lua scripts. A script makes the records of its scene when
// it is run, the first of which names the background.
void Scene::loadScriptedScene(bool fromSaveFile) {
+ if (!fromSaveFile) {
+ runSceneEndScript();
+ }
+
// A scene that goes by name has no number; see _nextScriptSceneName
const Common::String sceneName = _nextScriptSceneName.empty() ?
Common::String::format("s%u", _sceneState.nextScene.sceneID) : _nextScriptSceneName;
@@ -2457,31 +2463,21 @@ void Scene::processMainStream() {
}
#ifdef ENABLE_NANCY_V4
-// The original does this whenever its window loses the focus, which leaving the
-// game does too. The game is being played while the lower matte shows; the
-// main menu starts it again from the scene it was in.
-void Scene::saveProfileOnQuit() {
- const Common::String &profile = g_nancy->_profile.current;
- if (g_nancy->getGameType() != kGameTypeNancyDossier1 || !_ndui || !_scriptScene || profile.empty()) {
- return;
- }
-
- const UI::NDUI::Panel *matte = _ndui->findPanel("lowerMatte");
- if (!matte || !matte->isVisible()) {
+// Lights, Camera, Curses runs the OnSceneEnd script when the scene of the main
+// stream ends, and when the game is left, unless the stream is paused. It saves
+// the game of the profile, which is done at once, while the scene is still the
+// one the player was in.
+void Scene::runSceneEndScript() {
+ if (g_nancy->getGameType() != kGameTypeNancyDossier1 || !_ndui || !_scriptScene || _scriptScene->isPausedByScript()) {
return;
}
- Script::saveDataString("LastSceneIn", getMainSceneName());
-
- int slot = _ndui->findSaveSlot(profile);
- for (int i = 1; slot == -1 && i < g_nancy->getMetaEngine()->getMaximumSaveSlot(); ++i) {
- if (i != g_nancy->getAutosaveSlot() && !g_nancy->getMetaEngine()->querySaveMetaInfos(ConfMan.getActiveDomainName().c_str(), i).isValid()) {
- slot = i;
- }
- }
+ _scriptScene->include("OnSceneEnd");
- if (slot != -1) {
- g_nancy->saveGameState(slot, profile, false);
+ const UI::NDUI::Manager::Request request = _ndui->getRequest();
+ if (request.type == UI::NDUI::Manager::kRequestSave) {
+ _ndui->takeRequest();
+ g_nancy->saveGameState(request.slot, request.name, false);
}
}
#endif
diff --git a/engines/nancy/state/scene.h b/engines/nancy/state/scene.h
index 78c9e2a59ee..2af2f495fd7 100644
--- a/engines/nancy/state/scene.h
+++ b/engines/nancy/state/scene.h
@@ -380,9 +380,9 @@ public:
// Nancy19: the scripts of the UI stream have made the panels
void onScriptedUILoaded();
- // Lights, Camera, Curses saves the profile being played when the game is
- // left, if the player was playing
- void saveProfileOnQuit();
+ // Lights, Camera, Curses: the script that ends a scene of the main stream,
+ // which saves the profile being played. It also runs when the game is left.
+ void runSceneEndScript();
// Nancy19: hands a message a script sent to the scenes it is for, of the main
// stream and of the others. Returns false when there is none.
diff --git a/engines/nancy/ui/ndui/manager.h b/engines/nancy/ui/ndui/manager.h
index a6f871d9aa4..4f573bb90d7 100644
--- a/engines/nancy/ui/ndui/manager.h
+++ b/engines/nancy/ui/ndui/manager.h
@@ -91,6 +91,7 @@ public:
~Manager();
Request takeRequest();
+ const Request &getRequest() const { return _request; }
// Nancy18 scenes save and load games by name, which is how it does second chances
void requestSave(const Common::String &name);
Commit: 909d70fd92107c22c9263ab272148812c74462ca
https://github.com/scummvm/scummvm/commit/909d70fd92107c22c9263ab272148812c74462ca
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-20T04:04:32+02:00
Commit Message:
NANCY: DOSSIER1: Show the score after loading a game
Lights, Camera, Curses keeps its UI when a profile is loaded or a new
game starts, and the score is set as the main menu's scene ends. The
port makes the UI anew instead, so it now sets the score itself, which
until then showed only once it changed.
Changed paths:
engines/nancy/state/scene.cpp
diff --git a/engines/nancy/state/scene.cpp b/engines/nancy/state/scene.cpp
index a4cfb9b711c..52a5c41e7f5 100644
--- a/engines/nancy/state/scene.cpp
+++ b/engines/nancy/state/scene.cpp
@@ -2349,6 +2349,7 @@ void Scene::load(bool fromSaveFile) {
// Nancy19 scenes are Lua scripts. A script makes the records of its scene when
// it is run, the first of which names the background.
void Scene::loadScriptedScene(bool fromSaveFile) {
+ const bool isUINew = fromSaveFile || !_scriptScene;
if (!fromSaveFile) {
runSceneEndScript();
}
@@ -2435,6 +2436,15 @@ void Scene::loadScriptedScene(bool fromSaveFile) {
if (_ndui) {
_ndui->onSceneChange(_sceneState.currentScene.sceneID);
_ndui->requestAutosave();
+
+ // Lights, Camera, Curses keeps its UI when a profile gets loaded or a new
+ // game starts, and the OnSceneEnd script of the main menu sets the score,
+ // which otherwise only shows once it changes. Here the UI is made anew.
+ if (isUINew && g_nancy->getGameType() == kGameTypeNancyDossier1) {
+ ScriptValueData *values = (ScriptValueData *)getPuzzleData(ScriptValueData::getTag());
+ const int32 score = values ? values->values.getValOrDefault("uiScore", 0) : 0;
+ _ndui->takeAction(UI::NDUI::kActionSetText, "TotalScore", Common::String::format("%d", score));
+ }
}
_streams.changeEnvironment(summary->getEnvironment());
Commit: b7f6029ddcaf75ec7e5f0c2d2722214ca1db74bf
https://github.com/scummvm/scummvm/commit/b7f6029ddcaf75ec7e5f0c2d2722214ca1db74bf
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-20T04:04:34+02:00
Commit Message:
NANCY: Blend transparent pixels onto black ones
A picture with a color key was drawn through blitFrom, which also
treats black pixels on the screen as transparent and draws partly
transparent pixels onto them at full strength. This left white specks
in the hotspot lenses of Lights, Camera, Curses over dark parts of the
scene. Such pictures now go through the alpha blending of the engine.
Changed paths:
engines/nancy/graphics.cpp
diff --git a/engines/nancy/graphics.cpp b/engines/nancy/graphics.cpp
index d594f04f321..07f36182848 100644
--- a/engines/nancy/graphics.cpp
+++ b/engines/nancy/graphics.cpp
@@ -884,14 +884,23 @@ static bool hasByteChannels(const Graphics::PixelFormat &format) {
// its components and back, which made the canvases of Nancy32's snow, as large
// as the viewport and nearly all transparent, slow to draw; this one skips the
// transparent pixels at once.
+// The pixels of a color key get left out too. blitFrom would treat the black
+// pixels of the target as transparent as well, as black is its color key from
+// Nancy16 on, and draw partly transparent pixels onto them at full strength.
static bool blitAlpha32(Graphics::ManagedSurface &target, const Graphics::ManagedSurface &src, const Common::Rect &source, const Common::Rect &dest) {
const Graphics::PixelFormat &srcFormat = src.format;
const Graphics::PixelFormat &destFormat = target.format;
if (!hasByteChannels(srcFormat) || srcFormat.aBits() != 8 || !hasByteChannels(destFormat) ||
- source.width() != dest.width() || source.height() != dest.height() || src.hasTransparentColor()) {
+ source.width() != dest.width() || source.height() != dest.height()) {
return false;
}
+ // The key is matched by its color alone, whatever its alpha, as blitFrom does.
+ // A key of 0 is a black that is fully transparent, which the alpha leaves out.
+ const uint32 colorMask = srcFormat.ARGBToColor(0, 0xFF, 0xFF, 0xFF);
+ const bool hasKey = src.hasTransparentColor() && src.getTransparentColor() != 0;
+ const uint32 key = src.getTransparentColor() & colorMask;
+
Common::Rect clipped = dest.findIntersectingRect(Common::Rect(target.w, target.h));
if (clipped.isEmpty()) {
return true;
@@ -909,7 +918,7 @@ static bool blitAlpha32(Graphics::ManagedSurface &target, const Graphics::Manage
for (int x = 0; x < clipped.width(); ++x) {
const uint32 color = srcRow[x];
const uint32 alpha = (color >> srcFormat.aShift) & 0xFF;
- if (alpha == 0) {
+ if (alpha == 0 || (hasKey && (color & colorMask) == key)) {
continue;
}
Commit: 614110a0415673f8dabb220082b317adabd836a2
https://github.com/scummvm/scummvm/commit/614110a0415673f8dabb220082b317adabd836a2
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-20T04:04:35+02:00
Commit Message:
NANCY: NANCY16: Smooth NDUI pictures drawn at another size
Nancy16 to Nancy21 draw the UI through a D3DX sprite, which turns on
linear filtering. Pictures drawn at another size, like the 60x60
inventory icons of Lights, Camera, Curses in 45x45 buttons, are now
smoothed instead of having rough edges.
Changed paths:
engines/nancy/ui/ndui/element.cpp
diff --git a/engines/nancy/ui/ndui/element.cpp b/engines/nancy/ui/ndui/element.cpp
index 4e257d02127..787d12284a0 100644
--- a/engines/nancy/ui/ndui/element.cpp
+++ b/engines/nancy/ui/ndui/element.cpp
@@ -172,7 +172,39 @@ bool Element::hasReached(ControlState state) const {
return current == _colors[state];
}
-// The texture is stretched to fill the destination, and tinted by the current color
+// Samples a texture between its four nearest pixels, like a Direct3D sampler with
+// linear filtering does, at a position in pixels where pixel centers are at .5
+static void sampleBilinear(const Graphics::ManagedSurface &texture, double x, double y, byte &a, byte &r, byte &g, byte &b) {
+ x -= 0.5;
+ y -= 0.5;
+ const int x0 = (int)floor(x);
+ const int y0 = (int)floor(y);
+ const double fx = x - x0;
+ const double fy = y - y0;
+
+ double channels[4] = { 0.0, 0.0, 0.0, 0.0 };
+ for (int i = 0; i < 4; ++i) {
+ const int px = CLIP<int>(x0 + (i & 1), 0, texture.w - 1);
+ const int py = CLIP<int>(y0 + (i >> 1), 0, texture.h - 1);
+ const double weight = ((i & 1) ? fx : 1.0 - fx) * ((i >> 1) ? fy : 1.0 - fy);
+
+ byte pa, pr, pg, pb;
+ texture.format.colorToARGB(texture.getPixel(px, py), pa, pr, pg, pb);
+ channels[0] += pa * weight;
+ channels[1] += pr * weight;
+ channels[2] += pg * weight;
+ channels[3] += pb * weight;
+ }
+
+ a = (byte)CLIP<int>((int)(channels[0] + 0.5), 0, 255);
+ r = (byte)CLIP<int>((int)(channels[1] + 0.5), 0, 255);
+ g = (byte)CLIP<int>((int)(channels[2] + 0.5), 0, 255);
+ b = (byte)CLIP<int>((int)(channels[3] + 0.5), 0, 255);
+}
+
+// The texture is stretched to fill the destination, and tinted by the current color.
+// Nancy16 to Nancy21 draw it through a D3DX sprite, whose Begin sets linear
+// filtering, so a texture drawn at another size is smoothed.
void Element::drawSprite(Graphics::ManagedSurface &surface, const Common::Rect &src, const Common::Rect &dest, const Graphics::ManagedSurface &texture) const {
byte tintA = colorChannelToByte(_current[0]);
if (tintA == 0 || src.isEmpty() || dest.isEmpty()) {
@@ -184,6 +216,29 @@ void Element::drawSprite(Graphics::ManagedSurface &surface, const Common::Rect &
byte tintB = colorChannelToByte(_current[3]);
Common::Rect clipped = dest.findIntersectingRect(Common::Rect(surface.w, surface.h));
+
+ const bool isFiltered = g_nancy->getGameType() <= kGameTypeNancy21 &&
+ (src.width() != dest.width() || src.height() != dest.height());
+ if (isFiltered) {
+ const double scaleX = (double)src.width() / dest.width();
+ const double scaleY = (double)src.height() / dest.height();
+ for (int y = clipped.top; y < clipped.bottom; ++y) {
+ const double srcY = src.top + (y - dest.top + 0.5) * scaleY;
+ for (int x = clipped.left; x < clipped.right; ++x) {
+ const double srcX = src.left + (x - dest.left + 0.5) * scaleX;
+
+ byte a, r, g, b;
+ sampleBilinear(texture, srcX, srcY, a, r, g, b);
+ a = a * tintA / 255;
+ if (a != 0) {
+ blendPixel(surface, x, y, a, r * tintR / 255, g * tintG / 255, b * tintB / 255);
+ }
+ }
+ }
+
+ return;
+ }
+
for (int y = clipped.top; y < clipped.bottom; ++y) {
int srcY = src.top + (y - dest.top) * src.height() / dest.height();
for (int x = clipped.left; x < clipped.right; ++x) {
Commit: 680ee8c611976bf1c244728c708c203ccd97f7f4
https://github.com/scummvm/scummvm/commit/680ee8c611976bf1c244728c708c203ccd97f7f4
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-20T04:04:36+02:00
Commit Message:
NANCY: DOSSIER1: Keep the music of the area playing
Lights, Camera, Curses loops the music of the area until another
area's music replaces it, where Nancy19 plays it once. The music no
longer stops after a while.
Changed paths:
engines/nancy/script/records.cpp
engines/nancy/sound.h
diff --git a/engines/nancy/script/records.cpp b/engines/nancy/script/records.cpp
index ef077ec4e5f..ef40b1b61bc 100644
--- a/engines/nancy/script/records.cpp
+++ b/engines/nancy/script/records.cpp
@@ -543,9 +543,12 @@ void SummaryRecord::readTable(int tableIndex) {
static const uint16 kThemeChannel = 0;
static const uint16 kThemeVolume = 85;
-// Starts one of the themes of the area, unless one is playing
+// Starts one of the themes of the area. Nancy19 plays it once, unless a theme
+// is playing. Lights, Camera, Curses plays it over and over, in place of the
+// theme playing, unless that is the same.
void SummaryRecord::playTheme() {
- if (g_nancy->_sound->isSoundPlaying(kThemeChannel)) {
+ const bool isLooped = g_nancy->getGameType() == kGameTypeNancyDossier1;
+ if (!isLooped && g_nancy->_sound->isSoundPlaying(kThemeChannel)) {
return;
}
@@ -561,8 +564,13 @@ void SummaryRecord::playTheme() {
SoundDescription sound;
sound.name = environment.musicNames[g_nancy->_randomSource->getRandomNumber(environment.musicNames.size() - 1)];
+ if (isLooped && g_nancy->_sound->isSoundPlaying(kThemeChannel) &&
+ g_nancy->_sound->getSoundName(kThemeChannel).equalsIgnoreCase(sound.name)) {
+ return;
+ }
+
sound.channelID = kThemeChannel;
- sound.numLoops = 1;
+ sound.numLoops = isLooped ? 0 : 1;
sound.volume = kThemeVolume;
g_nancy->_sound->loadSound(sound);
diff --git a/engines/nancy/sound.h b/engines/nancy/sound.h
index 18dbae7fde4..3b59137bd71 100644
--- a/engines/nancy/sound.h
+++ b/engines/nancy/sound.h
@@ -83,6 +83,9 @@ public:
bool isSoundPlaying(const SoundDescription &description) const;
bool isSoundPlaying(const Common::String &chunkName) const;
+ // The name of the sound last loaded into a channel
+ const Common::String &getSoundName(uint16 channelID) const { return _channels[channelID].name; }
+
// Goes up whenever a sound starts on the channel or the channel is stopped,
// but not when a sound ends by itself. Nancy19 records tell from it whether
// their sound was cut off.
Commit: c409955baac8a80bf74fa3836a9176ee90aad3ab
https://github.com/scummvm/scummvm/commit/c409955baac8a80bf74fa3836a9176ee90aad3ab
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-20T04:04:38+02:00
Commit Message:
NANCY: Remove blitAlpha32
It added a lot of code for a small speed gain. Pictures are drawn with
blitFrom again. The screen no longer has a color key: blitFrom treated
its black pixels as transparent and drew partly transparent pixels
onto them at full strength, e.g. the hotspot lenses of Dossier1.
Changed paths:
engines/nancy/graphics.cpp
diff --git a/engines/nancy/graphics.cpp b/engines/nancy/graphics.cpp
index 07f36182848..89f61e1e4f6 100644
--- a/engines/nancy/graphics.cpp
+++ b/engines/nancy/graphics.cpp
@@ -123,8 +123,10 @@ void GraphicsManager::init() {
(bsum->bTrans << format.bShift);
}
+ // The screen has no color key: blitFrom would treat its pixels of that color
+ // as transparent too, and draw partly transparent pixels onto them at full
+ // strength, e.g. the lenses of Dossier1 over dark parts of a scene
initGraphics(_screen.w, _screen.h, &getScreenPixelFormat());
- _screen.setTransparentColor(getTransColor());
_screen.clear();
// Nancy16 runs at a higher resolution than the game was made for. The
@@ -134,7 +136,6 @@ void GraphicsManager::init() {
if (g_nancy->getGameType() >= kGameTypeNancy16 && viewportData &&
(viewportData->bounds.width() != _screen.w || viewportData->bounds.height() != _screen.h)) {
_gameSurface.create(viewportData->bounds.width(), viewportData->bounds.height(), getScreenPixelFormat());
- _gameSurface.setTransparentColor(getTransColor());
_gameSurface.clear();
}
@@ -879,87 +880,6 @@ static bool hasByteChannels(const Graphics::PixelFormat &format) {
(format.aBits() == 8 || format.aBits() == 0);
}
-// Blends a 32 bit picture with an alpha channel onto a 32 bit target, giving
-// the same pixels as ManagedSurface::blitFrom. That one turns every pixel into
-// its components and back, which made the canvases of Nancy32's snow, as large
-// as the viewport and nearly all transparent, slow to draw; this one skips the
-// transparent pixels at once.
-// The pixels of a color key get left out too. blitFrom would treat the black
-// pixels of the target as transparent as well, as black is its color key from
-// Nancy16 on, and draw partly transparent pixels onto them at full strength.
-static bool blitAlpha32(Graphics::ManagedSurface &target, const Graphics::ManagedSurface &src, const Common::Rect &source, const Common::Rect &dest) {
- const Graphics::PixelFormat &srcFormat = src.format;
- const Graphics::PixelFormat &destFormat = target.format;
- if (!hasByteChannels(srcFormat) || srcFormat.aBits() != 8 || !hasByteChannels(destFormat) ||
- source.width() != dest.width() || source.height() != dest.height()) {
- return false;
- }
-
- // The key is matched by its color alone, whatever its alpha, as blitFrom does.
- // A key of 0 is a black that is fully transparent, which the alpha leaves out.
- const uint32 colorMask = srcFormat.ARGBToColor(0, 0xFF, 0xFF, 0xFF);
- const bool hasKey = src.hasTransparentColor() && src.getTransparentColor() != 0;
- const uint32 key = src.getTransparentColor() & colorMask;
-
- Common::Rect clipped = dest.findIntersectingRect(Common::Rect(target.w, target.h));
- if (clipped.isEmpty()) {
- return true;
- }
-
- const int offsetX = source.left - dest.left;
- const int offsetY = source.top - dest.top;
- const bool isSameFormat = srcFormat == destFormat;
- const bool hasDestAlpha = destFormat.aBits() == 8;
-
- for (int y = clipped.top; y < clipped.bottom; ++y) {
- const uint32 *srcRow = (const uint32 *)src.getBasePtr(clipped.left + offsetX, y + offsetY);
- uint32 *destRow = (uint32 *)target.getBasePtr(clipped.left, y);
-
- for (int x = 0; x < clipped.width(); ++x) {
- const uint32 color = srcRow[x];
- const uint32 alpha = (color >> srcFormat.aShift) & 0xFF;
- if (alpha == 0 || (hasKey && (color & colorMask) == key)) {
- continue;
- }
-
- const uint32 r = (color >> srcFormat.rShift) & 0xFF;
- const uint32 g = (color >> srcFormat.gShift) & 0xFF;
- const uint32 b = (color >> srcFormat.bShift) & 0xFF;
-
- if (alpha == 0xFF) {
- destRow[x] = isSameFormat ? color : destFormat.ARGBToColor(0xFF, r, g, b);
- continue;
- }
-
- const uint32 destColor = destRow[x];
- const uint32 destAlpha = hasDestAlpha ? (destColor >> destFormat.aShift) & 0xFF : 0xFF;
- uint32 dr = (destColor >> destFormat.rShift) & 0xFF;
- uint32 dg = (destColor >> destFormat.gShift) & 0xFF;
- uint32 db = (destColor >> destFormat.bShift) & 0xFF;
- uint32 da = destAlpha;
-
- if (destAlpha == 0xFF) {
- // x * 257 * 257 >> 24 is about x / 255, rounded as ManagedSurface::blitFrom does
- dr = (((dr * (255U - alpha) + r * alpha) * (257U * 257U)) >> 24) & 0xFF;
- dg = (((dg * (255U - alpha) + g * alpha) * (257U * 257U)) >> 24) & 0xFF;
- db = (((db * (255U - alpha) + b * alpha) * (257U * 257U)) >> 24) & 0xFF;
- } else {
- const double sAlpha = alpha / 255.0;
- const double dAlpha = destAlpha / 255.0 * (1.0 - sAlpha);
- dr = (uint32)((r * sAlpha + dr * dAlpha) / (sAlpha + dAlpha));
- dg = (uint32)((g * sAlpha + dg * dAlpha) / (sAlpha + dAlpha));
- db = (uint32)((b * sAlpha + db * dAlpha) / (sAlpha + dAlpha));
- da = (uint32)(255. * (sAlpha + dAlpha));
- }
-
- destRow[x] = destFormat.ARGBToColor(da, dr, dg, db);
- }
- }
-
- target.addDirtyRect(clipped);
- return true;
-}
-
// The channels of every pixel get multiplied by those of the color, through
// tables, with no conversions of the pixel formats. A picture without alpha
// leaves out its pixels of the color key.
@@ -1015,10 +935,7 @@ void GraphicsManager::blitObject(Graphics::ManagedSurface &target, const RenderO
if (!src.isZoomed()) {
const Common::Rect source = src._drawSurface.getBounds().findIntersectingRect(src.convertToLocal(screenRect));
- if (!blitAlpha32(target, src._drawSurface, source, screenRect)) {
- target.blitFrom(src._drawSurface, source, screenRect);
- }
-
+ target.blitFrom(src._drawSurface, source, screenRect);
return;
}
@@ -1090,9 +1007,7 @@ void GraphicsManager::blitMaskedObject(Graphics::ManagedSurface &target, const R
}
}
- if (!blitAlpha32(target, part, part.getBounds(), screenRect)) {
- target.blitFrom(part, part.getBounds(), screenRect);
- }
+ target.blitFrom(part, part.getBounds(), screenRect);
}
Common::Rect GraphicsManager::getDrawnPosition(const RenderObject &object) const {
Commit: 91c72a6e3dd1b3db40a2b203fe55cffd539365e7
https://github.com/scummvm/scummvm/commit/91c72a6e3dd1b3db40a2b203fe55cffd539365e7
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-20T04:04:39+02:00
Commit Message:
NANCY: DOSSIER1: Speed up drawing under the flashlight
Records the flashlight cuts holes into, like the 41 dark overlays of
scene 3300, worked out the flashlight's picture for every pixel they
drew, which slowed the game down. This is now worked out once for
each row and each column of the area drawn.
Changed paths:
engines/nancy/graphics.cpp
diff --git a/engines/nancy/graphics.cpp b/engines/nancy/graphics.cpp
index 89f61e1e4f6..153d5ebe056 100644
--- a/engines/nancy/graphics.cpp
+++ b/engines/nancy/graphics.cpp
@@ -958,24 +958,44 @@ void GraphicsManager::blitObject(Graphics::ManagedSurface &target, const RenderO
}
}
-// Whether a stencil object covers a pixel of the screen: where its picture
-// isn't transparent, as the alpha test of the original lets through. The mask
-// of the flashlight is black where it lights, so its alpha is what counts.
-static bool isStencilPixel(const RenderObject &stencil, int x, int y) {
- const Common::Rect local = stencil.convertToLocal(Common::Rect(x, y, x + 1, y + 1));
+// Marks the pixels of a part of the screen that a stencil object covers: where
+// its picture isn't transparent, as the alpha test of the original lets through.
+// The mask of the flashlight is black where it lights, so its alpha is what
+// counts. Where a pixel is in the picture goes by its column and its row alone,
+// so they are worked out once for each column and each row.
+static void markStencilPixels(const RenderObject &stencil, const Common::Rect &screenRect, Common::Array<byte> &covered) {
const Graphics::ManagedSurface &surface = stencil._drawSurface;
- if (!surface.getBounds().contains(local.left, local.top)) {
- return false;
- }
- const uint32 color = surface.getPixel(local.left, local.top);
- if (surface.format.aBits() == 0) {
- return !surface.hasTransparentColor() || color != surface.getTransparentColor();
+ Common::Array<int> columns(screenRect.width());
+ for (int x = 0; x < screenRect.width(); ++x) {
+ const int sx = screenRect.left + x;
+ columns[x] = stencil.convertToLocal(Common::Rect(sx, screenRect.top, sx + 1, screenRect.top + 1)).left;
}
- byte a, r, g, b;
- surface.format.colorToARGB(color, a, r, g, b);
- return a != 0;
+ for (int y = 0; y < screenRect.height(); ++y) {
+ const int sy = screenRect.top + y;
+ const int localY = stencil.convertToLocal(Common::Rect(screenRect.left, sy, screenRect.left + 1, sy + 1)).top;
+ if (localY < 0 || localY >= surface.h) {
+ continue;
+ }
+
+ byte *coveredRow = &covered[y * screenRect.width()];
+ for (int x = 0; x < screenRect.width(); ++x) {
+ const int localX = columns[x];
+ if (coveredRow[x] || localX < 0 || localX >= surface.w) {
+ continue;
+ }
+
+ const uint32 color = surface.getPixel(localX, localY);
+ if (surface.format.aBits() == 0) {
+ coveredRow[x] = !surface.hasTransparentColor() || color != surface.getTransparentColor();
+ } else {
+ byte a, r, g, b;
+ surface.format.colorToARGB(color, a, r, g, b);
+ coveredRow[x] = a != 0;
+ }
+ }
+ }
}
// Draws an object without the pixels the stencils cover, through a transparent
@@ -988,21 +1008,20 @@ void GraphicsManager::blitMaskedObject(Graphics::ManagedSurface &target, const R
return;
}
+ Common::Array<byte> covered(screenRect.width() * screenRect.height(), 0);
+ for (const RenderObject *stencil : stencils) {
+ markStencilPixels(*stencil, screenRect, covered);
+ }
+
Graphics::ManagedSurface part(source.width(), source.height(), _transparentPixelFormat);
for (int y = 0; y < source.height(); ++y) {
for (int x = 0; x < source.width(); ++x) {
const uint32 color = image.getPixel(source.left + x, source.top + y);
byte a = 0, r = 0, g = 0, b = 0;
- if (!image.hasTransparentColor() || color != image.getTransparentColor()) {
+ if (!covered[y * source.width() + x] && (!image.hasTransparentColor() || color != image.getTransparentColor())) {
image.format.colorToARGB(color, a, r, g, b);
}
- for (uint i = 0; a != 0 && i < stencils.size(); ++i) {
- if (isStencilPixel(*stencils[i], screenRect.left + x, screenRect.top + y)) {
- a = 0;
- }
- }
-
part.setPixel(x, y, _transparentPixelFormat.ARGBToColor(a, r, g, b));
}
}
More information about the Scummvm-git-logs
mailing list