Merge pull request #2742 from AdmiralCurtiss/display-savestate-stats

Display Savestate information in Overlay and Menu.
This commit is contained in:
Scott Mansell
2015-11-08 02:20:56 +13:00
5 changed files with 65 additions and 16 deletions

View File

@ -225,7 +225,6 @@ std::string Timer::GetTimeFormatted()
}
// Returns a timestamp with decimals for precise time comparisons
// ----------------
double Timer::GetDoubleTime()
{
#ifdef _WIN32
@ -245,7 +244,7 @@ double Timer::GetDoubleTime()
// sure that we are detecting actual actions, perhaps 60 seconds is
// enough really, but I leave a year of seconds anyway, in case the
// user's clock is incorrect or something like that.
TmpSeconds = TmpSeconds - (38 * 365 * 24 * 60 * 60);
TmpSeconds = TmpSeconds - DOUBLE_TIME_OFFSET;
// Make a smaller integer that fits in the double
u32 Seconds = (u32)TmpSeconds;
@ -261,4 +260,16 @@ double Timer::GetDoubleTime()
return TmpTime;
}
// Formats a timestamp from GetDoubleTime() into a date and time string
std::string Timer::GetDateTimeFormatted(double time)
{
// revert adjustments from GetDoubleTime() to get a normal Unix timestamp again
time_t seconds = (time_t)time + DOUBLE_TIME_OFFSET;
tm* localTime = localtime(&seconds);
char tmp[32] = {};
strftime(tmp, sizeof(tmp), "%x %X", localTime);
return tmp;
}
} // Namespace Common

View File

@ -26,15 +26,22 @@ public:
static void RestoreResolution();
static u64 GetTimeSinceJan1970();
static u64 GetLocalTimeSinceJan1970();
// Returns a timestamp with decimals for precise time comparisons
static double GetDoubleTime();
static std::string GetTimeFormatted();
// Formats a timestamp from GetDoubleTime() into a date and time string
static std::string GetDateTimeFormatted(double time);
std::string GetTimeElapsedFormatted() const;
u64 GetTimeElapsed();
static u32 GetTimeMs();
static u64 GetTimeUs();
// Arbitrarily chosen value (38 years) that is subtracted in GetDoubleTime()
// to increase sub-second precision of the resulting double timestamp
static const int DOUBLE_TIME_OFFSET = (38 * 365 * 24 * 60 * 60);
private:
u64 m_LastTime;
u64 m_StartTime;