FilePreferences config - fix message when clicking ok, reduce dependency from the entire config file to the only object it sets, remove usage of GlobalWin
This commit is contained in:
parent
7ab20f5667
commit
8bb055b392
|
@ -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"
|
||||
|
|
|
@ -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<string, string> _preferredPlatformsForExtensions;
|
||||
|
||||
public FileExtensionPreferences(Config config)
|
||||
public FileExtensionPreferences(IDictionary<string, string> 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<FileExtensionPreferencesPicker>())
|
||||
{
|
||||
_config.PreferredPlatformsForExtensions[picker.FileExtension] = picker.CurrentlySelectedSystemId;
|
||||
_preferredPlatformsForExtensions[picker.FileExtension] = picker.CurrentlySelectedSystemId;
|
||||
}
|
||||
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
|
||||
|
|
|
@ -9,10 +9,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public partial class FileExtensionPreferencesPicker : UserControl
|
||||
{
|
||||
public FileExtensionPreferencesPicker()
|
||||
private IDictionary<string, string> _preferredPlatformsForExtensions;
|
||||
|
||||
public FileExtensionPreferencesPicker(IDictionary<string, string> preferredPlatformsForExtensions)
|
||||
{
|
||||
InitializeComponent();
|
||||
_preferredPlatformsForExtensions = preferredPlatformsForExtensions;
|
||||
_availableSystems = new SystemLookup().AllSystems.ToList();
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private readonly List<SystemLookup.SystemInfo> _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<string>()
|
||||
.FirstOrDefault(item => item == (selectedSystem != null ? selectedSystem.FullName : ""));
|
||||
.FirstOrDefault(item => item == (selectedSystem?.FullName ?? ""));
|
||||
|
||||
if (selectedItem != null)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue