pass in dependencies to OpenAdvancedChooser

This commit is contained in:
adelikat 2020-01-03 14:19:42 -06:00
parent 6183d6e3a6
commit ee84c92ada
3 changed files with 19 additions and 15 deletions

View File

@ -284,7 +284,7 @@ namespace BizHawk.Client.EmuHawk
StopAVIMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Stop A/V"].Bindings; StopAVIMenuItem.ShortcutKeyDisplayString = Config.HotkeyBindings["Stop A/V"].Bindings;
CaptureOSDMenuItem.Checked = Config.AVI_CaptureOSD; 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; SynclessRecordingMenuItem.Enabled = !OSTailoredCode.IsUnixHost;
if (_currAviWriter == null) if (_currAviWriter == null)
@ -314,7 +314,7 @@ namespace BizHawk.Client.EmuHawk
private void OpenAdvancedMenuItem_Click(object sender, EventArgs e) 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) if (oac.ShowHawkDialog() == DialogResult.Cancel)
{ {
return; return;

View File

@ -7,20 +7,22 @@ using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores.Libretro; using BizHawk.Emulation.Cores.Libretro;
using BizHawk.Client.Common; 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 namespace BizHawk.Client.EmuHawk
{ {
public partial class OpenAdvancedChooser : Form public partial class OpenAdvancedChooser : Form
{ {
private readonly MainForm _mainForm; private readonly MainForm _mainForm;
private readonly Config _config;
public AdvancedRomLoaderType Result; public AdvancedRomLoaderType Result;
public string SuggestedExtensionFilter; public string SuggestedExtensionFilter;
private RetroDescription _currentDescription;
public OpenAdvancedChooser(MainForm mainForm) public OpenAdvancedChooser(MainForm mainForm, Config config)
{ {
_mainForm = mainForm; _mainForm = mainForm;
_config = config;
InitializeComponent(); InitializeComponent();
@ -39,21 +41,22 @@ namespace BizHawk.Client.EmuHawk
RefreshLibretroCore(false); RefreshLibretroCore(false);
} }
RetroDescription CurrentDescription; private void RefreshLibretroCore(bool bootstrap)
void RefreshLibretroCore(bool bootstrap)
{ {
txtLibretroCore.Text = ""; txtLibretroCore.Text = "";
btnLibretroLaunchNoGame.Enabled = false; btnLibretroLaunchNoGame.Enabled = false;
btnLibretroLaunchGame.Enabled = false; btnLibretroLaunchGame.Enabled = false;
var core = Global.Config.LibretroCore; var core = _config.LibretroCore;
if (string.IsNullOrEmpty(core)) if (string.IsNullOrEmpty(core))
{
return; return;
}
txtLibretroCore.Text = core; 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 try
{ {
//OLD COMMENTS: //OLD COMMENTS:
@ -70,7 +73,7 @@ namespace BizHawk.Client.EmuHawk
//print descriptive information //print descriptive information
var descr = retro.Description; var descr = retro.Description;
CurrentDescription = descr; _currentDescription = descr;
Console.WriteLine($"core name: {descr.LibraryName} version {descr.LibraryVersion}"); Console.WriteLine($"core name: {descr.LibraryName} version {descr.LibraryVersion}");
Console.WriteLine($"extensions: {descr.ValidExtensions}"); Console.WriteLine($"extensions: {descr.ValidExtensions}");
Console.WriteLine($"{nameof(descr.NeedsRomAsPath)}: {descr.NeedsRomAsPath}"); 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 //build a list of extensions suggested for use for this core
StringWriter sw = new StringWriter(); StringWriter sw = new StringWriter();
foreach(var ext in CurrentDescription.ValidExtensions.Split('|')) foreach(var ext in _currentDescription.ValidExtensions.Split('|'))
sw.Write("*.{0};",ext); sw.Write("*.{0};",ext);
var filter = sw.ToString(); var filter = sw.ToString();
filter = filter.Substring(0,filter.Length-1); //remove last semicolon filter = filter.Substring(0,filter.Length-1); //remove last semicolon
var args = new List<string> { "Rom Files" }; var args = new List<string> { "Rom Files" };
if (!CurrentDescription.NeedsArchives) if (!_currentDescription.NeedsArchives)
filter += ";%ARCH%"; filter += ";%ARCH%";
args.Add(filter); args.Add(filter);
if (!CurrentDescription.NeedsArchives) if (!_currentDescription.NeedsArchives)
{ {
args.Add("Archive Files"); args.Add("Archive Files");
args.Add("%ARCH%"); args.Add("%ARCH%");
@ -155,7 +158,7 @@ namespace BizHawk.Client.EmuHawk
private void txtLibretroCore_DragDrop(object sender, DragEventArgs e) private void txtLibretroCore_DragDrop(object sender, DragEventArgs e)
{ {
var filePaths = (string[])e.Data.GetData(DataFormats.FileDrop); var filePaths = (string[])e.Data.GetData(DataFormats.FileDrop);
Global.Config.LibretroCore = filePaths[0]; _config.LibretroCore = filePaths[0];
RefreshLibretroCore(false); RefreshLibretroCore(false);
} }
} }

View File

@ -221,6 +221,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=Dega/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Dega/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=delaminated/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=delaminated/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Dendy/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Dendy/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=descr/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=desmume/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=desmume/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=desync/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=desync/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Dipswitch/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Dipswitch/@EntryIndexedValue">True</s:Boolean>