diff --git a/BizHawk.Client.EmuHawk/MainForm.Events.cs b/BizHawk.Client.EmuHawk/MainForm.Events.cs index 7bdffcaa50..2c4db6d01a 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Events.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Events.cs @@ -29,6 +29,7 @@ using BizHawk.Emulation.Cores.Nintendo.Gameboy; using BizHawk.Emulation.Cores.Computers.SinclairSpectrum; using BizHawk.Emulation.Cores.Computers.AmstradCPC; using BizHawk.Emulation.Cores.Intellivision; +using BizHawk.Emulation.Cores.Sony.PSX; namespace BizHawk.Client.EmuHawk { @@ -2161,16 +2162,22 @@ namespace BizHawk.Client.EmuHawk private void PSXControllerSettingsMenuItem_Click(object sender, EventArgs e) { - using var form = new PSXControllerConfigNew(); - form.ShowDialog(); + if (Emulator is Octoshock psx) + { + using var form = new PSXControllerConfig(this, psx.GetSyncSettings().Clone()); + form.ShowDialog(); + } } private void PSXOptionsMenuItem_Click(object sender, EventArgs e) { - var result = PSXOptions.DoSettingsDialog(this); - if (result == DialogResult.OK) + if (Emulator is Octoshock psx) { - FrameBufferResized(); + var result = PSXOptions.DoSettingsDialog(this, psx); + if (result == DialogResult.OK) + { + FrameBufferResized(); + } } } diff --git a/BizHawk.Client.EmuHawk/config/PSX/PSXControllerConfigNew.Designer.cs b/BizHawk.Client.EmuHawk/config/PSX/PSXControllerConfigNew.Designer.cs index a9b42fbd1e..38c2147516 100644 --- a/BizHawk.Client.EmuHawk/config/PSX/PSXControllerConfigNew.Designer.cs +++ b/BizHawk.Client.EmuHawk/config/PSX/PSXControllerConfigNew.Designer.cs @@ -1,6 +1,6 @@ namespace BizHawk.Client.EmuHawk { - partial class PSXControllerConfigNew + partial class PSXControllerConfig { /// /// Required designer variable. @@ -430,7 +430,7 @@ this.Icon = global::BizHawk.Client.EmuHawk.Properties.Resources.GameController_MultiSize; this.MaximizeBox = false; this.MinimizeBox = false; - this.Name = "PSXControllerConfigNew"; + this.Name = "PSXControllerConfig"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Controller / Memcard Configuration"; this.Load += new System.EventHandler(this.PSXControllerConfigNew_Load); diff --git a/BizHawk.Client.EmuHawk/config/PSX/PSXControllerConfigNew.cs b/BizHawk.Client.EmuHawk/config/PSX/PSXControllerConfigNew.cs index 703b6c7891..9797b30b11 100644 --- a/BizHawk.Client.EmuHawk/config/PSX/PSXControllerConfigNew.cs +++ b/BizHawk.Client.EmuHawk/config/PSX/PSXControllerConfigNew.cs @@ -6,10 +6,17 @@ using BizHawk.Client.Common; namespace BizHawk.Client.EmuHawk { - public partial class PSXControllerConfigNew : Form + public partial class PSXControllerConfig : Form { - public PSXControllerConfigNew() + private readonly MainForm _mainForm; + private readonly Octoshock.SyncSettings _syncSettings; + + public PSXControllerConfig( + MainForm mainForm, + Octoshock.SyncSettings syncSettings) { + _mainForm = mainForm; + _syncSettings = syncSettings; InitializeComponent(); } @@ -26,9 +33,7 @@ namespace BizHawk.Client.EmuHawk combo.SelectedIndex = 0; } - var psxSettings = ((Octoshock)Global.Emulator).GetSyncSettings(); - GuiFromUserConfig(psxSettings.FIOConfig); - + GuiFromUserConfig(_syncSettings.FIOConfig); RefreshLabels(); } @@ -131,13 +136,10 @@ namespace BizHawk.Client.EmuHawk private void BtnOk_Click(object sender, EventArgs e) { - var psxSettings = ((Octoshock)Global.Emulator).GetSyncSettings(); - - psxSettings.FIOConfig = UserConfigFromGui(); - GlobalWin.MainForm.PutCoreSyncSettings(psxSettings); + _syncSettings.FIOConfig = UserConfigFromGui(); + _mainForm.PutCoreSyncSettings(_syncSettings); DialogResult = DialogResult.OK; - Close(); } } diff --git a/BizHawk.Client.EmuHawk/config/PSX/PSXOptions.cs b/BizHawk.Client.EmuHawk/config/PSX/PSXOptions.cs index a5175cb108..29fad05239 100644 --- a/BizHawk.Client.EmuHawk/config/PSX/PSXOptions.cs +++ b/BizHawk.Client.EmuHawk/config/PSX/PSXOptions.cs @@ -10,11 +10,17 @@ namespace BizHawk.Client.EmuHawk public partial class PSXOptions : Form { // backups of the labels for string replacing - private readonly string lblPixelPro_text, lblMednafen_text, lblTweakedMednafen_text; + private readonly string _lblPixelProText, _lblMednafenText, _lblTweakedMednafenText; - private PSXOptions(Octoshock.Settings settings, Octoshock.SyncSettings syncSettings, OctoshockDll.eVidStandard vidStandard, Size currentVideoSize) + private PSXOptions( + MainForm mainForm, + Octoshock.Settings settings, + Octoshock.SyncSettings syncSettings, + OctoshockDll.eVidStandard vidStandard, + Size currentVideoSize) { InitializeComponent(); + _mainForm = mainForm; _settings = settings; _syncSettings = syncSettings; _previewVideoStandard = vidStandard; @@ -29,9 +35,9 @@ namespace BizHawk.Client.EmuHawk lblPAL.Font = new Font(lblPAL.Font, FontStyle.Bold); } - lblPixelPro_text = lblPixelPro.Text; - lblMednafen_text = lblMednafen.Text; - lblTweakedMednafen_text = lblTweakedMednafen.Text; + _lblPixelProText = lblPixelPro.Text; + _lblMednafenText = lblMednafen.Text; + _lblTweakedMednafenText = lblTweakedMednafen.Text; rbPixelPro.Checked = _settings.ResolutionMode == Octoshock.eResolutionMode.PixelPro; rbDebugMode.Checked = _settings.ResolutionMode == Octoshock.eResolutionMode.Debug; @@ -55,6 +61,7 @@ namespace BizHawk.Client.EmuHawk } private Size _previewVideoSize; + private readonly MainForm _mainForm; private readonly OctoshockDll.eVidStandard _previewVideoStandard; private readonly Octoshock.Settings _settings; private readonly Octoshock.SyncSettings _syncSettings; @@ -66,16 +73,15 @@ namespace BizHawk.Client.EmuHawk MessageBox.Show("Finetuned Display Options will take effect if you OK from PSX Options"); } - public static DialogResult DoSettingsDialog(IWin32Window owner) + public static DialogResult DoSettingsDialog(MainForm mainForm, Octoshock psx) { - var psx = (Octoshock)Global.Emulator; var s = psx.GetSettings(); var ss = psx.GetSyncSettings(); var vid = psx.SystemVidStandard; var size = psx.CurrentVideoSize; - using var dlg = new PSXOptions(s, ss, vid, size); + using var dlg = new PSXOptions(mainForm, s, ss, vid, size); - var result = dlg.ShowDialog(owner); + var result = dlg.ShowDialog(mainForm); return result; } @@ -116,8 +122,8 @@ namespace BizHawk.Client.EmuHawk SyncSettingsFromGui(_settings, _syncSettings); _settings.Validate(); - GlobalWin.MainForm.PutCoreSettings(_settings); - GlobalWin.MainForm.PutCoreSyncSettings(_syncSettings); + _mainForm.PutCoreSettings(_settings); + _mainForm.PutCoreSyncSettings(_syncSettings); DialogResult = DialogResult.OK; Close(); @@ -145,15 +151,15 @@ namespace BizHawk.Client.EmuHawk temp.ResolutionMode = Octoshock.eResolutionMode.PixelPro; var ri = Octoshock.CalculateResolution(_previewVideoStandard, temp, w, h); - lblPixelPro.Text = lblPixelPro_text.Replace("800x480", $"{ri.Resolution.Width}x{ri.Resolution.Height}"); + lblPixelPro.Text = _lblPixelProText.Replace("800x480", $"{ri.Resolution.Width}x{ri.Resolution.Height}"); temp.ResolutionMode = Octoshock.eResolutionMode.Mednafen; ri = Octoshock.CalculateResolution(_previewVideoStandard, temp, w, h); - lblMednafen.Text = lblMednafen_text.Replace("320x240", $"{ri.Resolution.Width}x{ri.Resolution.Height}"); + lblMednafen.Text = _lblMednafenText.Replace("320x240", $"{ri.Resolution.Width}x{ri.Resolution.Height}"); temp.ResolutionMode = Octoshock.eResolutionMode.TweakedMednafen; ri = Octoshock.CalculateResolution(_previewVideoStandard, temp, w, h); - lblTweakedMednafen.Text = lblTweakedMednafen_text.Replace("400x300", $"{ri.Resolution.Width}x{ri.Resolution.Height}"); + lblTweakedMednafen.Text = _lblTweakedMednafenText.Replace("400x300", $"{ri.Resolution.Width}x{ri.Resolution.Height}"); } private void DrawingArea_ValueChanged(object sender, EventArgs e) diff --git a/BizHawk.sln.DotSettings b/BizHawk.sln.DotSettings index 5a2f1a4261..a72d0de73b 100644 --- a/BizHawk.sln.DotSettings +++ b/BizHawk.sln.DotSettings @@ -191,6 +191,7 @@ True True True + True True True True @@ -216,6 +217,7 @@ True True True + True True True True @@ -226,6 +228,7 @@ True True True + True True True True @@ -265,6 +268,7 @@ True True True + True True True True