From ee84c92ada86b6fdaba1dbc4f16e26c1310be8f2 Mon Sep 17 00:00:00 2001 From: adelikat Date: Fri, 3 Jan 2020 14:19:42 -0600 Subject: [PATCH] pass in dependencies to OpenAdvancedChooser --- BizHawk.Client.EmuHawk/MainForm.Events.cs | 4 +-- BizHawk.Client.EmuHawk/OpenAdvancedChooser.cs | 29 ++++++++++--------- BizHawk.sln.DotSettings | 1 + 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/BizHawk.Client.EmuHawk/MainForm.Events.cs b/BizHawk.Client.EmuHawk/MainForm.Events.cs index 46d039deae..366997f573 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Events.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Events.cs @@ -284,7 +284,7 @@ namespace BizHawk.Client.EmuHawk StopAVIMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Stop A/V"].Bindings; CaptureOSDMenuItem.Checked = Config.AVI_CaptureOSD; - RecordAVMenuItem.Enabled = !OSTailoredCode.IsUnixHost && !string.IsNullOrEmpty(Global.Config.VideoWriter) && _currAviWriter == null; + RecordAVMenuItem.Enabled = !OSTailoredCode.IsUnixHost && !string.IsNullOrEmpty(Config.VideoWriter) && _currAviWriter == null; SynclessRecordingMenuItem.Enabled = !OSTailoredCode.IsUnixHost; if (_currAviWriter == null) @@ -314,7 +314,7 @@ namespace BizHawk.Client.EmuHawk private void OpenAdvancedMenuItem_Click(object sender, EventArgs e) { - using var oac = new OpenAdvancedChooser(this); + using var oac = new OpenAdvancedChooser(this, Config); if (oac.ShowHawkDialog() == DialogResult.Cancel) { return; diff --git a/BizHawk.Client.EmuHawk/OpenAdvancedChooser.cs b/BizHawk.Client.EmuHawk/OpenAdvancedChooser.cs index 504c42844a..42d9a1e3c6 100644 --- a/BizHawk.Client.EmuHawk/OpenAdvancedChooser.cs +++ b/BizHawk.Client.EmuHawk/OpenAdvancedChooser.cs @@ -7,20 +7,22 @@ using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Libretro; using BizHawk.Client.Common; -//these match strings from OpenAdvance. should we make them constants in there? - +// these match strings from OpenAdvance. should we make them constants in there? namespace BizHawk.Client.EmuHawk { public partial class OpenAdvancedChooser : Form { private readonly MainForm _mainForm; + private readonly Config _config; public AdvancedRomLoaderType Result; public string SuggestedExtensionFilter; + private RetroDescription _currentDescription; - public OpenAdvancedChooser(MainForm mainForm) + public OpenAdvancedChooser(MainForm mainForm, Config config) { _mainForm = mainForm; + _config = config; InitializeComponent(); @@ -39,21 +41,22 @@ namespace BizHawk.Client.EmuHawk RefreshLibretroCore(false); } - RetroDescription CurrentDescription; - void RefreshLibretroCore(bool bootstrap) + private void RefreshLibretroCore(bool bootstrap) { txtLibretroCore.Text = ""; btnLibretroLaunchNoGame.Enabled = false; btnLibretroLaunchGame.Enabled = false; - var core = Global.Config.LibretroCore; + var core = _config.LibretroCore; if (string.IsNullOrEmpty(core)) + { return; + } txtLibretroCore.Text = core; - CurrentDescription = null; + _currentDescription = null; - //scan the current libretro core to see if it can be launched with NoGame,and other stuff + // scan the current libretro core to see if it can be launched with NoGame,and other stuff try { //OLD COMMENTS: @@ -70,7 +73,7 @@ namespace BizHawk.Client.EmuHawk //print descriptive information var descr = retro.Description; - CurrentDescription = descr; + _currentDescription = descr; Console.WriteLine($"core name: {descr.LibraryName} version {descr.LibraryVersion}"); Console.WriteLine($"extensions: {descr.ValidExtensions}"); Console.WriteLine($"{nameof(descr.NeedsRomAsPath)}: {descr.NeedsRomAsPath}"); @@ -93,15 +96,15 @@ namespace BizHawk.Client.EmuHawk { //build a list of extensions suggested for use for this core StringWriter sw = new StringWriter(); - foreach(var ext in CurrentDescription.ValidExtensions.Split('|')) + foreach(var ext in _currentDescription.ValidExtensions.Split('|')) sw.Write("*.{0};",ext); var filter = sw.ToString(); filter = filter.Substring(0,filter.Length-1); //remove last semicolon var args = new List { "Rom Files" }; - if (!CurrentDescription.NeedsArchives) + if (!_currentDescription.NeedsArchives) filter += ";%ARCH%"; args.Add(filter); - if (!CurrentDescription.NeedsArchives) + if (!_currentDescription.NeedsArchives) { args.Add("Archive Files"); args.Add("%ARCH%"); @@ -155,7 +158,7 @@ namespace BizHawk.Client.EmuHawk private void txtLibretroCore_DragDrop(object sender, DragEventArgs e) { var filePaths = (string[])e.Data.GetData(DataFormats.FileDrop); - Global.Config.LibretroCore = filePaths[0]; + _config.LibretroCore = filePaths[0]; RefreshLibretroCore(false); } } diff --git a/BizHawk.sln.DotSettings b/BizHawk.sln.DotSettings index fa36f122e1..839260d942 100644 --- a/BizHawk.sln.DotSettings +++ b/BizHawk.sln.DotSettings @@ -221,6 +221,7 @@ True True True + True True True True