[Scummvm-git-logs] scummvm master -> 24312ed3274427457c3cb3989df977dafe8caab7
alxpnv
noreply at scummvm.org
Tue Aug 2 11:36:30 UTC 2022
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
24312ed327 ASYLUM: bring back Load Game screen thumbnails
Commit: 24312ed3274427457c3cb3989df977dafe8caab7
https://github.com/scummvm/scummvm/commit/24312ed3274427457c3cb3989df977dafe8caab7
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2022-08-02T14:39:09+03:00
Commit Message:
ASYLUM: bring back Load Game screen thumbnails
Changed paths:
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
engines/asylum/views/menu.cpp
engines/asylum/views/menu.h
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index a0138b885b6..8cd593dcada 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -183,6 +183,10 @@ void Screen::draw(GraphicResource *resource, uint32 frameIndex, const Common::Po
}
}
+void Screen::draw(const Graphics::Surface &surface, int x, int y) {
+ _backBuffer.copyRectToSurface(surface, x, y, Common::Rect(0, 0, surface.w, surface.h));
+}
+
//////////////////////////////////////////////////////////////////////////
// Misc
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index 9854a5ea5c7..1a17d918372 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -91,6 +91,7 @@ public:
void drawTransparent(ResourceId resourceId, uint32 frameIndex, const Common::Point &source, DrawFlags flags, uint32 transTableNum);
void drawTransparent(GraphicResource *resource, uint32 frameIndex, const Common::Point &source, DrawFlags flags, uint32 transTableNum);
void draw(ResourceId resourceId, uint32 frameIndex, const Common::Point &source, DrawFlags flags, ResourceId resourceId2, const Common::Point &destination, bool colorKey = true);
+ void draw(const Graphics::Surface &surface, int x, int y);
// Misc
void clear();
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 630dab6fbab..57e9f52cbcb 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -26,6 +26,8 @@
#include "common/keyboard.h"
+#include "graphics/palette.h"
+
#include "asylum/views/menu.h"
#include "asylum/resources/actor.h"
@@ -78,6 +80,9 @@ Menu::Menu(AsylumEngine *vm): _vm(vm) {
_prefixWidth = 0;
_loadingDuringStartup = false;
+ // Thumbnails
+ _thumbnailIndex = -1;
+
// Credits
_creditsFrameIndex = 0;
switch (_vm->getLanguage()) {
@@ -734,6 +739,39 @@ void Menu::updateNewGame() {
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1323));
}
+bool Menu::hasThumbnail(int index) {
+ if (getSaveLoad()->hasSavegame(index + _startIndex))
+ return _vm->getMetaEngine()->querySaveMetaInfos(_vm->getTargetName().c_str(), index + _startIndex).getThumbnail();
+
+ return false;
+}
+
+void Menu::readThumbnail() {
+ if (_thumbnailSurface.getPixels())
+ _thumbnailSurface.free();
+
+ Graphics::PaletteLookup paletteLookup(getScreen()->getPalette(), 256);
+ SaveStateDescriptor desc = _vm->getMetaEngine()->querySaveMetaInfos(_vm->getTargetName().c_str(), _thumbnailIndex + _startIndex);
+ const Graphics::Surface *thumbnail = desc.getThumbnail();
+ int w = thumbnail->w, h = thumbnail->h;
+
+ _thumbnailSurface.create(w, h, Graphics::PixelFormat::createFormatCLUT8());
+ for (int i = 0; i < w; i++)
+ for (int j = 0; j < h; j++) {
+ byte r, g, b;
+ thumbnail->format.colorToRGB(thumbnail->getPixel(i, j), r, g, b);
+ _thumbnailSurface.setPixel(i, j, paletteLookup.findBestColor(r, g, b));
+ }
+}
+
+void Menu::showThumbnail() {
+ int x, y;
+ x = _thumbnailIndex < 6 ? 150 : 470;
+ y = 179 + (_thumbnailIndex % 6) * 29;
+
+ getScreen()->draw(_thumbnailSurface, x, y);
+}
+
void Menu::updateLoadGame() {
Common::Point cursor = getCursor()->position();
@@ -769,6 +807,7 @@ void Menu::updateLoadGame() {
getText()->loadFont(kFontYellow);
getText()->drawCentered(Common::Point(10, 100), 620, MAKE_RESOURCE(kResourcePackText, 1325));
+ int current = -1;
if (_dword_455C78) {
getText()->drawCentered(Common::Point(10, 190), 620, MAKE_RESOURCE(kResourcePackText, 1332));
getText()->drawCentered(Common::Point(10, 190 + 29), 620, MAKE_RESOURCE(kResourcePackText, 1333));
@@ -798,6 +837,8 @@ void Menu::updateLoadGame() {
getText()->loadFont(kFontYellow);
} else {
getText()->loadFont(kFontBlue);
+ if (hasThumbnail(index))
+ current = index;
}
getText()->setPosition(Common::Point(30, y));
@@ -819,6 +860,8 @@ void Menu::updateLoadGame() {
getText()->loadFont(kFontYellow);
} else {
getText()->loadFont(kFontBlue);
+ if (hasThumbnail(index))
+ current = index;
}
getText()->setPosition(Common::Point(350, y));
@@ -860,6 +903,18 @@ void Menu::updateLoadGame() {
getText()->setPosition(Common::Point(550, 340));
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1327));
+
+ if (current == -1) {
+ _thumbnailIndex = -1;
+ return;
+ }
+
+ if (current != _thumbnailIndex) {
+ _thumbnailIndex = current;
+ readThumbnail();
+ }
+
+ showThumbnail();
}
void Menu::updateSaveGame() {
diff --git a/engines/asylum/views/menu.h b/engines/asylum/views/menu.h
index a6033eb6e8d..6217d4b0c28 100644
--- a/engines/asylum/views/menu.h
+++ b/engines/asylum/views/menu.h
@@ -22,6 +22,8 @@
#ifndef ASYLUM_VIEWS_MENU_H
#define ASYLUM_VIEWS_MENU_H
+#include "graphics/surface.h"
+
#include "asylum/eventhandler.h"
#include "asylum/shared.h"
@@ -131,6 +133,10 @@ private:
int32 _prefixWidth;
bool _loadingDuringStartup;
+ // Thumbnails
+ int _thumbnailIndex;
+ Graphics::Surface _thumbnailSurface;
+
/**
* Setups menu screen
*/
@@ -207,6 +213,11 @@ private:
bool key(const AsylumEvent &evt);
bool click(const AsylumEvent &evt);
+ // Thumbnails
+ bool hasThumbnail(int index);
+ void readThumbnail();
+ void showThumbnail();
+
// Update handlers
void updateNewGame();
void updateLoadGame();
More information about the Scummvm-git-logs
mailing list