From 20c1fe0f170aa0ffa2268ea771a9d891991825c3 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Sat, 28 May 2022 19:38:59 +1000 Subject: [PATCH] Pass `ISettingsAdapter` to config dialogs, remove `IMainFormForConfig` --- .../IMainFormForConfig.cs | 17 -- src/BizHawk.Client.EmuHawk/MainForm.Events.cs | 178 +++++++++--------- src/BizHawk.Client.EmuHawk/MainForm.cs | 2 +- .../config/A7800/A7800ControllerSettings.cs | 15 +- .../config/A7800/A7800FilterSettings.cs | 15 +- .../AmstradCPC/AmstradCPCAudioSettings.cs | 15 +- .../AmstradCPCCoreEmulationSettings.cs | 14 +- .../AmstradCPC/AmstradCPCNonSyncSettings.cs | 15 +- .../ColecoVision/ColecoControllerSettings.cs | 15 +- .../config/GB/GBLPrefs.cs | 5 +- .../config/GB/GBPrefs.cs | 5 +- .../config/GB/SameBoyColorChooserForm.cs | 13 +- .../config/INTV/IntvControllerSettings.cs | 15 +- .../config/N64/N64ControllersSetup.cs | 14 +- .../config/N64/N64VideoPluginconfig.cs | 18 +- .../config/NES/NESGraphicsConfig.cs | 13 +- .../config/NES/NESSyncSettingsForm.cs | 14 +- .../config/NES/NESVSSettings.cs | 18 +- .../config/NES/NesControllerSettings.cs | 15 +- .../config/NES/QuickNesConfig.cs | 15 +- .../config/PSX/PSXControllerConfig.cs | 14 +- .../config/PSX/PSXOptions.cs | 18 +- .../config/ProfileConfig.cs | 4 +- .../config/SNES/BSNESControllerConfig.cs | 16 +- .../config/SNES/BSNESOptions.cs | 5 +- .../config/SNES/SNESControllerConfig.cs | 14 +- .../config/SNES/SNESOptions.cs | 5 +- .../config/TI83/TI83PaletteConfig.cs | 15 +- .../ZXSpectrum/ZXSpectrumAudioSettings.cs | 15 +- .../ZXSpectrumCoreEmulationSettings.cs | 15 +- .../ZXSpectrum/ZXSpectrumJoystickSettings.cs | 15 +- .../ZXSpectrum/ZXSpectrumNonSyncSettings.cs | 15 +- 32 files changed, 293 insertions(+), 289 deletions(-) delete mode 100644 src/BizHawk.Client.EmuHawk/IMainFormForConfig.cs diff --git a/src/BizHawk.Client.EmuHawk/IMainFormForConfig.cs b/src/BizHawk.Client.EmuHawk/IMainFormForConfig.cs deleted file mode 100644 index 94787aa83d..0000000000 --- a/src/BizHawk.Client.EmuHawk/IMainFormForConfig.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; - -using BizHawk.Client.Common; -using BizHawk.Emulation.Common; - -namespace BizHawk.Client.EmuHawk -{ - public interface IMainFormForConfig - { - /// loaded emulator is not instance of - ISettingsAdapter GetSettingsAdapterForLoadedCore() - where T : IEmulator; - - ISettingsAdapter GetSettingsAdapterFor() - where T : IEmulator; - } -} diff --git a/src/BizHawk.Client.EmuHawk/MainForm.Events.cs b/src/BizHawk.Client.EmuHawk/MainForm.Events.cs index ce0e0acfcd..cceddea33a 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.Events.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.Events.cs @@ -1346,15 +1346,15 @@ namespace BizHawk.Client.EmuHawk Tools.Load(); } - private DialogResult OpenNesHawkGraphicsSettingsDialog(NES.NESSettings s) + private DialogResult OpenNesHawkGraphicsSettingsDialog(ISettingsAdapter settable) { - using NESGraphicsConfig form = new(Config, this, this, s); + using NESGraphicsConfig form = new(Config, this, settable); return this.ShowDialogWithTempMute(form); } - private DialogResult OpenQuickNesGraphicsSettingsDialog(QuickNES.QuickNESSettings s) + private DialogResult OpenQuickNesGraphicsSettingsDialog(ISettingsAdapter settable) { - using QuickNesConfig form = new(this, Config, s); + using QuickNesConfig form = new(Config, settable); return this.ShowDialogWithTempMute(form); } @@ -1362,9 +1362,9 @@ namespace BizHawk.Client.EmuHawk { _ = Emulator switch { - NES nesHawk => OpenNesHawkGraphicsSettingsDialog(nesHawk.GetSettings().Clone()), - SubNESHawk subNESHawk => OpenNesHawkGraphicsSettingsDialog(subNESHawk.GetSettings().Clone()), - QuickNES quickNes => OpenQuickNesGraphicsSettingsDialog(quickNes.GetSettings().Clone()), + NES => OpenNesHawkGraphicsSettingsDialog(GetSettingsAdapterForLoadedCore()), + SubNESHawk => OpenNesHawkGraphicsSettingsDialog(GetSettingsAdapterForLoadedCore()), + QuickNES => OpenQuickNesGraphicsSettingsDialog(GetSettingsAdapterForLoadedCore()), _ => DialogResult.None }; } @@ -1374,9 +1374,9 @@ namespace BizHawk.Client.EmuHawk Tools.Load(); } - private DialogResult OpenNesHawkVSSettingsDialog(NES.NESSyncSettings ss) + private DialogResult OpenNesHawkVSSettingsDialog(ISettingsAdapter settable) { - using NesVsSettings form = new(this, ss); + using NesVsSettings form = new(settable); return this.ShowDialogWithTempMute(form); } @@ -1384,8 +1384,8 @@ namespace BizHawk.Client.EmuHawk { _ = Emulator switch { - NES { IsVS: true } nesHawk => OpenNesHawkVSSettingsDialog(nesHawk.GetSyncSettings().Clone()), - SubNESHawk { IsVs: true } subNESHawk => OpenNesHawkVSSettingsDialog(subNESHawk.GetSyncSettings().Clone()), + NES { IsVS: true } => OpenNesHawkVSSettingsDialog(GetSettingsAdapterForLoadedCore()), + SubNESHawk { IsVs: true } => OpenNesHawkVSSettingsDialog(GetSettingsAdapterForLoadedCore()), _ => DialogResult.None }; } @@ -1438,9 +1438,9 @@ namespace BizHawk.Client.EmuHawk } } - private DialogResult OpenNesHawkGamepadSettingsDialog(NES.NESSyncSettings ss) + private DialogResult OpenNesHawkGamepadSettingsDialog(ISettingsAdapter settable) { - using NesControllerSettings form = new(this, ss); + using NesControllerSettings form = new(settable); return this.ShowDialogWithTempMute(form); } @@ -1456,16 +1456,16 @@ namespace BizHawk.Client.EmuHawk { _ = Emulator switch { - NES nesHawk => OpenNesHawkGamepadSettingsDialog(nesHawk.GetSyncSettings().Clone()), - SubNESHawk subNESHawk => OpenNesHawkGamepadSettingsDialog(subNESHawk.GetSyncSettings().Clone()), + NES => OpenNesHawkGamepadSettingsDialog(GetSettingsAdapterForLoadedCore()), + SubNESHawk => OpenNesHawkGamepadSettingsDialog(GetSettingsAdapterForLoadedCore()), QuickNES => OpenQuickNesGamepadSettingsDialog(), _ => DialogResult.None }; } - private DialogResult OpenNesHawkAdvancedSettingsDialog(NES.NESSyncSettings ss, bool hasMapperProperties) + private DialogResult OpenNesHawkAdvancedSettingsDialog(ISettingsAdapter settable, bool hasMapperProperties) { - using NESSyncSettingsForm form = new(this, this, ss, hasMapperProperties: hasMapperProperties); + using NESSyncSettingsForm form = new(this, settable, hasMapperProperties: hasMapperProperties); return this.ShowDialogWithTempMute(form); } @@ -1473,8 +1473,8 @@ namespace BizHawk.Client.EmuHawk { _ = Emulator switch { - NES nesHawk => OpenNesHawkAdvancedSettingsDialog(nesHawk.GetSyncSettings().Clone(), nesHawk.HasMapperProperties), - SubNESHawk subNESHawk => OpenNesHawkAdvancedSettingsDialog(subNESHawk.GetSyncSettings().Clone(), subNESHawk.HasMapperProperties), + NES nesHawk => OpenNesHawkAdvancedSettingsDialog(GetSettingsAdapterForLoadedCore(), nesHawk.HasMapperProperties), + SubNESHawk subNESHawk => OpenNesHawkAdvancedSettingsDialog(GetSettingsAdapterForLoadedCore(), subNESHawk.HasMapperProperties), _ => DialogResult.None }; } @@ -1520,9 +1520,9 @@ namespace BizHawk.Client.EmuHawk } } - private DialogResult OpenTI83PaletteSettingsDialog(TI83Common.TI83CommonSettings s) + private DialogResult OpenTI83PaletteSettingsDialog(ISettingsAdapter settable) { - using TI83PaletteConfig form = new(this, s); + using TI83PaletteConfig form = new(settable); return this.ShowDialogWithTempMute(form); } @@ -1530,8 +1530,8 @@ namespace BizHawk.Client.EmuHawk { var result = Emulator switch { - Emu83 emu83 => OpenTI83PaletteSettingsDialog(emu83.GetSettings().Clone()), - TI83 ti83Hawk => OpenTI83PaletteSettingsDialog(ti83Hawk.GetSettings().Clone()), + Emu83 => OpenTI83PaletteSettingsDialog(GetSettingsAdapterForLoadedCore()), + TI83 => OpenTI83PaletteSettingsDialog(GetSettingsAdapterForLoadedCore()), _ => DialogResult.None }; if (result.IsOk()) AddOnScreenMessage("Palette settings saved"); @@ -1544,9 +1544,9 @@ namespace BizHawk.Client.EmuHawk = MovieSession.Movie.NotActive(); } - private DialogResult OpenA7800HawkGamepadSettingsDialog(A7800Hawk.A7800SyncSettings ss) + private DialogResult OpenA7800HawkGamepadSettingsDialog(ISettingsAdapter settable) { - using A7800ControllerSettings form = new(this, ss); + using A7800ControllerSettings form = new(settable); return this.ShowDialogWithTempMute(form); } @@ -1554,14 +1554,14 @@ namespace BizHawk.Client.EmuHawk { _ = Emulator switch { - A7800Hawk a7800Hawk => OpenA7800HawkGamepadSettingsDialog(a7800Hawk.GetSyncSettings().Clone()), + A7800Hawk => OpenA7800HawkGamepadSettingsDialog(GetSettingsAdapterForLoadedCore()), _ => DialogResult.None }; } - private DialogResult OpenA7800HawkFilterSettingsDialog(A7800Hawk.A7800SyncSettings ss) + private DialogResult OpenA7800HawkFilterSettingsDialog(ISettingsAdapter settable) { - using A7800FilterSettings form = new(this, ss); + using A7800FilterSettings form = new(settable); return this.ShowDialogWithTempMute(form); } @@ -1569,13 +1569,13 @@ namespace BizHawk.Client.EmuHawk { _ = Emulator switch { - A7800Hawk a7800Hawk => OpenA7800HawkFilterSettingsDialog(a7800Hawk.GetSyncSettings().Clone()), + A7800Hawk => OpenA7800HawkFilterSettingsDialog(GetSettingsAdapterForLoadedCore()), _ => DialogResult.None }; } - private DialogResult OpenGambatteSettingsDialog(Gameboy gambatte) - => GBPrefs.DoGBPrefsDialog(Config, this, Game, this, MovieSession, gambatte); + private DialogResult OpenGambatteSettingsDialog(ISettingsAdapter settable, Gameboy gambatte) + => GBPrefs.DoGBPrefsDialog(Config, this, Game, MovieSession, settable, gambatte); private DialogResult OpenGBHawkSettingsDialog() => OpenGenericCoreConfig("Gameboy Settings"); @@ -1587,16 +1587,16 @@ namespace BizHawk.Client.EmuHawk { _ = Emulator switch { - Gameboy gambatte => OpenGambatteSettingsDialog(gambatte), + Gameboy gambatte => OpenGambatteSettingsDialog(GetSettingsAdapterForLoadedCore(), gambatte), GBHawk => OpenGBHawkSettingsDialog(), Sameboy => OpenSameBoySettingsDialog(), _ => DialogResult.None }; } - private DialogResult OpenSameBoyPaletteSettingsDialog(Sameboy.SameboySettings s) + private DialogResult OpenSameBoyPaletteSettingsDialog(ISettingsAdapter settable) { - using SameBoyColorChooserForm form = new(Config, this, Game, this, s); + using SameBoyColorChooserForm form = new(Config, this, Game, settable); return this.ShowDialogWithTempMute(form); } @@ -1604,7 +1604,7 @@ namespace BizHawk.Client.EmuHawk { _ = Emulator switch { - Sameboy sameBoy => OpenSameBoyPaletteSettingsDialog(sameBoy.GetSettings().Clone()), + Sameboy => OpenSameBoyPaletteSettingsDialog(GetSettingsAdapterForLoadedCore()), _ => DialogResult.None }; } @@ -1624,9 +1624,9 @@ namespace BizHawk.Client.EmuHawk PSXControllerSettingsMenuItem.Enabled = MovieSession.Movie.NotActive(); } - private DialogResult OpenOctoshockGamepadSettingsDialog(Octoshock.SyncSettings ss) + private DialogResult OpenOctoshockGamepadSettingsDialog(ISettingsAdapter settable) { - using PSXControllerConfig form = new(this, ss); + using PSXControllerConfig form = new(settable); return this.ShowDialogWithTempMute(form); } @@ -1634,19 +1634,19 @@ namespace BizHawk.Client.EmuHawk { _ = Emulator switch { - Octoshock octoshock => OpenOctoshockGamepadSettingsDialog(octoshock.GetSyncSettings().Clone()), + Octoshock => OpenOctoshockGamepadSettingsDialog(GetSettingsAdapterForLoadedCore()), _ => DialogResult.None }; } - private DialogResult OpenOctoshockSettingsDialog(Octoshock octoshock) - => PSXOptions.DoSettingsDialog(Config, this, this, octoshock); + private DialogResult OpenOctoshockSettingsDialog(ISettingsAdapter settable, Octoshock octoshock) + => PSXOptions.DoSettingsDialog(Config, this, settable, octoshock); private void PsxOptionsMenuItem_Click(object sender, EventArgs e) { var result = Emulator switch { - Octoshock octoshock => OpenOctoshockSettingsDialog(octoshock), + Octoshock octoshock => OpenOctoshockSettingsDialog(GetSettingsAdapterForLoadedCore(), octoshock), _ => DialogResult.None }; if (result.IsOk()) FrameBufferResized(); @@ -1672,15 +1672,15 @@ namespace BizHawk.Client.EmuHawk SnesGfxDebuggerMenuItem.Enabled = true; } - private DialogResult OpenOldBSNESGamepadSettingsDialog(LibsnesCore.SnesSyncSettings ss) + private DialogResult OpenOldBSNESGamepadSettingsDialog(ISettingsAdapter settable) { - using SNESControllerSettings form = new(this, ss); + using SNESControllerSettings form = new(settable); return this.ShowDialogWithTempMute(form); } - private DialogResult OpenBSNESGamepadSettingsDialog(BsnesCore.SnesSyncSettings ss) + private DialogResult OpenBSNESGamepadSettingsDialog(ISettingsAdapter settable) { - using BSNESControllerSettings form = new(this, ss); + using BSNESControllerSettings form = new(settable); return this.ShowDialogWithTempMute(form); } @@ -1688,8 +1688,8 @@ namespace BizHawk.Client.EmuHawk { _ = Emulator switch { - LibsnesCore oldBSNES => OpenOldBSNESGamepadSettingsDialog(oldBSNES.GetSyncSettings().Clone()), - BsnesCore bsnes => OpenBSNESGamepadSettingsDialog(bsnes.GetSyncSettings().Clone()), + LibsnesCore => OpenOldBSNESGamepadSettingsDialog(GetSettingsAdapterForLoadedCore()), + BsnesCore => OpenBSNESGamepadSettingsDialog(GetSettingsAdapterForLoadedCore()), _ => DialogResult.None }; } @@ -1699,18 +1699,18 @@ namespace BizHawk.Client.EmuHawk Tools.Load(); } - private DialogResult OpenOldBSNESSettingsDialog(LibsnesCore bsnes) - => SNESOptions.DoSettingsDialog(this, this, bsnes); + private DialogResult OpenOldBSNESSettingsDialog(ISettingsAdapter settable, LibsnesCore bsnes) + => SNESOptions.DoSettingsDialog(this, settable, bsnes); - private DialogResult OpenBSNESSettingsDialog(BsnesCore bsnes) - => BSNESOptions.DoSettingsDialog(this, this, bsnes); + private DialogResult OpenBSNESSettingsDialog(ISettingsAdapter settable, BsnesCore bsnes) + => BSNESOptions.DoSettingsDialog(this, settable, bsnes); private void SnesOptionsMenuItem_Click(object sender, EventArgs e) { _ = Emulator switch { - LibsnesCore oldBSNES => OpenOldBSNESSettingsDialog(oldBSNES), - BsnesCore bsnes => OpenBSNESSettingsDialog(bsnes), + LibsnesCore oldBSNES => OpenOldBSNESSettingsDialog(GetSettingsAdapterForLoadedCore(), oldBSNES), + BsnesCore bsnes => OpenBSNESSettingsDialog(GetSettingsAdapterForLoadedCore(), bsnes), _ => DialogResult.None }; } @@ -1746,9 +1746,9 @@ namespace BizHawk.Client.EmuHawk } } - private DialogResult OpenColecoHawkGamepadSettingsDialog(ColecoVision.ColecoSyncSettings ss) + private DialogResult OpenColecoHawkGamepadSettingsDialog(ISettingsAdapter settable) { - using ColecoControllerSettings form = new(this, ss); + using ColecoControllerSettings form = new(settable); return this.ShowDialogWithTempMute(form); } @@ -1756,7 +1756,7 @@ namespace BizHawk.Client.EmuHawk { _ = Emulator switch { - ColecoVision colecoHawk => OpenColecoHawkGamepadSettingsDialog(colecoHawk.GetSyncSettings().Clone()), + ColecoVision => OpenColecoHawkGamepadSettingsDialog(GetSettingsAdapterForLoadedCore()), _ => DialogResult.None }; } @@ -1777,24 +1777,24 @@ namespace BizHawk.Client.EmuHawk N64ExpansionSlotMenuItem.Enabled = !((N64)Emulator).IsOverridingUserExpansionSlotSetting; } - private DialogResult OpenMupen64PlusGraphicsSettingsDialog() + private DialogResult OpenMupen64PlusGraphicsSettingsDialog(ISettingsAdapter settable) { - using N64VideoPluginConfig form = new(this); + using N64VideoPluginConfig form = new(settable); return this.ShowDialogWithTempMute(form); } private void N64PluginSettingsMenuItem_Click(object sender, EventArgs e) { - if (OpenMupen64PlusGraphicsSettingsDialog().IsOk() + if (OpenMupen64PlusGraphicsSettingsDialog(GetSettingsAdapterFor()).IsOk() && Emulator is not N64) // If it's loaded, the reboot required message will appear { AddOnScreenMessage("Plugin settings saved"); } } - private DialogResult OpenMupen64PlusGamepadSettingsDialog(N64SyncSettings ss) + private DialogResult OpenMupen64PlusGamepadSettingsDialog(ISettingsAdapter settable) { - using N64ControllersSetup form = new(this, ss); + using N64ControllersSetup form = new(settable); return this.ShowDialogWithTempMute(form); } @@ -1802,7 +1802,7 @@ namespace BizHawk.Client.EmuHawk { _ = Emulator switch { - N64 mupen64Plus => OpenMupen64PlusGamepadSettingsDialog(mupen64Plus.GetSyncSettings().Clone()), + N64 => OpenMupen64PlusGamepadSettingsDialog(GetSettingsAdapterForLoadedCore()), _ => DialogResult.None }; } @@ -1831,14 +1831,14 @@ namespace BizHawk.Client.EmuHawk } } - private DialogResult OpenGambatteLinkSettingsDialog(GambatteLink gambatteLink) - => GBLPrefs.DoGBLPrefsDialog(Config, this, Game, this, MovieSession, gambatteLink); + private DialogResult OpenGambatteLinkSettingsDialog(ISettingsAdapter settable, GambatteLink gambatteLink) + => GBLPrefs.DoGBLPrefsDialog(Config, this, Game, MovieSession, settable, gambatteLink); private void GblSettingsMenuItem_Click(object sender, EventArgs e) { _ = Emulator switch { - GambatteLink gambatteLink => OpenGambatteLinkSettingsDialog(gambatteLink), + GambatteLink gambatteLink => OpenGambatteLinkSettingsDialog(GetSettingsAdapterForLoadedCore(), gambatteLink), _ => DialogResult.None }; } @@ -1949,9 +1949,9 @@ namespace BizHawk.Client.EmuHawk IntVControllerSettingsMenuItem.Enabled = MovieSession.Movie.NotActive(); } - private DialogResult OpenIntelliHawkGamepadSettingsDialog(Intellivision.IntvSyncSettings ss) + private DialogResult OpenIntelliHawkGamepadSettingsDialog(ISettingsAdapter settable) { - using IntvControllerSettings form = new(this, ss); + using IntvControllerSettings form = new(settable); return this.ShowDialogWithTempMute(form); } @@ -1959,14 +1959,14 @@ namespace BizHawk.Client.EmuHawk { _ = Emulator switch { - Intellivision intelliHawk => OpenIntelliHawkGamepadSettingsDialog(intelliHawk.GetSyncSettings().Clone()), + Intellivision => OpenIntelliHawkGamepadSettingsDialog(GetSettingsAdapterForLoadedCore()), _ => DialogResult.None }; } - private DialogResult OpenZXHawkGamepadSettingsDialog(ZXSpectrum.ZXSpectrumSyncSettings ss) + private DialogResult OpenZXHawkGamepadSettingsDialog(ISettingsAdapter settable) { - using ZxSpectrumJoystickSettings form = new(this, this, ss); + using ZxSpectrumJoystickSettings form = new(this, settable); return this.ShowDialogWithTempMute(form); } @@ -1974,14 +1974,14 @@ namespace BizHawk.Client.EmuHawk { _ = Emulator switch { - ZXSpectrum zxHawk => OpenZXHawkGamepadSettingsDialog(zxHawk.GetSyncSettings().Clone()), + ZXSpectrum => OpenZXHawkGamepadSettingsDialog(GetSettingsAdapterForLoadedCore()), _ => DialogResult.None }; } - private DialogResult OpenZXHawkSyncSettingsDialog(ZXSpectrum.ZXSpectrumSyncSettings ss) + private DialogResult OpenZXHawkSyncSettingsDialog(ISettingsAdapter settable) { - using ZxSpectrumCoreEmulationSettings form = new(this, ss); + using ZxSpectrumCoreEmulationSettings form = new(settable); return this.ShowDialogWithTempMute(form); } @@ -1989,14 +1989,14 @@ namespace BizHawk.Client.EmuHawk { _ = Emulator switch { - ZXSpectrum zxHawk => OpenZXHawkSyncSettingsDialog(zxHawk.GetSyncSettings().Clone()), + ZXSpectrum => OpenZXHawkSyncSettingsDialog(GetSettingsAdapterForLoadedCore()), _ => DialogResult.None }; } - private DialogResult OpenZXHawkSettingsDialog(ZXSpectrum.ZXSpectrumSettings s) + private DialogResult OpenZXHawkSettingsDialog(ISettingsAdapter settable) { - using ZxSpectrumNonSyncSettings form = new(this, s); + using ZxSpectrumNonSyncSettings form = new(settable); return this.ShowDialogWithTempMute(form); } @@ -2004,14 +2004,14 @@ namespace BizHawk.Client.EmuHawk { _ = Emulator switch { - ZXSpectrum zxHawk => OpenZXHawkSettingsDialog(zxHawk.GetSettings().Clone()), + ZXSpectrum => OpenZXHawkSettingsDialog(GetSettingsAdapterForLoadedCore()), _ => DialogResult.None }; } - private DialogResult OpenZXHawkAudioSettingsDialog(ZXSpectrum.ZXSpectrumSettings s) + private DialogResult OpenZXHawkAudioSettingsDialog(ISettingsAdapter settable) { - using ZxSpectrumAudioSettings form = new(this, s); + using ZxSpectrumAudioSettings form = new(settable); return this.ShowDialogWithTempMute(form); } @@ -2019,7 +2019,7 @@ namespace BizHawk.Client.EmuHawk { _ = Emulator switch { - ZXSpectrum zxHawk => OpenZXHawkAudioSettingsDialog(zxHawk.GetSettings().Clone()), + ZXSpectrum => OpenZXHawkAudioSettingsDialog(GetSettingsAdapterForLoadedCore()), _ => DialogResult.None }; } @@ -2126,9 +2126,9 @@ namespace BizHawk.Client.EmuHawk } } - private DialogResult OpenCPCHawkSyncSettingsDialog(AmstradCPC.AmstradCPCSyncSettings ss) + private DialogResult OpenCPCHawkSyncSettingsDialog(ISettingsAdapter settable) { - using AmstradCpcCoreEmulationSettings form = new(this, ss); + using AmstradCpcCoreEmulationSettings form = new(settable); return this.ShowDialogWithTempMute(form); } @@ -2136,14 +2136,14 @@ namespace BizHawk.Client.EmuHawk { _ = Emulator switch { - AmstradCPC cpcHawk => OpenCPCHawkSyncSettingsDialog(cpcHawk.GetSyncSettings().Clone()), + AmstradCPC => OpenCPCHawkSyncSettingsDialog(GetSettingsAdapterForLoadedCore()), _ => DialogResult.None }; } - private DialogResult OpenCPCHawkAudioSettingsDialog(AmstradCPC.AmstradCPCSettings s) + private DialogResult OpenCPCHawkAudioSettingsDialog(ISettingsAdapter settable) { - using AmstradCpcAudioSettings form = new(this, s); + using AmstradCpcAudioSettings form = new(settable); return this.ShowDialogWithTempMute(form); } @@ -2151,7 +2151,7 @@ namespace BizHawk.Client.EmuHawk { _ = Emulator switch { - AmstradCPC cpcHawk => OpenCPCHawkAudioSettingsDialog(cpcHawk.GetSettings().Clone()), + AmstradCPC => OpenCPCHawkAudioSettingsDialog(GetSettingsAdapterForLoadedCore()), _ => DialogResult.None }; } @@ -2233,9 +2233,9 @@ namespace BizHawk.Client.EmuHawk AmstradCPCDisksSubMenu.DropDownItems.AddRange(items.ToArray()); } - private DialogResult OpenCPCHawkSettingsDialog(AmstradCPC.AmstradCPCSettings s) + private DialogResult OpenCPCHawkSettingsDialog(ISettingsAdapter settable) { - using AmstradCpcNonSyncSettings form = new(this, s); + using AmstradCpcNonSyncSettings form = new(settable); return this.ShowDialogWithTempMute(form); } @@ -2243,7 +2243,7 @@ namespace BizHawk.Client.EmuHawk { _ = Emulator switch { - AmstradCPC cpcHawk => OpenCPCHawkSettingsDialog(cpcHawk.GetSettings().Clone()), + AmstradCPC => OpenCPCHawkSettingsDialog(GetSettingsAdapterForLoadedCore()), _ => DialogResult.None }; } diff --git a/src/BizHawk.Client.EmuHawk/MainForm.cs b/src/BizHawk.Client.EmuHawk/MainForm.cs index e9fe1657ba..1e12ab4271 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.cs @@ -45,7 +45,7 @@ using BizHawk.Common.CollectionExtensions; namespace BizHawk.Client.EmuHawk { - public partial class MainForm : FormBase, IDialogParent, IMainFormForApi, IMainFormForConfig, IMainFormForTools + public partial class MainForm : FormBase, IDialogParent, IMainFormForApi, IMainFormForTools { private void MainForm_Load(object sender, EventArgs e) { diff --git a/src/BizHawk.Client.EmuHawk/config/A7800/A7800ControllerSettings.cs b/src/BizHawk.Client.EmuHawk/config/A7800/A7800ControllerSettings.cs index 432d0cafc1..9e473f089a 100644 --- a/src/BizHawk.Client.EmuHawk/config/A7800/A7800ControllerSettings.cs +++ b/src/BizHawk.Client.EmuHawk/config/A7800/A7800ControllerSettings.cs @@ -1,20 +1,21 @@ using System; using System.Windows.Forms; + +using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Atari.A7800Hawk; namespace BizHawk.Client.EmuHawk { public partial class A7800ControllerSettings : Form { - private readonly IMainFormForConfig _mainForm; + private readonly ISettingsAdapter _settable; + private readonly A7800Hawk.A7800SyncSettings _syncSettings; - public A7800ControllerSettings( - IMainFormForConfig mainForm, - A7800Hawk.A7800SyncSettings syncSettings) + public A7800ControllerSettings(ISettingsAdapter settable) { - _mainForm = mainForm; - _syncSettings = syncSettings; + _settable = settable; + _syncSettings = (A7800Hawk.A7800SyncSettings) settable.GetSyncSettings(); InitializeComponent(); Icon = Properties.Resources.GameControllerIcon; } @@ -42,7 +43,7 @@ namespace BizHawk.Client.EmuHawk _syncSettings.Port1 = Port1ComboBox.SelectedItem.ToString(); _syncSettings.Port2 = Port2ComboBox.SelectedItem.ToString(); - _mainForm.GetSettingsAdapterForLoadedCore().PutCoreSyncSettings(_syncSettings); + _settable.PutCoreSyncSettings(_syncSettings); } DialogResult = DialogResult.OK; diff --git a/src/BizHawk.Client.EmuHawk/config/A7800/A7800FilterSettings.cs b/src/BizHawk.Client.EmuHawk/config/A7800/A7800FilterSettings.cs index 1c78394b4d..7386432e56 100644 --- a/src/BizHawk.Client.EmuHawk/config/A7800/A7800FilterSettings.cs +++ b/src/BizHawk.Client.EmuHawk/config/A7800/A7800FilterSettings.cs @@ -1,21 +1,22 @@ using System; using System.Linq; using System.Windows.Forms; + +using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Atari.A7800Hawk; namespace BizHawk.Client.EmuHawk { public partial class A7800FilterSettings : Form { - private readonly IMainFormForConfig _mainForm; + private readonly ISettingsAdapter _settable; + private readonly A7800Hawk.A7800SyncSettings _syncSettings; - public A7800FilterSettings( - IMainFormForConfig mainForm, - A7800Hawk.A7800SyncSettings syncSettings) + public A7800FilterSettings(ISettingsAdapter settable) { - _mainForm = mainForm; - _syncSettings = syncSettings; + _settable = settable; + _syncSettings = (A7800Hawk.A7800SyncSettings) _settable.GetSyncSettings(); InitializeComponent(); Icon = Properties.Resources.GameControllerIcon; } @@ -39,7 +40,7 @@ namespace BizHawk.Client.EmuHawk if (changed) { _syncSettings.Filter = Port1ComboBox.SelectedItem.ToString(); - _mainForm.GetSettingsAdapterForLoadedCore().PutCoreSyncSettings(_syncSettings); + _settable.PutCoreSyncSettings(_syncSettings); } DialogResult = DialogResult.OK; diff --git a/src/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCAudioSettings.cs b/src/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCAudioSettings.cs index 3ae996a263..5e95e7f5c4 100644 --- a/src/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCAudioSettings.cs +++ b/src/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCAudioSettings.cs @@ -1,20 +1,21 @@ using System; using System.Windows.Forms; + +using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Computers.AmstradCPC; namespace BizHawk.Client.EmuHawk { public partial class AmstradCpcAudioSettings : Form { - private readonly IMainFormForConfig _mainForm; + private readonly ISettingsAdapter _settable; + private readonly AmstradCPC.AmstradCPCSettings _settings; - public AmstradCpcAudioSettings( - IMainFormForConfig mainForm, - AmstradCPC.AmstradCPCSettings settings) + public AmstradCpcAudioSettings(ISettingsAdapter settable) { - _mainForm = mainForm; - _settings = settings; + _settable = settable; + _settings = (AmstradCPC.AmstradCPCSettings) _settable.GetSettings(); InitializeComponent(); Icon = Properties.Resources.GameControllerIcon; @@ -51,7 +52,7 @@ namespace BizHawk.Client.EmuHawk _settings.TapeVolume = tapeVolumetrackBar.Value; _settings.AYVolume = ayVolumetrackBar.Value; - _mainForm.GetSettingsAdapterForLoadedCore().PutCoreSettings(_settings); + _settable.PutCoreSettings(_settings); } DialogResult = DialogResult.OK; Close(); diff --git a/src/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCCoreEmulationSettings.cs b/src/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCCoreEmulationSettings.cs index 2887647ee3..179c014657 100644 --- a/src/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCCoreEmulationSettings.cs +++ b/src/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCCoreEmulationSettings.cs @@ -1,19 +1,21 @@ using System; using System.Windows.Forms; + +using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Computers.AmstradCPC; namespace BizHawk.Client.EmuHawk { public partial class AmstradCpcCoreEmulationSettings : Form { - private readonly IMainFormForConfig _mainForm; + private readonly ISettingsAdapter _settable; + private readonly AmstradCPC.AmstradCPCSyncSettings _syncSettings; - public AmstradCpcCoreEmulationSettings(IMainFormForConfig mainForm, - AmstradCPC.AmstradCPCSyncSettings syncSettings) + public AmstradCpcCoreEmulationSettings(ISettingsAdapter settable) { - _mainForm = mainForm; - _syncSettings = syncSettings; + _settable = settable; + _syncSettings = (AmstradCPC.AmstradCPCSyncSettings) _settable.GetSyncSettings(); InitializeComponent(); } @@ -59,7 +61,7 @@ namespace BizHawk.Client.EmuHawk _syncSettings.DeterministicEmulation = determEmucheckBox1.Checked; _syncSettings.AutoStartStopTape = autoLoadcheckBox1.Checked; - _mainForm.GetSettingsAdapterForLoadedCore().PutCoreSyncSettings(_syncSettings); + _settable.PutCoreSyncSettings(_syncSettings); DialogResult = DialogResult.OK; Close(); diff --git a/src/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCNonSyncSettings.cs b/src/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCNonSyncSettings.cs index 646573e5b0..644093431a 100644 --- a/src/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCNonSyncSettings.cs +++ b/src/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCNonSyncSettings.cs @@ -1,20 +1,21 @@ using System; using System.Windows.Forms; + +using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Computers.AmstradCPC; namespace BizHawk.Client.EmuHawk { public partial class AmstradCpcNonSyncSettings : Form { - private readonly IMainFormForConfig _mainForm; + private readonly ISettingsAdapter _settable; + private readonly AmstradCPC.AmstradCPCSettings _settings; - public AmstradCpcNonSyncSettings( - IMainFormForConfig mainForm, - AmstradCPC.AmstradCPCSettings settings) + public AmstradCpcNonSyncSettings(ISettingsAdapter settable) { - _mainForm = mainForm; - _settings = settings; + _settable = settable; + _settings = (AmstradCPC.AmstradCPCSettings) _settable.GetSettings(); InitializeComponent(); Icon = Properties.Resources.GameControllerIcon; } @@ -40,7 +41,7 @@ namespace BizHawk.Client.EmuHawk { _settings.OSDMessageVerbosity = (AmstradCPC.OSDVerbosity)Enum.Parse(typeof(AmstradCPC.OSDVerbosity), osdMessageVerbositycomboBox1.SelectedItem.ToString()); - _mainForm.GetSettingsAdapterForLoadedCore().PutCoreSettings(_settings); + _settable.PutCoreSettings(_settings); DialogResult = DialogResult.OK; Close(); diff --git a/src/BizHawk.Client.EmuHawk/config/ColecoVision/ColecoControllerSettings.cs b/src/BizHawk.Client.EmuHawk/config/ColecoVision/ColecoControllerSettings.cs index 0f4e3c44d2..bf7f4a2577 100644 --- a/src/BizHawk.Client.EmuHawk/config/ColecoVision/ColecoControllerSettings.cs +++ b/src/BizHawk.Client.EmuHawk/config/ColecoVision/ColecoControllerSettings.cs @@ -1,20 +1,21 @@ using System; using System.Windows.Forms; + +using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.ColecoVision; namespace BizHawk.Client.EmuHawk { public partial class ColecoControllerSettings : Form { - private readonly IMainFormForConfig _mainForm; + private readonly ISettingsAdapter _settable; + private readonly ColecoVision.ColecoSyncSettings _syncSettings; - public ColecoControllerSettings( - IMainFormForConfig mainForm, - ColecoVision.ColecoSyncSettings settings) + public ColecoControllerSettings(ISettingsAdapter settable) { - _mainForm = mainForm; - _syncSettings = settings; + _settable = settable; + _syncSettings = (ColecoVision.ColecoSyncSettings) _settable.GetSyncSettings(); InitializeComponent(); Icon = Properties.Resources.GameControllerIcon; } @@ -42,7 +43,7 @@ namespace BizHawk.Client.EmuHawk _syncSettings.Port1 = Port1ComboBox.SelectedItem.ToString(); _syncSettings.Port2 = Port2ComboBox.SelectedItem.ToString(); - _mainForm.GetSettingsAdapterForLoadedCore().PutCoreSyncSettings(_syncSettings); + _settable.PutCoreSyncSettings(_syncSettings); } DialogResult = DialogResult.OK; diff --git a/src/BizHawk.Client.EmuHawk/config/GB/GBLPrefs.cs b/src/BizHawk.Client.EmuHawk/config/GB/GBLPrefs.cs index 395f2bcf86..7c9b80f23c 100644 --- a/src/BizHawk.Client.EmuHawk/config/GB/GBLPrefs.cs +++ b/src/BizHawk.Client.EmuHawk/config/GB/GBLPrefs.cs @@ -48,12 +48,13 @@ namespace BizHawk.Client.EmuHawk private bool SyncSettingsChanged => gbPrefControl1.SyncSettingsChanged || gbPrefControl2.SyncSettingsChanged || gbPrefControl3.SyncSettingsChanged || gbPrefControl4.SyncSettingsChanged; + /// TODO only use public static DialogResult DoGBLPrefsDialog( Config config, IDialogParent dialogParent, IGameInfo game, - IMainFormForConfig mainForm, IMovieSession movieSession, + ISettingsAdapter settable, GambatteLink gambatte) { var s = gambatte.GetSettings(); @@ -74,7 +75,7 @@ namespace BizHawk.Client.EmuHawk gambatte.PutSettings(s); if (dlg.SyncSettingsChanged) { - mainForm.GetSettingsAdapterForLoadedCore().PutCoreSyncSettings(ss); + settable.PutCoreSyncSettings(ss); } } return result; diff --git a/src/BizHawk.Client.EmuHawk/config/GB/GBPrefs.cs b/src/BizHawk.Client.EmuHawk/config/GB/GBPrefs.cs index 9bf1144d4e..1cdcd6c9be 100644 --- a/src/BizHawk.Client.EmuHawk/config/GB/GBPrefs.cs +++ b/src/BizHawk.Client.EmuHawk/config/GB/GBPrefs.cs @@ -17,12 +17,13 @@ namespace BizHawk.Client.EmuHawk Icon = Properties.Resources.GambatteIcon; } + /// TODO only use public static DialogResult DoGBPrefsDialog( Config config, IDialogParent dialogParent, IGameInfo game, - IMainFormForConfig mainForm, IMovieSession movieSession, + ISettingsAdapter settable, Gameboy gb) { var s = gb.GetSettings(); @@ -38,7 +39,7 @@ namespace BizHawk.Client.EmuHawk gb.PutSettings(s); if (dlg.gbPrefControl1.SyncSettingsChanged) { - mainForm.GetSettingsAdapterForLoadedCore().PutCoreSyncSettings(ss); + settable.PutCoreSyncSettings(ss); } } return result; diff --git a/src/BizHawk.Client.EmuHawk/config/GB/SameBoyColorChooserForm.cs b/src/BizHawk.Client.EmuHawk/config/GB/SameBoyColorChooserForm.cs index 8439c2ef0e..dd10798ead 100644 --- a/src/BizHawk.Client.EmuHawk/config/GB/SameBoyColorChooserForm.cs +++ b/src/BizHawk.Client.EmuHawk/config/GB/SameBoyColorChooserForm.cs @@ -12,9 +12,11 @@ namespace BizHawk.Client.EmuHawk { public partial class SameBoyColorChooserForm : Form, IDialogParent { - private readonly IMainFormForConfig _mainForm; private readonly IGameInfo _game; private readonly Config _config; + + private readonly ISettingsAdapter _settable; + private readonly Sameboy.SameboySettings _settings; public IDialogController DialogController { get; } @@ -23,13 +25,12 @@ namespace BizHawk.Client.EmuHawk Config config, IDialogController dialogController, IGameInfo game, - IMainFormForConfig mainForm, - Sameboy.SameboySettings settings) + ISettingsAdapter settable) { - _mainForm = mainForm; _game = game; _config = config; - _settings = settings; + _settable = settable; + _settings = (Sameboy.SameboySettings) _settable.GetSettings(); DialogController = dialogController; InitializeComponent(); SetAllColors(_settings.GetCustomPalette()); @@ -324,7 +325,7 @@ namespace BizHawk.Client.EmuHawk _settings.SetCustomPalette(colors); - _mainForm.GetSettingsAdapterForLoadedCore().PutCoreSettings(_settings); + _settable.PutCoreSettings(_settings); DialogResult = DialogResult.OK; Close(); diff --git a/src/BizHawk.Client.EmuHawk/config/INTV/IntvControllerSettings.cs b/src/BizHawk.Client.EmuHawk/config/INTV/IntvControllerSettings.cs index 8579db5983..3305341838 100644 --- a/src/BizHawk.Client.EmuHawk/config/INTV/IntvControllerSettings.cs +++ b/src/BizHawk.Client.EmuHawk/config/INTV/IntvControllerSettings.cs @@ -1,20 +1,21 @@ using System; using System.Windows.Forms; + +using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Intellivision; namespace BizHawk.Client.EmuHawk { public partial class IntvControllerSettings : Form { - private readonly IMainFormForConfig _mainForm; + private readonly ISettingsAdapter _settable; + private readonly Intellivision.IntvSyncSettings _syncSettings; - public IntvControllerSettings( - IMainFormForConfig mainForm, - Intellivision.IntvSyncSettings syncSettings) + public IntvControllerSettings(ISettingsAdapter settable) { - _mainForm = mainForm; - _syncSettings = syncSettings; + _settable = settable; + _syncSettings = (Intellivision.IntvSyncSettings) _settable.GetSyncSettings(); InitializeComponent(); Icon = Properties.Resources.GameControllerIcon; } @@ -42,7 +43,7 @@ namespace BizHawk.Client.EmuHawk _syncSettings.Port1 = Port1ComboBox.SelectedItem.ToString(); _syncSettings.Port2 = Port2ComboBox.SelectedItem.ToString(); - _mainForm.GetSettingsAdapterForLoadedCore().PutCoreSyncSettings(_syncSettings); + _settable.PutCoreSyncSettings(_syncSettings); } DialogResult = DialogResult.OK; diff --git a/src/BizHawk.Client.EmuHawk/config/N64/N64ControllersSetup.cs b/src/BizHawk.Client.EmuHawk/config/N64/N64ControllersSetup.cs index 3ae4bacc45..ea095f1a3e 100644 --- a/src/BizHawk.Client.EmuHawk/config/N64/N64ControllersSetup.cs +++ b/src/BizHawk.Client.EmuHawk/config/N64/N64ControllersSetup.cs @@ -3,13 +3,15 @@ using System.Collections.Generic; using System.Linq; using System.Windows.Forms; +using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Nintendo.N64; namespace BizHawk.Client.EmuHawk { public partial class N64ControllersSetup : Form { - private readonly IMainFormForConfig _mainForm; + private readonly ISettingsAdapter _settable; + private readonly N64SyncSettings _syncSettings; private List ControllerSettingControls => Controls @@ -17,12 +19,10 @@ namespace BizHawk.Client.EmuHawk .OrderBy(n => n.ControllerNumber) .ToList(); - public N64ControllersSetup( - IMainFormForConfig mainForm, - N64SyncSettings syncSettings) + public N64ControllersSetup(ISettingsAdapter settable) { - _mainForm = mainForm; - _syncSettings = syncSettings; + _settable = settable; + _syncSettings = (N64SyncSettings) _settable.GetSyncSettings(); InitializeComponent(); Icon = Properties.Resources.GameControllerIcon; } @@ -52,7 +52,7 @@ namespace BizHawk.Client.EmuHawk _syncSettings.Controllers[c.ControllerNumber - 1].PakType = c.PakType; }); - _mainForm.GetSettingsAdapterForLoadedCore().PutCoreSyncSettings(_syncSettings); + _settable.PutCoreSyncSettings(_syncSettings); DialogResult = DialogResult.OK; Close(); diff --git a/src/BizHawk.Client.EmuHawk/config/N64/N64VideoPluginconfig.cs b/src/BizHawk.Client.EmuHawk/config/N64/N64VideoPluginconfig.cs index 0f694a5cd7..60b4626a22 100644 --- a/src/BizHawk.Client.EmuHawk/config/N64/N64VideoPluginconfig.cs +++ b/src/BizHawk.Client.EmuHawk/config/N64/N64VideoPluginconfig.cs @@ -4,13 +4,15 @@ using System.Windows.Forms; using BizHawk.Common.StringExtensions; using BizHawk.Common.ReflectionExtensions; +using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Nintendo.N64; namespace BizHawk.Client.EmuHawk { public partial class N64VideoPluginConfig : Form { - private readonly IMainFormForConfig _mainForm; + private readonly ISettingsAdapter _settable; + private readonly N64Settings _s; private readonly N64SyncSettings _ss; @@ -37,13 +39,12 @@ namespace BizHawk.Client.EmuHawk private readonly bool _programmaticallyChangingPluginComboBox = false; - public N64VideoPluginConfig(IMainFormForConfig mainForm) + public N64VideoPluginConfig(ISettingsAdapter settable) { - _mainForm = mainForm; + _settable = settable; - var settable = _mainForm.GetSettingsAdapterFor(); - _s = (N64Settings) settable.GetSettings(); - _ss = (N64SyncSettings) settable.GetSyncSettings(); + _s = (N64Settings) _settable.GetSettings(); + _ss = (N64SyncSettings) _settable.GetSyncSettings(); InitializeComponent(); Icon = Properties.Resources.MonitorIcon; @@ -102,9 +103,8 @@ namespace BizHawk.Client.EmuHawk .ToString() .GetEnumFromDescription(); - var settable = _mainForm.GetSettingsAdapterFor(); - settable.PutCoreSettings(_s); - settable.PutCoreSyncSettings(_ss); + _settable.PutCoreSettings(_s); + _settable.PutCoreSyncSettings(_ss); } private void N64VideoPluginConfig_Load(object sender, EventArgs e) diff --git a/src/BizHawk.Client.EmuHawk/config/NES/NESGraphicsConfig.cs b/src/BizHawk.Client.EmuHawk/config/NES/NESGraphicsConfig.cs index 45e3a3d1f9..3e98008dac 100644 --- a/src/BizHawk.Client.EmuHawk/config/NES/NESGraphicsConfig.cs +++ b/src/BizHawk.Client.EmuHawk/config/NES/NESGraphicsConfig.cs @@ -15,8 +15,10 @@ namespace BizHawk.Client.EmuHawk // Allow selection of palette file from archive // Hotkeys for BG & Sprite display toggle // NTSC filter settings? Hue, Tint (This should probably be a client thing, not a nes specific thing?) - private readonly IMainFormForConfig _mainForm; private readonly Config _config; + + private readonly ISettingsAdapter _settable; + private NES.NESSettings _settings; //private Bitmap _bmp; @@ -25,12 +27,11 @@ namespace BizHawk.Client.EmuHawk public NESGraphicsConfig( Config config, IDialogController dialogController, - IMainFormForConfig mainForm, - NES.NESSettings settings) + ISettingsAdapter settable) { - _mainForm = mainForm; _config = config; - _settings = settings; + _settable = settable; + _settings = (NES.NESSettings) _settable.GetSettings(); DialogController = dialogController; InitializeComponent(); } @@ -153,7 +154,7 @@ namespace BizHawk.Client.EmuHawk _settings.BackgroundColor &= 0x00FFFFFF; } - _mainForm.GetSettingsAdapterForLoadedCore().PutCoreSettings(_settings); + _settable.PutCoreSettings(_settings); Close(); } diff --git a/src/BizHawk.Client.EmuHawk/config/NES/NESSyncSettingsForm.cs b/src/BizHawk.Client.EmuHawk/config/NES/NESSyncSettingsForm.cs index 5562580757..87653e1210 100644 --- a/src/BizHawk.Client.EmuHawk/config/NES/NESSyncSettingsForm.cs +++ b/src/BizHawk.Client.EmuHawk/config/NES/NESSyncSettingsForm.cs @@ -5,26 +5,28 @@ using System.Text; using System.Windows.Forms; using BizHawk.Client.Common; +using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Nintendo.NES; namespace BizHawk.Client.EmuHawk { public partial class NESSyncSettingsForm : Form, IDialogParent { - private readonly IMainFormForConfig _mainForm; private readonly DataTableDictionaryBind _dataTableDictionary; + + private readonly ISettingsAdapter _settable; + private readonly NES.NESSyncSettings _syncSettings; public IDialogController DialogController { get; } public NESSyncSettingsForm( IDialogController dialogController, - IMainFormForConfig mainForm, - NES.NESSyncSettings syncSettings, + ISettingsAdapter settable, bool hasMapperProperties) { - _mainForm = mainForm; - _syncSettings = syncSettings; + _settable = settable; + _syncSettings = (NES.NESSyncSettings) _settable.GetSyncSettings(); DialogController = dialogController; InitializeComponent(); HelpBtn.Image = Properties.Resources.Help; @@ -93,7 +95,7 @@ namespace BizHawk.Client.EmuHawk DialogResult = DialogResult.OK; if (changed) { - _mainForm.GetSettingsAdapterForLoadedCore().PutCoreSyncSettings(_syncSettings); + _settable.PutCoreSyncSettings(_syncSettings); } } diff --git a/src/BizHawk.Client.EmuHawk/config/NES/NESVSSettings.cs b/src/BizHawk.Client.EmuHawk/config/NES/NESVSSettings.cs index a6d541e276..f640e4359a 100644 --- a/src/BizHawk.Client.EmuHawk/config/NES/NESVSSettings.cs +++ b/src/BizHawk.Client.EmuHawk/config/NES/NESVSSettings.cs @@ -1,21 +1,21 @@ using System; using System.Windows.Forms; + +using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Nintendo.NES; namespace BizHawk.Client.EmuHawk { public partial class NesVsSettings : Form { - private readonly IMainFormForConfig _mainForm; - private readonly NES.NESSyncSettings _settings; - + private readonly ISettingsAdapter _settable; - public NesVsSettings( - IMainFormForConfig mainForm, - NES.NESSyncSettings syncSettings) + private readonly NES.NESSyncSettings _settings; + + public NesVsSettings(ISettingsAdapter settable) { - _mainForm = mainForm; - _settings = syncSettings; + _settable = settable; + _settings = (NES.NESSyncSettings) _settable.GetSyncSettings(); InitializeComponent(); } @@ -42,7 +42,7 @@ namespace BizHawk.Client.EmuHawk _settings.VSDipswitches.Dip_Switch_7 = Dipswitch7CheckBox.Checked; _settings.VSDipswitches.Dip_Switch_8 = Dipswitch8CheckBox.Checked; - _mainForm.GetSettingsAdapterForLoadedCore().PutCoreSyncSettings(_settings); + _settable.PutCoreSyncSettings(_settings); Close(); } diff --git a/src/BizHawk.Client.EmuHawk/config/NES/NesControllerSettings.cs b/src/BizHawk.Client.EmuHawk/config/NES/NesControllerSettings.cs index e24c5b267d..b14c2e2661 100644 --- a/src/BizHawk.Client.EmuHawk/config/NES/NesControllerSettings.cs +++ b/src/BizHawk.Client.EmuHawk/config/NES/NesControllerSettings.cs @@ -1,21 +1,22 @@ using System; using System.Linq; using System.Windows.Forms; + +using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Nintendo.NES; namespace BizHawk.Client.EmuHawk { public partial class NesControllerSettings : Form { - private readonly IMainFormForConfig _mainForm; + private readonly ISettingsAdapter _settable; + private readonly NES.NESSyncSettings _syncSettings; - public NesControllerSettings( - IMainFormForConfig mainForm, - NES.NESSyncSettings syncSettings) + public NesControllerSettings(ISettingsAdapter settable) { - _mainForm = mainForm; - _syncSettings = syncSettings; + _settable = settable; + _syncSettings = (NES.NESSyncSettings) _settable.GetSyncSettings(); InitializeComponent(); Icon = Properties.Resources.GameControllerIcon; @@ -53,7 +54,7 @@ namespace BizHawk.Client.EmuHawk if (changed) { - _mainForm.GetSettingsAdapterForLoadedCore().PutCoreSyncSettings(_syncSettings); + _settable.PutCoreSyncSettings(_syncSettings); } DialogResult = DialogResult.OK; diff --git a/src/BizHawk.Client.EmuHawk/config/NES/QuickNesConfig.cs b/src/BizHawk.Client.EmuHawk/config/NES/QuickNesConfig.cs index 48eb1c148f..adbc3a77d8 100644 --- a/src/BizHawk.Client.EmuHawk/config/NES/QuickNesConfig.cs +++ b/src/BizHawk.Client.EmuHawk/config/NES/QuickNesConfig.cs @@ -11,18 +11,17 @@ namespace BizHawk.Client.EmuHawk { public partial class QuickNesConfig : Form { - private readonly IMainFormForConfig _mainForm; private readonly Config _config; + + private readonly ISettingsAdapter _settable; + private readonly QuickNES.QuickNESSettings _settings; - public QuickNesConfig( - IMainFormForConfig mainForm, - Config config, - QuickNES.QuickNESSettings settings) + public QuickNesConfig(Config config, ISettingsAdapter settable) { - _mainForm = mainForm; _config = config; - _settings = settings; + _settable = settable; + _settings = (QuickNES.QuickNESSettings) _settable.GetSettings(); InitializeComponent(); Icon = Properties.Resources.QuickNesIcon; } @@ -106,7 +105,7 @@ namespace BizHawk.Client.EmuHawk private void ButtonOk_Click(object sender, EventArgs e) { - _mainForm.GetSettingsAdapterForLoadedCore().PutCoreSettings(_settings); + _settable.PutCoreSettings(_settings); DialogResult = DialogResult.OK; Close(); } diff --git a/src/BizHawk.Client.EmuHawk/config/PSX/PSXControllerConfig.cs b/src/BizHawk.Client.EmuHawk/config/PSX/PSXControllerConfig.cs index 8a3839f224..ae18241484 100644 --- a/src/BizHawk.Client.EmuHawk/config/PSX/PSXControllerConfig.cs +++ b/src/BizHawk.Client.EmuHawk/config/PSX/PSXControllerConfig.cs @@ -1,21 +1,21 @@ using System; using System.Windows.Forms; +using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Sony.PSX; namespace BizHawk.Client.EmuHawk { public partial class PSXControllerConfig : Form { - private readonly IMainFormForConfig _mainForm; + private readonly ISettingsAdapter _settable; + private readonly Octoshock.SyncSettings _syncSettings; - public PSXControllerConfig( - IMainFormForConfig mainForm, - Octoshock.SyncSettings syncSettings) + public PSXControllerConfig(ISettingsAdapter settable) { - _mainForm = mainForm; - _syncSettings = syncSettings; + _settable = settable; + _syncSettings = (Octoshock.SyncSettings) _settable.GetSyncSettings(); InitializeComponent(); Icon = Properties.Resources.GameControllerIcon; } @@ -141,7 +141,7 @@ namespace BizHawk.Client.EmuHawk private void BtnOk_Click(object sender, EventArgs e) { _syncSettings.FIOConfig = UserConfigFromGui(); - _mainForm.GetSettingsAdapterForLoadedCore().PutCoreSyncSettings(_syncSettings); + _settable.PutCoreSyncSettings(_syncSettings); DialogResult = DialogResult.OK; Close(); diff --git a/src/BizHawk.Client.EmuHawk/config/PSX/PSXOptions.cs b/src/BizHawk.Client.EmuHawk/config/PSX/PSXOptions.cs index 289c0e4ee8..5aa25e006a 100644 --- a/src/BizHawk.Client.EmuHawk/config/PSX/PSXOptions.cs +++ b/src/BizHawk.Client.EmuHawk/config/PSX/PSXOptions.cs @@ -4,6 +4,7 @@ using System.Windows.Forms; using BizHawk.Emulation.Cores.Sony.PSX; using BizHawk.Client.Common; +using BizHawk.Emulation.Common; namespace BizHawk.Client.EmuHawk { @@ -12,20 +13,22 @@ namespace BizHawk.Client.EmuHawk // backups of the labels for string replacing private readonly string _lblPixelProText, _lblMednafenText, _lblTweakedMednafenText; + private readonly ISettingsAdapter _settable; + public IDialogController DialogController { get; } private PSXOptions( Config config, IDialogController dialogController, - IMainFormForConfig mainForm, + ISettingsAdapter settable, Octoshock.Settings settings, Octoshock.SyncSettings syncSettings, OctoshockDll.eVidStandard vidStandard, Size currentVideoSize) { InitializeComponent(); - _mainForm = mainForm; _config = config; + _settable = settable; _settings = settings; _syncSettings = syncSettings; _previewVideoStandard = vidStandard; @@ -67,7 +70,6 @@ namespace BizHawk.Client.EmuHawk } private Size _previewVideoSize; - private readonly IMainFormForConfig _mainForm; private readonly Config _config; private readonly OctoshockDll.eVidStandard _previewVideoStandard; private readonly Octoshock.Settings _settings; @@ -80,17 +82,18 @@ namespace BizHawk.Client.EmuHawk DialogController.ShowMessageBox("Finetuned Display Options will take effect if you OK from PSX Options"); } + /// TODO only use public static DialogResult DoSettingsDialog( Config config, IDialogParent dialogParent, - IMainFormForConfig mainForm, + ISettingsAdapter settable, Octoshock psx) { var s = psx.GetSettings(); var ss = psx.GetSyncSettings(); var vid = psx.SystemVidStandard; var size = psx.CurrentVideoSize; - using var dlg = new PSXOptions(config, dialogParent.DialogController, mainForm, s, ss, vid, size); + using var dlg = new PSXOptions(config, dialogParent.DialogController, settable, s, ss, vid, size); return dialogParent.ShowDialogAsChild(dlg); } @@ -131,9 +134,8 @@ namespace BizHawk.Client.EmuHawk SyncSettingsFromGui(_settings, _syncSettings); _settings.Validate(); - var settable = _mainForm.GetSettingsAdapterForLoadedCore(); - settable.PutCoreSettings(_settings); - settable.PutCoreSyncSettings(_syncSettings); + _settable.PutCoreSettings(_settings); + _settable.PutCoreSyncSettings(_syncSettings); DialogResult = DialogResult.OK; Close(); diff --git a/src/BizHawk.Client.EmuHawk/config/ProfileConfig.cs b/src/BizHawk.Client.EmuHawk/config/ProfileConfig.cs index 78c3b9e6d7..f674d37ada 100644 --- a/src/BizHawk.Client.EmuHawk/config/ProfileConfig.cs +++ b/src/BizHawk.Client.EmuHawk/config/ProfileConfig.cs @@ -15,11 +15,11 @@ namespace BizHawk.Client.EmuHawk { public partial class ProfileConfig : Form { - private readonly IMainFormForConfig _mainForm; + private readonly MainForm _mainForm; private readonly Config _config; - public ProfileConfig(Config config, IMainFormForConfig mainForm) + public ProfileConfig(Config config, MainForm mainForm) { _mainForm = mainForm; _config = config; diff --git a/src/BizHawk.Client.EmuHawk/config/SNES/BSNESControllerConfig.cs b/src/BizHawk.Client.EmuHawk/config/SNES/BSNESControllerConfig.cs index fa801e601e..bee670affb 100644 --- a/src/BizHawk.Client.EmuHawk/config/SNES/BSNESControllerConfig.cs +++ b/src/BizHawk.Client.EmuHawk/config/SNES/BSNESControllerConfig.cs @@ -1,21 +1,21 @@ using System; using System.Windows.Forms; + +using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Nintendo.BSNES; -using BizHawk.Emulation.Cores.Nintendo.SNES; namespace BizHawk.Client.EmuHawk { public partial class BSNESControllerSettings : Form { - private readonly IMainFormForConfig _mainForm; + private readonly ISettingsAdapter _settable; + private readonly BsnesCore.SnesSyncSettings _syncSettings; - public BSNESControllerSettings( - IMainFormForConfig mainForm, - BsnesCore.SnesSyncSettings syncSettings) + public BSNESControllerSettings(ISettingsAdapter settable) { - _mainForm = mainForm; - _syncSettings = syncSettings; + _settable = settable; + _syncSettings = (BsnesCore.SnesSyncSettings) _settable.GetSyncSettings(); InitializeComponent(); Icon = Properties.Resources.GameControllerIcon; } @@ -41,7 +41,7 @@ namespace BizHawk.Client.EmuHawk _syncSettings.RightPort = (BsnesApi.BSNES_INPUT_DEVICE) Port2ComboBox.SelectedIndex; _syncSettings.LimitAnalogChangeSensitivity = LimitAnalogChangeCheckBox.Checked; - _mainForm.GetSettingsAdapterForLoadedCore().PutCoreSyncSettings(_syncSettings); + _settable.PutCoreSyncSettings(_syncSettings); } DialogResult = DialogResult.OK; diff --git a/src/BizHawk.Client.EmuHawk/config/SNES/BSNESOptions.cs b/src/BizHawk.Client.EmuHawk/config/SNES/BSNESOptions.cs index fad7a0c8d6..1a3859da78 100644 --- a/src/BizHawk.Client.EmuHawk/config/SNES/BSNESOptions.cs +++ b/src/BizHawk.Client.EmuHawk/config/SNES/BSNESOptions.cs @@ -2,6 +2,7 @@ using System.Windows.Forms; using BizHawk.Client.Common; +using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Nintendo.BSNES; namespace BizHawk.Client.EmuHawk @@ -13,7 +14,8 @@ namespace BizHawk.Client.EmuHawk InitializeComponent(); } - public static DialogResult DoSettingsDialog(IDialogParent dialogParent, IMainFormForConfig mainForm, BsnesCore bsnes) + /// TODO only use + public static DialogResult DoSettingsDialog(IDialogParent dialogParent, ISettingsAdapter settable, BsnesCore bsnes) { var s = bsnes.GetSettings(); var ss = bsnes.GetSyncSettings(); @@ -67,7 +69,6 @@ namespace BizHawk.Client.EmuHawk s.ShowBG4_0 = dlg.ShowBg4_0; s.ShowBG4_1 = dlg.ShowBg4_1; - var settable = mainForm.GetSettingsAdapterForLoadedCore(); settable.PutCoreSettings(s); settable.PutCoreSyncSettings(ss); } diff --git a/src/BizHawk.Client.EmuHawk/config/SNES/SNESControllerConfig.cs b/src/BizHawk.Client.EmuHawk/config/SNES/SNESControllerConfig.cs index ff7e7dd0fd..5401ff2e2d 100644 --- a/src/BizHawk.Client.EmuHawk/config/SNES/SNESControllerConfig.cs +++ b/src/BizHawk.Client.EmuHawk/config/SNES/SNESControllerConfig.cs @@ -1,22 +1,22 @@ using System; using System.Windows.Forms; +using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Nintendo.SNES; namespace BizHawk.Client.EmuHawk { public partial class SNESControllerSettings : Form { - private readonly IMainFormForConfig _mainForm; + private readonly ISettingsAdapter _settable; + private readonly LibsnesCore.SnesSyncSettings _syncSettings; private bool _suppressDropdownChangeEvents; - public SNESControllerSettings( - IMainFormForConfig mainForm, - LibsnesCore.SnesSyncSettings syncSettings) + public SNESControllerSettings(ISettingsAdapter settable) { - _mainForm = mainForm; - _syncSettings = syncSettings; + _settable = settable; + _syncSettings = (LibsnesCore.SnesSyncSettings) _settable.GetSyncSettings(); InitializeComponent(); Icon = Properties.Resources.GameControllerIcon; } @@ -44,7 +44,7 @@ namespace BizHawk.Client.EmuHawk _syncSettings.RightPort = (LibsnesControllerDeck.ControllerType)Enum.Parse(typeof(LibsnesControllerDeck.ControllerType), Port2ComboBox.SelectedItem.ToString()); _syncSettings.LimitAnalogChangeSensitivity = LimitAnalogChangeCheckBox.Checked; - _mainForm.GetSettingsAdapterForLoadedCore().PutCoreSyncSettings(_syncSettings); + _settable.PutCoreSyncSettings(_syncSettings); } DialogResult = DialogResult.OK; diff --git a/src/BizHawk.Client.EmuHawk/config/SNES/SNESOptions.cs b/src/BizHawk.Client.EmuHawk/config/SNES/SNESOptions.cs index a03a9d2b41..52b71796cd 100644 --- a/src/BizHawk.Client.EmuHawk/config/SNES/SNESOptions.cs +++ b/src/BizHawk.Client.EmuHawk/config/SNES/SNESOptions.cs @@ -2,6 +2,7 @@ using System.Windows.Forms; using BizHawk.Client.Common; +using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Nintendo.SNES; namespace BizHawk.Client.EmuHawk @@ -16,7 +17,8 @@ namespace BizHawk.Client.EmuHawk private bool _suppressDoubleSize; private bool _userDoubleSizeOption; - public static DialogResult DoSettingsDialog(IDialogParent dialogParent, IMainFormForConfig mainForm, LibsnesCore bsnes) + /// TODO only use + public static DialogResult DoSettingsDialog(IDialogParent dialogParent, ISettingsAdapter settable, LibsnesCore bsnes) { var s = bsnes.GetSettings(); var ss = bsnes.GetSyncSettings(); @@ -50,7 +52,6 @@ namespace BizHawk.Client.EmuHawk s.ShowBG3_0 = s.ShowBG3_1 = dlg.ShowBg3; s.ShowBG4_0 = s.ShowBG4_1 = dlg.ShowBg4; - var settable = mainForm.GetSettingsAdapterForLoadedCore(); settable.PutCoreSettings(s); settable.PutCoreSyncSettings(ss); } diff --git a/src/BizHawk.Client.EmuHawk/config/TI83/TI83PaletteConfig.cs b/src/BizHawk.Client.EmuHawk/config/TI83/TI83PaletteConfig.cs index eb5fb0e04a..030480a65a 100644 --- a/src/BizHawk.Client.EmuHawk/config/TI83/TI83PaletteConfig.cs +++ b/src/BizHawk.Client.EmuHawk/config/TI83/TI83PaletteConfig.cs @@ -1,21 +1,22 @@ using System; using System.Drawing; using System.Windows.Forms; + +using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Calculators.TI83; namespace BizHawk.Client.EmuHawk { public partial class TI83PaletteConfig : Form { - private readonly IMainFormForConfig _mainForm; + private readonly ISettingsAdapter _settable; + private readonly TI83Common.TI83CommonSettings _settings; - public TI83PaletteConfig( - IMainFormForConfig mainForm, - TI83Common.TI83CommonSettings settings) + public TI83PaletteConfig(ISettingsAdapter settable) { - _mainForm = mainForm; - _settings = settings; + _settable = settable; + _settings = (TI83Common.TI83CommonSettings) _settable.GetSettings(); InitializeComponent(); Icon = Properties.Resources.CalculateIcon; } @@ -32,7 +33,7 @@ namespace BizHawk.Client.EmuHawk _settings.BGColor = (uint)BackgroundPanel.BackColor.ToArgb(); _settings.ForeColor = (uint)ForeGroundPanel.BackColor.ToArgb(); - _mainForm.GetSettingsAdapterForLoadedCore().PutCoreSettings(_settings); + _settable.PutCoreSettings(_settings); DialogResult = DialogResult.OK; Close(); diff --git a/src/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumAudioSettings.cs b/src/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumAudioSettings.cs index 295b092244..ad5e108ed4 100644 --- a/src/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumAudioSettings.cs +++ b/src/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumAudioSettings.cs @@ -1,20 +1,21 @@ using System; using System.Windows.Forms; + +using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Computers.SinclairSpectrum; namespace BizHawk.Client.EmuHawk { public partial class ZxSpectrumAudioSettings : Form { - private readonly IMainFormForConfig _mainForm; + private readonly ISettingsAdapter _settable; + private readonly ZXSpectrum.ZXSpectrumSettings _settings; - public ZxSpectrumAudioSettings( - IMainFormForConfig mainForm, - ZXSpectrum.ZXSpectrumSettings settings) + public ZxSpectrumAudioSettings(ISettingsAdapter settable) { - _mainForm = mainForm; - _settings = settings; + _settable = settable; + _settings = (ZXSpectrum.ZXSpectrumSettings) _settable.GetSettings(); InitializeComponent(); Icon = Properties.Resources.GameControllerIcon; } @@ -55,7 +56,7 @@ namespace BizHawk.Client.EmuHawk _settings.EarVolume = earVolumetrackBar.Value; _settings.AYVolume = ayVolumetrackBar.Value; - _mainForm.GetSettingsAdapterForLoadedCore().PutCoreSettings(_settings); + _settable.PutCoreSettings(_settings); } DialogResult = DialogResult.OK; Close(); diff --git a/src/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumCoreEmulationSettings.cs b/src/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumCoreEmulationSettings.cs index c544f5c13d..026e5cf9e2 100644 --- a/src/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumCoreEmulationSettings.cs +++ b/src/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumCoreEmulationSettings.cs @@ -1,20 +1,21 @@ using System; using System.Windows.Forms; + +using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Computers.SinclairSpectrum; namespace BizHawk.Client.EmuHawk { public partial class ZxSpectrumCoreEmulationSettings : Form { - private readonly IMainFormForConfig _mainForm; + private readonly ISettingsAdapter _settable; + private readonly ZXSpectrum.ZXSpectrumSyncSettings _syncSettings; - public ZxSpectrumCoreEmulationSettings( - IMainFormForConfig mainForm, - ZXSpectrum.ZXSpectrumSyncSettings syncSettings) + public ZxSpectrumCoreEmulationSettings(ISettingsAdapter settable) { - _mainForm = mainForm; - _syncSettings = syncSettings; + _settable = settable; + _syncSettings = (ZXSpectrum.ZXSpectrumSyncSettings) _settable.GetSyncSettings(); InitializeComponent(); Icon = Properties.Resources.GameControllerIcon; } @@ -61,7 +62,7 @@ namespace BizHawk.Client.EmuHawk _syncSettings.DeterministicEmulation = determEmucheckBox1.Checked; _syncSettings.AutoLoadTape = autoLoadcheckBox1.Checked; - _mainForm.GetSettingsAdapterForLoadedCore().PutCoreSyncSettings(_syncSettings); + _settable.PutCoreSyncSettings(_syncSettings); } DialogResult = DialogResult.OK; Close(); diff --git a/src/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumJoystickSettings.cs b/src/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumJoystickSettings.cs index 99d49f9d17..7c09673812 100644 --- a/src/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumJoystickSettings.cs +++ b/src/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumJoystickSettings.cs @@ -3,25 +3,24 @@ using System.Linq; using System.Windows.Forms; using BizHawk.Client.Common; +using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Computers.SinclairSpectrum; namespace BizHawk.Client.EmuHawk { public partial class ZxSpectrumJoystickSettings : Form, IDialogParent { - private readonly IMainFormForConfig _mainForm; + private readonly ISettingsAdapter _settable; + private readonly ZXSpectrum.ZXSpectrumSyncSettings _syncSettings; private string[] _possibleControllers; public IDialogController DialogController { get; } - public ZxSpectrumJoystickSettings( - IDialogController dialogController, - IMainFormForConfig mainForm, - ZXSpectrum.ZXSpectrumSyncSettings syncSettings) + public ZxSpectrumJoystickSettings(IDialogController dialogController, ISettingsAdapter settable) { - _mainForm = mainForm; - _syncSettings = syncSettings; + _settable = settable; + _syncSettings = (ZXSpectrum.ZXSpectrumSyncSettings) _settable.GetSyncSettings(); DialogController = dialogController; InitializeComponent(); Icon = Properties.Resources.GameControllerIcon; @@ -107,7 +106,7 @@ namespace BizHawk.Client.EmuHawk _syncSettings.JoystickType2 = (JoystickType)Enum.Parse(typeof(JoystickType), Port2ComboBox.SelectedItem.ToString()); _syncSettings.JoystickType3 = (JoystickType)Enum.Parse(typeof(JoystickType), Port3ComboBox.SelectedItem.ToString()); - _mainForm.GetSettingsAdapterForLoadedCore().PutCoreSyncSettings(_syncSettings); + _settable.PutCoreSyncSettings(_syncSettings); DialogResult = DialogResult.OK; Close(); diff --git a/src/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumNonSyncSettings.cs b/src/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumNonSyncSettings.cs index d64052068d..f208ae4964 100644 --- a/src/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumNonSyncSettings.cs +++ b/src/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumNonSyncSettings.cs @@ -1,21 +1,22 @@ using System; using System.Windows.Forms; + +using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Computers.SinclairSpectrum; namespace BizHawk.Client.EmuHawk { public partial class ZxSpectrumNonSyncSettings : Form { - private readonly IMainFormForConfig _mainForm; + private readonly ISettingsAdapter _settable; + private readonly ZXSpectrum.ZXSpectrumSettings _settings; private int _bgColor; - public ZxSpectrumNonSyncSettings( - IMainFormForConfig mainForm, - ZXSpectrum.ZXSpectrumSettings settings) + public ZxSpectrumNonSyncSettings(ISettingsAdapter settable) { - _mainForm = mainForm; - _settings = settings; + _settable = settable; + _settings = (ZXSpectrum.ZXSpectrumSettings) _settable.GetSettings(); InitializeComponent(); Icon = Properties.Resources.GameControllerIcon; } @@ -58,7 +59,7 @@ namespace BizHawk.Client.EmuHawk _settings.BackgroundColor = _bgColor; _settings.UseCoreBorderForBackground = checkBoxShowCoreBrdColor.Checked; - _mainForm.GetSettingsAdapterForLoadedCore().PutCoreSettings(_settings); + _settable.PutCoreSettings(_settings); DialogResult = DialogResult.OK; Close();