aboutsummaryrefslogtreecommitdiff
path: root/engines/sword25/gfx
diff options
context:
space:
mode:
authormd52011-05-05 22:03:15 +0300
committermd52011-05-05 22:03:15 +0300
commitd7334628bd59a8d4019be788d1a42b9171beae3b (patch)
tree5650a1c8ee5f18ab544283eaaa222e3308db2639 /engines/sword25/gfx
parent51136ac4aeed8733c10e0c148ea1a8dc30e824ca (diff)
downloadscummvm-rg350-d7334628bd59a8d4019be788d1a42b9171beae3b.tar.gz
scummvm-rg350-d7334628bd59a8d4019be788d1a42b9171beae3b.tar.bz2
scummvm-rg350-d7334628bd59a8d4019be788d1a42b9171beae3b.zip
SWORD25: Moved the thumbnail handling code to its appropriate place
PNGLoader is able to load images embedded in saved games already. This helps remove some duplicate code
Diffstat (limited to 'engines/sword25/gfx')
-rw-r--r--engines/sword25/gfx/image/renderedimage.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/engines/sword25/gfx/image/renderedimage.cpp b/engines/sword25/gfx/image/renderedimage.cpp
index 806d9b27ad..65ff1c703d 100644
--- a/engines/sword25/gfx/image/renderedimage.cpp
+++ b/engines/sword25/gfx/image/renderedimage.cpp
@@ -36,6 +36,7 @@
// INCLUDES
// -----------------------------------------------------------------------------
+#include "common/savefile.h"
#include "sword25/package/packagemanager.h"
#include "sword25/gfx/image/pngloader.h"
#include "sword25/gfx/image/renderedimage.h"
@@ -44,6 +45,14 @@
namespace Sword25 {
+// Duplicated from kernel/persistenceservice.cpp
+static Common::String generateSavegameFilename(uint slotID) {
+ char buffer[100];
+ // NOTE: This is hardcoded to sword25
+ snprintf(buffer, 100, "%s.%.3d", "sword25", slotID);
+ return Common::String(buffer);
+}
+
// -----------------------------------------------------------------------------
// CONSTRUCTION / DESTRUCTION
// -----------------------------------------------------------------------------
@@ -62,7 +71,20 @@ RenderedImage::RenderedImage(const Common::String &filename, bool &result) :
// Load file
byte *pFileData;
uint fileSize;
- pFileData = pPackage->getFile(filename, &fileSize);
+
+ if (filename.hasPrefix("/saves")) {
+ // A savegame thumbnail
+ Common::SaveFileManager *sfm = g_system->getSavefileManager();
+ int slotNum = atoi(filename.c_str() + filename.size() - 3);
+ Common::InSaveFile *file = sfm->openForLoading(generateSavegameFilename(slotNum));
+ fileSize = file->size();
+ pFileData = new byte[fileSize];
+ file->read(pFileData, fileSize);
+ delete file;
+ } else {
+ pFileData = pPackage->getFile(filename, &fileSize);
+ }
+
if (!pFileData) {
error("File \"%s\" could not be loaded.", filename.c_str());
return;