Sound config - pass in Config
This commit is contained in:
parent
aede4e7cda
commit
c5b1328f77
|
@ -1001,7 +1001,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void SoundMenuItem_Click(object sender, EventArgs e)
|
private void SoundMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
using var form = new SoundConfig();
|
using var form = new SoundConfig(Global.Config);
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
RewireSound();
|
RewireSound();
|
||||||
|
|
|
@ -380,7 +380,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void TrackBarCompression_ValueChanged(object sender, EventArgs e)
|
private void TrackBarCompression_ValueChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
// TODO - make a UserControl which is trackbar and NUD combined
|
// TODO - make a UserControl which is TrackBar and NUD combined
|
||||||
nudCompression.Value = ((TrackBar)sender).Value;
|
nudCompression.Value = ((TrackBar)sender).Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,10 +10,12 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
public partial class SoundConfig : Form
|
public partial class SoundConfig : Form
|
||||||
{
|
{
|
||||||
|
private readonly Config _config;
|
||||||
private bool _programmaticallyChangingValue;
|
private bool _programmaticallyChangingValue;
|
||||||
|
|
||||||
public SoundConfig()
|
public SoundConfig(Config config)
|
||||||
{
|
{
|
||||||
|
_config = config;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,10 +23,10 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
_programmaticallyChangingValue = true;
|
_programmaticallyChangingValue = true;
|
||||||
|
|
||||||
cbEnableMaster.Checked = Global.Config.SoundEnabled;
|
cbEnableMaster.Checked = _config.SoundEnabled;
|
||||||
cbEnableNormal.Checked = Global.Config.SoundEnabledNormal;
|
cbEnableNormal.Checked = _config.SoundEnabledNormal;
|
||||||
cbEnableRWFF.Checked = Global.Config.SoundEnabledRWFF;
|
cbEnableRWFF.Checked = _config.SoundEnabledRWFF;
|
||||||
cbMuteFrameAdvance.Checked = Global.Config.MuteFrameAdvance;
|
cbMuteFrameAdvance.Checked = _config.MuteFrameAdvance;
|
||||||
|
|
||||||
if (OSTailoredCode.IsUnixHost)
|
if (OSTailoredCode.IsUnixHost)
|
||||||
{
|
{
|
||||||
|
@ -33,14 +35,14 @@ namespace BizHawk.Client.EmuHawk
|
||||||
rbOutputMethodXAudio2.Enabled = false;
|
rbOutputMethodXAudio2.Enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
rbOutputMethodDirectSound.Checked = Global.Config.SoundOutputMethod == Config.ESoundOutputMethod.DirectSound;
|
rbOutputMethodDirectSound.Checked = _config.SoundOutputMethod == Config.ESoundOutputMethod.DirectSound;
|
||||||
rbOutputMethodXAudio2.Checked = Global.Config.SoundOutputMethod == Config.ESoundOutputMethod.XAudio2;
|
rbOutputMethodXAudio2.Checked = _config.SoundOutputMethod == Config.ESoundOutputMethod.XAudio2;
|
||||||
rbOutputMethodOpenAL.Checked = Global.Config.SoundOutputMethod == Config.ESoundOutputMethod.OpenAL;
|
rbOutputMethodOpenAL.Checked = _config.SoundOutputMethod == Config.ESoundOutputMethod.OpenAL;
|
||||||
BufferSizeNumeric.Value = Global.Config.SoundBufferSizeMs;
|
BufferSizeNumeric.Value = _config.SoundBufferSizeMs;
|
||||||
tbNormal.Value = Global.Config.SoundVolume;
|
tbNormal.Value = _config.SoundVolume;
|
||||||
nudNormal.Value = Global.Config.SoundVolume;
|
nudNormal.Value = _config.SoundVolume;
|
||||||
tbRWFF.Value = Global.Config.SoundVolumeRWFF;
|
tbRWFF.Value = _config.SoundVolumeRWFF;
|
||||||
nudRWFF.Value = Global.Config.SoundVolumeRWFF;
|
nudRWFF.Value = _config.SoundVolumeRWFF;
|
||||||
UpdateSoundDialog();
|
UpdateSoundDialog();
|
||||||
|
|
||||||
_programmaticallyChangingValue = false;
|
_programmaticallyChangingValue = false;
|
||||||
|
@ -53,22 +55,22 @@ namespace BizHawk.Client.EmuHawk
|
||||||
MessageBox.Show("Buffer size must be at least 60 milliseconds for DirectSound.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show("Buffer size must be at least 60 milliseconds for DirectSound.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var oldOutputMethod = Global.Config.SoundOutputMethod;
|
var oldOutputMethod = _config.SoundOutputMethod;
|
||||||
var oldDevice = Global.Config.SoundDevice;
|
var oldDevice = _config.SoundDevice;
|
||||||
Global.Config.SoundEnabled = cbEnableMaster.Checked;
|
_config.SoundEnabled = cbEnableMaster.Checked;
|
||||||
Global.Config.SoundEnabledNormal = cbEnableNormal.Checked;
|
_config.SoundEnabledNormal = cbEnableNormal.Checked;
|
||||||
Global.Config.SoundEnabledRWFF = cbEnableRWFF.Checked;
|
_config.SoundEnabledRWFF = cbEnableRWFF.Checked;
|
||||||
Global.Config.MuteFrameAdvance = cbMuteFrameAdvance.Checked;
|
_config.MuteFrameAdvance = cbMuteFrameAdvance.Checked;
|
||||||
if (rbOutputMethodDirectSound.Checked) Global.Config.SoundOutputMethod = Config.ESoundOutputMethod.DirectSound;
|
if (rbOutputMethodDirectSound.Checked) _config.SoundOutputMethod = Config.ESoundOutputMethod.DirectSound;
|
||||||
if (rbOutputMethodXAudio2.Checked) Global.Config.SoundOutputMethod = Config.ESoundOutputMethod.XAudio2;
|
if (rbOutputMethodXAudio2.Checked) _config.SoundOutputMethod = Config.ESoundOutputMethod.XAudio2;
|
||||||
if (rbOutputMethodOpenAL.Checked) Global.Config.SoundOutputMethod = Config.ESoundOutputMethod.OpenAL;
|
if (rbOutputMethodOpenAL.Checked) _config.SoundOutputMethod = Config.ESoundOutputMethod.OpenAL;
|
||||||
Global.Config.SoundBufferSizeMs = (int)BufferSizeNumeric.Value;
|
_config.SoundBufferSizeMs = (int)BufferSizeNumeric.Value;
|
||||||
Global.Config.SoundVolume = tbNormal.Value;
|
_config.SoundVolume = tbNormal.Value;
|
||||||
Global.Config.SoundVolumeRWFF = tbRWFF.Value;
|
_config.SoundVolumeRWFF = tbRWFF.Value;
|
||||||
Global.Config.SoundDevice = (string)listBoxSoundDevices.SelectedItem ?? "<default>";
|
_config.SoundDevice = (string)listBoxSoundDevices.SelectedItem ?? "<default>";
|
||||||
GlobalWin.Sound.StopSound();
|
GlobalWin.Sound.StopSound();
|
||||||
if (Global.Config.SoundOutputMethod != oldOutputMethod
|
if (_config.SoundOutputMethod != oldOutputMethod
|
||||||
|| Global.Config.SoundDevice != oldDevice)
|
|| _config.SoundDevice != oldDevice)
|
||||||
{
|
{
|
||||||
GlobalWin.Sound.Dispose();
|
GlobalWin.Sound.Dispose();
|
||||||
GlobalWin.Sound = new Sound(GlobalWin.MainForm.Handle);
|
GlobalWin.Sound = new Sound(GlobalWin.MainForm.Handle);
|
||||||
|
@ -101,7 +103,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
foreach (var name in deviceNames)
|
foreach (var name in deviceNames)
|
||||||
{
|
{
|
||||||
listBoxSoundDevices.Items.Add(name);
|
listBoxSoundDevices.Items.Add(name);
|
||||||
if (name == Global.Config.SoundDevice)
|
if (name == _config.SoundDevice)
|
||||||
{
|
{
|
||||||
listBoxSoundDevices.SelectedItem = name;
|
listBoxSoundDevices.SelectedItem = name;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue