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