From 49b91ea78f0dca007077d5390bef7e95f9d6e9cb Mon Sep 17 00:00:00 2001 From: Shanoah Alkire Date: Sun, 14 Oct 2018 02:41:41 -0700 Subject: [PATCH] Saveslots: This version is still commented out, and somewhat broken at the moment. If you uncomment it, after loading a game, pause and then resume to force the save and load menus to update. --- pcsx2/System/SysCoreThread.cpp | 3 --- pcsx2/gui/AppCoreThread.cpp | 5 ---- pcsx2/gui/Saveslots.cpp | 46 +++++++++++++++++++++++++++++++++- pcsx2/gui/Saveslots.h | 1 + pcsx2/gui/SysState.cpp | 13 +++------- pcsx2/gui/UpdateUI.cpp | 42 +------------------------------ 6 files changed, 51 insertions(+), 59 deletions(-) diff --git a/pcsx2/System/SysCoreThread.cpp b/pcsx2/System/SysCoreThread.cpp index d69e5014a7..7a9d28240c 100644 --- a/pcsx2/System/SysCoreThread.cpp +++ b/pcsx2/System/SysCoreThread.cpp @@ -236,9 +236,6 @@ void SysCoreThread::GameStartingInThread() sApp.PostAppMethod(&Pcsx2App::resetDebugger); ApplyLoadedPatches(PPT_ONCE_ON_LOAD); -#ifdef USE_SAVESLOT_UI_UPDATES - UI_UpdateSysControls(); -#endif } bool SysCoreThread::StateCheckInThread() diff --git a/pcsx2/gui/AppCoreThread.cpp b/pcsx2/gui/AppCoreThread.cpp index 64ff0eecf7..4eb8f0e803 100644 --- a/pcsx2/gui/AppCoreThread.cpp +++ b/pcsx2/gui/AppCoreThread.cpp @@ -485,11 +485,6 @@ void LoadAllPatchesAndStuff(const Pcsx2Config& cfg) Pcsx2Config dummy; PatchesVerboseReset(); _ApplySettings(cfg, dummy); - - // And I'm hacking in updating the UI here too. -#ifdef USE_SAVESLOT_UI_UPDATES - UI_UpdateSysControls(); -#endif } void AppCoreThread::ApplySettings( const Pcsx2Config& src ) diff --git a/pcsx2/gui/Saveslots.cpp b/pcsx2/gui/Saveslots.cpp index 54fb88197c..b032853e39 100644 --- a/pcsx2/gui/Saveslots.cpp +++ b/pcsx2/gui/Saveslots.cpp @@ -125,7 +125,51 @@ void States_DefrostCurrentSlotBackup() _States_DefrostCurrentSlot(true); } -// I'd keep an eye on this function, as it may still be problematic. +void States_UpdateSaveslotMenu() +{ +#ifdef USE_NEW_SAVESLOTS_UI + // Run though all the slots.Update if they need updating or the crc changed. + for (int i = 0; i < 10; i++) + { + 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; + + // Either the cache needs updating, or the menu items do, or both. + if (saveslot_cache[i].menu_update || saveslot_cache[i].invalid_cache) + { + #ifdef SAVESLOT_LOGS + Console.WriteLn("Updating slot %i.", i); + if (saveslot_cache[i].menu_update) Console.WriteLn("Menu update needed."); + if (saveslot_cache[i].invalid_cache) Console.WriteLn("Invalid cache. (CRC different or just initialized.)"); + #endif + + if (saveslot_cache[i].invalid_cache) + { + // Pull everything from disk. + saveslot_cache[i].UpdateCache(); + + #ifdef SAVESLOT_LOGS + saveslot_cache[i].ConsoleDump(); + #endif + } + + // 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()); + } + + } + Sstates_updateLoadBackupMenuItem(false); +#endif +} + void Sstates_updateLoadBackupMenuItem(bool isBeforeSave) { wxString file = SaveStateBase::GetFilename(StatesC); diff --git a/pcsx2/gui/Saveslots.h b/pcsx2/gui/Saveslots.h index 1e5741d862..351251e45a 100644 --- a/pcsx2/gui/Saveslots.h +++ b/pcsx2/gui/Saveslots.h @@ -119,4 +119,5 @@ extern void States_CycleSlotForward(); extern void States_CycleSlotBackward(); extern void States_SetCurrentSlot(int slot); extern int States_GetCurrentSlot(); +extern void States_UpdateSaveslotMenu(); extern void Sstates_updateLoadBackupMenuItem(bool isBeforeSave); \ No newline at end of file diff --git a/pcsx2/gui/SysState.cpp b/pcsx2/gui/SysState.cpp index 34e1eca646..674e83ff4a 100644 --- a/pcsx2/gui/SysState.cpp +++ b/pcsx2/gui/SysState.cpp @@ -476,11 +476,6 @@ protected: void CleanupEvent() { -#ifdef USE_NEW_SAVESLOTS_UI - // I have a feeling this doesn't need to be here, so I'm commenting this out for the moment. - // I'll remove it if it doesn't cause other issues. - //UI_UpdateSysControls(); -#endif } }; @@ -679,8 +674,8 @@ void StateCopy_SaveToSlot( uint num ) Console.Indent().WriteLn( Color_StrongGreen, L"filename: %s", WX_STR(file) ); StateCopy_SaveToFile( file ); -#ifdef USE_NEW_SAVESLOTS_UI - UI_UpdateSysControls(); +#ifdef USE_SAVESLOT_UI_UPDATES + States_UpdateSaveslotMenu(); #endif } @@ -698,7 +693,7 @@ void StateCopy_LoadFromSlot( uint slot, bool isFromBackup ) Console.Indent().WriteLn( Color_StrongGreen, L"filename: %s", WX_STR(file) ); StateCopy_LoadFromFile( file ); -#ifdef USE_NEW_SAVESLOTS_UI - UI_UpdateSysControls(); +#ifdef USE_SAVESLOT_UI_UPDATES + States_UpdateSaveslotMenu(); #endif } diff --git a/pcsx2/gui/UpdateUI.cpp b/pcsx2/gui/UpdateUI.cpp index 33f259a9dd..f317e9d60c 100644 --- a/pcsx2/gui/UpdateUI.cpp +++ b/pcsx2/gui/UpdateUI.cpp @@ -43,47 +43,7 @@ static void _SaveLoadStuff(bool enabled) sMainFrame.EnableMenuItem(MenuId_Sys_LoadStates, enabled); sMainFrame.EnableMenuItem(MenuId_Sys_SaveStates, enabled); -#ifdef USE_NEW_SAVESLOTS_UI - // Run though all the slots.Update if they need updating or the crc changed. - for (int i = 0; i < 10; i++) - { - 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; - - // Either the cache needs updating, or the menu items do, or both. - if (saveslot_cache[i].menu_update || saveslot_cache[i].invalid_cache) - { - #ifdef SAVESLOT_LOGS - Console.WriteLn("Updating slot %i.", i); - if (saveslot_cache[i].menu_update) Console.WriteLn("Menu update needed."); - if (saveslot_cache[i].invalid_cache) Console.WriteLn("Invalid cache. (CRC different or just initialized.)"); - #endif - - if (saveslot_cache[i].invalid_cache) - { - // Pull everything from disk. - saveslot_cache[i].UpdateCache(); - - #ifdef SAVESLOT_LOGS - saveslot_cache[i].ConsoleDump(); - #endif - } - - // 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()); - } - - } - Sstates_updateLoadBackupMenuItem(false); -#endif + States_UpdateSaveslotMenu(); } // Updates the enable/disable status of all System related controls: menus, toolbars,