FirmwareManager - don't use Global, pass in actual dependencies
This commit is contained in:
parent
965c7555ce
commit
80c36d8155
|
@ -54,7 +54,7 @@ namespace BizHawk.Client.Common
|
||||||
private byte[] GetFirmwareWithPath(string sysId, string firmwareId, bool required, string msg, out string path)
|
private byte[] GetFirmwareWithPath(string sysId, string firmwareId, bool required, string msg, out string path)
|
||||||
{
|
{
|
||||||
var firmwarePath = _firmwareManager.Request(
|
var firmwarePath = _firmwareManager.Request(
|
||||||
_pathEntries.FirmwaresPathFragment,
|
_pathEntries,
|
||||||
_firmwareUserSpecifications,
|
_firmwareUserSpecifications,
|
||||||
sysId,
|
sysId,
|
||||||
firmwareId);
|
firmwareId);
|
||||||
|
|
|
@ -41,7 +41,7 @@ namespace BizHawk.Client.Common
|
||||||
public string FirmwareId { get; set; }
|
public string FirmwareId { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResolutionInfo Resolve(string firmwaresPath, IDictionary<string, string> userSpecifications, FirmwareDatabase.FirmwareRecord record, bool forbidScan = false)
|
public ResolutionInfo Resolve(PathEntryCollection pathEntries, IDictionary<string, string> userSpecifications, FirmwareDatabase.FirmwareRecord record, bool forbidScan = false)
|
||||||
{
|
{
|
||||||
// purpose of forbidScan: sometimes this is called from a loop in Scan(). we don't want to repeatedly DoScanAndResolve in that case, its already been done.
|
// purpose of forbidScan: sometimes this is called from a loop in Scan(). we don't want to repeatedly DoScanAndResolve in that case, its already been done.
|
||||||
bool first = true;
|
bool first = true;
|
||||||
|
@ -55,7 +55,7 @@ namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
if (!forbidScan)
|
if (!forbidScan)
|
||||||
{
|
{
|
||||||
DoScanAndResolve(firmwaresPath, userSpecifications);
|
DoScanAndResolve(pathEntries, userSpecifications);
|
||||||
}
|
}
|
||||||
|
|
||||||
first = false;
|
first = false;
|
||||||
|
@ -66,9 +66,9 @@ namespace BizHawk.Client.Common
|
||||||
}
|
}
|
||||||
|
|
||||||
// Requests the specified firmware. tries really hard to scan and resolve as necessary
|
// Requests the specified firmware. tries really hard to scan and resolve as necessary
|
||||||
public string Request(string firmwaresPath, IDictionary<string, string> userSpecifications, string sysId, string firmwareId)
|
public string Request(PathEntryCollection pathEntries, IDictionary<string, string> userSpecifications, string sysId, string firmwareId)
|
||||||
{
|
{
|
||||||
var resolved = Resolve(firmwaresPath, userSpecifications, FirmwareDatabase.LookupFirmwareRecord(sysId, firmwareId));
|
var resolved = Resolve(pathEntries, userSpecifications, FirmwareDatabase.LookupFirmwareRecord(sysId, firmwareId));
|
||||||
if (resolved == null)
|
if (resolved == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
|
@ -138,7 +138,7 @@ namespace BizHawk.Client.Common
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DoScanAndResolve(string firmwaresPath, IDictionary<string, string> userSpecifications)
|
public void DoScanAndResolve(PathEntryCollection pathEntries, IDictionary<string, string> userSpecifications)
|
||||||
{
|
{
|
||||||
// build a list of file sizes. Only those will be checked during scanning
|
// build a list of file sizes. Only those will be checked during scanning
|
||||||
var sizes = new HashSet<long>();
|
var sizes = new HashSet<long>();
|
||||||
|
@ -151,7 +151,7 @@ namespace BizHawk.Client.Common
|
||||||
|
|
||||||
// build a list of files under the global firmwares path, and build a hash for each of them while we're at it
|
// build a list of files under the global firmwares path, and build a hash for each of them while we're at it
|
||||||
var todo = new Queue<DirectoryInfo>();
|
var todo = new Queue<DirectoryInfo>();
|
||||||
todo.Enqueue(new DirectoryInfo(Global.Config.PathEntries.AbsolutePathFor(firmwaresPath, null)));
|
todo.Enqueue(new DirectoryInfo(pathEntries.AbsolutePathFor(pathEntries.FirmwaresPathFragment, null)));
|
||||||
|
|
||||||
while (todo.Count != 0)
|
while (todo.Count != 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -949,7 +949,7 @@ namespace BizHawk.Client.Common
|
||||||
var ti83Bios = nextComm.CoreFileProvider.GetFirmware("TI83", "Rom", true);
|
var ti83Bios = nextComm.CoreFileProvider.GetFirmware("TI83", "Rom", true);
|
||||||
|
|
||||||
// TODO: make the ti-83 a proper firmware file
|
// TODO: make the ti-83 a proper firmware file
|
||||||
var ti83BiosPath = Global.FirmwareManager.Request(Global.Config.PathEntries.FirmwaresPathFragment, Global.Config.FirmwareUserSpecifications, "TI83", "Rom");
|
var ti83BiosPath = Global.FirmwareManager.Request(Global.Config.PathEntries, Global.Config.FirmwareUserSpecifications, "TI83", "Rom");
|
||||||
using (var ti83AsHawkFile = new HawkFile(ti83BiosPath))
|
using (var ti83AsHawkFile = new HawkFile(ti83BiosPath))
|
||||||
{
|
{
|
||||||
var ti83BiosAsRom = new RomGame(ti83AsHawkFile);
|
var ti83BiosAsRom = new RomGame(ti83AsHawkFile);
|
||||||
|
|
|
@ -248,7 +248,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
lvFirmwares.BeginUpdate();
|
lvFirmwares.BeginUpdate();
|
||||||
Manager.DoScanAndResolve(
|
Manager.DoScanAndResolve(
|
||||||
_config.PathEntries.FirmwaresPathFragment,
|
_config.PathEntries,
|
||||||
_config.FirmwareUserSpecifications);
|
_config.FirmwareUserSpecifications);
|
||||||
|
|
||||||
// for each type of firmware, try resolving and record the result
|
// for each type of firmware, try resolving and record the result
|
||||||
|
@ -256,7 +256,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
var fr = lvi.Tag as FirmwareDatabase.FirmwareRecord;
|
var fr = lvi.Tag as FirmwareDatabase.FirmwareRecord;
|
||||||
var ri = Manager.Resolve(
|
var ri = Manager.Resolve(
|
||||||
_config.PathEntries.FirmwaresPathFragment,
|
_config.PathEntries,
|
||||||
_config.FirmwareUserSpecifications,
|
_config.FirmwareUserSpecifications,
|
||||||
fr,
|
fr,
|
||||||
true);
|
true);
|
||||||
|
@ -342,11 +342,11 @@ namespace BizHawk.Client.EmuHawk
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Manager.DoScanAndResolve(_config.PathEntries.FirmwaresPathFragment, _config.FirmwareUserSpecifications);
|
Manager.DoScanAndResolve(_config.PathEntries, _config.FirmwareUserSpecifications);
|
||||||
|
|
||||||
foreach (var fr in FirmwareDatabase.FirmwareRecords)
|
foreach (var fr in FirmwareDatabase.FirmwareRecords)
|
||||||
{
|
{
|
||||||
var ri = Manager.Resolve(_config.PathEntries.FirmwaresPathFragment, _config.FirmwareUserSpecifications, fr);
|
var ri = Manager.Resolve(_config.PathEntries, _config.FirmwareUserSpecifications, fr);
|
||||||
if (ri?.KnownFirmwareFile == null) continue;
|
if (ri?.KnownFirmwareFile == null) continue;
|
||||||
if (ri.UserSpecified) continue;
|
if (ri.UserSpecified) continue;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue