GNAP: Add thumbnails, rewrite partially querySaveMetaInfos.
Gnap's hand and device are in the middle of the screen, there's place for improvement
This commit is contained in:
parent
931846182b
commit
3bf35331ab
3 changed files with 28 additions and 23 deletions
|
@ -88,10 +88,8 @@ bool GnapMetaEngine::hasFeature(MetaEngineFeature f) const {
|
|||
(f == kSupportsLoadingDuringStartup) ||
|
||||
(f == kSupportsDeleteSave) ||
|
||||
(f == kSavesSupportMetaInfo) ||
|
||||
(f == kSavesSupportCreationDate);
|
||||
#if 0
|
||||
(f == kSavesSupportThumbnail) ||
|
||||
#endif
|
||||
(f == kSavesSupportCreationDate);
|
||||
}
|
||||
|
||||
bool Gnap::GnapEngine::hasFeature(EngineFeature f) const {
|
||||
|
@ -147,35 +145,35 @@ SaveStateDescriptor GnapMetaEngine::querySaveMetaInfos(const char *target, int s
|
|||
Common::String fileName = Common::String::format("%s.%03d", target, slot);
|
||||
Common::InSaveFile *file = g_system->getSavefileManager()->openForLoading(fileName);
|
||||
if (file) {
|
||||
char saveIdentBuffer[5];
|
||||
file->read(saveIdentBuffer, 5);
|
||||
|
||||
int32 version = file->readSint32BE();
|
||||
if (version != GNAP_SAVEGAME_VERSION) {
|
||||
int32 version = file->readByte();
|
||||
if (version > GNAP_SAVEGAME_VERSION) {
|
||||
delete file;
|
||||
return SaveStateDescriptor();
|
||||
}
|
||||
|
||||
uint32 saveNameLength = file->readUint16BE();
|
||||
char saveName[256];
|
||||
file->read(saveName, saveNameLength);
|
||||
saveName[saveNameLength] = 0;
|
||||
char ch;
|
||||
int i = 0;
|
||||
while ((ch = (char)file->readByte()) != '\0')
|
||||
saveName[i++] = ch;
|
||||
|
||||
SaveStateDescriptor desc(slot, saveName);
|
||||
|
||||
Graphics::Surface *const thumbnail = Graphics::loadThumbnail(*file);
|
||||
desc.setThumbnail(thumbnail);
|
||||
if (version != 1) {
|
||||
Graphics::Surface *const thumbnail = Graphics::loadThumbnail(*file);
|
||||
desc.setThumbnail(thumbnail);
|
||||
}
|
||||
|
||||
uint32 saveDate = file->readUint32BE();
|
||||
uint16 saveTime = file->readUint16BE();
|
||||
|
||||
int day = (saveDate >> 24) & 0xFF;
|
||||
int month = (saveDate >> 16) & 0xFF;
|
||||
int year = saveDate & 0xFFFF;
|
||||
int year = file->readSint16LE();
|
||||
int month = file->readSint16LE();
|
||||
int day = file->readSint16LE();
|
||||
int hour = file->readSint16LE();
|
||||
int minutes = file->readSint16LE();
|
||||
|
||||
desc.setSaveDate(year, month, day);
|
||||
|
||||
int hour = (saveTime >> 8) & 0xFF;
|
||||
int minutes = saveTime & 0xFF;
|
||||
|
||||
desc.setSaveTime(hour, minutes);
|
||||
|
||||
delete file;
|
||||
|
|
|
@ -59,7 +59,7 @@ class GameSys;
|
|||
class SoundMan;
|
||||
class MusicPlayer;
|
||||
|
||||
#define GNAP_SAVEGAME_VERSION 1
|
||||
#define GNAP_SAVEGAME_VERSION 2
|
||||
|
||||
struct MouseButtonState {
|
||||
bool _left;
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "common/translation.h"
|
||||
|
||||
#include "gui/saveload.h"
|
||||
#include "graphics/thumbnail.h"
|
||||
|
||||
#include "gnap/gnap.h"
|
||||
#include "gnap/datarchive.h"
|
||||
|
@ -576,7 +577,7 @@ void GnapEngine::writeSavegameHeader(Common::OutSaveFile *out, GnapSavegameHeade
|
|||
out->writeString(header._saveName);
|
||||
out->writeByte('\0');
|
||||
|
||||
// TODO: Add thumbnail
|
||||
Graphics::saveThumbnail(*out);
|
||||
|
||||
// Write out the save date/time
|
||||
TimeDate td;
|
||||
|
@ -608,7 +609,13 @@ bool GnapEngine::readSavegameHeader(Common::InSaveFile *in, GnapSavegameHeader &
|
|||
header._saveName += ch;
|
||||
|
||||
// TODO: Get the thumbnail
|
||||
header._thumbnail = nullptr;
|
||||
if (header._version == 1)
|
||||
header._thumbnail = nullptr;
|
||||
else {
|
||||
header._thumbnail = Graphics::loadThumbnail(*in);
|
||||
if (!header._thumbnail)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Read in save date/time
|
||||
header._year = in->readSint16LE();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue