From fb7ce84edbb6dccf4e5c3b48de3f71e9b17ebdff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 19 May 2026 12:19:13 +0200 Subject: [PATCH] SaveState: Show time/date when loading states --- Core/SaveState.cpp | 22 ++++++++++++++-------- Core/SaveStateRewind.cpp | 6 ------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Core/SaveState.cpp b/Core/SaveState.cpp index 344343f3d2..521c6057c1 100644 --- a/Core/SaveState.cpp +++ b/Core/SaveState.cpp @@ -106,10 +106,10 @@ enum class OperationType { struct Operation { // The slot number is for visual purposes only. Set to -1 for operations where we don't display a message for example. Operation(OperationType t, const Path &f, int slot_, Callback cb) - : type(t), filename(f), callback(cb), slot(slot_) {} + : type(t), path(f), callback(cb), slot(slot_) {} OperationType type; - Path filename; + Path path; Callback callback; int slot; }; @@ -675,8 +675,7 @@ int g_screenshotFailures; return oldestSlot; } - std::string GetSlotDateAsString(std::string_view gamePrefix, int slot) { - std::string fn = GenerateSaveSlotFilename(gamePrefix, slot, STATE_EXTENSION); + static std::string GetSaveFileDateAsString(const std::string &fn) { auto iter = g_files.find(fn); if (iter == g_files.end()) { return ""; @@ -703,6 +702,11 @@ int g_screenshotFailures; return buf; } + std::string GetSlotDateAsString(std::string_view gamePrefix, int slot) { + std::string fn = GenerateSaveSlotFilename(gamePrefix, slot, STATE_EXTENSION); + return GetSaveFileDateAsString(fn); + } + std::vector Flush() { std::lock_guard guard(mutex); std::vector copy = g_pendingOperations; @@ -822,12 +826,14 @@ int g_screenshotFailures; switch (op.type) { case OperationType::Load: - INFO_LOG(Log::SaveState, "Loading state from '%s'", op.filename.c_str()); + INFO_LOG(Log::SaveState, "Loading state from '%s'", op.path.c_str()); // Use the state's latest version as a guess for saveStateInitialGitVersion. - result = CChunkFileReader::Load(op.filename, &saveStateInitialGitVersion, state, &errorString); + result = CChunkFileReader::Load(op.path, &saveStateInitialGitVersion, state, &errorString); if (result == CChunkFileReader::ERROR_NONE) { callbackMessage = op.slot != LOAD_UNDO_SLOT ? sc->T("Loaded State") : sc->T("State load undone"); callbackResult = TriggerLoadWarnings(callbackMessage); + callbackMetadata = SaveState::GetSaveFileDateAsString(op.path.GetFilename().c_str()); + hasLoadedState = true; Core_ResetException(); @@ -858,7 +864,7 @@ int g_screenshotFailures; break; case OperationType::Save: - INFO_LOG(Log::SaveState, "Saving state to '%s'", op.filename.c_str()); + INFO_LOG(Log::SaveState, "Saving state to '%s'", op.path.c_str()); title = g_paramSFO.GetValueString("TITLE"); if (title.empty()) { // Homebrew title @@ -866,7 +872,7 @@ int g_screenshotFailures; std::size_t lslash = title.find_last_of('/'); title = title.substr(lslash + 1); } - result = CChunkFileReader::Save(op.filename, title, PPSSPP_GIT_VERSION, state); + result = CChunkFileReader::Save(op.path, title, PPSSPP_GIT_VERSION, state); if (result == CChunkFileReader::ERROR_NONE) { callbackMessage = slot_prefix + std::string(sc->T("Saved State")); callbackResult = Status::SUCCESS; diff --git a/Core/SaveStateRewind.cpp b/Core/SaveStateRewind.cpp index aa4cc62926..dc7eaf0c7a 100644 --- a/Core/SaveStateRewind.cpp +++ b/Core/SaveStateRewind.cpp @@ -68,12 +68,6 @@ CChunkFileReader::Error StateRingbuffer::Restore(std::string *errorString, std:: auto di = GetI18NCategory(I18NCat::DIALOG); metadata->append(" ("); metadata->append(ApplySafeSubstitutions(di->T("%1 seconds ago"), static_cast(time_now_d() - states_[n].savedTime))); - /* - char buffer[26]; - double unixTime = time_to_unix_utc(states_[n].savedTime); - FormatUnixTime(unixTime, buffer, sizeof(buffer), false); - metadata->append(buffer); - */ metadata->append(")"); }