From 21d3ea523c1ca8c20e9312141c5e06e5327cc60f Mon Sep 17 00:00:00 2001 From: JosJuice Date: Wed, 21 Oct 2020 19:49:56 +0200 Subject: Android: Show how long ago each savestate was created --- Source/Core/Core/State.cpp | 11 +++++++++++ Source/Core/Core/State.h | 3 +++ 2 files changed, 14 insertions(+) (limited to 'Source/Core') diff --git a/Source/Core/Core/State.cpp b/Source/Core/Core/State.cpp index b1622185e9..9aac96e24a 100644 --- a/Source/Core/Core/State.cpp +++ b/Source/Core/Core/State.cpp @@ -482,6 +482,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(header.time * MS_PER_SEC) + + (Common::Timer::DOUBLE_TIME_OFFSET * MS_PER_SEC); +} + static void LoadFileStateData(const std::string& filename, std::vector& 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 -- cgit v1.2.3