From 792b3171180829d3f4f9fba357febce819dd3278 Mon Sep 17 00:00:00 2001 From: adelikat Date: Sun, 29 Nov 2020 19:34:57 -0600 Subject: [PATCH] add Start/StopSound methods to IEmuHawkMainFormToTools interface and use it in tools instead of GlobalWin.Sound --- src/BizHawk.Client.EmuHawk/IEmuHawkMainFormToTools.cs | 3 +++ src/BizHawk.Client.EmuHawk/MainForm.cs | 3 +++ src/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs | 4 ++-- .../tools/TAStudio/TAStudio.IToolForm.cs | 4 ++-- .../tools/TAStudio/TAStudio.MenuItems.cs | 8 ++++---- src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs | 8 ++++---- src/BizHawk.Client.EmuHawk/tools/ToolFormBase.cs | 1 - src/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs | 4 ++-- 8 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/BizHawk.Client.EmuHawk/IEmuHawkMainFormToTools.cs b/src/BizHawk.Client.EmuHawk/IEmuHawkMainFormToTools.cs index 3ec737348c..e2d62014cc 100644 --- a/src/BizHawk.Client.EmuHawk/IEmuHawkMainFormToTools.cs +++ b/src/BizHawk.Client.EmuHawk/IEmuHawkMainFormToTools.cs @@ -114,5 +114,8 @@ namespace BizHawk.Client.EmuHawk /// only referenced from void UpdateStatusSlots(); + + void StartSound(); + void StopSound(); } } diff --git a/src/BizHawk.Client.EmuHawk/MainForm.cs b/src/BizHawk.Client.EmuHawk/MainForm.cs index 83c43ef75e..7bf5c77599 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.cs @@ -4474,5 +4474,8 @@ namespace BizHawk.Client.EmuHawk } public DialogResult ShowDialogAsChild(Form dialog) => dialog.ShowDialog(this); + + public void StartSound() => Sound.StartSound(); + public void StopSound() => Sound.StopSound(); } } diff --git a/src/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs b/src/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs index 1d5b012e85..fa53825125 100644 --- a/src/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs +++ b/src/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs @@ -738,9 +738,9 @@ namespace BizHawk.Client.EmuHawk { if (LuaImp.ScriptList.Changes && !string.IsNullOrEmpty(LuaImp.ScriptList.Filename)) { - GlobalWin.Sound.StopSound(); + MainForm.StopSound(); var result = MessageBox.Show("Save changes to session?", "Lua Console", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button3); - GlobalWin.Sound.StartSound(); + MainForm.StartSound(); if (result == DialogResult.Yes) { SaveOrSaveAs(); diff --git a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs index 36f38453e1..1ff746f53d 100644 --- a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs +++ b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs @@ -106,7 +106,7 @@ namespace BizHawk.Client.EmuHawk if (CurrentTasMovie != null && CurrentTasMovie.Changes) { - GlobalWin.Sound.StopSound(); + MainForm.StopSound(); var result = MessageBox.Show( "Save Changes?", "Tastudio", @@ -114,7 +114,7 @@ namespace BizHawk.Client.EmuHawk MessageBoxIcon.Question, MessageBoxDefaultButton.Button3); - GlobalWin.Sound.StartSound(); + MainForm.StartSound(); if (result == DialogResult.Yes) { _exiting = true; // Asking to save changes should only ever be called when closing something diff --git a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs index 7250e63fbb..0a743605fd 100644 --- a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs +++ b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs @@ -182,7 +182,7 @@ namespace BizHawk.Client.EmuHawk else { _autosaveTimer.Stop(); - GlobalWin.Sound.StopSound(); + MainForm.StopSound(); MessageStatusLabel.Text = "Saving..."; Cursor = Cursors.WaitCursor; Update(); @@ -195,7 +195,7 @@ namespace BizHawk.Client.EmuHawk MessageStatusLabel.Text = "Backup .tasproj saved to \"Movie backups\" path."; Settings.RecentTas.Add(CurrentTasMovie.Filename); Cursor = Cursors.Default; - GlobalWin.Sound.StartSound(); + MainForm.StartSound(); } } @@ -283,7 +283,7 @@ namespace BizHawk.Client.EmuHawk var file = new FileInfo(bk2.Filename); if (file.Exists) { - GlobalWin.Sound.StopSound(); + MainForm.StopSound(); var result = MessageBox.Show( "Overwrite Existing File?", "Tastudio", @@ -291,7 +291,7 @@ namespace BizHawk.Client.EmuHawk MessageBoxIcon.Question, MessageBoxDefaultButton.Button3); - GlobalWin.Sound.StartSound(); + MainForm.StartSound(); if (result == DialogResult.Yes) { bk2.Save(); diff --git a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs index 5f2447a662..9d5ecac5b2 100644 --- a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs +++ b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs @@ -787,7 +787,7 @@ namespace BizHawk.Client.EmuHawk else { _autosaveTimer?.Stop(); - GlobalWin.Sound.StopSound(); + MainForm.StopSound(); MessageStatusLabel.Text = "Saving..."; Cursor = Cursors.WaitCursor; Update(); @@ -800,14 +800,14 @@ namespace BizHawk.Client.EmuHawk MessageStatusLabel.Text = "File saved."; Settings.RecentTas.Add(CurrentTasMovie.Filename); Cursor = Cursors.Default; - GlobalWin.Sound.StartSound(); + MainForm.StartSound(); } } private void SaveAsTas() { _autosaveTimer.Stop(); - GlobalWin.Sound.StopSound(); + MainForm.StopSound(); ClearLeftMouseStates(); var filename = CurrentTasMovie.Filename; if (string.IsNullOrWhiteSpace(filename) || filename == DefaultTasProjName()) @@ -843,7 +843,7 @@ namespace BizHawk.Client.EmuHawk } MainForm.SetWindowText(); - GlobalWin.Sound.StartSound(); + MainForm.StartSound(); } protected override string WindowTitle diff --git a/src/BizHawk.Client.EmuHawk/tools/ToolFormBase.cs b/src/BizHawk.Client.EmuHawk/tools/ToolFormBase.cs index af4f71750c..f3ef662b40 100644 --- a/src/BizHawk.Client.EmuHawk/tools/ToolFormBase.cs +++ b/src/BizHawk.Client.EmuHawk/tools/ToolFormBase.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Drawing; using System.IO; using System.Windows.Forms; diff --git a/src/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs b/src/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs index 4696ab85cf..b9ade830c6 100644 --- a/src/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs +++ b/src/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs @@ -153,9 +153,9 @@ namespace BizHawk.Client.EmuHawk { if (_watches.Changes) { - GlobalWin.Sound.StopSound(); + MainForm.StopSound(); var result = MessageBox.Show("Save Changes?", "RAM Watch", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button3); - GlobalWin.Sound.StartSound(); + MainForm.StartSound(); if (result == DialogResult.Yes) { if (string.IsNullOrWhiteSpace(_watches.CurrentFileName))