code cleanup in ZxSpectrum config dialogs

This commit is contained in:
adelikat 2019-12-16 18:03:26 -06:00
parent 7675e35d85
commit c722a1ef9f
11 changed files with 54 additions and 65 deletions

View File

@ -2612,31 +2612,31 @@ namespace BizHawk.Client.EmuHawk
private void ZXSpectrumControllerConfigurationMenuItem_Click(object sender, EventArgs e)
{
using var form = new ZXSpectrumJoystickSettings();
using var form = new ZxSpectrumJoystickSettings();
form.ShowDialog();
}
private void ZXSpectrumCoreEmulationSettingsMenuItem_Click(object sender, EventArgs e)
{
using var form = new ZXSpectrumCoreEmulationSettings();
using var form = new ZxSpectrumCoreEmulationSettings();
form.ShowDialog();
}
private void ZXSpectrumNonSyncSettingsMenuItem_Click(object sender, EventArgs e)
{
using var form = new ZXSpectrumNonSyncSettings();
using var form = new ZxSpectrumNonSyncSettings();
form.ShowDialog();
}
private void ZXSpectrumAudioSettingsMenuItem_Click(object sender, EventArgs e)
{
using var form = new ZXSpectrumAudioSettings();
using var form = new ZxSpectrumAudioSettings();
form.ShowDialog();
}
private void ZXSpectrumPokeMemoryMenuItem_Click(object sender, EventArgs e)
{
using var form = new ZXSpectrumPokeMemory();
using var form = new ZxSpectrumPokeMemory();
form.ShowDialog();
}

View File

