diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs index 7f0b1fdb1f..f51216f42c 100644 --- a/BizHawk.Client.EmuHawk/MainForm.cs +++ b/BizHawk.Client.EmuHawk/MainForm.cs @@ -100,11 +100,18 @@ namespace BizHawk.Client.EmuHawk Closing += (o, e) => { - Global.CheatList.SaveOnClose(); - CloseGame(); - Global.MovieSession.Movie.Stop(); - GlobalWin.Tools.Close(); - SaveConfig(); + if (GlobalWin.Tools.AskSave()) + { + Global.CheatList.SaveOnClose(); + CloseGame(); + Global.MovieSession.Movie.Stop(); + GlobalWin.Tools.Close(); + SaveConfig(); + } + else + { + e.Cancel = true; + } }; ResizeBegin += (o, e) => @@ -3726,21 +3733,24 @@ namespace BizHawk.Client.EmuHawk public void CloseROM(bool clearSRAM = false) { - CloseGame(clearSRAM); - Global.CoreComm = new CoreComm(); - CoreFileProvider.SyncCoreCommInputSignals(); - Global.Emulator = new NullEmulator(Global.CoreComm); - Global.Game = GameInfo.GetNullGame(); + if (GlobalWin.Tools.AskSave()) + { + CloseGame(clearSRAM); + Global.CoreComm = new CoreComm(); + CoreFileProvider.SyncCoreCommInputSignals(); + Global.Emulator = new NullEmulator(Global.CoreComm); + Global.Game = GameInfo.GetNullGame(); - GlobalWin.Tools.Restart(); + GlobalWin.Tools.Restart(); - RewireSound(); - ResetRewindBuffer(); - Cheats_Restart(); - Text = "BizHawk" + (INTERIM ? " (interim) " : ""); - HandlePlatformMenus(); - StateSlots.Clear(); - UpdateDumpIcon(); + RewireSound(); + ResetRewindBuffer(); + Cheats_Restart(); + Text = "BizHawk" + (INTERIM ? " (interim) " : ""); + HandlePlatformMenus(); + StateSlots.Clear(); + UpdateDumpIcon(); + } } private void SwapBackupSavestate(string path) //Move inside Saveslot Manager diff --git a/BizHawk.Client.EmuHawk/tools/Cheats/CheatForm.cs b/BizHawk.Client.EmuHawk/tools/Cheats/CheatForm.cs index 0e1ce3cbcc..fcdd397a57 100644 --- a/BizHawk.Client.EmuHawk/tools/Cheats/CheatForm.cs +++ b/BizHawk.Client.EmuHawk/tools/Cheats/CheatForm.cs @@ -51,7 +51,18 @@ namespace BizHawk.Client.EmuHawk public Cheats() { InitializeComponent(); - Closing += (o, e) => SaveConfigSettings(); + Closing += (o, e) => + { + if (AskSave()) + { + SaveConfigSettings(); + } + else + { + e.Cancel = true; + } + }; + CheatListView.QueryItemText += CheatListView_QueryItemText; CheatListView.QueryItemBkColor += CheatListView_QueryItemBkColor; CheatListView.VirtualMode = true; @@ -75,15 +86,7 @@ namespace BizHawk.Client.EmuHawk public void Restart() { - if (!IsHandleCreated || IsDisposed) - { - return; - } - else - { - NewList(); - ToggleGameGenieButton(); - } + StartNewList(); } private void UpdateListView() @@ -152,6 +155,7 @@ namespace BizHawk.Client.EmuHawk } else if (result == DialogResult.No) { + Global.CheatList.Changes = false; return true; } else if (result == DialogResult.Cancel) @@ -545,6 +549,14 @@ namespace BizHawk.Client.EmuHawk } } + private void StartNewList() + { + Global.CheatList.NewList(GlobalWin.MainForm.GenerateDefaultCheatFilename()); + UpdateListView(); + UpdateMessageLabel(); + ToggleGameGenieButton(); + } + private void NewList() { bool result = true; @@ -555,9 +567,7 @@ namespace BizHawk.Client.EmuHawk if (result) { - Global.CheatList.NewList(GlobalWin.MainForm.GenerateDefaultCheatFilename()); - UpdateListView(); - UpdateMessageLabel(); + StartNewList(); } } diff --git a/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs b/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs index 4dcd005e29..72f496b613 100644 --- a/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs +++ b/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs @@ -38,8 +38,18 @@ namespace BizHawk.Client.EmuHawk WatchListView.QueryItemText += WatchListView_QueryItemText; WatchListView.QueryItemBkColor += WatchListView_QueryItemBkColor; WatchListView.VirtualMode = true; - Closing += (o, e) => SaveConfigSettings(); - _sortedColumn = ""; + Closing += (o, e) => + { + if (AskSave()) + { + SaveConfigSettings(); + } + else + { + e.Cancel = true; + } + }; + _sortedColumn = String.Empty; _sortReverse = false; TopMost = Global.Config.RamWatchAlwaysOnTop; @@ -169,6 +179,7 @@ namespace BizHawk.Client.EmuHawk } else if (result == DialogResult.No) { + Watches.Changes = false; return true; } else if (result == DialogResult.Cancel) @@ -234,13 +245,6 @@ namespace BizHawk.Client.EmuHawk } } - protected override void OnClosing(CancelEventArgs e) - { - if (!AskSave()) - e.Cancel = true; - base.OnClosing(e); - } - private int GetColumnWidth(string columnName) { var width = Global.Config.RamWatchColumnWidths[columnName];