Refactor SoundConfig
Everything is initialised in the constructor, I used object initialiser syntax where possible, layout is done with FLPs instead of absolute positioning, and I changed the text a little
This commit is contained in:
parent
223866b995
commit
f11966b1de
|
@ -519,9 +519,6 @@
|
|||
<Compile Include="config\SoundConfig.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="config\SoundConfig.Designer.cs">
|
||||
<DependentUpon>SoundConfig.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="config\TI83\TI83PaletteConfig.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
|
|
@ -1,400 +0,0 @@
|
|||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
partial class SoundConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.Cancel = new System.Windows.Forms.Button();
|
||||
this.OK = new System.Windows.Forms.Button();
|
||||
this.cbEnableNormal = new System.Windows.Forms.CheckBox();
|
||||
this.grpSoundVol = new System.Windows.Forms.GroupBox();
|
||||
this.nudRWFF = new System.Windows.Forms.NumericUpDown();
|
||||
this.cbEnableRWFF = new System.Windows.Forms.CheckBox();
|
||||
this.tbRWFF = new System.Windows.Forms.TrackBar();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.tbNormal = new System.Windows.Forms.TrackBar();
|
||||
this.nudNormal = new System.Windows.Forms.NumericUpDown();
|
||||
this.listBoxSoundDevices = new System.Windows.Forms.ListBox();
|
||||
this.SoundDeviceLabel = new System.Windows.Forms.Label();
|
||||
this.BufferSizeLabel = new System.Windows.Forms.Label();
|
||||
this.BufferSizeNumeric = new System.Windows.Forms.NumericUpDown();
|
||||
this.BufferSizeUnitsLabel = new System.Windows.Forms.Label();
|
||||
this.grpOutputMethod = new System.Windows.Forms.GroupBox();
|
||||
this.rbOutputMethodOpenAL = new System.Windows.Forms.RadioButton();
|
||||
this.rbOutputMethodXAudio2 = new System.Windows.Forms.RadioButton();
|
||||
this.rbOutputMethodDirectSound = new System.Windows.Forms.RadioButton();
|
||||
this.cbMuteFrameAdvance = new System.Windows.Forms.CheckBox();
|
||||
this.cbEnableMaster = new System.Windows.Forms.CheckBox();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.grpSoundVol.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.nudRWFF)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.tbRWFF)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.tbNormal)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.nudNormal)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.BufferSizeNumeric)).BeginInit();
|
||||
this.grpOutputMethod.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// Cancel
|
||||
//
|
||||
this.Cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.Cancel.Location = new System.Drawing.Point(317, 244);
|
||||
this.Cancel.Name = "Cancel";
|
||||
this.Cancel.Size = new System.Drawing.Size(75, 23);
|
||||
this.Cancel.TabIndex = 1;
|
||||
this.Cancel.Text = "&Cancel";
|
||||
this.Cancel.UseVisualStyleBackColor = true;
|
||||
this.Cancel.Click += new System.EventHandler(this.Cancel_Click);
|
||||
//
|
||||
// OK
|
||||
//
|
||||
this.OK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.OK.Location = new System.Drawing.Point(236, 244);
|
||||
this.OK.Name = "OK";
|
||||
this.OK.Size = new System.Drawing.Size(75, 23);
|
||||
this.OK.TabIndex = 0;
|
||||
this.OK.Text = "&OK";
|
||||
this.OK.UseVisualStyleBackColor = true;
|
||||
this.OK.Click += new System.EventHandler(this.Ok_Click);
|
||||
//
|
||||
// cbEnableNormal
|
||||
//
|
||||
this.cbEnableNormal.AutoSize = true;
|
||||
this.cbEnableNormal.Location = new System.Drawing.Point(6, 20);
|
||||
this.cbEnableNormal.Name = "cbEnableNormal";
|
||||
this.cbEnableNormal.Size = new System.Drawing.Size(48, 17);
|
||||
this.cbEnableNormal.TabIndex = 0;
|
||||
this.cbEnableNormal.Text = "Ena.";
|
||||
this.cbEnableNormal.UseVisualStyleBackColor = true;
|
||||
this.cbEnableNormal.CheckedChanged += new System.EventHandler(this.UpdateSoundDialog);
|
||||
//
|
||||
// grpSoundVol
|
||||
//
|
||||
this.grpSoundVol.Controls.Add(this.nudRWFF);
|
||||
this.grpSoundVol.Controls.Add(this.cbEnableRWFF);
|
||||
this.grpSoundVol.Controls.Add(this.tbRWFF);
|
||||
this.grpSoundVol.Controls.Add(this.label2);
|
||||
this.grpSoundVol.Controls.Add(this.label1);
|
||||
this.grpSoundVol.Controls.Add(this.tbNormal);
|
||||
this.grpSoundVol.Controls.Add(this.nudNormal);
|
||||
this.grpSoundVol.Controls.Add(this.cbEnableNormal);
|
||||
this.grpSoundVol.Location = new System.Drawing.Point(12, 12);
|
||||
this.grpSoundVol.Name = "grpSoundVol";
|
||||
this.grpSoundVol.Size = new System.Drawing.Size(117, 255);
|
||||
this.grpSoundVol.TabIndex = 2;
|
||||
this.grpSoundVol.TabStop = false;
|
||||
this.grpSoundVol.Text = "Volume";
|
||||
//
|
||||
// nudRWFF
|
||||
//
|
||||
this.nudRWFF.Location = new System.Drawing.Point(58, 223);
|
||||
this.nudRWFF.Name = "nudRWFF";
|
||||
this.nudRWFF.Size = new System.Drawing.Size(45, 20);
|
||||
this.nudRWFF.TabIndex = 7;
|
||||
this.nudRWFF.Value = new decimal(new int[] {
|
||||
100,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// cbEnableRWFF
|
||||
//
|
||||
this.cbEnableRWFF.AutoSize = true;
|
||||
this.cbEnableRWFF.Location = new System.Drawing.Point(58, 20);
|
||||
this.cbEnableRWFF.Name = "cbEnableRWFF";
|
||||
this.cbEnableRWFF.Size = new System.Drawing.Size(48, 17);
|
||||
this.cbEnableRWFF.TabIndex = 4;
|
||||
this.cbEnableRWFF.Text = "Ena.";
|
||||
this.cbEnableRWFF.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// tbRWFF
|
||||
//
|
||||
this.tbRWFF.LargeChange = 10;
|
||||
this.tbRWFF.Location = new System.Drawing.Point(64, 53);
|
||||
this.tbRWFF.Maximum = 100;
|
||||
this.tbRWFF.Name = "tbRWFF";
|
||||
this.tbRWFF.Orientation = System.Windows.Forms.Orientation.Vertical;
|
||||
this.tbRWFF.Size = new System.Drawing.Size(42, 164);
|
||||
this.tbRWFF.TabIndex = 6;
|
||||
this.tbRWFF.TickFrequency = 10;
|
||||
this.tbRWFF.Scroll += new System.EventHandler(this.TbRwff_Scroll);
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(56, 42);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(50, 13);
|
||||
this.label2.TabIndex = 5;
|
||||
this.label2.Text = "RW && FF";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(6, 42);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(40, 13);
|
||||
this.label1.TabIndex = 1;
|
||||
this.label1.Text = "Normal";
|
||||
//
|
||||
// tbNormal
|
||||
//
|
||||
this.tbNormal.LargeChange = 10;
|
||||
this.tbNormal.Location = new System.Drawing.Point(8, 53);
|
||||
this.tbNormal.Maximum = 100;
|
||||
this.tbNormal.Name = "tbNormal";
|
||||
this.tbNormal.Orientation = System.Windows.Forms.Orientation.Vertical;
|
||||
this.tbNormal.Size = new System.Drawing.Size(42, 164);
|
||||
this.tbNormal.TabIndex = 2;
|
||||
this.tbNormal.TickFrequency = 10;
|
||||
this.tbNormal.Scroll += new System.EventHandler(this.TrackBar1_Scroll);
|
||||
//
|
||||
// nudNormal
|
||||
//
|
||||
this.nudNormal.Location = new System.Drawing.Point(5, 223);
|
||||
this.nudNormal.Name = "nudNormal";
|
||||
this.nudNormal.Size = new System.Drawing.Size(45, 20);
|
||||
this.nudNormal.TabIndex = 3;
|
||||
this.nudNormal.Value = new decimal(new int[] {
|
||||
100,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.nudNormal.ValueChanged += new System.EventHandler(this.SoundVolNumeric_ValueChanged);
|
||||
//
|
||||
// listBoxSoundDevices
|
||||
//
|
||||
this.listBoxSoundDevices.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.listBoxSoundDevices.FormattingEnabled = true;
|
||||
this.listBoxSoundDevices.Location = new System.Drawing.Point(138, 110);
|
||||
this.listBoxSoundDevices.Name = "listBoxSoundDevices";
|
||||
this.listBoxSoundDevices.Size = new System.Drawing.Size(254, 95);
|
||||
this.listBoxSoundDevices.TabIndex = 8;
|
||||
//
|
||||
// SoundDeviceLabel
|
||||
//
|
||||
this.SoundDeviceLabel.AutoSize = true;
|
||||
this.SoundDeviceLabel.Location = new System.Drawing.Point(135, 89);
|
||||
this.SoundDeviceLabel.Name = "SoundDeviceLabel";
|
||||
this.SoundDeviceLabel.Size = new System.Drawing.Size(78, 13);
|
||||
this.SoundDeviceLabel.TabIndex = 7;
|
||||
this.SoundDeviceLabel.Text = "Sound Device:";
|
||||
//
|
||||
// BufferSizeLabel
|
||||
//
|
||||
this.BufferSizeLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.BufferSizeLabel.AutoSize = true;
|
||||
this.BufferSizeLabel.Location = new System.Drawing.Point(135, 210);
|
||||
this.BufferSizeLabel.Name = "BufferSizeLabel";
|
||||
this.BufferSizeLabel.Size = new System.Drawing.Size(61, 13);
|
||||
this.BufferSizeLabel.TabIndex = 9;
|
||||
this.BufferSizeLabel.Text = "Buffer Size:";
|
||||
//
|
||||
// BufferSizeNumeric
|
||||
//
|
||||
this.BufferSizeNumeric.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.BufferSizeNumeric.Location = new System.Drawing.Point(202, 208);
|
||||
this.BufferSizeNumeric.Maximum = new decimal(new int[] {
|
||||
250,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.BufferSizeNumeric.Minimum = new decimal(new int[] {
|
||||
30,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.BufferSizeNumeric.Name = "BufferSizeNumeric";
|
||||
this.BufferSizeNumeric.Size = new System.Drawing.Size(59, 20);
|
||||
this.BufferSizeNumeric.TabIndex = 10;
|
||||
this.BufferSizeNumeric.Value = new decimal(new int[] {
|
||||
100,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// BufferSizeUnitsLabel
|
||||
//
|
||||
this.BufferSizeUnitsLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.BufferSizeUnitsLabel.AutoSize = true;
|
||||
this.BufferSizeUnitsLabel.Location = new System.Drawing.Point(267, 210);
|
||||
this.BufferSizeUnitsLabel.Name = "BufferSizeUnitsLabel";
|
||||
this.BufferSizeUnitsLabel.Size = new System.Drawing.Size(63, 13);
|
||||
this.BufferSizeUnitsLabel.TabIndex = 11;
|
||||
this.BufferSizeUnitsLabel.Text = "milliseconds";
|
||||
//
|
||||
// grpOutputMethod
|
||||
//
|
||||
this.grpOutputMethod.Controls.Add(this.rbOutputMethodOpenAL);
|
||||
this.grpOutputMethod.Controls.Add(this.rbOutputMethodXAudio2);
|
||||
this.grpOutputMethod.Controls.Add(this.rbOutputMethodDirectSound);
|
||||
this.grpOutputMethod.Location = new System.Drawing.Point(292, 12);
|
||||
this.grpOutputMethod.Name = "grpOutputMethod";
|
||||
this.grpOutputMethod.Size = new System.Drawing.Size(100, 90);
|
||||
this.grpOutputMethod.TabIndex = 12;
|
||||
this.grpOutputMethod.TabStop = false;
|
||||
this.grpOutputMethod.Text = "Output Method";
|
||||
//
|
||||
// rbOutputMethodOpenAL
|
||||
//
|
||||
this.rbOutputMethodOpenAL.AutoSize = true;
|
||||
this.rbOutputMethodOpenAL.Location = new System.Drawing.Point(6, 65);
|
||||
this.rbOutputMethodOpenAL.Name = "rbOutputMethodOpenAL";
|
||||
this.rbOutputMethodOpenAL.Size = new System.Drawing.Size(64, 17);
|
||||
this.rbOutputMethodOpenAL.TabIndex = 2;
|
||||
this.rbOutputMethodOpenAL.TabStop = true;
|
||||
this.rbOutputMethodOpenAL.Text = "OpenAL";
|
||||
this.rbOutputMethodOpenAL.UseVisualStyleBackColor = true;
|
||||
this.rbOutputMethodOpenAL.CheckedChanged += new System.EventHandler(this.OutputMethodRadioButtons_CheckedChanged);
|
||||
//
|
||||
// rbOutputMethodXAudio2
|
||||
//
|
||||
this.rbOutputMethodXAudio2.AutoSize = true;
|
||||
this.rbOutputMethodXAudio2.Location = new System.Drawing.Point(6, 42);
|
||||
this.rbOutputMethodXAudio2.Name = "rbOutputMethodXAudio2";
|
||||
this.rbOutputMethodXAudio2.Size = new System.Drawing.Size(65, 17);
|
||||
this.rbOutputMethodXAudio2.TabIndex = 1;
|
||||
this.rbOutputMethodXAudio2.TabStop = true;
|
||||
this.rbOutputMethodXAudio2.Text = "XAudio2";
|
||||
this.rbOutputMethodXAudio2.UseVisualStyleBackColor = true;
|
||||
this.rbOutputMethodXAudio2.CheckedChanged += new System.EventHandler(this.OutputMethodRadioButtons_CheckedChanged);
|
||||
//
|
||||
// rbOutputMethodDirectSound
|
||||
//
|
||||
this.rbOutputMethodDirectSound.AutoSize = true;
|
||||
this.rbOutputMethodDirectSound.Location = new System.Drawing.Point(6, 19);
|
||||
this.rbOutputMethodDirectSound.Name = "rbOutputMethodDirectSound";
|
||||
this.rbOutputMethodDirectSound.Size = new System.Drawing.Size(84, 17);
|
||||
this.rbOutputMethodDirectSound.TabIndex = 0;
|
||||
this.rbOutputMethodDirectSound.TabStop = true;
|
||||
this.rbOutputMethodDirectSound.Text = "DirectSound";
|
||||
this.rbOutputMethodDirectSound.UseVisualStyleBackColor = true;
|
||||
this.rbOutputMethodDirectSound.CheckedChanged += new System.EventHandler(this.OutputMethodRadioButtons_CheckedChanged);
|
||||
//
|
||||
// cbMuteFrameAdvance
|
||||
//
|
||||
this.cbMuteFrameAdvance.AutoSize = true;
|
||||
this.cbMuteFrameAdvance.Location = new System.Drawing.Point(139, 68);
|
||||
this.cbMuteFrameAdvance.Name = "cbMuteFrameAdvance";
|
||||
this.cbMuteFrameAdvance.Size = new System.Drawing.Size(128, 17);
|
||||
this.cbMuteFrameAdvance.TabIndex = 6;
|
||||
this.cbMuteFrameAdvance.Text = "Mute Frame Advance";
|
||||
this.cbMuteFrameAdvance.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// cbEnableMaster
|
||||
//
|
||||
this.cbEnableMaster.AutoSize = true;
|
||||
this.cbEnableMaster.Location = new System.Drawing.Point(139, 16);
|
||||
this.cbEnableMaster.Name = "cbEnableMaster";
|
||||
this.cbEnableMaster.Size = new System.Drawing.Size(128, 17);
|
||||
this.cbEnableMaster.TabIndex = 4;
|
||||
this.cbEnableMaster.Text = "Sound Master Enable";
|
||||
this.cbEnableMaster.UseVisualStyleBackColor = true;
|
||||
this.cbEnableMaster.CheckedChanged += new System.EventHandler(this.UpdateSoundDialog);
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.label3.Location = new System.Drawing.Point(161, 35);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(126, 26);
|
||||
this.label3.TabIndex = 5;
|
||||
this.label3.Text = "Controls whether cores even generate audio.";
|
||||
//
|
||||
// SoundConfig
|
||||
//
|
||||
this.AcceptButton = this.OK;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this.Cancel;
|
||||
this.ClientSize = new System.Drawing.Size(404, 279);
|
||||
this.Controls.Add(this.label3);
|
||||
this.Controls.Add(this.cbEnableMaster);
|
||||
this.Controls.Add(this.cbMuteFrameAdvance);
|
||||
this.Controls.Add(this.grpOutputMethod);
|
||||
this.Controls.Add(this.BufferSizeUnitsLabel);
|
||||
this.Controls.Add(this.BufferSizeNumeric);
|
||||
this.Controls.Add(this.BufferSizeLabel);
|
||||
this.Controls.Add(this.SoundDeviceLabel);
|
||||
this.Controls.Add(this.listBoxSoundDevices);
|
||||
this.Controls.Add(this.grpSoundVol);
|
||||
this.Controls.Add(this.OK);
|
||||
this.Controls.Add(this.Cancel);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MinimumSize = new System.Drawing.Size(279, 259);
|
||||
this.Name = "SoundConfig";
|
||||
this.ShowIcon = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Sound Configuration";
|
||||
this.Load += new System.EventHandler(this.SoundConfig_Load);
|
||||
this.grpSoundVol.ResumeLayout(false);
|
||||
this.grpSoundVol.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.nudRWFF)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.tbRWFF)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.tbNormal)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.nudNormal)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.BufferSizeNumeric)).EndInit();
|
||||
this.grpOutputMethod.ResumeLayout(false);
|
||||
this.grpOutputMethod.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button Cancel;
|
||||
private System.Windows.Forms.Button OK;
|
||||
private System.Windows.Forms.CheckBox cbEnableNormal;
|
||||
private System.Windows.Forms.GroupBox grpSoundVol;
|
||||
private System.Windows.Forms.NumericUpDown nudNormal;
|
||||
private System.Windows.Forms.TrackBar tbNormal;
|
||||
private System.Windows.Forms.ListBox listBoxSoundDevices;
|
||||
private System.Windows.Forms.Label SoundDeviceLabel;
|
||||
private System.Windows.Forms.Label BufferSizeLabel;
|
||||
private System.Windows.Forms.NumericUpDown BufferSizeNumeric;
|
||||
private System.Windows.Forms.Label BufferSizeUnitsLabel;
|
||||
private System.Windows.Forms.GroupBox grpOutputMethod;
|
||||
private System.Windows.Forms.RadioButton rbOutputMethodXAudio2;
|
||||
private System.Windows.Forms.RadioButton rbOutputMethodDirectSound;
|
||||
private System.Windows.Forms.RadioButton rbOutputMethodOpenAL;
|
||||
private System.Windows.Forms.NumericUpDown nudRWFF;
|
||||
private System.Windows.Forms.CheckBox cbEnableRWFF;
|
||||
private System.Windows.Forms.TrackBar tbRWFF;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.CheckBox cbMuteFrameAdvance;
|
||||
private System.Windows.Forms.CheckBox cbEnableMaster;
|
||||
private System.Windows.Forms.Label label3;
|
||||
}
|
||||
}
|
|
@ -1,153 +1,246 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using BizHawk.Client.Common;
|
||||
using BizHawk.Client.EmuHawk.CustomControls;
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
public partial class SoundConfig : Form
|
||||
public sealed class SoundConfig : Form
|
||||
{
|
||||
private bool _programmaticallyChangingValue;
|
||||
private readonly CheckBox cbEnableNormal;
|
||||
private readonly TrackBar tbNormal;
|
||||
private readonly CheckBox cbEnableRWFFW;
|
||||
private readonly TrackBar tbRWFFW;
|
||||
private readonly CheckBox cbEnableMaster;
|
||||
private readonly CheckBox cbMuteFrameAdvance;
|
||||
private readonly RadioButton rbOutputMethodDirectSound;
|
||||
private readonly RadioButton rbOutputMethodXAudio2;
|
||||
private readonly RadioButton rbOutputMethodOpenAL;
|
||||
private readonly ListBox lbSoundDevices;
|
||||
private readonly NumericUpDown nudBufferSize;
|
||||
|
||||
public SoundConfig()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void SoundConfig_Load(object sender, EventArgs e)
|
||||
{
|
||||
_programmaticallyChangingValue = true;
|
||||
|
||||
cbEnableMaster.Checked = Global.Config.SoundEnabled;
|
||||
cbEnableNormal.Checked = Global.Config.SoundEnabledNormal;
|
||||
cbEnableRWFF.Checked = Global.Config.SoundEnabledRWFF;
|
||||
cbMuteFrameAdvance.Checked = Global.Config.MuteFrameAdvance;
|
||||
|
||||
if (OSTailoredCode.CurrentOS != OSTailoredCode.DistinctOS.Windows)
|
||||
cbEnableNormal = new CheckBox { AutoSize = true, Text = "Enable", UseVisualStyleBackColor = true };
|
||||
var trackBarSize = new Size(32, 160);
|
||||
tbNormal = new TrackBar { LargeChange = 10, Maximum = 100, Orientation = Orientation.Vertical, Size = trackBarSize, TickFrequency = 10 };
|
||||
var nudSize = new Size(48, 19);
|
||||
var nudNormal = new NumericUpDown { Size = nudSize };
|
||||
nudNormal.ValueChanged += (sender, e) =>
|
||||
{
|
||||
// Disable DirectSound and XAudio2 on Mono
|
||||
rbOutputMethodDirectSound.Enabled = false;
|
||||
rbOutputMethodXAudio2.Enabled = false;
|
||||
}
|
||||
|
||||
rbOutputMethodDirectSound.Checked = Global.Config.SoundOutputMethod == Config.ESoundOutputMethod.DirectSound;
|
||||
rbOutputMethodXAudio2.Checked = Global.Config.SoundOutputMethod == Config.ESoundOutputMethod.XAudio2;
|
||||
rbOutputMethodOpenAL.Checked = Global.Config.SoundOutputMethod == Config.ESoundOutputMethod.OpenAL;
|
||||
BufferSizeNumeric.Value = Global.Config.SoundBufferSizeMs;
|
||||
tbNormal.Value = Global.Config.SoundVolume;
|
||||
var newValue = (int) ((NumericUpDown) sender).Value;
|
||||
tbNormal.Value = newValue;
|
||||
cbEnableNormal.Checked = newValue != 0; // mute when set to 0% volume
|
||||
};
|
||||
tbNormal.Scroll += (sender, e) => nudNormal.Value = ((TrackBar) sender).Value;
|
||||
nudNormal.Value = Global.Config.SoundVolume;
|
||||
tbRWFF.Value = Global.Config.SoundVolumeRWFF;
|
||||
nudRWFF.Value = Global.Config.SoundVolumeRWFF;
|
||||
UpdateSoundDialog();
|
||||
|
||||
_programmaticallyChangingValue = false;
|
||||
}
|
||||
|
||||
private void Ok_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (rbOutputMethodDirectSound.Checked && (int)BufferSizeNumeric.Value < 60)
|
||||
cbEnableRWFFW = new CheckBox { AutoSize = true, Text = "Enable", UseVisualStyleBackColor = true };
|
||||
tbRWFFW = new TrackBar { LargeChange = 10, Maximum = 100, Orientation = Orientation.Vertical, Size = trackBarSize, TickFrequency = 10 };
|
||||
var nudRWFFW = new NumericUpDown { Size = nudSize };
|
||||
nudRWFFW.ValueChanged += (sender, e) =>
|
||||
{
|
||||
MessageBox.Show("Buffer size must be at least 60 milliseconds for DirectSound.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
var oldOutputMethod = Global.Config.SoundOutputMethod;
|
||||
var oldDevice = Global.Config.SoundDevice;
|
||||
Global.Config.SoundEnabled = cbEnableMaster.Checked;
|
||||
Global.Config.SoundEnabledNormal = cbEnableNormal.Checked;
|
||||
Global.Config.SoundEnabledRWFF = cbEnableRWFF.Checked;
|
||||
Global.Config.MuteFrameAdvance = cbMuteFrameAdvance.Checked;
|
||||
if (rbOutputMethodDirectSound.Checked) Global.Config.SoundOutputMethod = Config.ESoundOutputMethod.DirectSound;
|
||||
if (rbOutputMethodXAudio2.Checked) Global.Config.SoundOutputMethod = Config.ESoundOutputMethod.XAudio2;
|
||||
if (rbOutputMethodOpenAL.Checked) Global.Config.SoundOutputMethod = Config.ESoundOutputMethod.OpenAL;
|
||||
Global.Config.SoundBufferSizeMs = (int)BufferSizeNumeric.Value;
|
||||
Global.Config.SoundVolume = tbNormal.Value;
|
||||
Global.Config.SoundVolumeRWFF = tbRWFF.Value;
|
||||
Global.Config.SoundDevice = (string)listBoxSoundDevices.SelectedItem ?? "<default>";
|
||||
GlobalWin.Sound.StopSound();
|
||||
if (Global.Config.SoundOutputMethod != oldOutputMethod
|
||||
|| Global.Config.SoundDevice != oldDevice)
|
||||
var newValue = (int) ((NumericUpDown) sender).Value;
|
||||
tbRWFFW.Value = newValue;
|
||||
cbEnableRWFFW.Checked = newValue != 0; // mute when set to 0% volume
|
||||
};
|
||||
tbRWFFW.Scroll += (sender, e) => nudRWFFW.Value = ((TrackBar) sender).Value;
|
||||
nudRWFFW.Value = Global.Config.SoundVolumeRWFF;
|
||||
cbEnableRWFFW.Checked = Global.Config.SoundEnabledRWFF;
|
||||
|
||||
var flpRWFFW = new SingleColumnFLP
|
||||
{
|
||||
GlobalWin.Sound.Dispose();
|
||||
GlobalWin.Sound = new Sound(GlobalWin.MainForm.Handle);
|
||||
}
|
||||
Controls = { new Label { AutoSize = true, Text = "RW/FFW" }, cbEnableRWFFW, tbRWFFW, nudRWFFW },
|
||||
Margin = Padding.Empty
|
||||
};
|
||||
cbEnableNormal.CheckedChanged += (sender, e) => flpRWFFW.Enabled = ((CheckBox) sender).Checked;
|
||||
cbEnableNormal.Checked = Global.Config.SoundEnabledNormal;
|
||||
|
||||
GlobalWin.Sound.StartSound();
|
||||
GlobalWin.OSD.AddMessage("Sound settings saved");
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
|
||||
private void Cancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
GlobalWin.OSD.AddMessage("Sound config aborted");
|
||||
Close();
|
||||
}
|
||||
|
||||
private void PopulateDeviceList()
|
||||
{
|
||||
IEnumerable<string> deviceNames = Enumerable.Empty<string>();
|
||||
if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows)
|
||||
var grpSoundVol = new FLPInGroupBox
|
||||
{
|
||||
if (rbOutputMethodDirectSound.Checked) deviceNames = DirectSoundSoundOutput.GetDeviceNames();
|
||||
if (rbOutputMethodXAudio2.Checked) deviceNames = XAudio2SoundOutput.GetDeviceNames();
|
||||
}
|
||||
if (rbOutputMethodOpenAL.Checked) deviceNames = OpenALSoundOutput.GetDeviceNames();
|
||||
Controls = {
|
||||
new SingleColumnFLP
|
||||
{
|
||||
Controls = { new Label { AutoSize = true, Text = "Normal" }, cbEnableNormal, tbNormal, nudNormal },
|
||||
Margin = Padding.Empty
|
||||
},
|
||||
flpRWFFW
|
||||
},
|
||||
InnerFLP = { FlowDirection = FlowDirection.LeftToRight },
|
||||
Size = new Size(124, 248),
|
||||
Text = "Volume"
|
||||
};
|
||||
|
||||
listBoxSoundDevices.Items.Clear();
|
||||
listBoxSoundDevices.Items.Add("<default>");
|
||||
listBoxSoundDevices.SelectedIndex = 0;
|
||||
foreach (var name in deviceNames)
|
||||
cbEnableMaster = new CheckBox { AutoSize = true, Text = "Master sound toggle", UseVisualStyleBackColor = true };
|
||||
cbMuteFrameAdvance = new CheckBox
|
||||
{
|
||||
listBoxSoundDevices.Items.Add(name);
|
||||
if (name == Global.Config.SoundDevice)
|
||||
AutoSize = true,
|
||||
Checked = Global.Config.MuteFrameAdvance,
|
||||
Text = "Mute Frame Advance",
|
||||
UseVisualStyleBackColor = true
|
||||
};
|
||||
cbEnableMaster.CheckedChanged += (sender, e) => grpSoundVol.Enabled = ((CheckBox) sender).Checked;
|
||||
cbEnableMaster.Checked = Global.Config.SoundEnabled;
|
||||
|
||||
var onWindows = OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows;
|
||||
rbOutputMethodDirectSound = new RadioButton { AutoSize = true, Enabled = onWindows, Text = "DirectSound", UseVisualStyleBackColor = true };
|
||||
rbOutputMethodXAudio2 = new RadioButton { AutoSize = true, Enabled = onWindows, Text = "XAudio2", UseVisualStyleBackColor = true };
|
||||
rbOutputMethodOpenAL = new RadioButton { AutoSize = true, Text = "OpenAL", UseVisualStyleBackColor = true };
|
||||
lbSoundDevices = new ListBox { FormattingEnabled = true, Size = new Size(224, 96) };
|
||||
void UpdateDeviceList(object sender, EventArgs e)
|
||||
{
|
||||
if ((sender as RadioButton)?.Checked == false) return; // only update for the radio button just clicked, or once in the constructor
|
||||
|
||||
IEnumerable<string> deviceNames;
|
||||
if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows)
|
||||
{
|
||||
listBoxSoundDevices.SelectedItem = name;
|
||||
if (rbOutputMethodDirectSound.Checked) deviceNames = DirectSoundSoundOutput.GetDeviceNames();
|
||||
else if (rbOutputMethodXAudio2.Checked) deviceNames = XAudio2SoundOutput.GetDeviceNames();
|
||||
else if (rbOutputMethodOpenAL.Checked) deviceNames = OpenALSoundOutput.GetDeviceNames();
|
||||
else deviceNames = Enumerable.Empty<string>(); // never hit
|
||||
}
|
||||
else
|
||||
{
|
||||
deviceNames = OpenALSoundOutput.GetDeviceNames();
|
||||
}
|
||||
lbSoundDevices.Items.Clear();
|
||||
lbSoundDevices.Items.Add("<default>");
|
||||
var i = 1;
|
||||
foreach (var name in deviceNames)
|
||||
{
|
||||
lbSoundDevices.Items.Add(name);
|
||||
if (name == Global.Config.SoundDevice) lbSoundDevices.SelectedIndex = i;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OutputMethodRadioButtons_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (!((RadioButton)sender).Checked)
|
||||
rbOutputMethodDirectSound.CheckedChanged += UpdateDeviceList;
|
||||
rbOutputMethodXAudio2.CheckedChanged += UpdateDeviceList;
|
||||
rbOutputMethodOpenAL.CheckedChanged += UpdateDeviceList;
|
||||
var checkedRadio = Global.Config.SoundOutputMethod switch
|
||||
{
|
||||
return;
|
||||
}
|
||||
Config.ESoundOutputMethod.DirectSound => rbOutputMethodDirectSound,
|
||||
Config.ESoundOutputMethod.XAudio2 => rbOutputMethodXAudio2,
|
||||
Config.ESoundOutputMethod.OpenAL => rbOutputMethodOpenAL,
|
||||
_ => null
|
||||
};
|
||||
if (checkedRadio != null) checkedRadio.Checked = true;
|
||||
|
||||
PopulateDeviceList();
|
||||
}
|
||||
|
||||
private void TrackBar1_Scroll(object sender, EventArgs e)
|
||||
{
|
||||
nudNormal.Value = tbNormal.Value;
|
||||
}
|
||||
|
||||
private void TbRwff_Scroll(object sender, EventArgs e)
|
||||
{
|
||||
nudRWFF.Value = tbRWFF.Value;
|
||||
}
|
||||
|
||||
private void SoundVolNumeric_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
tbNormal.Value = (int)nudNormal.Value;
|
||||
|
||||
// If the user is changing the volume, automatically turn on/off sound accordingly
|
||||
if (!_programmaticallyChangingValue)
|
||||
var grpOutputMethod = new FLPInGroupBox
|
||||
{
|
||||
cbEnableNormal.Checked = tbNormal.Value != 0;
|
||||
}
|
||||
Controls = { rbOutputMethodDirectSound, rbOutputMethodXAudio2, rbOutputMethodOpenAL },
|
||||
Size = new Size(88, 84),
|
||||
Text = "Output Method"
|
||||
};
|
||||
|
||||
var flpDeviceSelector = new SingleColumnFLP
|
||||
{
|
||||
AutoSize = false,
|
||||
Controls = { new Label { AutoSize = true, Text = "Sound Device:" }, lbSoundDevices },
|
||||
Size = new Size(254, 112)
|
||||
};
|
||||
|
||||
nudBufferSize = new NumericUpDown { Maximum = 250.0M, Minimum = 30.0M, Size = nudSize, Value = Global.Config.SoundBufferSizeMs };
|
||||
|
||||
var flpRHS = new FlowLayoutPanel
|
||||
{
|
||||
AutoSize = true,
|
||||
Controls =
|
||||
{
|
||||
new SingleColumnFLP
|
||||
{
|
||||
Controls =
|
||||
{
|
||||
cbEnableMaster,
|
||||
new Label { AutoSize = true, Margin = new Padding(24, 0, 0, 16), Text = "Controls whether cores\neven generate audio." },
|
||||
cbMuteFrameAdvance
|
||||
}
|
||||
},
|
||||
grpOutputMethod,
|
||||
flpDeviceSelector,
|
||||
new SingleRowFLP
|
||||
{
|
||||
Controls =
|
||||
{
|
||||
new Label { AutoSize = true, Margin = new Padding(0, 4, 0, 0), Text = "Buffer Size:" },
|
||||
nudBufferSize,
|
||||
new Label { AutoSize = true, Margin = new Padding(0, 4, 0, 0), Text = "milliseconds" }
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
flpRHS.SetFlowBreak(grpOutputMethod, true);
|
||||
flpRHS.SetFlowBreak(flpDeviceSelector, true);
|
||||
|
||||
var btnOk = new Button { Text = "&OK", UseVisualStyleBackColor = true };
|
||||
btnOk.Click += (sender, e) =>
|
||||
{
|
||||
if (rbOutputMethodDirectSound.Checked && nudBufferSize.Value < 60.0M)
|
||||
{
|
||||
MessageBox.Show("Buffer size must be at least 60 milliseconds for DirectSound.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
var oldOutputMethod = Global.Config.SoundOutputMethod;
|
||||
var oldDevice = Global.Config.SoundDevice;
|
||||
|
||||
SaveControlsTo(Global.Config);
|
||||
|
||||
GlobalWin.Sound.StopSound();
|
||||
if (Global.Config.SoundOutputMethod != oldOutputMethod || Global.Config.SoundDevice != oldDevice)
|
||||
{
|
||||
GlobalWin.Sound.Dispose();
|
||||
GlobalWin.Sound = new Sound(GlobalWin.MainForm.Handle);
|
||||
}
|
||||
GlobalWin.Sound.StartSound();
|
||||
|
||||
GlobalWin.OSD.AddMessage("Sound settings saved");
|
||||
DialogResult = DialogResult.OK;
|
||||
};
|
||||
|
||||
var btnCancel = new Button { Text = "&Cancel", UseVisualStyleBackColor = true };
|
||||
btnCancel.Click += (sender, e) =>
|
||||
{
|
||||
GlobalWin.OSD.AddMessage("Sound config aborted");
|
||||
Close();
|
||||
};
|
||||
|
||||
SuspendLayout();
|
||||
AcceptButton = btnOk;
|
||||
AutoScaleDimensions = new SizeF(6F, 13F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
CancelButton = btnCancel;
|
||||
ClientSize = new Size(372, 276);
|
||||
Controls.AddRange(new Control[]
|
||||
{
|
||||
new SingleRowFLP { Controls = { btnOk, btnCancel }, Location = new Point(208, 244) },
|
||||
new SingleRowFLP { Controls = { grpSoundVol, flpRHS }, Location = new Point(4, 0) }
|
||||
});
|
||||
FormBorderStyle = FormBorderStyle.FixedDialog;
|
||||
Name = "SoundConfig";
|
||||
ShowIcon = false;
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Sound Configuration";
|
||||
ResumeLayout();
|
||||
}
|
||||
|
||||
private void UpdateSoundDialog()
|
||||
private void SaveControlsTo(Config config)
|
||||
{
|
||||
cbEnableRWFF.Enabled = cbEnableNormal.Checked;
|
||||
grpSoundVol.Enabled = cbEnableMaster.Checked;
|
||||
}
|
||||
|
||||
private void UpdateSoundDialog(object sender, EventArgs e)
|
||||
{
|
||||
UpdateSoundDialog();
|
||||
config.SoundEnabledNormal = cbEnableNormal.Checked;
|
||||
config.SoundVolume = tbNormal.Value;
|
||||
config.SoundEnabledRWFF = cbEnableRWFFW.Checked;
|
||||
config.SoundVolumeRWFF = tbRWFFW.Value;
|
||||
config.SoundEnabled = cbEnableMaster.Checked;
|
||||
config.MuteFrameAdvance = cbMuteFrameAdvance.Checked;
|
||||
if (rbOutputMethodDirectSound.Checked) config.SoundOutputMethod = Config.ESoundOutputMethod.DirectSound;
|
||||
else if (rbOutputMethodXAudio2.Checked) config.SoundOutputMethod = Config.ESoundOutputMethod.XAudio2;
|
||||
else if (rbOutputMethodOpenAL.Checked) config.SoundOutputMethod = Config.ESoundOutputMethod.OpenAL;
|
||||
config.SoundDevice = (string) lbSoundDevices.SelectedItem ?? "<default>";
|
||||
config.SoundBufferSizeMs = (int) nudBufferSize.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue