diff options
| author | LC <mathew1800@gmail.com> | 2020-10-23 13:59:43 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-23 13:59:43 -0400 |
| commit | 4f5c8bb42ae617a5c2823277a4a9ced1df2be445 (patch) | |
| tree | 162dd619f06bad7c0773f144ab59c81a18df4ea0 /Source/Core | |
| parent | ce6eda7c717c1dad7d79b91ec421c196ac969357 (diff) | |
| parent | 21d3ea523c1ca8c20e9312141c5e06e5327cc60f (diff) | |
Merge pull request #9177 from JosJuice/android-savestate-time
Android: Show how long ago each savestate was created
Diffstat (limited to 'Source/Core')
| -rw-r--r-- | Source/Core/Core/State.cpp | 11 | ||||
| -rw-r--r-- | Source/Core/Core/State.h | 3 |
2 files changed, 14 insertions, 0 deletions
diff --git a/Source/Core/Core/State.cpp b/Source/Core/Core/State.cpp index d5c6bf74c0..29a79f9e42 100644 --- a/Source/Core/Core/State.cpp +++ b/Source/Core/Core/State.cpp @@ -478,6 +478,17 @@ std::string GetInfoStringOfSlot(int slot, bool translate) return Common::Timer::GetDateTimeFormatted(header.time); } +u64 GetUnixTimeOfSlot(int slot) +{ + State::StateHeader header; + if (!ReadHeader(MakeStateFilename(slot), header)) + return 0; + + constexpr u64 MS_PER_SEC = 1000; + return static_cast<u64>(header.time * MS_PER_SEC) + + (Common::Timer::DOUBLE_TIME_OFFSET * MS_PER_SEC); +} + static void LoadFileStateData(const std::string& filename, std::vector<u8>& ret_data) { Flush(); diff --git a/Source/Core/Core/State.h b/Source/Core/Core/State.h index d8c4b0e8ed..9fcb9d1773 100644 --- a/Source/Core/Core/State.h +++ b/Source/Core/Core/State.h @@ -36,6 +36,9 @@ bool ReadHeader(const std::string& filename, StateHeader& header); // which can be presented to the user for identification purposes std::string GetInfoStringOfSlot(int slot, bool translate = true); +// Returns when the savestate in the given slot was created, or 0 if the slot is empty. +u64 GetUnixTimeOfSlot(int slot); + // These don't happen instantly - they get scheduled as events. // ...But only if we're not in the main CPU thread. // If we're in the main CPU thread then they run immediately instead |
