Add helpers for getting selected radio button of group
This commit is contained in:
parent
6bf948a7b7
commit
905b18e429
|
@ -190,6 +190,7 @@
|
||||||
//
|
//
|
||||||
this.rbDispMethodOpenGL.Checked = true;
|
this.rbDispMethodOpenGL.Checked = true;
|
||||||
this.rbDispMethodOpenGL.Name = "rbDispMethodOpenGL";
|
this.rbDispMethodOpenGL.Name = "rbDispMethodOpenGL";
|
||||||
|
this.rbDispMethodOpenGL.Tag = BizHawk.Client.Common.EDispMethod.OpenGL;
|
||||||
this.rbDispMethodOpenGL.Text = "OpenGL";
|
this.rbDispMethodOpenGL.Text = "OpenGL";
|
||||||
//
|
//
|
||||||
// lblDispMethodOpenGL
|
// lblDispMethodOpenGL
|
||||||
|
@ -427,6 +428,7 @@
|
||||||
// rbARSquare
|
// rbARSquare
|
||||||
//
|
//
|
||||||
this.rbARSquare.Name = "rbARSquare";
|
this.rbARSquare.Name = "rbARSquare";
|
||||||
|
this.rbARSquare.Tag = BizHawk.Client.Common.EDispManagerAR.None;
|
||||||
this.rbARSquare.Text = "Use 1:1 pixel size (for crispness or debugging)";
|
this.rbARSquare.Text = "Use 1:1 pixel size (for crispness or debugging)";
|
||||||
this.rbARSquare.CheckedChanged += new System.EventHandler(this.rbARSquare_CheckedChanged);
|
this.rbARSquare.CheckedChanged += new System.EventHandler(this.rbARSquare_CheckedChanged);
|
||||||
//
|
//
|
||||||
|
@ -438,6 +440,7 @@
|
||||||
// rbARBySystem
|
// rbARBySystem
|
||||||
//
|
//
|
||||||
this.rbARBySystem.Name = "rbARBySystem";
|
this.rbARBySystem.Name = "rbARBySystem";
|
||||||
|
this.rbARBySystem.Tag = BizHawk.Client.Common.EDispManagerAR.System;
|
||||||
this.rbARBySystem.Text = "Use system\'s recommendation";
|
this.rbARBySystem.Text = "Use system\'s recommendation";
|
||||||
this.rbARBySystem.CheckedChanged += new System.EventHandler(this.rbARBySystem_CheckedChanged);
|
this.rbARBySystem.CheckedChanged += new System.EventHandler(this.rbARBySystem_CheckedChanged);
|
||||||
//
|
//
|
||||||
|
@ -452,6 +455,7 @@
|
||||||
// rbARCustomSize
|
// rbARCustomSize
|
||||||
//
|
//
|
||||||
this.rbARCustomSize.Name = "rbARCustomSize";
|
this.rbARCustomSize.Name = "rbARCustomSize";
|
||||||
|
this.rbARCustomSize.Tag = BizHawk.Client.Common.EDispManagerAR.Custom;
|
||||||
this.rbARCustomSize.Text = "Use custom size:";
|
this.rbARCustomSize.Text = "Use custom size:";
|
||||||
//
|
//
|
||||||
// txtARCustomWidth
|
// txtARCustomWidth
|
||||||
|
@ -480,6 +484,7 @@
|
||||||
// rbARCustomRatio
|
// rbARCustomRatio
|
||||||
//
|
//
|
||||||
this.rbARCustomRatio.Name = "rbARCustomRatio";
|
this.rbARCustomRatio.Name = "rbARCustomRatio";
|
||||||
|
this.rbARCustomRatio.Tag = BizHawk.Client.Common.EDispManagerAR.CustomRatio;
|
||||||
this.rbARCustomRatio.Text = "Use custom AR:";
|
this.rbARCustomRatio.Text = "Use custom AR:";
|
||||||
//
|
//
|
||||||
// txtARCustomRatioH
|
// txtARCustomRatioH
|
||||||
|
@ -616,6 +621,7 @@
|
||||||
//
|
//
|
||||||
this.rbDispMethodD3D.Checked = true;
|
this.rbDispMethodD3D.Checked = true;
|
||||||
this.rbDispMethodD3D.Name = "rbDispMethodD3D";
|
this.rbDispMethodD3D.Name = "rbDispMethodD3D";
|
||||||
|
this.rbDispMethodD3D.Tag = BizHawk.Client.Common.EDispMethod.SlimDX9;
|
||||||
this.rbDispMethodD3D.Text = "Direct3D9";
|
this.rbDispMethodD3D.Text = "Direct3D9";
|
||||||
//
|
//
|
||||||
// lblDispMethodD3D
|
// lblDispMethodD3D
|
||||||
|
@ -649,6 +655,7 @@
|
||||||
//
|
//
|
||||||
this.rbDispMethodGDIPlus.Checked = true;
|
this.rbDispMethodGDIPlus.Checked = true;
|
||||||
this.rbDispMethodGDIPlus.Name = "rbDispMethodGDIPlus";
|
this.rbDispMethodGDIPlus.Name = "rbDispMethodGDIPlus";
|
||||||
|
this.rbDispMethodGDIPlus.Tag = BizHawk.Client.Common.EDispMethod.GdiPlus;
|
||||||
this.rbDispMethodGDIPlus.Text = "GDI+";
|
this.rbDispMethodGDIPlus.Text = "GDI+";
|
||||||
//
|
//
|
||||||
// lblDispMethodGDIPlus
|
// lblDispMethodGDIPlus
|
||||||
|
|
|
@ -130,14 +130,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
if (rbDispFeaturesMinimal.Checked) _config.DispSpeedupFeatures = 1;
|
if (rbDispFeaturesMinimal.Checked) _config.DispSpeedupFeatures = 1;
|
||||||
if (rbDispFeaturesNothing.Checked) _config.DispSpeedupFeatures = 0;
|
if (rbDispFeaturesNothing.Checked) _config.DispSpeedupFeatures = 0;
|
||||||
|
|
||||||
if (rbARSquare.Checked)
|
_config.DispManagerAR = grpAspectRatio.Tracker.GetSelectionTagAs<EDispManagerAR>() ?? throw new InvalidOperationException();
|
||||||
_config.DispManagerAR = EDispManagerAR.None;
|
|
||||||
else if (rbARBySystem.Checked)
|
|
||||||
_config.DispManagerAR = EDispManagerAR.System;
|
|
||||||
else if (rbARCustomSize.Checked)
|
|
||||||
_config.DispManagerAR = EDispManagerAR.Custom;
|
|
||||||
else if (rbARCustomRatio.Checked)
|
|
||||||
_config.DispManagerAR = EDispManagerAR.CustomRatio;
|
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(txtARCustomWidth.Text))
|
if (string.IsNullOrWhiteSpace(txtARCustomWidth.Text))
|
||||||
{
|
{
|
||||||
|
@ -188,12 +181,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
|
|
||||||
var oldDisplayMethod = _config.DispMethod;
|
var oldDisplayMethod = _config.DispMethod;
|
||||||
if(rbDispMethodOpenGL.Checked)
|
_config.DispMethod = grpDispMethod.Tracker.GetSelectionTagAs<EDispMethod>() ?? throw new InvalidOperationException();
|
||||||
_config.DispMethod = EDispMethod.OpenGL;
|
|
||||||
if(rbDispMethodGDIPlus.Checked)
|
|
||||||
_config.DispMethod = EDispMethod.GdiPlus;
|
|
||||||
if(rbDispMethodD3D.Checked)
|
|
||||||
_config.DispMethod = EDispMethod.SlimDX9;
|
|
||||||
|
|
||||||
if (int.TryParse(txtCropLeft.Text, out int dispCropLeft))
|
if (int.TryParse(txtCropLeft.Text, out int dispCropLeft))
|
||||||
{
|
{
|
||||||
|
|
|
@ -478,11 +478,13 @@
|
||||||
// rbKopiLua
|
// rbKopiLua
|
||||||
//
|
//
|
||||||
this.rbKopiLua.Name = "rbKopiLua";
|
this.rbKopiLua.Name = "rbKopiLua";
|
||||||
|
this.rbKopiLua.Tag = BizHawk.Client.Common.ELuaEngine.NLuaPlusKopiLua;
|
||||||
this.rbKopiLua.Text = "NLua+KopiLua - Reliable but slower";
|
this.rbKopiLua.Text = "NLua+KopiLua - Reliable but slower";
|
||||||
//
|
//
|
||||||
// rbLuaInterface
|
// rbLuaInterface
|
||||||
//
|
//
|
||||||
this.rbLuaInterface.Name = "rbLuaInterface";
|
this.rbLuaInterface.Name = "rbLuaInterface";
|
||||||
|
this.rbLuaInterface.Tag = BizHawk.Client.Common.ELuaEngine.LuaPlusLuaInterface;
|
||||||
this.rbLuaInterface.Text = "Lua+LuaInterface - Faster but memory leaks, use at your own risk!";
|
this.rbLuaInterface.Text = "Lua+LuaInterface - Faster but memory leaks, use at your own risk!";
|
||||||
//
|
//
|
||||||
// flpDialogButtons
|
// flpDialogButtons
|
||||||
|
|
|
@ -118,14 +118,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
_config.MoviesInAwe = cbMoviesInAWE.Checked;
|
_config.MoviesInAwe = cbMoviesInAWE.Checked;
|
||||||
|
|
||||||
var prevLuaEngine = _config.LuaEngine;
|
var prevLuaEngine = _config.LuaEngine;
|
||||||
if (rbLuaInterface.Checked)
|
_config.LuaEngine = grpLuaEngine.Tracker.GetSelectionTagAs<ELuaEngine>() ?? throw new InvalidOperationException();
|
||||||
{
|
|
||||||
_config.LuaEngine = ELuaEngine.LuaPlusLuaInterface;
|
|
||||||
}
|
|
||||||
else if (rbKopiLua.Checked)
|
|
||||||
{
|
|
||||||
_config.LuaEngine = ELuaEngine.NLuaPlusKopiLua;
|
|
||||||
}
|
|
||||||
|
|
||||||
_mainForm.AddOnScreenMessage("Custom configurations saved.");
|
_mainForm.AddOnScreenMessage("Custom configurations saved.");
|
||||||
if (prevLuaEngine != _config.LuaEngine)
|
if (prevLuaEngine != _config.LuaEngine)
|
||||||
|
|
|
@ -288,18 +288,21 @@
|
||||||
// rbSoundMethodDirectSound
|
// rbSoundMethodDirectSound
|
||||||
//
|
//
|
||||||
this.rbSoundMethodDirectSound.Name = "rbSoundMethodDirectSound";
|
this.rbSoundMethodDirectSound.Name = "rbSoundMethodDirectSound";
|
||||||
|
this.rbSoundMethodDirectSound.Tag = BizHawk.Client.Common.ESoundOutputMethod.DirectSound;
|
||||||
this.rbSoundMethodDirectSound.Text = "DirectSound";
|
this.rbSoundMethodDirectSound.Text = "DirectSound";
|
||||||
this.rbSoundMethodDirectSound.CheckedChanged += new System.EventHandler(this.rbSoundMethodAllRadios_CheckedChanged);
|
this.rbSoundMethodDirectSound.CheckedChanged += new System.EventHandler(this.rbSoundMethodAllRadios_CheckedChanged);
|
||||||
//
|
//
|
||||||
// rbSoundMethodXAudio2
|
// rbSoundMethodXAudio2
|
||||||
//
|
//
|
||||||
this.rbSoundMethodXAudio2.Name = "rbSoundMethodXAudio2";
|
this.rbSoundMethodXAudio2.Name = "rbSoundMethodXAudio2";
|
||||||
|
this.rbSoundMethodXAudio2.Tag = BizHawk.Client.Common.ESoundOutputMethod.XAudio2;
|
||||||
this.rbSoundMethodXAudio2.Text = "XAudio2";
|
this.rbSoundMethodXAudio2.Text = "XAudio2";
|
||||||
this.rbSoundMethodXAudio2.CheckedChanged += new System.EventHandler(this.rbSoundMethodAllRadios_CheckedChanged);
|
this.rbSoundMethodXAudio2.CheckedChanged += new System.EventHandler(this.rbSoundMethodAllRadios_CheckedChanged);
|
||||||
//
|
//
|
||||||
// rbSoundMethodOpenAL
|
// rbSoundMethodOpenAL
|
||||||
//
|
//
|
||||||
this.rbSoundMethodOpenAL.Name = "rbSoundMethodOpenAL";
|
this.rbSoundMethodOpenAL.Name = "rbSoundMethodOpenAL";
|
||||||
|
this.rbSoundMethodOpenAL.Tag = BizHawk.Client.Common.ESoundOutputMethod.OpenAL;
|
||||||
this.rbSoundMethodOpenAL.Text = "OpenAL";
|
this.rbSoundMethodOpenAL.Text = "OpenAL";
|
||||||
this.rbSoundMethodOpenAL.CheckedChanged += new System.EventHandler(this.rbSoundMethodAllRadios_CheckedChanged);
|
this.rbSoundMethodOpenAL.CheckedChanged += new System.EventHandler(this.rbSoundMethodAllRadios_CheckedChanged);
|
||||||
//
|
//
|
||||||
|
|
|
@ -62,9 +62,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
_config.SoundEnabledNormal = cbFullSpeedEnable.Checked;
|
_config.SoundEnabledNormal = cbFullSpeedEnable.Checked;
|
||||||
_config.SoundEnabledRWFF = cbRewindFFWEnable.Checked;
|
_config.SoundEnabledRWFF = cbRewindFFWEnable.Checked;
|
||||||
_config.MuteFrameAdvance = cbMuteFrameAdvance.Checked;
|
_config.MuteFrameAdvance = cbMuteFrameAdvance.Checked;
|
||||||
if (rbSoundMethodDirectSound.Checked) _config.SoundOutputMethod = ESoundOutputMethod.DirectSound;
|
_config.SoundOutputMethod = grpSoundMethod.Tracker.GetSelectionTagAs<ESoundOutputMethod>() ?? ESoundOutputMethod.Dummy;
|
||||||
if (rbSoundMethodXAudio2.Checked) _config.SoundOutputMethod = ESoundOutputMethod.XAudio2;
|
|
||||||
if (rbSoundMethodOpenAL.Checked) _config.SoundOutputMethod = ESoundOutputMethod.OpenAL;
|
|
||||||
_config.SoundBufferSizeMs = (int)nudBufferSize.Value;
|
_config.SoundBufferSizeMs = (int)nudBufferSize.Value;
|
||||||
_config.SoundVolume = tbFullSpeedVolume.Value;
|
_config.SoundVolume = tbFullSpeedVolume.Value;
|
||||||
_config.SoundVolumeRWFF = tbRewindFFWVolume.Value;
|
_config.SoundVolumeRWFF = tbRewindFFWVolume.Value;
|
||||||
|
|
|
@ -7,6 +7,8 @@ namespace BizHawk.WinForms.Controls
|
||||||
|
|
||||||
string Name { get; }
|
string Name { get; }
|
||||||
|
|
||||||
|
object Tag { get; }
|
||||||
|
|
||||||
void UncheckFromTracker();
|
void UncheckFromTracker();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
@ -12,6 +13,20 @@ namespace BizHawk.WinForms.Controls
|
||||||
/// <inheritdoc cref="IRadioButtonReadOnlyTracker"/>
|
/// <inheritdoc cref="IRadioButtonReadOnlyTracker"/>
|
||||||
public sealed class RadioButtonGroupTracker : List<ITrackedRadioButton>, IRadioButtonReadOnlyTracker
|
public sealed class RadioButtonGroupTracker : List<ITrackedRadioButton>, IRadioButtonReadOnlyTracker
|
||||||
{
|
{
|
||||||
|
/// <value>The selected radio button, or <see langword="null"/> if no button is selected or if the collection is empty.</value>
|
||||||
|
public ITrackedRadioButton? Selection
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (Count == 0) return null;
|
||||||
|
foreach (var rb in this) if (rb.Checked) return rb;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <returns>The <see cref="Control.Tag"/> of the selected radio button, cast to <typeparamref name="T"/><c>?</c>, or <see langword="null"/> if no button is selected or if the collection is empty.</returns>
|
||||||
|
public T? GetSelectionTagAs<T>() where T : struct, Enum => (T?) Selection?.Tag;
|
||||||
|
|
||||||
public void UpdateDeselected(string name)
|
public void UpdateDeselected(string name)
|
||||||
{
|
{
|
||||||
foreach (var rb in this) if (rb.Name != name) rb.UncheckFromTracker();
|
foreach (var rb in this) if (rb.Name != name) rb.UncheckFromTracker();
|
||||||
|
|
Loading…
Reference in New Issue