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;
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;

View File

@ -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<string> { "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);
}
}

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/=delaminated/@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/=desync/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Dipswitch/@EntryIndexedValue">True</s:Boolean>