diff --git a/src/BizHawk.Client.EmuHawk/MainForm.Events.cs b/src/BizHawk.Client.EmuHawk/MainForm.Events.cs index ae66c47f0c..6aa7b48301 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.Events.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.Events.cs @@ -932,7 +932,7 @@ namespace BizHawk.Client.EmuHawk private void FileExtensionsMenuItem_Click(object sender, EventArgs e) { - using var form = new FileExtensionPreferences(Config); + using var form = new FileExtensionPreferences(Config.PreferredPlatformsForExtensions); var result = form.ShowDialog(); AddOnScreenMessage(result.IsOk() ? "Rom Extension Preferences changed" diff --git a/src/BizHawk.Client.EmuHawk/config/FileExtensionPreferences.cs b/src/BizHawk.Client.EmuHawk/config/FileExtensionPreferences.cs index b8a15cef9d..f83e5ab365 100644 --- a/src/BizHawk.Client.EmuHawk/config/FileExtensionPreferences.cs +++ b/src/BizHawk.Client.EmuHawk/config/FileExtensionPreferences.cs @@ -1,19 +1,18 @@ using System; +using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Windows.Forms; -using BizHawk.Client.Common; - namespace BizHawk.Client.EmuHawk { public partial class FileExtensionPreferences : Form { - private readonly Config _config; + private readonly IDictionary _preferredPlatformsForExtensions; - public FileExtensionPreferences(Config config) + public FileExtensionPreferences(IDictionary preferredPlatformsForExtensions) { - _config = config; + _preferredPlatformsForExtensions = preferredPlatformsForExtensions; InitializeComponent(); } @@ -21,9 +20,9 @@ namespace BizHawk.Client.EmuHawk { int spacing = UIHelper.ScaleY(30); int count = 0; - foreach (var kvp in _config.PreferredPlatformsForExtensions) + foreach (var kvp in _preferredPlatformsForExtensions) { - var picker = new FileExtensionPreferencesPicker + var picker = new FileExtensionPreferencesPicker(_preferredPlatformsForExtensions) { FileExtension = kvp.Key, OriginalPreference = kvp.Value, @@ -39,9 +38,10 @@ namespace BizHawk.Client.EmuHawk { foreach (var picker in PrefPanel.Controls.OfType()) { - _config.PreferredPlatformsForExtensions[picker.FileExtension] = picker.CurrentlySelectedSystemId; + _preferredPlatformsForExtensions[picker.FileExtension] = picker.CurrentlySelectedSystemId; } + DialogResult = DialogResult.OK; Close(); } diff --git a/src/BizHawk.Client.EmuHawk/config/FileExtensionPreferencesPicker.cs b/src/BizHawk.Client.EmuHawk/config/FileExtensionPreferencesPicker.cs index 8b6eb14a13..55f6d4ad18 100644 --- a/src/BizHawk.Client.EmuHawk/config/FileExtensionPreferencesPicker.cs +++ b/src/BizHawk.Client.EmuHawk/config/FileExtensionPreferencesPicker.cs @@ -9,10 +9,13 @@ namespace BizHawk.Client.EmuHawk { public partial class FileExtensionPreferencesPicker : UserControl { - public FileExtensionPreferencesPicker() + private IDictionary _preferredPlatformsForExtensions; + + public FileExtensionPreferencesPicker(IDictionary preferredPlatformsForExtensions) { - InitializeComponent(); + _preferredPlatformsForExtensions = preferredPlatformsForExtensions; _availableSystems = new SystemLookup().AllSystems.ToList(); + InitializeComponent(); } private readonly List _availableSystems; @@ -47,14 +50,14 @@ namespace BizHawk.Client.EmuHawk { PopulatePlatforms(); - var selectedSystemId = GlobalWin.Config.PreferredPlatformsForExtensions[FileExtension]; + var selectedSystemId = _preferredPlatformsForExtensions[FileExtension]; if (!string.IsNullOrEmpty(selectedSystemId)) { var selectedSystem = _availableSystems.FirstOrDefault(s => s.SystemId == selectedSystemId); var selectedItem = PlatformDropdown.Items .OfType() - .FirstOrDefault(item => item == (selectedSystem != null ? selectedSystem.FullName : "")); + .FirstOrDefault(item => item == (selectedSystem?.FullName ?? "")); if (selectedItem != null) {