diff options
author | Paul Gilbert | 2010-09-20 09:38:53 +0000 |
---|---|---|
committer | Eugene Sandulenko | 2010-10-12 23:59:49 +0000 |
commit | 3e84d4fe73ac36bcfb36bbe8a26ce99ab71e92db (patch) | |
tree | 2c7fe72f16be514e9e7cad0bce288c6a22148dbf /engines/sword25/gfx | |
parent | 80521ed5dd279316d0534fc3cc4b61c27d19ef4e (diff) | |
download | scummvm-rg350-3e84d4fe73ac36bcfb36bbe8a26ce99ab71e92db.tar.gz scummvm-rg350-3e84d4fe73ac36bcfb36bbe8a26ce99ab71e92db.tar.bz2 scummvm-rg350-3e84d4fe73ac36bcfb36bbe8a26ce99ab71e92db.zip |
SWORD25: Implemented thumbnail loading for savegame list
svn-id: r53374
Diffstat (limited to 'engines/sword25/gfx')
-rw-r--r-- | engines/sword25/gfx/image/b25sloader.cpp | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/engines/sword25/gfx/image/b25sloader.cpp b/engines/sword25/gfx/image/b25sloader.cpp index 3be6374e67..513e74ccea 100644 --- a/engines/sword25/gfx/image/b25sloader.cpp +++ b/engines/sword25/gfx/image/b25sloader.cpp @@ -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; - - // 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; + uint compressedGamedataSize; + LoadString(stream); + LoadString(stream); + Common::String gameSize = LoadString(stream); + compressedGamedataSize = atoi(gameSize.c_str()); + LoadString(stream); + + // Return the offset of where the thumbnail starts + return static_cast<uint>(stream.pos() + compressedGamedataSize); } } |