diff --git a/src/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs b/src/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs index a6a9b84acd..08fda9cde3 100644 --- a/src/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs +++ b/src/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs @@ -700,28 +700,14 @@ namespace BizHawk.Client.EmuHawk public override bool AskSaveChanges() { - if (LuaImp.ScriptList.Changes && !string.IsNullOrEmpty(LuaImp.ScriptList.Filename)) - { - var result = MainForm.DoWithTempMute(() => MessageBox.Show("Save changes to session?", "Lua Console", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button3)); - if (result == DialogResult.Yes) - { - SaveOrSaveAs(); - - return true; - } - - if (result == DialogResult.No) - { - LuaImp.ScriptList.Changes = false; - return true; - } - - if (result == DialogResult.Cancel) - { - return false; - } - } - + if (!LuaImp.ScriptList.Changes || string.IsNullOrEmpty(LuaImp.ScriptList.Filename)) return true; + var result = DialogController.DoWithTempMute(() => this.ModalMessageBox3( + caption: "Closing with Unsaved Changes", + icon: EMsgBoxIcon.Question, + text: $"Save {WindowTitleStatic} session?")); + if (result is null) return false; + if (result.Value) SaveOrSaveAs(); + else LuaImp.ScriptList.Changes = false; return true; } diff --git a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs index 772b08c130..39cfc1317d 100644 --- a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs +++ b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs @@ -1,6 +1,4 @@ -using System.Windows.Forms; - -using BizHawk.Client.Common; +using BizHawk.Client.Common; using BizHawk.Emulation.Common; namespace BizHawk.Client.EmuHawk @@ -135,30 +133,14 @@ namespace BizHawk.Client.EmuHawk } StopSeeking(); - - if (CurrentTasMovie != null && CurrentTasMovie.Changes) - { - var result = MainForm.DoWithTempMute(() => MessageBox.Show( - "Save Changes?", - "Tastudio", - MessageBoxButtons.YesNoCancel, - MessageBoxIcon.Question, - MessageBoxDefaultButton.Button3)); - if (result == DialogResult.Yes) - { - SaveTas(); - } - else if (result == DialogResult.No) - { - CurrentTasMovie.ClearChanges(); - return true; - } - else if (result == DialogResult.Cancel) - { - return false; - } - } - + if (CurrentTasMovie?.Changes is not true) return true; + var result = DialogController.DoWithTempMute(() => this.ModalMessageBox3( + caption: "Closing with Unsaved Changes", + icon: EMsgBoxIcon.Question, + text: $"Save {WindowTitleStatic} project?")); + if (result is null) return false; + if (result.Value) SaveTas(); + else CurrentTasMovie.ClearChanges(); return true; } } diff --git a/src/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs b/src/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs index 3f39a3e7b8..fdbe531156 100644 --- a/src/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs +++ b/src/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs @@ -206,32 +206,28 @@ namespace BizHawk.Client.EmuHawk public override bool AskSaveChanges() { - if (_watches.Changes) + if (!_watches.Changes) return true; + var result = DialogController.DoWithTempMute(() => this.ModalMessageBox3( + caption: "Closing with Unsaved Changes", + icon: EMsgBoxIcon.Question, + text: "Save watch file?")); + if (result is null) return false; + if (result.Value) { - var result = MainForm.DoWithTempMute(() => MessageBox.Show("Save Changes?", "RAM Watch", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button3)); - if (result == DialogResult.Yes) + if (string.IsNullOrWhiteSpace(_watches.CurrentFileName)) { - if (string.IsNullOrWhiteSpace(_watches.CurrentFileName)) - { - SaveAs(); - } - else - { - _watches.Save(); - Config.RecentWatches.Add(_watches.CurrentFileName); - } + SaveAs(); } - else if (result == DialogResult.No) + else { - _watches.Changes = false; - return true; - } - else if (result == DialogResult.Cancel) - { - return false; + _watches.Save(); + Config.RecentWatches.Add(_watches.CurrentFileName); } } - + else + { + _watches.Changes = false; + } return true; }