Move Start/StopSound calls from InputPrompt to callers
This commit is contained in:
parent
2295d47192
commit
cc4acd9c64
|
@ -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);
|
||||
|
|
|
@ -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())
|
||||
{
|
||||
|
|
|
@ -13,12 +13,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
/// </summary>
|
||||
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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue