add Start/StopSound methods to IEmuHawkMainFormToTools interface and use it in tools instead of GlobalWin.Sound

This commit is contained in:
adelikat 2020-11-29 19:34:57 -06:00
parent ac93f28939
commit 792b317118
8 changed files with 20 additions and 15 deletions

View File

@ -114,5 +114,8 @@ namespace BizHawk.Client.EmuHawk
/// <remarks>only referenced from <see cref="BookmarksBranchesBox"/></remarks>
void UpdateStatusSlots();
void StartSound();
void StopSound();
}
}

View File

@ -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();
}
}

View File

@ -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();

View File

@ -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

View File

@ -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();

View File

@ -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

View File

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Windows.Forms;

View File

@ -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))