[Scummvm-git-logs] scummvm master -> 9ca91becc78f931211f32d649ac2daf83293df3a
klusark
noreply at scummvm.org
Tue Nov 10 15:23:44 UTC 2026
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
9ca91becc7 GRIM: Add support for thumbnail save images in the launcher
Commit: 9ca91becc78f931211f32d649ac2daf83293df3a
https://github.com/scummvm/scummvm/commit/9ca91becc78f931211f32d649ac2daf83293df3a
Author: Joel Teichroeb (joel at teichroeb.net)
Date: 2026-11-10T10:22:57-05:00
Commit Message:
GRIM: Add support for thumbnail save images in the launcher
Assisted-by: Claude:claude-opus-5-5
Changed paths:
engines/grim/metaengine.cpp
engines/grim/savegame.cpp
engines/grim/savegame.h
diff --git a/engines/grim/metaengine.cpp b/engines/grim/metaengine.cpp
index 6b8f54e169e..177f354c9cd 100644
--- a/engines/grim/metaengine.cpp
+++ b/engines/grim/metaengine.cpp
@@ -28,6 +28,9 @@
#include "common/translation.h"
#include "common/config-manager.h"
+#include "graphics/scaler.h"
+#include "graphics/surface.h"
+
namespace Grim {
static const ADExtraGuiOptionsMap gameGuiOptions[] = {
@@ -75,6 +78,7 @@ public:
SaveStateList listSaves(const char *target) const override;
+ SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const override;
};
Common::Error GrimMetaEngine::createInstance(OSystem *syst, Engine **engine, const Grim::GrimGameDescription *desc) const {
@@ -101,7 +105,9 @@ Common::Error GrimMetaEngine::createInstance(OSystem *syst, Engine **engine, con
bool GrimMetaEngine::hasFeature(MetaEngineFeature f) const {
return
(f == kSupportsListSaves) ||
- (f == kSupportsLoadingDuringStartup);
+ (f == kSupportsLoadingDuringStartup) ||
+ (f == kSavesSupportMetaInfo) ||
+ (f == kSavesSupportThumbnail);
}
Common::KeymapArray GrimMetaEngine::initKeymaps(const char *target) const {
@@ -165,6 +171,58 @@ SaveStateList GrimMetaEngine::listSaves(const char *target) const {
return saveList;
}
+SaveStateDescriptor GrimMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
+ Common::String gameId = ConfMan.get("gameid", target);
+ Common::Platform platform = Common::parsePlatform(ConfMan.get("platform", target));
+ const bool isEMI = gameId == "monkey4";
+ Common::String filename;
+
+ if (isEMI) {
+ if (platform == Common::kPlatformPS2)
+ filename = Common::String::format("efmi%03d.ps2", slot);
+ else
+ filename = Common::String::format("efmi%03d.gsv", slot);
+ } else {
+ filename = Common::String::format("grim%02d.gsv", slot);
+ }
+
+ SaveGame *savedState = SaveGame::openForLoading(filename);
+ if (!savedState || !savedState->isCompatible()) {
+ delete savedState;
+ return {};
+ }
+
+ SaveStateDescriptor desc(this, slot, Common::U32String());
+
+ // Grim stores a 250x188 screenshot, EMI a 160x120 one stretched to 256x128
+ const int width = isEMI ? 256 : 250;
+ const int height = isEMI ? 128 : 188;
+ if (savedState->hasSection('SIMG')) {
+ uint32 dataSize = savedState->beginSection('SIMG');
+ if (dataSize == (uint32)(width * height * 2)) {
+ Graphics::Surface screenshot;
+ screenshot.create(width, height, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0));
+ uint16 *pixels = (uint16 *)screenshot.getPixels();
+ for (int i = 0; i < width * height; i++)
+ pixels[i] = savedState->readLEUint16();
+ desc.setThumbnail(screenshot.scale(kThumbnailWidth, kThumbnailHeight2, true));
+ screenshot.free();
+ }
+ savedState->endSection();
+ }
+
+ uint32 descTag = platform == Common::kPlatformPS2 ? 'PS2S' : 'SUBS';
+ if (savedState->hasSection(descTag)) {
+ savedState->beginSection(descTag);
+ Common::String str = savedState->readString();
+ savedState->endSection();
+ desc.setDescription(str.c_str());
+ }
+
+ delete savedState;
+ return desc;
+}
+
} // End of namespace Grim
#if PLUGIN_ENABLED_DYNAMIC(GRIM)
diff --git a/engines/grim/savegame.cpp b/engines/grim/savegame.cpp
index 12fd899b0c4..4ca9016ac0f 100644
--- a/engines/grim/savegame.cpp
+++ b/engines/grim/savegame.cpp
@@ -105,6 +105,28 @@ bool SaveGame::isCompatible() const {
return _majorVersion == SAVEGAME_MAJOR_VERSION && _minorVersion <= SAVEGAME_MINOR_VERSION;
}
+bool SaveGame::hasSection(uint32 sectionTag) {
+ if (_saving || _currentSection != 0)
+ return false;
+
+ int64 pos = _inSaveFile->pos();
+ bool found = false;
+ for (;;) {
+ uint32 tag = _inSaveFile->readUint32BE();
+ if (_inSaveFile->eos() || _inSaveFile->err() || tag == SAVEGAME_FOOTERTAG)
+ break;
+ if (tag == sectionTag) {
+ found = true;
+ break;
+ }
+ uint32 size = _inSaveFile->readUint32BE();
+ _inSaveFile->seek(size, SEEK_CUR);
+ }
+ _inSaveFile->clearErr();
+ _inSaveFile->seek(pos);
+ return found;
+}
+
uint SaveGame::saveMajorVersion() const {
return _majorVersion;
}
diff --git a/engines/grim/savegame.h b/engines/grim/savegame.h
index 3142fa3664d..9481275fe23 100644
--- a/engines/grim/savegame.h
+++ b/engines/grim/savegame.h
@@ -51,6 +51,7 @@ public:
static uint SAVEGAME_MINOR_VERSION;
bool isCompatible() const;
+ bool hasSection(uint32 sectionTag);
uint saveMajorVersion() const;
uint saveMinorVersion() const;
More information about the Scummvm-git-logs
mailing list