diff --git a/src/BizHawk.Client.EmuHawk/Extensions/ToolExtensions.cs b/src/BizHawk.Client.EmuHawk/Extensions/ToolExtensions.cs index 9d3d74ba2c..1babbc8db4 100644 --- a/src/BizHawk.Client.EmuHawk/Extensions/ToolExtensions.cs +++ b/src/BizHawk.Client.EmuHawk/Extensions/ToolExtensions.cs @@ -193,13 +193,15 @@ namespace BizHawk.Client.EmuHawk.ToolExtensions var settingsItem = new ToolStripMenuItem { Text = "&Recent Settings..." }; settingsItem.Click += (o, ev) => { - using var prompt = new InputPrompt(mainForm) + using var prompt = new InputPrompt { TextInputType = InputPrompt.InputType.Unsigned, Message = "Number of recent files to track", InitialValue = recent.MAX_RECENT_FILES.ToString() }; + mainForm.StopSound(); var result = prompt.ShowDialog(); + mainForm.StartSound(); if (result == DialogResult.OK) { int val = int.Parse(prompt.PromptText); diff --git a/src/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs b/src/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs index a97a753247..75e236e05f 100644 --- a/src/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs +++ b/src/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs @@ -1598,14 +1598,16 @@ namespace BizHawk.Client.EmuHawk private void GoToAddressMenuItem_Click(object sender, EventArgs e) { - using var inputPrompt = new InputPrompt(MainForm) + using var inputPrompt = new InputPrompt { Text = "Go to Address", StartLocation = this.ChildPointToScreen(MemoryViewerBox), Message = "Enter a hexadecimal value" }; + MainForm.StopSound(); var result = inputPrompt.ShowHawkDialog(this); + MainForm.StartSound(); if (result == DialogResult.OK && inputPrompt.PromptText.IsHex()) { diff --git a/src/BizHawk.Client.EmuHawk/tools/InputPrompt.cs b/src/BizHawk.Client.EmuHawk/tools/InputPrompt.cs index f833df5936..595e5c7b3c 100644 --- a/src/BizHawk.Client.EmuHawk/tools/InputPrompt.cs +++ b/src/BizHawk.Client.EmuHawk/tools/InputPrompt.cs @@ -13,12 +13,8 @@ namespace BizHawk.Client.EmuHawk /// public partial class InputPrompt : Form { - private readonly IMainFormForTools _mainForm; - - public InputPrompt(IMainFormForTools mainForm) + public InputPrompt() { - _mainForm = mainForm; - _mainForm.StopSound(); InitializeComponent(); StartLocation = new Point(-1, -1); } @@ -58,14 +54,12 @@ namespace BizHawk.Client.EmuHawk { DialogResult = DialogResult.OK; Close(); - _mainForm.StartSound(); } private void Cancel_Click(object sender, EventArgs e) { DialogResult = DialogResult.Cancel; Close(); - _mainForm.StartSound(); } private void PromptBox_KeyPress(object sender, KeyPressEventArgs e) diff --git a/src/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs b/src/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs index 6599681e48..7d1e515908 100644 --- a/src/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs +++ b/src/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs @@ -566,7 +566,7 @@ namespace BizHawk.Client.EmuHawk return false; } - var i = new InputPrompt(MainForm) + var i = new InputPrompt { Text = $"Text for branch {index}", TextInputType = InputPrompt.InputType.Text, @@ -577,7 +577,9 @@ namespace BizHawk.Client.EmuHawk var point = Cursor.Position; point.Offset(i.Width / -2, i.Height / -2); + MainForm.StopSound(); var result = i.ShowHawkDialog(this, position: point); + MainForm.StartSound(); if (result.IsOk()) { branch.UserText = i.PromptText; diff --git a/src/BizHawk.Client.EmuHawk/tools/TAStudio/MarkerControl.cs b/src/BizHawk.Client.EmuHawk/tools/TAStudio/MarkerControl.cs index d3d76d683b..f5c2d4ea12 100644 --- a/src/BizHawk.Client.EmuHawk/tools/TAStudio/MarkerControl.cs +++ b/src/BizHawk.Client.EmuHawk/tools/TAStudio/MarkerControl.cs @@ -182,7 +182,7 @@ namespace BizHawk.Client.EmuHawk TasMovieMarker marker; if (editText) { - var i = new InputPrompt(Tastudio.MainForm) + var i = new InputPrompt { Text = $"Marker for frame {frame}", TextInputType = InputPrompt.InputType.Text, @@ -196,7 +196,9 @@ namespace BizHawk.Client.EmuHawk var point = Cursor.Position; point.Offset(i.Width / -2, i.Height / -2); + Tastudio.MainForm.StopSound(); var result = i.ShowHawkDialog(this, position: point); + Tastudio.MainForm.StartSound(); if (!result.IsOk()) { return; @@ -234,7 +236,7 @@ namespace BizHawk.Client.EmuHawk { var markerFrame = marker.Frame; var point = default(Point); - var i = new InputPrompt(Tastudio.MainForm) + var i = new InputPrompt { Text = $"Marker for frame {markerFrame}", TextInputType = InputPrompt.InputType.Text, @@ -251,7 +253,9 @@ namespace BizHawk.Client.EmuHawk point.Offset(i.Width / -2, i.Height / -2); } + Tastudio.MainForm.StopSound(); var result = i.ShowHawkDialog(this, position: point); + Tastudio.MainForm.StartSound(); if (result == DialogResult.OK) { diff --git a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs index 8755697500..5aaa905707 100644 --- a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs +++ b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs @@ -822,14 +822,17 @@ namespace BizHawk.Client.EmuHawk private void SetMaxUndoLevelsMenuItem_Click(object sender, EventArgs e) { - using var prompt = new InputPrompt(MainForm) + using var prompt = new InputPrompt { TextInputType = InputPrompt.InputType.Unsigned, Message = "Number of Undo Levels to keep", InitialValue = CurrentTasMovie.ChangeLog.MaxSteps.ToString() }; - if (prompt.ShowDialog().IsOk()) + MainForm.StopSound(); + var result = prompt.ShowDialog(); + MainForm.StartSound(); + if (result.IsOk()) { int val = 0; try @@ -850,14 +853,17 @@ namespace BizHawk.Client.EmuHawk private void SetBranchCellHoverIntervalMenuItem_Click(object sender, EventArgs e) { - using var prompt = new InputPrompt(MainForm) + using var prompt = new InputPrompt { TextInputType = InputPrompt.InputType.Unsigned, Message = "ScreenshotPopUp Delay", InitialValue = Settings.BranchCellHoverInterval.ToString() }; - if (prompt.ShowDialog().IsOk()) + MainForm.StopSound(); + var result = prompt.ShowDialog(); + MainForm.StartSound(); + if (result.IsOk()) { int val = int.Parse(prompt.PromptText); if (val > 0) @@ -870,14 +876,17 @@ namespace BizHawk.Client.EmuHawk private void SetSeekingCutoffIntervalMenuItem_Click(object sender, EventArgs e) { - using var prompt = new InputPrompt(MainForm) + using var prompt = new InputPrompt { TextInputType = InputPrompt.InputType.Unsigned, Message = "Seeking Cutoff Interval", InitialValue = Settings.SeekingCutoffInterval.ToString() }; - if (prompt.ShowDialog().IsOk()) + MainForm.StopSound(); + var result = prompt.ShowDialog(); + MainForm.StartSound(); + if (result.IsOk()) { int val = int.Parse(prompt.PromptText); if (val > 0) @@ -890,14 +899,17 @@ namespace BizHawk.Client.EmuHawk private void SetAutosaveIntervalMenuItem_Click(object sender, EventArgs e) { - using var prompt = new InputPrompt(MainForm) + using var prompt = new InputPrompt { TextInputType = InputPrompt.InputType.Unsigned, Message = "Autosave Interval in seconds\nSet to 0 to disable", InitialValue = (Settings.AutosaveInterval / 1000).ToString() }; - if (prompt.ShowDialog().IsOk()) + MainForm.StopSound(); + var result = prompt.ShowDialog(); + MainForm.StartSound(); + if (result.IsOk()) { uint val = uint.Parse(prompt.PromptText) * 1000; Settings.AutosaveInterval = val; @@ -1170,13 +1182,16 @@ namespace BizHawk.Client.EmuHawk private void WheelScrollSpeedMenuItem_Click(object sender, EventArgs e) { - var inputPrompt = new InputPrompt(MainForm) + var inputPrompt = new InputPrompt { TextInputType = InputPrompt.InputType.Unsigned, Message = "Frames per tick:", InitialValue = TasView.ScrollSpeed.ToString() }; - if (inputPrompt.ShowDialog() == DialogResult.OK) + MainForm.StopSound(); + var result = inputPrompt.ShowDialog(); + MainForm.StartSound(); + if (result == DialogResult.OK) { TasView.ScrollSpeed = int.Parse(inputPrompt.PromptText); Settings.ScrollSpeed = TasView.ScrollSpeed; diff --git a/src/BizHawk.Client.EmuHawk/tools/TraceLogger.cs b/src/BizHawk.Client.EmuHawk/tools/TraceLogger.cs index bd9fe52911..0b62b3ccda 100644 --- a/src/BizHawk.Client.EmuHawk/tools/TraceLogger.cs +++ b/src/BizHawk.Client.EmuHawk/tools/TraceLogger.cs @@ -343,7 +343,7 @@ namespace BizHawk.Client.EmuHawk private void MaxLinesMenuItem_Click(object sender, EventArgs e) { - using var prompt = new InputPrompt(MainForm) + using var prompt = new InputPrompt { StartLocation = this.ChildPointToScreen(TraceView), TextInputType = InputPrompt.InputType.Unsigned, @@ -351,7 +351,9 @@ namespace BizHawk.Client.EmuHawk InitialValue = MaxLines.ToString() }; + MainForm.StopSound(); var result = prompt.ShowHawkDialog(this); + MainForm.StartSound(); if (result == DialogResult.OK) { var max = int.Parse(prompt.PromptText); @@ -364,7 +366,7 @@ namespace BizHawk.Client.EmuHawk private void SegmentSizeMenuItem_Click(object sender, EventArgs e) { - using var prompt = new InputPrompt(MainForm) + using var prompt = new InputPrompt { StartLocation = this.ChildPointToScreen(TraceView), TextInputType = InputPrompt.InputType.Unsigned, @@ -372,7 +374,9 @@ namespace BizHawk.Client.EmuHawk InitialValue = FileSizeCap.ToString() }; + MainForm.StopSound(); var result = prompt.ShowHawkDialog(this); + MainForm.StartSound(); if (result == DialogResult.OK) { FileSizeCap = int.Parse(prompt.PromptText); diff --git a/src/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs b/src/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs index a96147f1ec..7ae2361d13 100644 --- a/src/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs +++ b/src/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs @@ -891,14 +891,17 @@ namespace BizHawk.Client.EmuHawk private void GoToSpecifiedAddress() { WatchListView.DeselectAll(); - var prompt = new InputPrompt(MainForm) + var prompt = new InputPrompt { Text = "Go to Address", StartLocation = this.ChildPointToScreen(WatchListView), Message = "Enter a hexadecimal value" }; - while (prompt.ShowHawkDialog(this).IsOk()) + MainForm.StopSound(); + var result = prompt.ShowHawkDialog(this); + MainForm.StartSound(); + while (result.IsOk()) { try { diff --git a/src/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs b/src/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs index ecfda442fa..14e0eb7c38 100644 --- a/src/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs +++ b/src/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs @@ -420,7 +420,7 @@ namespace BizHawk.Client.EmuHawk } else if (SelectedSeparators.Any() && !duplicate) { - var inputPrompt = new InputPrompt(MainForm) + var inputPrompt = new InputPrompt { Text = "Edit Separator", StartLocation = this.ChildPointToScreen(WatchListView), @@ -428,7 +428,9 @@ namespace BizHawk.Client.EmuHawk TextInputType = InputPrompt.InputType.Text }; + MainForm.StopSound(); var result = inputPrompt.ShowHawkDialog(); + MainForm.StartSound(); if (result == DialogResult.OK) {