mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-11 01:25:07 +02:00
SaveState: Show time/date when loading states
This commit is contained in:
+14
-8
@@ -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<Operation> Flush() {
|
||||
std::lock_guard<std::mutex> guard(mutex);
|
||||
std::vector<Operation> 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;
|
||||
|
||||
@@ -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<int>(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(")");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user