mirror of
https://github.com/libretro/scummvm.git
synced 2025-04-03 15:21:40 +00:00
CGE: Add play time metadata to savegames
This commit is contained in:
parent
03312fba61
commit
057fb9bc6e
@ -56,7 +56,7 @@ class Walk;
|
||||
class Text;
|
||||
class Talk;
|
||||
|
||||
#define kSavegameVersion 2
|
||||
#define kSavegameVersion 3
|
||||
#define kSavegameStrSize 11
|
||||
#define kPocketX 174
|
||||
#define kPocketY 176
|
||||
@ -99,8 +99,9 @@ struct SavegameHeader {
|
||||
uint8 version;
|
||||
Common::String saveName;
|
||||
Graphics::Surface *thumbnail;
|
||||
int saveYear, saveMonth, saveDay;
|
||||
int saveHour, saveMinutes;
|
||||
int16 saveYear, saveMonth, saveDay;
|
||||
int16 saveHour, saveMinutes;
|
||||
uint32 playTime;
|
||||
};
|
||||
|
||||
extern const char *savegameStr;
|
||||
|
@ -242,6 +242,8 @@ bool CGEEngine::loadGame(int slotNumber, SavegameHeader *header, bool tiny) {
|
||||
delete readStream;
|
||||
return true;
|
||||
}
|
||||
|
||||
g_engine->setTotalPlayTime(saveHeader.playTime * 1000);
|
||||
}
|
||||
|
||||
// Get in the savegame
|
||||
@ -367,6 +369,8 @@ void CGEEngine::writeSavegameHeader(Common::OutSaveFile *out, SavegameHeader &he
|
||||
out->writeSint16LE(td.tm_mday);
|
||||
out->writeSint16LE(td.tm_hour);
|
||||
out->writeSint16LE(td.tm_min);
|
||||
|
||||
out->writeUint32LE(g_engine->getTotalPlayTime() / 1000);
|
||||
}
|
||||
|
||||
void CGEEngine::syncGame(Common::SeekableReadStream *readStream, Common::WriteStream *writeStream, bool tiny) {
|
||||
@ -421,13 +425,22 @@ void CGEEngine::syncGame(Common::SeekableReadStream *readStream, Common::WriteSt
|
||||
}
|
||||
|
||||
WARN_UNUSED_RESULT bool CGEEngine::readSavegameHeader(Common::InSaveFile *in, SavegameHeader &header, bool skipThumbnail) {
|
||||
header.version = 0;
|
||||
header.saveName.clear();
|
||||
header.thumbnail = nullptr;
|
||||
header.saveYear = 0;
|
||||
header.saveMonth = 0;
|
||||
header.saveDay = 0;
|
||||
header.saveHour = 0;
|
||||
header.saveMinutes = 0;
|
||||
header.playTime = 0;
|
||||
|
||||
// Get the savegame version
|
||||
header.version = in->readByte();
|
||||
if (header.version > kSavegameVersion)
|
||||
return false;
|
||||
|
||||
// Read in the string
|
||||
header.saveName.clear();
|
||||
char ch;
|
||||
while ((ch = (char)in->readByte()) != '\0')
|
||||
header.saveName += ch;
|
||||
@ -438,12 +451,16 @@ WARN_UNUSED_RESULT bool CGEEngine::readSavegameHeader(Common::InSaveFile *in, Sa
|
||||
}
|
||||
|
||||
// Read in save date/time
|
||||
header.saveYear = in->readSint16LE();
|
||||
header.saveMonth = in->readSint16LE();
|
||||
header.saveDay = in->readSint16LE();
|
||||
header.saveHour = in->readSint16LE();
|
||||
header.saveYear = in->readSint16LE();
|
||||
header.saveMonth = in->readSint16LE();
|
||||
header.saveDay = in->readSint16LE();
|
||||
header.saveHour = in->readSint16LE();
|
||||
header.saveMinutes = in->readSint16LE();
|
||||
|
||||
if (header.version >= 3) {
|
||||
header.playTime = in->readUint32LE();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -176,12 +176,13 @@ const ADGameDescription *CGEMetaEngine::fallbackDetect(const FileMap &allFiles,
|
||||
|
||||
bool CGEMetaEngine::hasFeature(MetaEngineFeature f) const {
|
||||
return
|
||||
(f == kSupportsListSaves) ||
|
||||
(f == kSupportsLoadingDuringStartup) ||
|
||||
(f == kSupportsDeleteSave) ||
|
||||
(f == kSavesSupportMetaInfo) ||
|
||||
(f == kSavesSupportThumbnail) ||
|
||||
(f == kSavesSupportCreationDate) ||
|
||||
(f == kSupportsListSaves) ||
|
||||
(f == kSupportsLoadingDuringStartup) ||
|
||||
(f == kSupportsDeleteSave) ||
|
||||
(f == kSavesSupportMetaInfo) ||
|
||||
(f == kSavesSupportThumbnail) ||
|
||||
(f == kSavesSupportCreationDate) ||
|
||||
(f == kSavesSupportPlayTime) ||
|
||||
(f == kSimpleSavesNames);
|
||||
}
|
||||
|
||||
@ -263,6 +264,10 @@ SaveStateDescriptor CGEMetaEngine::querySaveMetaInfos(const char *target, int sl
|
||||
desc.setSaveDate(header.saveYear, header.saveMonth, header.saveDay);
|
||||
desc.setSaveTime(header.saveHour, header.saveMinutes);
|
||||
|
||||
if (header.playTime) {
|
||||
desc.setPlayTime(header.playTime * 1000);
|
||||
}
|
||||
|
||||
// Slot 0 is used for the 'automatic save on exit' save in Soltys, thus
|
||||
// we prevent it from being deleted or overwritten by accident.
|
||||
desc.setDeletableFlag(slot != 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user