From bdc8be2f6bd9456ccd96ba2d62ce1f2519f923f8 Mon Sep 17 00:00:00 2001 From: adelikat Date: Mon, 16 Dec 2019 17:06:29 -0600 Subject: [PATCH] declare dependencies in PCE config dialogs --- BizHawk.Client.EmuHawk/MainForm.Events.cs | 10 +++-- .../config/PCE/PCEControllerConfig.cs | 17 ++++---- .../config/PCE/PCEGraphicsConfig.cs | 41 ++++++++++--------- 3 files changed, 37 insertions(+), 31 deletions(-) diff --git a/BizHawk.Client.EmuHawk/MainForm.Events.cs b/BizHawk.Client.EmuHawk/MainForm.Events.cs index 05b0e55b75..7bdffcaa50 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Events.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Events.cs @@ -1716,16 +1716,20 @@ namespace BizHawk.Client.EmuHawk private void PceControllerSettingsMenuItem_Click(object sender, EventArgs e) { - using (var dlg = new PCEControllerConfig()) + if (Emulator is PCEngine pce) { + using var dlg = new PCEControllerConfig(this, pce.GetSyncSettings().Clone()); dlg.ShowDialog(); } } private void PceGraphicsSettingsMenuItem_Click(object sender, EventArgs e) { - using var form = new PCEGraphicsConfig(); - form.ShowDialog(); + if (Emulator is PCEngine pce) + { + using var form = new PCEGraphicsConfig(this, pce.GetSettings().Clone()); + form.ShowDialog(); + } } private void PceBgViewerMenuItem_Click(object sender, EventArgs e) diff --git a/BizHawk.Client.EmuHawk/config/PCE/PCEControllerConfig.cs b/BizHawk.Client.EmuHawk/config/PCE/PCEControllerConfig.cs index c67095376c..d7f0908e47 100644 --- a/BizHawk.Client.EmuHawk/config/PCE/PCEControllerConfig.cs +++ b/BizHawk.Client.EmuHawk/config/PCE/PCEControllerConfig.cs @@ -1,30 +1,31 @@ using System; using System.Windows.Forms; - using BizHawk.Emulation.Cores.PCEngine; -using BizHawk.Client.Common; namespace BizHawk.Client.EmuHawk { public partial class PCEControllerConfig : Form { - private PCEngine.PCESyncSettings _controllerSettings; + private readonly MainForm _mainForm; + private readonly PCEngine.PCESyncSettings _syncSettings; - public PCEControllerConfig() + public PCEControllerConfig( + MainForm mainForm, + PCEngine.PCESyncSettings syncSettings) { + _mainForm = mainForm; + _syncSettings = syncSettings; InitializeComponent(); } private void PCEControllerConfig_Load(object sender, EventArgs e) { - var pceSettings = ((PCEngine)Global.Emulator).GetSyncSettings(); - _controllerSettings = pceSettings; // Assumes only controller data is in sync settings! If there are ever more sync settings, this dialog should just become a general sync settings dialog (or both settings/sync settings) - ControllerPropertyGrid.SelectedObject = _controllerSettings; + ControllerPropertyGrid.SelectedObject = _syncSettings; } private void OkBtn_Click(object sender, EventArgs e) { - GlobalWin.MainForm.PutCoreSyncSettings(_controllerSettings); + _mainForm.PutCoreSyncSettings(_syncSettings); DialogResult = DialogResult.OK; Close(); } diff --git a/BizHawk.Client.EmuHawk/config/PCE/PCEGraphicsConfig.cs b/BizHawk.Client.EmuHawk/config/PCE/PCEGraphicsConfig.cs index fd08ec4724..a5841e4d37 100644 --- a/BizHawk.Client.EmuHawk/config/PCE/PCEGraphicsConfig.cs +++ b/BizHawk.Client.EmuHawk/config/PCE/PCEGraphicsConfig.cs @@ -1,41 +1,42 @@ using System; using System.Windows.Forms; - -using BizHawk.Client.Common; using BizHawk.Emulation.Cores.PCEngine; namespace BizHawk.Client.EmuHawk { public partial class PCEGraphicsConfig : Form { - public PCEGraphicsConfig() + private readonly MainForm _mainForm; + private readonly PCEngine.PCESettings _settings; + + public PCEGraphicsConfig( + MainForm mainForm, + PCEngine.PCESettings settings) { + _mainForm = mainForm; + _settings = settings; InitializeComponent(); } private void PCEGraphicsConfig_Load(object sender, EventArgs e) { - PCEngine.PCESettings s = ((PCEngine)Global.Emulator).GetSettings(); - - DispOBJ1.Checked = s.ShowOBJ1; - DispBG1.Checked = s.ShowBG1; - DispOBJ2.Checked = s.ShowOBJ2; - DispBG2.Checked = s.ShowBG2; - NTSC_FirstLineNumeric.Value = s.Top_Line; - NTSC_LastLineNumeric.Value = s.Bottom_Line; + DispOBJ1.Checked = _settings.ShowOBJ1; + DispBG1.Checked = _settings.ShowBG1; + DispOBJ2.Checked = _settings.ShowOBJ2; + DispBG2.Checked = _settings.ShowBG2; + NTSC_FirstLineNumeric.Value = _settings.Top_Line; + NTSC_LastLineNumeric.Value = _settings.Bottom_Line; } private void Ok_Click(object sender, EventArgs e) { - var pce = (PCEngine)Global.Emulator; - PCEngine.PCESettings s = pce.GetSettings(); - s.ShowOBJ1 = DispOBJ1.Checked; - s.ShowBG1 = DispBG1.Checked; - s.ShowOBJ2 = DispOBJ2.Checked; - s.ShowBG2 = DispBG2.Checked; - s.Top_Line = (int)NTSC_FirstLineNumeric.Value; - s.Bottom_Line = (int)NTSC_LastLineNumeric.Value; - pce.PutSettings(s); + _settings.ShowOBJ1 = DispOBJ1.Checked; + _settings.ShowBG1 = DispBG1.Checked; + _settings.ShowOBJ2 = DispOBJ2.Checked; + _settings.ShowBG2 = DispBG2.Checked; + _settings.Top_Line = (int)NTSC_FirstLineNumeric.Value; + _settings.Bottom_Line = (int)NTSC_LastLineNumeric.Value; + _mainForm.PutCoreSettings(_settings); Close(); }