CoreFileProvider - pass dependencies in, instead of using Globals
This commit is contained in:
parent
b1cac9ba00
commit
81d6ca335e
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using BizHawk.Common.PathExtensions;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
@ -9,22 +10,31 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
private readonly FirmwareManager _firmwareManager;
|
||||
private readonly Action<string> _showWarning;
|
||||
private readonly PathEntryCollection _pathEntries;
|
||||
private readonly IDictionary<string, string> _firmwareUserSpecifications;
|
||||
|
||||
public CoreFileProvider(Action<string> showWarning, FirmwareManager firmwareManager)
|
||||
public CoreFileProvider(
|
||||
Action<string> showWarning,
|
||||
FirmwareManager firmwareManager,
|
||||
PathEntryCollection pathEntries,
|
||||
IDictionary<string, string> firmwareUserSpecifications)
|
||||
{
|
||||
_showWarning = showWarning;
|
||||
_firmwareManager = firmwareManager;
|
||||
_pathEntries = pathEntries;
|
||||
_firmwareManager = firmwareManager;
|
||||
_firmwareUserSpecifications = firmwareUserSpecifications;
|
||||
}
|
||||
|
||||
public string DllPath() => PathUtils.GetDllDirectory();
|
||||
|
||||
// Poop
|
||||
public string GetRetroSaveRAMDirectory(GameInfo game)
|
||||
=> Global.Config.PathEntries.RetroSaveRamAbsolutePath(game, Global.MovieSession.Movie.IsActive(), Global.MovieSession.Movie.Filename);
|
||||
=> _pathEntries.RetroSaveRamAbsolutePath(game, Global.MovieSession.Movie.IsActive(), Global.MovieSession.Movie.Filename);
|
||||
|
||||
// Poop
|
||||
public string GetRetroSystemPath(GameInfo game)
|
||||
=> Global.Config.PathEntries.RetroSystemAbsolutePath(game);
|
||||
=> _pathEntries.RetroSystemAbsolutePath(game);
|
||||
|
||||
private void FirmwareWarn(string sysID, string firmwareID, bool required, string msg = null)
|
||||
{
|
||||
|
@ -44,8 +54,8 @@ namespace BizHawk.Client.Common
|
|||
private byte[] GetFirmwareWithPath(string sysId, string firmwareId, bool required, string msg, out string path)
|
||||
{
|
||||
var firmwarePath = _firmwareManager.Request(
|
||||
Global.Config.PathEntries.FirmwaresPathFragment,
|
||||
Global.Config.FirmwareUserSpecifications,
|
||||
_pathEntries.FirmwaresPathFragment,
|
||||
_firmwareUserSpecifications,
|
||||
sysId,
|
||||
firmwareId);
|
||||
|
||||
|
|
|
@ -86,7 +86,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private CoreComm CreateCoreComm()
|
||||
{
|
||||
var cfp = new CoreFileProvider(ShowMessageCoreComm, Global.FirmwareManager);
|
||||
var cfp = new CoreFileProvider(
|
||||
ShowMessageCoreComm,
|
||||
Global.FirmwareManager,
|
||||
Config.PathEntries,
|
||||
Config.FirmwareUserSpecifications);
|
||||
return new CoreComm(ShowMessageCoreComm, NotifyCoreComm, cfp);
|
||||
}
|
||||
|
||||
|
|
|
@ -71,13 +71,12 @@ namespace BizHawk.Client.EmuHawk
|
|||
// scan the current libretro core to see if it can be launched with NoGame,and other stuff
|
||||
try
|
||||
{
|
||||
//OLD COMMENTS:
|
||||
////a stub corecomm. to reinforce that this won't touch the frontend at all!
|
||||
////LibRetroEmulator should be able to survive having this stub corecomm
|
||||
//NEW COMMENTS:
|
||||
//nope, we need to navigate to the dll path. this was a bad idea anyway. so many dlls get loaded, something to resolve them is needed
|
||||
var cfp = new CoreFileProvider(s => { }, Global.FirmwareManager);
|
||||
var coreComm = new CoreComm(null, null, cfp);
|
||||
var cfp = new CoreFileProvider(
|
||||
Console.WriteLine,
|
||||
Global.FirmwareManager,
|
||||
Global.Config.PathEntries,
|
||||
Global.Config.FirmwareUserSpecifications);
|
||||
var coreComm = new CoreComm(Console.WriteLine, Console.WriteLine, cfp);
|
||||
using var retro = new LibretroCore(coreComm, Global.Game, core);
|
||||
btnLibretroLaunchGame.Enabled = true;
|
||||
if (retro.Description.SupportsNoGame)
|
||||
|
|
|
@ -73,7 +73,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
_ldr = new RomLoader();
|
||||
_ldr.OnLoadError += OnLoadError;
|
||||
_ldr.ChooseArchive = ChooseArchive;
|
||||
var cfp = new CoreFileProvider(CommMessage, Global.FirmwareManager);
|
||||
var cfp = new CoreFileProvider(CommMessage, Global.FirmwareManager, Global.Config.PathEntries, Global.Config.FirmwareUserSpecifications);
|
||||
_comm = new CoreComm(CommMessage, CommMessage, cfp);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue