From 17eddda36ccef028d4914b4031dcebb634735f24 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 11 Jan 2020 19:40:35 +0100 Subject: [PATCH] - added date and play time display to savegames. --- source/common/menu/savegamemanager.cpp | 4 ++-- source/common/savegamehelp.cpp | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/source/common/menu/savegamemanager.cpp b/source/common/menu/savegamemanager.cpp index d57af7785..fb2334d19 100644 --- a/source/common/menu/savegamemanager.cpp +++ b/source/common/menu/savegamemanager.cpp @@ -379,8 +379,8 @@ unsigned FSavegameManager::ExtractSaveData(int index) FString comment = sjson_get_string(root, "Creation Time", ""); FString fcomment = sjson_get_string(root, "Map Label", ""); FString ncomment = sjson_get_string(root, "Map Name", ""); - FStringf pcomment("%s - %s\n", fcomment.GetChars(), ncomment.GetChars()); - comment += pcomment; + FString mtime = sjson_get_string(root, "Map Time", ""); + comment.AppendFormat("\n%s - %s\n%s", fcomment.GetChars(), ncomment.GetChars(), mtime.GetChars()); SaveCommentString = comment; // Extract pic (todo: let the renderer write a proper PNG file instead of a raw canvas dunp of the software renderer - and make it work for all games.) diff --git a/source/common/savegamehelp.cpp b/source/common/savegamehelp.cpp index 29d6e7025..84f681e2e 100644 --- a/source/common/savegamehelp.cpp +++ b/source/common/savegamehelp.cpp @@ -143,9 +143,13 @@ void G_WriteSaveHeader(const char *name) sjson_put_string(ctx, root, "Engine", savesig.savesig); sjson_put_string(ctx, root, "Game Resource", fileSystem.GetResourceFileName(1)); sjson_put_string(ctx, root, "Map Name", currentLevel->DisplayName()); + sjson_put_string(ctx, root, "Creation Time", myasctime()); sjson_put_string(ctx, root, "Title", name); sjson_put_string(ctx, root, "Map File", currentLevel->fileName); sjson_put_string(ctx, root, "Map Label", currentLevel->labelName); + auto gs = gi->getStats(); + FStringf timeStr("%02d:%02d", gs.timesecnd / 60, gs.timesecnd % 60); + sjson_put_string(ctx, root, "Map Time", timeStr); const char *fn = currentLevel->fileName; if (*fn == '/') fn++; if (strncmp(fn, "file://", 7) != 0) // this only has meaning for non-usermaps