diff --git a/engines/qdengine/metaengine.cpp b/engines/qdengine/metaengine.cpp index d3bef9842fa..3c062a9768a 100644 --- a/engines/qdengine/metaengine.cpp +++ b/engines/qdengine/metaengine.cpp @@ -19,9 +19,10 @@ * */ - +#define FORBIDDEN_SYMBOL_ALLOW_ALL #include "qdengine/metaengine.h" #include "qdengine/qdengine.h" +#include "qdengine/qdcore/qd_game_dispatcher.h" const char *QDEngineMetaEngine::getName() const { return "qdengine"; @@ -43,6 +44,12 @@ bool QDEngineMetaEngine::hasFeature(MetaEngineFeature f) const { (f == kSupportsLoadingDuringStartup); } +void QDEngineMetaEngine::getSavegameThumbnail(Graphics::Surface &thumb) { + QDEngine::qdGameDispatcher *dp = QDEngine::qdGameDispatcher::get_dispatcher(); + if (dp) + dp->game_screenshot(thumb); +} + #if PLUGIN_ENABLED_DYNAMIC(QDENGINE) REGISTER_PLUGIN_DYNAMIC(QDENGINE, PLUGIN_TYPE_ENGINE, QDEngineMetaEngine); #else diff --git a/engines/qdengine/metaengine.h b/engines/qdengine/metaengine.h index 267958d3300..f69d11a733f 100644 --- a/engines/qdengine/metaengine.h +++ b/engines/qdengine/metaengine.h @@ -37,6 +37,8 @@ public: * Used by e.g. the launcher to determine whether to enable the Load button. */ bool hasFeature(MetaEngineFeature f) const override; + + virtual void getSavegameThumbnail(Graphics::Surface &thumb) override; }; #endif // QDENGINE_METAENGINE_H diff --git a/engines/qdengine/qdcore/qd_game_dispatcher.cpp b/engines/qdengine/qdcore/qd_game_dispatcher.cpp index 298c7e1f59a..2cb35b96343 100644 --- a/engines/qdengine/qdcore/qd_game_dispatcher.cpp +++ b/engines/qdengine/qdcore/qd_game_dispatcher.cpp @@ -2912,11 +2912,38 @@ const char *qdGameDispatcher::get_save_name(int slot_id, SaveFileType file_type) return file_name.c_str(); } +bool qdGameDispatcher::game_screenshot(Graphics::Surface &thumb) const { + int w = qdGameConfig::get_config().screen_sx(); + int h = qdGameConfig::get_config().screen_sy(); + + thumb.create(w, h, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0)); + + if (qdGameScene * sp = get_active_scene()) { + qdSprite sprite(w, h, GR_RGB565); + + sp->redraw(); + + uint16 col; + for (int i = 0; i < h; i++) { + uint16 *dst = (uint16 *)thumb.getBasePtr(0, i); + for (int j = 0; j < w; j++) { + grDispatcher::instance()->GetPixel(j, i, col); + *dst = col; + dst++; + } + } + + return true; + } + + return false; +} + bool qdGameDispatcher::game_screenshot(const char *file_name, int sx, int sy) const { if (qdGameScene * sp = get_active_scene()) { qdSprite sprite(qdGameConfig::get_config().screen_sx(), qdGameConfig::get_config().screen_sy(), - GR_RGB888); + GR_RGB565); sp->redraw();