UI: Fixed date display on save states

This commit is contained in:
Sour 2020-02-05 19:53:18 -05:00
parent 8c0939861a
commit 3d36c7a27b
7 changed files with 4 additions and 30 deletions

View file

@ -27,18 +27,6 @@ string SaveStateManager::GetStateFilepath(int stateIndex)
return FolderUtilities::CombinePath(folder, filename);
}
uint64_t SaveStateManager::GetStateInfo(int stateIndex)
{
string filepath = SaveStateManager::GetStateFilepath(stateIndex);
ifstream file(filepath, ios::in | ios::binary);
if(file) {
file.close();
return FolderUtilities::GetFileModificationTime(filepath);
}
return 0;
}
void SaveStateManager::SelectSaveSlot(int slotIndex)
{
_lastIndex = slotIndex;

View file

@ -18,8 +18,6 @@ public:
SaveStateManager(shared_ptr<Console> console);
uint64_t GetStateInfo(int stateIndex);
void SaveState();
bool LoadState();

View file

@ -249,7 +249,6 @@ extern "C" {
DllExport void __stdcall LoadState(uint32_t stateIndex) { _console->GetSaveStateManager()->LoadState(stateIndex); }
DllExport void __stdcall SaveStateFile(char* filepath) { _console->GetSaveStateManager()->SaveState(filepath); }
DllExport void __stdcall LoadStateFile(char* filepath) { _console->GetSaveStateManager()->LoadState(filepath); }
DllExport int64_t __stdcall GetStateInfo(uint32_t stateIndex) { return _console->GetSaveStateManager()->GetStateInfo(stateIndex); }
DllExport void __stdcall LoadRecentGame(char* filepath, bool resetGame) { _console->GetSaveStateManager()->LoadRecentGame(filepath, resetGame); }
DllExport void __stdcall PgoRunTest(vector<string> testRoms, bool enableDebugger)

View file

@ -4,6 +4,7 @@ using Mesen.GUI.Forms;
using Mesen.GUI.Properties;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -18,15 +19,15 @@ namespace Mesen.GUI.Emulation
public static void UpdateStateMenu(ToolStripMenuItem menu, bool forSave)
{
for(uint i = 1; i <= NumberOfSaveSlots + (forSave ? 0 : 1); i++) {
Int64 fileTime = EmuApi.GetStateInfo(i);
string statePath = Path.Combine(ConfigManager.SaveStateFolder, EmuApi.GetRomInfo().GetRomName() + "_" + i + ".mss");
string label;
bool isAutoSaveSlot = i == NumberOfSaveSlots + 1;
string slotName = isAutoSaveSlot ? "Auto" : i.ToString();
if(fileTime == 0) {
if(!File.Exists(statePath)) {
label = slotName + ". " + ResourceHelper.GetMessage("EmptyState");
} else {
DateTime dateTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(fileTime).ToLocalTime();
DateTime dateTime = new FileInfo(statePath).LastWriteTime;
label = slotName + ". " + dateTime.ToShortDateString() + " " + dateTime.ToShortTimeString();
}

View file

@ -85,7 +85,6 @@ namespace Mesen.GUI
[DllImport(DllPath)] public static extern void LoadState(UInt32 stateIndex);
[DllImport(DllPath)] public static extern void SaveStateFile([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))]string filepath);
[DllImport(DllPath)] public static extern void LoadStateFile([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))]string filepath);
[DllImport(DllPath)] public static extern Int64 GetStateInfo(UInt32 stateIndex);
[DllImport(DllPath)] public static extern void SetCheats([In]UInt32[] cheats, UInt32 cheatCount);
[DllImport(DllPath)] public static extern void ClearCheats();

View file

@ -224,11 +224,6 @@ string FolderUtilities::CombinePath(string folder, string filename)
}
}
int64_t FolderUtilities::GetFileModificationTime(string filepath)
{
std::error_code errorCode;
return fs::last_write_time(fs::u8path(filepath), errorCode).time_since_epoch() / std::chrono::seconds(1);
}
#else
//Libretro: Avoid using filesystem API.
@ -277,8 +272,4 @@ string FolderUtilities::CombinePath(string folder, string filename)
return folder + filename;
}
int64_t FolderUtilities::GetFileModificationTime(string filepath)
{
return 0;
}
#endif

View file

@ -38,7 +38,5 @@ public:
static void CreateFolder(string folder);
static int64_t GetFileModificationTime(string filepath);
static string CombinePath(string folder, string filename);
};