From 8defe54e3bea9bd0687190ede54f7b020d5b0794 Mon Sep 17 00:00:00 2001 From: Shanoah Alkire Date: Fri, 5 Oct 2018 22:21:54 -0700 Subject: [PATCH] Redo how the saveslot code works. Still leaving disabled until it's been tested. --- pcsx2/gui/AppCoreThread.cpp | 5 +++++ pcsx2/gui/Saveslots.cpp | 1 + pcsx2/gui/Saveslots.h | 10 ++++++++-- pcsx2/gui/UpdateUI.cpp | 24 +++++++++++++++--------- 4 files changed, 29 insertions(+), 11 deletions(-) diff --git a/pcsx2/gui/AppCoreThread.cpp b/pcsx2/gui/AppCoreThread.cpp index 4eb8f0e803..3fa5dce9bf 100644 --- a/pcsx2/gui/AppCoreThread.cpp +++ b/pcsx2/gui/AppCoreThread.cpp @@ -485,6 +485,11 @@ void LoadAllPatchesAndStuff(const Pcsx2Config& cfg) Pcsx2Config dummy; PatchesVerboseReset(); _ApplySettings(cfg, dummy); + + // And I'm hacking in updating the UI here too. +#ifdef USE_NEW_SAVESLOTS_UI + UI_UpdateSysControls(); +#endif } void AppCoreThread::ApplySettings( const Pcsx2Config& src ) diff --git a/pcsx2/gui/Saveslots.cpp b/pcsx2/gui/Saveslots.cpp index 5c8b87ef77..46a3abf1e1 100644 --- a/pcsx2/gui/Saveslots.cpp +++ b/pcsx2/gui/Saveslots.cpp @@ -84,6 +84,7 @@ void States_FreezeCurrentSlot() saveslot_cache[StatesC].empty = false; saveslot_cache[StatesC].updated = wxDateTime::Now(); saveslot_cache[StatesC].crc = ElfCRC; + saveslot_cache[StatesC].menu_update = true; #endif GetSysExecutorThread().PostIdleEvent(SysExecEvent_ClearSavingLoadingFlag()); diff --git a/pcsx2/gui/Saveslots.h b/pcsx2/gui/Saveslots.h index d0ea7afa1c..6b7517e151 100644 --- a/pcsx2/gui/Saveslots.h +++ b/pcsx2/gui/Saveslots.h @@ -29,6 +29,7 @@ public: bool empty; wxDateTime updated; u32 crc; + bool menu_update, invalid_cache; Saveslot() { @@ -36,6 +37,8 @@ public: empty = true; updated = wxInvalidDateTime; crc = ElfCRC; + menu_update = false; + invalid_cache = true; } Saveslot(int i) @@ -44,6 +47,8 @@ public: empty = true; updated = wxInvalidDateTime; crc = ElfCRC; + menu_update = false; + invalid_cache = true; } bool isUsed() @@ -63,6 +68,7 @@ public: empty = !isUsed(); updated = GetTimestamp(); crc = ElfCRC; + invalid_cache = false; } wxString SlotName() @@ -86,8 +92,8 @@ public: if (updated != wxInvalidDateTime) Console.WriteLn(wxsFormat(_("Write time is %s %s."), updated.FormatDate(), updated.FormatTime())); - if (isUsed()) - Console.WriteLn(wxsFormat(_("The disk has a file on it dated %s %s."), GetTimestamp().FormatDate(), GetTimestamp().FormatTime())); + //if (isUsed()) + // Console.WriteLn(wxsFormat(_("The disk has a file on it dated %s %s."), GetTimestamp().FormatDate(), GetTimestamp().FormatTime())); } }; diff --git a/pcsx2/gui/UpdateUI.cpp b/pcsx2/gui/UpdateUI.cpp index 8598883dff..174632fee2 100644 --- a/pcsx2/gui/UpdateUI.cpp +++ b/pcsx2/gui/UpdateUI.cpp @@ -48,22 +48,28 @@ static void _SaveLoadStuff(bool enabled) { int load_menu_item = MenuId_State_Load01 + i + 1; int save_menu_item = MenuId_State_Save01 + i + 1; + + // We need to reload the file information if the crc changed. + if (saveslot_cache[i].crc != ElfCRC) saveslot_cache[i].invalid_cache = true; - // If the cache is out of sync with the actual files, we need to update things. First update, the cache'll be blank, and this will populate everything. - if (saveslot_cache[i].empty == saveslot_cache[i].isUsed()) + // Either the cache needs updating, or the menu items do, or both. + if (saveslot_cache[i].menu_update || saveslot_cache[i].invalid_cache) { - // If there is actually a file there, or the cache was for a different game, we force an update. - // If the cache says there's a saveslot for the current game that there isn't a file for, writing it is done in a different thread, - // so it might not be written yet. Which is why I cache to begin with. - if (saveslot_cache[i].isUsed() || (saveslot_cache[i].crc != ElfCRC)) + if (saveslot_cache[i].invalid_cache) { + // Pull everything from disk. saveslot_cache[i].UpdateCache(); } + + // Update from the cached information. + saveslot_cache[i].menu_update = false; + saveslot_cache[i].crc = ElfCRC; + + sMainFrame.EnableMenuItem(load_menu_item, !saveslot_cache[i].empty); + sMainFrame.SetMenuItemLabel(load_menu_item, saveslot_cache[i].SlotName()); + sMainFrame.SetMenuItemLabel(save_menu_item, saveslot_cache[i].SlotName()); } - sMainFrame.EnableMenuItem(load_menu_item, !saveslot_cache[i].empty); - sMainFrame.SetMenuItemLabel(load_menu_item, saveslot_cache[i].SlotName()); - sMainFrame.SetMenuItemLabel(save_menu_item, saveslot_cache[i].SlotName()); } Sstates_updateLoadBackupMenuItem(false); #endif