fix #3159
This commit is contained in:
parent
13069d08f4
commit
a515672d4d
|
@ -545,7 +545,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
olvi.SubItems.Add(new ListViewItem.ListViewSubItem());
|
||||
olvi.SubItems.Add(new ListViewItem.ListViewSubItem());
|
||||
olvi.SubItems.Add(new ListViewItem.ListViewSubItem());
|
||||
var ff = FirmwareDatabase.FirmwareFilesByHash[o.Hash];
|
||||
var ff = o.Hash is SHA1Checksum.Dummy
|
||||
? FirmwareDatabase.FirmwareFilesWithDummyHash[o]
|
||||
: FirmwareDatabase.FirmwareFilesByHash[o.Hash];
|
||||
olvi.ImageIndex = (int) (o.Status is FirmwareOptionStatus.Bad ? FirmwareOptionStatus.Unset : o.Status); // if bad, use unset's red '!' to differentiate from unacceptable
|
||||
olvi.ToolTipText = StatusDescs[o.Status];
|
||||
olvi.SubItems[0].Text = ff.Size.ToString();
|
||||
|
|
|
@ -16,6 +16,8 @@ namespace BizHawk.Emulation.Common
|
|||
|
||||
public static readonly IReadOnlyDictionary<string, FirmwareFile> FirmwareFilesByHash;
|
||||
|
||||
public static readonly IReadOnlyDictionary<FirmwareOption, FirmwareFile> FirmwareFilesWithDummyHash;
|
||||
|
||||
public static readonly IReadOnlyCollection<FirmwareOption> FirmwareOptions;
|
||||
|
||||
public static readonly IReadOnlyCollection<FirmwareRecord> FirmwareRecords;
|
||||
|
@ -26,6 +28,7 @@ namespace BizHawk.Emulation.Common
|
|||
{
|
||||
List<FirmwarePatchOption> allPatches = new();
|
||||
Dictionary<string, FirmwareFile> filesByHash = new();
|
||||
Dictionary<FirmwareOption, FirmwareFile> filesWithDummyHash = new();
|
||||
List<FirmwareOption> options = new();
|
||||
List<FirmwareRecord> records = new();
|
||||
|
||||
|
@ -45,7 +48,15 @@ namespace BizHawk.Emulation.Common
|
|||
isBad: isBad);
|
||||
|
||||
void Option(string systemId, string id, in FirmwareFile ff, FirmwareOptionStatus status = FirmwareOptionStatus.Acceptable)
|
||||
=> options.Add(new(new(systemId, id), ff.Hash, ff.Size, ff.IsBad ? FirmwareOptionStatus.Bad : status));
|
||||
{
|
||||
options.Add(new(new(systemId, id), ff.Hash, ff.Size, ff.IsBad ? FirmwareOptionStatus.Bad : status));
|
||||
if (ff.Hash is SHA1Checksum.Dummy)
|
||||
{
|
||||
// these shouldn't have more than 1 option
|
||||
// as these files represent an impossible to hash firmware
|
||||
filesWithDummyHash[options[options.Count - 1]] = ff;
|
||||
}
|
||||
}
|
||||
|
||||
void Firmware(string systemId, string id, string desc)
|
||||
=> records.Add(new(new(systemId, id), desc));
|
||||
|
@ -463,6 +474,7 @@ namespace BizHawk.Emulation.Common
|
|||
|
||||
AllPatches = allPatches;
|
||||
FirmwareFilesByHash = filesByHash;
|
||||
FirmwareFilesWithDummyHash = filesWithDummyHash;
|
||||
FirmwareOptions = options;
|
||||
FirmwareRecords = records;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,15 @@
|
|||
using System;
|
||||
|
||||
namespace BizHawk.Emulation.Common
|
||||
{
|
||||
public readonly struct FirmwareOption
|
||||
public readonly struct FirmwareOption : IEquatable<FirmwareOption>
|
||||
{
|
||||
public static bool operator ==(FirmwareOption a, FirmwareOption b)
|
||||
=> a.Equals(b);
|
||||
|
||||
public static bool operator !=(FirmwareOption a, FirmwareOption b)
|
||||
=> !(a == b);
|
||||
|
||||
public readonly string Hash;
|
||||
|
||||
public readonly FirmwareID ID;
|
||||
|
@ -19,5 +27,14 @@ namespace BizHawk.Emulation.Common
|
|||
Size = size;
|
||||
Status = status;
|
||||
}
|
||||
|
||||
public bool Equals(FirmwareOption other)
|
||||
=> Hash == other.Hash && ID == other.ID && Size == other.Size && Status == other.Status;
|
||||
|
||||
public readonly override bool Equals(object? obj)
|
||||
=> obj is FirmwareOption fr && Equals(fr);
|
||||
|
||||
public readonly override int GetHashCode()
|
||||
=> HashCode.Combine(Hash, ID, Size, Status);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue