mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-24 11:36:22 +00:00
SWORD25: Implemented thumbnail loading for savegame list
svn-id: r53374
This commit is contained in:
parent
80521ed5dd
commit
3e84d4fe73
@ -46,30 +46,36 @@ namespace Sword25 {
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
namespace {
|
||||
static Common::String LoadString(Common::ReadStream &In, uint MaxSize = 999) {
|
||||
Common::String Result;
|
||||
|
||||
char ch = (char)In.readByte();
|
||||
while ((ch != '\0') && (ch != ' ')) {
|
||||
Result += ch;
|
||||
if (Result.size() >= MaxSize) break;
|
||||
ch = (char)In.readByte();
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
uint FindEmbeddedPNG(const byte *FileDataPtr, uint FileSize) {
|
||||
if (memcmp(FileDataPtr, "BS25SAVEGAME", 12))
|
||||
return 0;
|
||||
|
||||
#if 0
|
||||
// Einen Stringstream mit dem Anfang der Datei intialisieren. 512 Byte sollten hierfür genügen.
|
||||
istringstream StringStream(string(FileDataPtr, FileDataPtr + min(static_cast<uint>(512), FileSize)));
|
||||
// Read in the header
|
||||
Common::MemoryReadStream stream(FileDataPtr, FileSize);
|
||||
|
||||
// Headerinformationen der Spielstandes einlesen.
|
||||
string Marker, VersionID;
|
||||
uint CompressedGamedataSize, UncompressedGamedataSize;
|
||||
StringStream >> Marker >> VersionID >> CompressedGamedataSize >> UncompressedGamedataSize;
|
||||
if (!StringStream.good()) return 0;
|
||||
uint compressedGamedataSize;
|
||||
LoadString(stream);
|
||||
LoadString(stream);
|
||||
Common::String gameSize = LoadString(stream);
|
||||
compressedGamedataSize = atoi(gameSize.c_str());
|
||||
LoadString(stream);
|
||||
|
||||
// Testen, ob wir tatsächlich einen Spielstand haben.
|
||||
if (Marker == "BS25SAVEGAME") {
|
||||
// Offset zum PNG innerhalb des Spielstandes berechnen und zurückgeben.
|
||||
return static_cast<uint>(StringStream.tellg()) + CompressedGamedataSize + 1;
|
||||
}
|
||||
#else
|
||||
warning("STUB:FindEmbeddedPNG()");
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
// Return the offset of where the thumbnail starts
|
||||
return static_cast<uint>(stream.pos() + compressedGamedataSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,8 +36,11 @@
|
||||
|
||||
#include "common/archive.h"
|
||||
#include "common/config-manager.h"
|
||||
#include "common/savefile.h"
|
||||
#include "common/str-array.h"
|
||||
#include "common/system.h"
|
||||
#include "common/unzip.h"
|
||||
#include "sword25/kernel/filesystemutil.h"
|
||||
#include "sword25/package/packagemanager.h"
|
||||
|
||||
namespace Sword25 {
|
||||
@ -142,7 +145,29 @@ bool PackageManager::LoadDirectoryAsPackage(const Common::String &directoryName,
|
||||
}
|
||||
|
||||
byte *PackageManager::GetFile(const Common::String &fileName, uint *fileSizePtr) {
|
||||
const Common::String B25S_EXTENSION(".b25s");
|
||||
Common::SeekableReadStream *in;
|
||||
|
||||
if (fileName.hasSuffix(B25S_EXTENSION)) {
|
||||
// Savegame loading logic
|
||||
Common::SaveFileManager *sfm = g_system->getSavefileManager();
|
||||
Common::InSaveFile *file = sfm->openForLoading(
|
||||
FileSystemUtil::GetInstance().GetPathFilename(fileName));
|
||||
if (!file) {
|
||||
BS_LOG_ERRORLN("Could not load savegame \"%s\".", fileName.c_str());
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (*fileSizePtr)
|
||||
*fileSizePtr = file->size();
|
||||
|
||||
byte *buffer = new byte[file->size()];
|
||||
file->read(buffer, file->size());
|
||||
|
||||
delete file;
|
||||
return buffer;
|
||||
}
|
||||
|
||||
Common::ArchiveMemberPtr fileNode = GetArchiveMember(normalizePath(fileName, _currentDirectory));
|
||||
if (!fileNode)
|
||||
return 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user