@ -1,6 +1,6 @@
namespace BizHawk.Client.EmuHawk
{
partial class ZXSpectrumAudioSettings
partial class ZxSpectrumAudioSettings
{
/// <summary>
/// Required designer variable.
@ -180,7 +180,7 @@
this.Controls.Add(this.OkBtn);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Icon = global::BizHawk.Client.EmuHawk.Properties.Resources.GameController_MultiSize;
this.Name = "ZXSpectrumAudioSettings";
this.Name = "ZxSpectrumAudioSettings";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Audio Settings";
this.Load += new System.EventHandler(this.IntvControllerSettings_Load);

View File

@ -1,18 +1,16 @@
using System;
using System.Linq;
using System.Windows.Forms;
using BizHawk.Client.Common;
using BizHawk.Emulation.Cores.Computers.SinclairSpectrum;
using System.Text;
namespace BizHawk.Client.EmuHawk
{
public partial class ZXSpectrumAudioSettings : Form
public partial class ZxSpectrumAudioSettings : Form
{
private ZXSpectrum.ZXSpectrumSettings _settings;
public ZXSpectrumAudioSettings()
public ZxSpectrumAudioSettings()
{
InitializeComponent();
}
@ -37,8 +35,6 @@ namespace BizHawk.Client.EmuHawk
// ay volume
ayVolumetrackBar.Value = _settings.AYVolume;
}
private void OkBtn_Click(object sender, EventArgs e)

View File

@ -1,6 +1,6 @@
namespace BizHawk.Client.EmuHawk
{
partial class ZXSpectrumCoreEmulationSettings
partial class ZxSpectrumCoreEmulationSettings
{
/// <summary>
/// Required designer variable.
@ -124,7 +124,7 @@
this.borderTypecomboBox1.Name = "borderTypecomboBox1";
this.borderTypecomboBox1.Size = new System.Drawing.Size(220, 21);
this.borderTypecomboBox1.TabIndex = 22;
this.borderTypecomboBox1.SelectedIndexChanged += new System.EventHandler(this.borderTypecomboBox1_SelectedIndexChanged);
this.borderTypecomboBox1.SelectedIndexChanged += new System.EventHandler(this.BorderTypeComboBox_SelectedIndexChanged);
//
// lblBorderInfo
//
@ -191,7 +191,7 @@
this.Controls.Add(this.OkBtn);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Icon = global::BizHawk.Client.EmuHawk.Properties.Resources.GameController_MultiSize;
this.Name = "ZXSpectrumCoreEmulationSettings";
this.Name = "ZxSpectrumCoreEmulationSettings";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Core Emulation Settings";
this.Load += new System.EventHandler(this.IntvControllerSettings_Load);

View File

@ -1,18 +1,16 @@
using System;
using System.Linq;
using System.Windows.Forms;
using BizHawk.Client.Common;
using BizHawk.Emulation.Cores.Computers.SinclairSpectrum;
using System.Text;
namespace BizHawk.Client.EmuHawk
{
public partial class ZXSpectrumCoreEmulationSettings : Form
public partial class ZxSpectrumCoreEmulationSettings : Form
{
private ZXSpectrum.ZXSpectrumSyncSettings _syncSettings;
public ZXSpectrumCoreEmulationSettings()
public ZxSpectrumCoreEmulationSettings()
{
InitializeComponent();
}
@ -30,7 +28,7 @@ namespace BizHawk.Client.EmuHawk
MachineSelectionComboBox.SelectedItem = _syncSettings.MachineType.ToString();
UpdateMachineNotes((MachineType)Enum.Parse(typeof(MachineType), MachineSelectionComboBox.SelectedItem.ToString()));
// border selecton
// border selection
var borderTypes = Enum.GetNames(typeof(ZXSpectrum.BorderType));
foreach (var val in borderTypes)
{
@ -82,7 +80,7 @@ namespace BizHawk.Client.EmuHawk
private void MachineSelectionComboBox_SelectionChangeCommitted(object sender, EventArgs e)
{
ComboBox cb = sender as ComboBox;
var cb = (ComboBox)sender;
UpdateMachineNotes((MachineType)Enum.Parse(typeof(MachineType), cb.SelectedItem.ToString()));
}
@ -91,9 +89,9 @@ namespace BizHawk.Client.EmuHawk
textBoxCoreDetails.Text = ZXMachineMetaData.GetMetaString(type);
}
private void borderTypecomboBox1_SelectedIndexChanged(object sender, EventArgs e)
private void BorderTypeComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
ComboBox cb = sender as ComboBox;
var cb = (ComboBox)sender;
UpdateBorderNotes((ZXSpectrum.BorderType)Enum.Parse(typeof(ZXSpectrum.BorderType), cb.SelectedItem.ToString()));
}

View File

@ -1,6 +1,6 @@
namespace BizHawk.Client.EmuHawk
{
partial class ZXSpectrumJoystickSettings
partial class ZxSpectrumJoystickSettings
{
/// <summary>
/// Required designer variable.
@ -28,7 +28,7 @@
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ZXSpectrumJoystickSettings));
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ZxSpectrumJoystickSettings));
this.OkBtn = new System.Windows.Forms.Button();
this.CancelBtn = new System.Windows.Forms.Button();
this.label5 = new System.Windows.Forms.Label();
@ -160,7 +160,7 @@
this.Controls.Add(this.OkBtn);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Icon = global::BizHawk.Client.EmuHawk.Properties.Resources.GameController_MultiSize;
this.Name = "ZXSpectrumJoystickSettings";
this.Name = "ZxSpectrumJoystickSettings";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Joystick Settings";
this.Load += new System.EventHandler(this.IntvControllerSettings_Load);

View File

@ -7,24 +7,23 @@ using BizHawk.Emulation.Cores.Computers.SinclairSpectrum;
namespace BizHawk.Client.EmuHawk
{
public partial class ZXSpectrumJoystickSettings : Form
public partial class ZxSpectrumJoystickSettings : Form
{
private ZXSpectrum.ZXSpectrumSyncSettings _syncSettings;
private string[] _possibleControllers;
public ZXSpectrumJoystickSettings()
public ZxSpectrumJoystickSettings()
{
InitializeComponent();
}
private string[] possibleControllers;
private void IntvControllerSettings_Load(object sender, EventArgs e)
{
_syncSettings = ((ZXSpectrum)Global.Emulator).GetSyncSettings().Clone();
possibleControllers = Enum.GetNames(typeof(JoystickType));
_possibleControllers = Enum.GetNames(typeof(JoystickType));
foreach (var val in possibleControllers)
foreach (var val in _possibleControllers)
{
Port1ComboBox.Items.Add(val);
Port2ComboBox.Items.Add(val);
@ -50,46 +49,46 @@ namespace BizHawk.Client.EmuHawk
bool selectionValid = true;
var j1 = Port1ComboBox.SelectedItem.ToString();
if (j1 != possibleControllers.First())
if (j1 != _possibleControllers.First())
{
if (j1 == Port2ComboBox.SelectedItem.ToString())
{
Port2ComboBox.SelectedItem = possibleControllers.First();
Port2ComboBox.SelectedItem = _possibleControllers.First();
selectionValid = false;
}
if (j1 == Port3ComboBox.SelectedItem.ToString())
{
Port3ComboBox.SelectedItem = possibleControllers.First();
Port3ComboBox.SelectedItem = _possibleControllers.First();
selectionValid = false;
}
}
var j2 = Port2ComboBox.SelectedItem.ToString();
if (j2 != possibleControllers.First())
if (j2 != _possibleControllers.First())
{
if (j2 == Port1ComboBox.SelectedItem.ToString())
{
Port1ComboBox.SelectedItem = possibleControllers.First();
Port1ComboBox.SelectedItem = _possibleControllers.First();
selectionValid = false;
}
if (j2 == Port3ComboBox.SelectedItem.ToString())
{
Port3ComboBox.SelectedItem = possibleControllers.First();
Port3ComboBox.SelectedItem = _possibleControllers.First();
selectionValid = false;
}
}
var j3 = Port3ComboBox.SelectedItem.ToString();
if (j3 != possibleControllers.First())
if (j3 != _possibleControllers.First())
{
if (j3 == Port1ComboBox.SelectedItem.ToString())
{
Port1ComboBox.SelectedItem = possibleControllers.First();
Port1ComboBox.SelectedItem = _possibleControllers.First();
selectionValid = false;
}
if (j3 == Port2ComboBox.SelectedItem.ToString())
{
Port2ComboBox.SelectedItem = possibleControllers.First();
Port2ComboBox.SelectedItem = _possibleControllers.First();
selectionValid = false;
}
}

View File

@ -1,6 +1,6 @@
namespace BizHawk.Client.EmuHawk
{
partial class ZXSpectrumNonSyncSettings
partial class ZxSpectrumNonSyncSettings
{
/// <summary>
/// Required designer variable.
@ -149,7 +149,7 @@
this.Controls.Add(this.OkBtn);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Icon = global::BizHawk.Client.EmuHawk.Properties.Resources.GameController_MultiSize;
this.Name = "ZXSpectrumNonSyncSettings";
this.Name = "ZxSpectrumNonSyncSettings";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Other Non-Sync Settings";
this.Load += new System.EventHandler(this.IntvControllerSettings_Load);

View File

@ -1,19 +1,17 @@
using System;
using System.Linq;
using System.Windows.Forms;
using BizHawk.Client.Common;
using BizHawk.Emulation.Cores.Computers.SinclairSpectrum;
using System.Text;
namespace BizHawk.Client.EmuHawk
{
public partial class ZXSpectrumNonSyncSettings : Form
public partial class ZxSpectrumNonSyncSettings : Form
{
private ZXSpectrum.ZXSpectrumSettings _settings;
private int bgColor;
private int _bgColor;
public ZXSpectrumNonSyncSettings()
public ZxSpectrumNonSyncSettings()
{
InitializeComponent();
}
@ -22,7 +20,7 @@ namespace BizHawk.Client.EmuHawk
{
_settings = ((ZXSpectrum)Global.Emulator).GetSettings().Clone();
bgColor = _settings.BackgroundColor;
_bgColor = _settings.BackgroundColor;
SetBtnColor();
@ -40,22 +38,22 @@ namespace BizHawk.Client.EmuHawk
private void SetBtnColor()
{
var c = System.Drawing.Color.FromArgb(bgColor);
var c = System.Drawing.Color.FromArgb(_bgColor);
buttonChooseBGColor.ForeColor = c;
buttonChooseBGColor.BackColor = c;
}
private void OkBtn_Click(object sender, EventArgs e)
{
bool changed =
bool changed =
_settings.OSDMessageVerbosity.ToString() != osdMessageVerbositycomboBox1.SelectedItem.ToString() ||
_settings.BackgroundColor != bgColor ||
_settings.BackgroundColor != _bgColor ||
_settings.UseCoreBorderForBackground != checkBoxShowCoreBrdColor.Checked;
if (changed)
{
_settings.OSDMessageVerbosity = (ZXSpectrum.OSDVerbosity)Enum.Parse(typeof(ZXSpectrum.OSDVerbosity), osdMessageVerbositycomboBox1.SelectedItem.ToString());
_settings.BackgroundColor = bgColor;
_settings.BackgroundColor = _bgColor;
_settings.UseCoreBorderForBackground = checkBoxShowCoreBrdColor.Checked;
GlobalWin.MainForm.PutCoreSettings(_settings);
@ -95,7 +93,7 @@ namespace BizHawk.Client.EmuHawk
private void OSDComboBox_SelectionChangeCommitted(object sender, EventArgs e)
{
ComboBox cb = sender as ComboBox;
var cb = (ComboBox)sender;
UpdateOSDNotes((ZXSpectrum.OSDVerbosity)Enum.Parse(typeof(ZXSpectrum.OSDVerbosity), cb.SelectedItem.ToString()));
}
@ -105,7 +103,7 @@ namespace BizHawk.Client.EmuHawk
System.Drawing.Color c = System.Drawing.Color.FromArgb(currColor);
using var cd = new ColorDialog();
System.Drawing.Color[] colors = new System.Drawing.Color[]
System.Drawing.Color[] colors =
{
System.Drawing.Color.FromArgb(0x00, 0x00, 0x00),
System.Drawing.Color.FromArgb(0x00, 0x00, 0xD7),
@ -125,7 +123,7 @@ namespace BizHawk.Client.EmuHawk
System.Drawing.Color.FromArgb(0xFF, 0xFF, 0xFF),
};
cd.CustomColors = new int[]
cd.CustomColors = new[]
{
System.Drawing.ColorTranslator.ToOle(colors[0]),
System.Drawing.ColorTranslator.ToOle(colors[1]),
@ -151,7 +149,7 @@ namespace BizHawk.Client.EmuHawk
{
var color = cd.Color;
var col = color.ToArgb();
bgColor = col;
_bgColor = col;
SetBtnColor();
}

View File

@ -1,6 +1,6 @@
namespace BizHawk.Client.EmuHawk
{
partial class ZXSpectrumPokeMemory
partial class ZxSpectrumPokeMemory
{
/// <summary>
/// Required designer variable.
@ -140,7 +140,7 @@
this.Controls.Add(this.OkBtn);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Icon = global::BizHawk.Client.EmuHawk.Properties.Resources.GameController_MultiSize;
this.Name = "ZXSpectrumPokeMemory";
this.Name = "ZxSpectrumPokeMemory";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Poke Memory";
((System.ComponentModel.ISupportInitialize)(this.numericUpDownAddress)).EndInit();

View File

@ -1,16 +1,14 @@
using System;
using System.Linq;
using System.Windows.Forms;
using BizHawk.Client.Common;
using BizHawk.Emulation.Cores.Computers.SinclairSpectrum;
using System.Text;
namespace BizHawk.Client.EmuHawk
{
public partial class ZXSpectrumPokeMemory : Form
public partial class ZxSpectrumPokeMemory : Form
{
public ZXSpectrumPokeMemory()
public ZxSpectrumPokeMemory()
{
InitializeComponent();
}
@ -24,7 +22,7 @@ namespace BizHawk.Client.EmuHawk
speccy.PokeMemory(addr, val);
DialogResult = DialogResult.OK;
Close();
Close();
}
private void CancelBtn_Click(object sender, EventArgs e)