diff --git a/BizHawk.Client.EmuHawk/MainForm.Designer.cs b/BizHawk.Client.EmuHawk/MainForm.Designer.cs index ef618fa03c..cf72722195 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Designer.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Designer.cs @@ -3559,14 +3559,14 @@ this.amstradCPCCoreEmulationSettingsToolStripMenuItem.Name = "amstradCPCCoreEmulationSettingsToolStripMenuItem"; this.amstradCPCCoreEmulationSettingsToolStripMenuItem.Size = new System.Drawing.Size(188, 22); this.amstradCPCCoreEmulationSettingsToolStripMenuItem.Text = "Core Emulation Settings"; - this.amstradCPCCoreEmulationSettingsToolStripMenuItem.Click += new System.EventHandler(this.amstradCPCCoreEmulationSettingsToolStripMenuItem_Click); + this.amstradCPCCoreEmulationSettingsToolStripMenuItem.Click += new System.EventHandler(this.AmstradCpcCoreEmulationSettingsToolStripMenuItem_Click); // // AmstradCPCAudioSettingsToolStripMenuItem // this.AmstradCPCAudioSettingsToolStripMenuItem.Name = "AmstradCPCAudioSettingsToolStripMenuItem"; this.AmstradCPCAudioSettingsToolStripMenuItem.Size = new System.Drawing.Size(188, 22); this.AmstradCPCAudioSettingsToolStripMenuItem.Text = "Audio Settings"; - this.AmstradCPCAudioSettingsToolStripMenuItem.Click += new System.EventHandler(this.AmstradCPCAudioSettingsToolStripMenuItem_Click); + this.AmstradCPCAudioSettingsToolStripMenuItem.Click += new System.EventHandler(this.AmstradCpcAudioSettingsToolStripMenuItem_Click); // // AmstradCPCNonSyncSettingsToolStripMenuItem // @@ -3580,7 +3580,7 @@ this.AmstradCPCPokeMemoryToolStripMenuItem.Name = "AmstradCPCPokeMemoryToolStripMenuItem"; this.AmstradCPCPokeMemoryToolStripMenuItem.Size = new System.Drawing.Size(188, 22); this.AmstradCPCPokeMemoryToolStripMenuItem.Text = "POKE Memory"; - this.AmstradCPCPokeMemoryToolStripMenuItem.Click += new System.EventHandler(this.AmstradCPCPokeMemoryToolStripMenuItem_Click); + this.AmstradCPCPokeMemoryToolStripMenuItem.Click += new System.EventHandler(this.AmstradCpcPokeMemoryToolStripMenuItem_Click); // // AmstradCPCMediaToolStripMenuItem // diff --git a/BizHawk.Client.EmuHawk/MainForm.Events.cs b/BizHawk.Client.EmuHawk/MainForm.Events.cs index 68cab77a84..83b79da44f 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Events.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Events.cs @@ -2687,22 +2687,31 @@ namespace BizHawk.Client.EmuHawk #region AmstradCPC - private void amstradCPCCoreEmulationSettingsToolStripMenuItem_Click(object sender, EventArgs e) + private void AmstradCpcCoreEmulationSettingsToolStripMenuItem_Click(object sender, EventArgs e) { - using var form = new AmstradCPCCoreEmulationSettings(); - form.ShowDialog(); + if (Emulator is AmstradCPC cpc) + { + using var form = new AmstradCpcCoreEmulationSettings(this, cpc.GetSyncSettings().Clone()); + form.ShowDialog(); + } } - private void AmstradCPCAudioSettingsToolStripMenuItem_Click(object sender, EventArgs e) + private void AmstradCpcAudioSettingsToolStripMenuItem_Click(object sender, EventArgs e) { - using var form = new AmstradCPCAudioSettings(); - form.ShowDialog(); + if (Emulator is AmstradCPC cpc) + { + using var form = new AmstradCpcAudioSettings(this, cpc.GetSettings().Clone()); + form.ShowDialog(); + } } - private void AmstradCPCPokeMemoryToolStripMenuItem_Click(object sender, EventArgs e) + private void AmstradCpcPokeMemoryToolStripMenuItem_Click(object sender, EventArgs e) { - using var form = new AmstradCPCPokeMemory(); - form.ShowDialog(); + if (Emulator is AmstradCPC cpc) + { + using var form = new AmstradCpcPokeMemory(this, cpc); + form.ShowDialog(); + } } private void AmstradCPCMediaToolStripMenuItem_DropDownOpened(object sender, EventArgs e) @@ -2784,8 +2793,12 @@ namespace BizHawk.Client.EmuHawk private void AmstradCPCNonSyncSettingsToolStripMenuItem_Click(object sender, EventArgs e) { - using var form = new AmstradCPCNonSyncSettings(); - form.ShowDialog(); + if (Emulator is AmstradCPC cpc) + { + using var form = new AmstradCpcNonSyncSettings(this, cpc.GetSettings().Clone()); + form.ShowDialog(); + } + } #endregion diff --git a/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCAudioSettings.Designer.cs b/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCAudioSettings.Designer.cs index 0bb32869c4..8cc1254764 100644 --- a/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCAudioSettings.Designer.cs +++ b/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCAudioSettings.Designer.cs @@ -1,6 +1,6 @@ namespace BizHawk.Client.EmuHawk { - partial class AmstradCPCAudioSettings + partial class AmstradCpcAudioSettings { /// /// Required designer variable. @@ -158,7 +158,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 = "AmstradCPCAudioSettings"; + this.Name = "AmstradCpcAudioSettings"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Audio Settings"; this.Load += new System.EventHandler(this.IntvControllerSettings_Load); diff --git a/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCAudioSettings.cs b/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCAudioSettings.cs index 0b1679cd0f..7bbbb07d69 100644 --- a/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCAudioSettings.cs +++ b/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCAudioSettings.cs @@ -1,26 +1,26 @@ using System; -using System.Linq; using System.Windows.Forms; - -using BizHawk.Client.Common; using BizHawk.Emulation.Cores.Computers.AmstradCPC; -using System.Text; namespace BizHawk.Client.EmuHawk { - public partial class AmstradCPCAudioSettings : Form + public partial class AmstradCpcAudioSettings : Form { - private AmstradCPC.AmstradCPCSettings _settings; + private readonly MainForm _mainForm; + private readonly AmstradCPC.AmstradCPCSettings _settings; - public AmstradCPCAudioSettings() + public AmstradCpcAudioSettings( + MainForm mainForm, + AmstradCPC.AmstradCPCSettings settings) { + _mainForm = mainForm; + _settings = settings; + InitializeComponent(); } private void IntvControllerSettings_Load(object sender, EventArgs e) { - _settings = ((AmstradCPC)Global.Emulator).GetSettings().Clone(); - // AY panning config var panTypes = Enum.GetNames(typeof(AY38912.AYPanConfig)); foreach (var val in panTypes) @@ -34,8 +34,6 @@ namespace BizHawk.Client.EmuHawk // ay volume ayVolumetrackBar.Value = _settings.AYVolume; - - } private void OkBtn_Click(object sender, EventArgs e) @@ -52,7 +50,7 @@ namespace BizHawk.Client.EmuHawk _settings.TapeVolume = tapeVolumetrackBar.Value; _settings.AYVolume = ayVolumetrackBar.Value; - GlobalWin.MainForm.PutCoreSettings(_settings); + _mainForm.PutCoreSettings(_settings); DialogResult = DialogResult.OK; Close(); @@ -66,7 +64,7 @@ namespace BizHawk.Client.EmuHawk private void CancelBtn_Click(object sender, EventArgs e) { - GlobalWin.OSD.AddMessage("Misc settings aborted"); + _mainForm.AddOnScreenMessage("Misc settings aborted"); DialogResult = DialogResult.Cancel; Close(); } diff --git a/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCCoreEmulationSettings.Designer.cs b/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCCoreEmulationSettings.Designer.cs index df2152d250..0561b63167 100644 --- a/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCCoreEmulationSettings.Designer.cs +++ b/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCCoreEmulationSettings.Designer.cs @@ -1,6 +1,6 @@ namespace BizHawk.Client.EmuHawk { - partial class AmstradCPCCoreEmulationSettings + partial class AmstradCpcCoreEmulationSettings { /// /// Required designer variable. @@ -155,6 +155,7 @@ this.borderTypecomboBox1.Name = "borderTypecomboBox1"; this.borderTypecomboBox1.Size = new System.Drawing.Size(159, 21); this.borderTypecomboBox1.TabIndex = 28; + this.borderTypecomboBox1.SelectedIndexChanged += new System.EventHandler(this.BorderTypeComboBox_SelectedIndexChanged); // // textBoxMachineNotes // @@ -169,7 +170,7 @@ this.textBoxMachineNotes.Size = new System.Drawing.Size(424, 222); this.textBoxMachineNotes.TabIndex = 31; // - // AmstradCPCCoreEmulationSettings + // AmstradCpcCoreEmulationSettings // this.AcceptButton = this.OkBtn; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -189,8 +190,7 @@ this.Controls.Add(this.CancelBtn); this.Controls.Add(this.OkBtn); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; - this.Icon = global::BizHawk.Client.EmuHawk.Properties.Resources.GameController_MultiSize; - this.Name = "AmstradCPCCoreEmulationSettings"; + this.Name = "AmstradCpcCoreEmulationSettings"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Core Emulation Settings"; this.Load += new System.EventHandler(this.IntvControllerSettings_Load); diff --git a/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCCoreEmulationSettings.cs b/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCCoreEmulationSettings.cs index fbb876166a..349925731f 100644 --- a/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCCoreEmulationSettings.cs +++ b/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCCoreEmulationSettings.cs @@ -1,27 +1,24 @@ using System; -using System.Linq; using System.Windows.Forms; - -using BizHawk.Client.Common; using BizHawk.Emulation.Cores.Computers.AmstradCPC; -using System.Text; -using static BizHawk.Emulation.Cores.Computers.AmstradCPC.AmstradCPC; namespace BizHawk.Client.EmuHawk { - public partial class AmstradCPCCoreEmulationSettings : Form + public partial class AmstradCpcCoreEmulationSettings : Form { - private AmstradCPC.AmstradCPCSyncSettings _syncSettings; + private readonly MainForm _mainForm; + private readonly AmstradCPC.AmstradCPCSyncSettings _syncSettings; - public AmstradCPCCoreEmulationSettings() + public AmstradCpcCoreEmulationSettings(MainForm mainForm, + AmstradCPC.AmstradCPCSyncSettings syncSettings) { + _mainForm = mainForm; + _syncSettings = syncSettings; InitializeComponent(); } private void IntvControllerSettings_Load(object sender, EventArgs e) { - _syncSettings = ((AmstradCPC)Global.Emulator).GetSyncSettings().Clone(); - // machine selection var machineTypes = Enum.GetNames(typeof(MachineType)); foreach (var val in machineTypes) @@ -31,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(AmstradCPC.BorderType)); foreach (var val in borderTypes) { @@ -62,7 +59,7 @@ namespace BizHawk.Client.EmuHawk _syncSettings.DeterministicEmulation = determEmucheckBox1.Checked; _syncSettings.AutoStartStopTape = autoLoadcheckBox1.Checked; - GlobalWin.MainForm.PutCoreSyncSettings(_syncSettings); + _mainForm.PutCoreSyncSettings(_syncSettings); DialogResult = DialogResult.OK; Close(); @@ -76,25 +73,25 @@ namespace BizHawk.Client.EmuHawk private void CancelBtn_Click(object sender, EventArgs e) { - GlobalWin.OSD.AddMessage("Core emulator settings aborted"); + _mainForm.AddOnScreenMessage("Core emulator settings aborted"); DialogResult = DialogResult.Cancel; Close(); } 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())); } private void UpdateMachineNotes(MachineType type) { - textBoxMachineNotes.Text = CPCMachineMetaData.GetMetaString(type); + textBoxMachineNotes.Text = AmstradCPC.CPCMachineMetaData.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((AmstradCPC.BorderType)Enum.Parse(typeof(AmstradCPC.BorderType), cb.SelectedItem.ToString())); } @@ -103,7 +100,7 @@ namespace BizHawk.Client.EmuHawk switch (type) { case AmstradCPC.BorderType.Uniform: - lblBorderInfo.Text = "Attempts to equalise the border areas"; + lblBorderInfo.Text = "Attempts to equalize the border areas"; break; case AmstradCPC.BorderType.Uncropped: lblBorderInfo.Text = "Pretty much the signal the gate array is generating (looks pants)"; diff --git a/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCNonSyncSettings.Designer.cs b/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCNonSyncSettings.Designer.cs index 15b97ab270..8df1d38753 100644 --- a/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCNonSyncSettings.Designer.cs +++ b/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCNonSyncSettings.Designer.cs @@ -1,6 +1,6 @@ namespace BizHawk.Client.EmuHawk { - partial class AmstradCPCNonSyncSettings + partial class AmstradCpcNonSyncSettings { /// /// Required designer variable. @@ -114,7 +114,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 = "AmstradCPCNonSyncSettings"; + this.Name = "AmstradCpcNonSyncSettings"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Other Non-Sync Settings"; this.Load += new System.EventHandler(this.IntvControllerSettings_Load); diff --git a/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCNonSyncSettings.cs b/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCNonSyncSettings.cs index 4614d6e334..39b468a567 100644 --- a/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCNonSyncSettings.cs +++ b/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCNonSyncSettings.cs @@ -1,30 +1,27 @@ using System; -using System.Linq; using System.Windows.Forms; - -using BizHawk.Client.Common; using BizHawk.Emulation.Cores.Computers.AmstradCPC; -using System.Text; namespace BizHawk.Client.EmuHawk { - public partial class AmstradCPCNonSyncSettings : Form + public partial class AmstradCpcNonSyncSettings : Form { - private AmstradCPC.AmstradCPCSettings _settings; + private readonly MainForm _mainForm; + private readonly AmstradCPC.AmstradCPCSettings _settings; - public AmstradCPCNonSyncSettings() + public AmstradCpcNonSyncSettings( + MainForm mainForm, + AmstradCPC.AmstradCPCSettings settings) { + _mainForm = mainForm; + _settings = settings; InitializeComponent(); } private void IntvControllerSettings_Load(object sender, EventArgs e) { - _settings = ((AmstradCPC)Global.Emulator).GetSettings().Clone(); - - - // OSD Message Verbosity - var osdTypes = Enum.GetNames(typeof(AmstradCPC.OSDVerbosity)); + var osdTypes = Enum.GetNames(typeof(AmstradCPC.OSDVerbosity)); foreach (var val in osdTypes) { osdMessageVerbositycomboBox1.Items.Add(val); @@ -35,7 +32,7 @@ namespace BizHawk.Client.EmuHawk private void OkBtn_Click(object sender, EventArgs e) { - bool changed = + bool changed = _settings.OSDMessageVerbosity.ToString() != osdMessageVerbositycomboBox1.SelectedItem.ToString(); if (changed) @@ -56,7 +53,7 @@ namespace BizHawk.Client.EmuHawk private void CancelBtn_Click(object sender, EventArgs e) { - GlobalWin.OSD.AddMessage("Misc settings aborted"); + _mainForm.AddOnScreenMessage("Misc settings aborted"); DialogResult = DialogResult.Cancel; Close(); } @@ -79,7 +76,7 @@ namespace BizHawk.Client.EmuHawk private void OSDComboBox_SelectionChangeCommitted(object sender, EventArgs e) { - ComboBox cb = sender as ComboBox; + var cb = (ComboBox)sender; UpdateOSDNotes((AmstradCPC.OSDVerbosity)Enum.Parse(typeof(AmstradCPC.OSDVerbosity), cb.SelectedItem.ToString())); } } diff --git a/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCPokeMemory.Designer.cs b/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCPokeMemory.Designer.cs index c926064d90..b373c75448 100644 --- a/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCPokeMemory.Designer.cs +++ b/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCPokeMemory.Designer.cs @@ -1,6 +1,6 @@ namespace BizHawk.Client.EmuHawk { - partial class AmstradCPCPokeMemory + partial class AmstradCpcPokeMemory { /// /// 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 = "AmstradCPCPokeMemory"; + this.Name = "AmstradCpcPokeMemory"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Poke Memory"; ((System.ComponentModel.ISupportInitialize)(this.numericUpDownAddress)).EndInit(); diff --git a/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCPokeMemory.cs b/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCPokeMemory.cs index f17efc62d6..e100ded8e0 100644 --- a/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCPokeMemory.cs +++ b/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCPokeMemory.cs @@ -1,35 +1,36 @@ using System; -using System.Linq; using System.Windows.Forms; -using BizHawk.Client.Common; using BizHawk.Emulation.Cores.Computers.AmstradCPC; -using System.Text; namespace BizHawk.Client.EmuHawk { - public partial class AmstradCPCPokeMemory : Form + public partial class AmstradCpcPokeMemory : Form { - public AmstradCPCPokeMemory() + private readonly MainForm _mainForm; + private readonly AmstradCPC _cpc; + + public AmstradCpcPokeMemory(MainForm mainForm, AmstradCPC cpc) { + _mainForm = mainForm; + _cpc = cpc; InitializeComponent(); } private void OkBtn_Click(object sender, EventArgs e) { - var ams = (AmstradCPC)Global.Emulator; var addr = (ushort)numericUpDownAddress.Value; var val = (byte)numericUpDownByte.Value; - ams.PokeMemory(addr, val); + _cpc.PokeMemory(addr, val); DialogResult = DialogResult.OK; - Close(); + Close(); } private void CancelBtn_Click(object sender, EventArgs e) { - GlobalWin.OSD.AddMessage("POKE memory aborted"); + _mainForm.AddOnScreenMessage("POKE memory aborted"); DialogResult = DialogResult.Cancel; Close(); }