From 952609eeaa906ee955a0328b9c9aedf8b3ca7c2a Mon Sep 17 00:00:00 2001 From: "J.D. Purcell" Date: Sun, 20 Oct 2019 23:36:00 -0400 Subject: [PATCH] Factor out some common stuff in rom load/close. --- BizHawk.Client.Common/SaveSlotManager.cs | 6 --- BizHawk.Client.EmuHawk/MainForm.cs | 50 ++++++++++-------------- 2 files changed, 21 insertions(+), 35 deletions(-) diff --git a/BizHawk.Client.Common/SaveSlotManager.cs b/BizHawk.Client.Common/SaveSlotManager.cs index 8584312e7e..7ec9588a22 100644 --- a/BizHawk.Client.Common/SaveSlotManager.cs +++ b/BizHawk.Client.Common/SaveSlotManager.cs @@ -97,12 +97,6 @@ namespace BizHawk.Client.Common return _redo[slot]; } - public void Clear() - { - ClearRedoList(); - Update(); - } - public void SwapBackupSavestate(string path) { // Takes the .state and .bak files and swaps them diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs index 978ac86acf..01ecb89b7e 100644 --- a/BizHawk.Client.EmuHawk/MainForm.cs +++ b/BizHawk.Client.EmuHawk/MainForm.cs @@ -3819,14 +3819,9 @@ namespace BizHawk.Client.EmuHawk } } - SetWindowText(); CurrentlyOpenRom = oa_openrom?.Path ?? openAdvancedArgs; CurrentlyOpenRomArgs = args; - HandlePlatformMenus(); - _stateSlots.Clear(); - UpdateCoreStatusBarButton(); - UpdateDumpIcon(); - SetMainformMovieInfo(); + OnRomChanged(); GlobalWin.DisplayManager.Blank(); Global.Rewinder.Initialize(); @@ -3854,26 +3849,17 @@ namespace BizHawk.Client.EmuHawk ClientApi.OnRomLoaded(Emulator); return true; } + else if (!(Emulator is NullEmulator)) + { + // The ROM has been loaded by a recursive invocation of the LoadROM method. + ClientApi.OnRomLoaded(Emulator); + return true; + } else { // This shows up if there's a problem - // TODO: put all these in a single method or something - - // The ROM has been loaded by a recursive invocation of the LoadROM method. - if (!(Emulator is NullEmulator)) - { - ClientApi.OnRomLoaded(Emulator); - return true; - } - ClientApi.UpdateEmulatorAndVP(Emulator); - HandlePlatformMenus(); - _stateSlots.Clear(); - UpdateStatusSlots(); - UpdateCoreStatusBarButton(); - UpdateDumpIcon(); - SetMainformMovieInfo(); - SetWindowText(); + OnRomChanged(); return false; } } @@ -3886,6 +3872,17 @@ namespace BizHawk.Client.EmuHawk } } + private void OnRomChanged() + { + SetWindowText(); + HandlePlatformMenus(); + _stateSlots.ClearRedoList(); + UpdateStatusSlots(); + UpdateCoreStatusBarButton(); + UpdateDumpIcon(); + SetMainformMovieInfo(); + } + private void CommitCoreSettingsToConfig() { // save settings object @@ -3979,17 +3976,12 @@ namespace BizHawk.Client.EmuHawk GlobalWin.Tools.Restart(); ApiManager.Restart(Emulator.ServiceProvider); RewireSound(); - Text = $"BizHawk{(VersionInfo.DeveloperBuild ? " (interim) " : "")}"; - HandlePlatformMenus(); - _stateSlots.Clear(); - UpdateDumpIcon(); - UpdateCoreStatusBarButton(); ClearHolds(); - PauseOnFrame = null; ToolFormBase.UpdateCheatRelatedTools(null, null); - UpdateStatusSlots(); + PauseOnFrame = null; CurrentlyOpenRom = null; CurrentlyOpenRomArgs = null; + OnRomChanged(); } }