mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Simplify item count statistics
This commit is contained in:
@@ -4,6 +4,7 @@ using System.Collections.Concurrent;
|
|||||||
#endif
|
#endif
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
@@ -98,202 +99,10 @@ namespace SabreTools.DatFiles
|
|||||||
public long TotalCount { get; private set; } = 0;
|
public long TotalCount { get; private set; } = 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Number of Adjuster items
|
/// Number of items for each item type
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonIgnore, XmlIgnore]
|
[JsonIgnore, XmlIgnore]
|
||||||
public long AdjusterCount { get; private set; } = 0;
|
public Dictionary<ItemType, long> ItemCounts { get; private set; } = [];
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of Analog items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long AnalogCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of Archive items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long ArchiveCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of BiosSet items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long BiosSetCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of Chip items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long ChipCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of top-level Condition items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long ConditionCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of Configuration items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long ConfigurationCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of DataArea items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long DataAreaCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of Device items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long DeviceCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of Device Reference items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long DeviceReferenceCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of DIP Switch items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long DipSwitchCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of Disk items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long DiskCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of DiskArea items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long DiskAreaCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of Display items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long DisplayCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of Driver items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long DriverCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of Feature items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long FeatureCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of Info items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long InfoCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of Input items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long InputCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of Media items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long MediaCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of Part items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long PartCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of PartFeature items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long PartFeatureCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of Port items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long PortCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of RamOption items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long RamOptionCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of Release items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long ReleaseCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of ReleaseDetails items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long ReleaseDetailsCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of Rom items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long RomCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of Sample items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long SampleCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of Serials items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long SerialsCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of SharedFeature items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long SharedFeatureCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of Slot items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long SlotCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of SoftwareList items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long SoftwareListCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of Sound items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long SoundCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of SourceDetails items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long SourceDetailsCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Number of machines
|
/// Number of machines
|
||||||
@@ -464,44 +273,13 @@ namespace SabreTools.DatFiles
|
|||||||
if (item.Remove)
|
if (item.Remove)
|
||||||
RemovedCount++;
|
RemovedCount++;
|
||||||
|
|
||||||
// Now we do different things for each item type
|
// Increment the item count for the type
|
||||||
|
AddItemCount(item.ItemType);
|
||||||
|
|
||||||
|
// Some item types require special processing
|
||||||
switch (item)
|
switch (item)
|
||||||
{
|
{
|
||||||
case Adjuster:
|
|
||||||
AdjusterCount++;
|
|
||||||
break;
|
|
||||||
case Analog:
|
|
||||||
AnalogCount++;
|
|
||||||
break;
|
|
||||||
case Archive:
|
|
||||||
ArchiveCount++;
|
|
||||||
break;
|
|
||||||
case BiosSet:
|
|
||||||
BiosSetCount++;
|
|
||||||
break;
|
|
||||||
case Chip:
|
|
||||||
ChipCount++;
|
|
||||||
break;
|
|
||||||
case Condition:
|
|
||||||
ConditionCount++;
|
|
||||||
break;
|
|
||||||
case Configuration:
|
|
||||||
ConfigurationCount++;
|
|
||||||
break;
|
|
||||||
case DataArea:
|
|
||||||
DataAreaCount++;
|
|
||||||
break;
|
|
||||||
case Device:
|
|
||||||
DeviceCount++;
|
|
||||||
break;
|
|
||||||
case DeviceReference:
|
|
||||||
DeviceReferenceCount++;
|
|
||||||
break;
|
|
||||||
case DipSwitch:
|
|
||||||
DipSwitchCount++;
|
|
||||||
break;
|
|
||||||
case Disk disk:
|
case Disk disk:
|
||||||
DiskCount++;
|
|
||||||
if (disk.ItemStatus != ItemStatus.Nodump)
|
if (disk.ItemStatus != ItemStatus.Nodump)
|
||||||
{
|
{
|
||||||
MD5Count += (string.IsNullOrEmpty(disk.MD5) ? 0 : 1);
|
MD5Count += (string.IsNullOrEmpty(disk.MD5) ? 0 : 1);
|
||||||
@@ -513,51 +291,13 @@ namespace SabreTools.DatFiles
|
|||||||
NodumpCount += (disk.ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
NodumpCount += (disk.ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
||||||
VerifiedCount += (disk.ItemStatus == ItemStatus.Verified ? 1 : 0);
|
VerifiedCount += (disk.ItemStatus == ItemStatus.Verified ? 1 : 0);
|
||||||
break;
|
break;
|
||||||
case DiskArea:
|
|
||||||
DiskAreaCount++;
|
|
||||||
break;
|
|
||||||
case Display:
|
|
||||||
DisplayCount++;
|
|
||||||
break;
|
|
||||||
case Driver:
|
|
||||||
DriverCount++;
|
|
||||||
break;
|
|
||||||
case Feature:
|
|
||||||
FeatureCount++;
|
|
||||||
break;
|
|
||||||
case Info:
|
|
||||||
InfoCount++;
|
|
||||||
break;
|
|
||||||
case Input:
|
|
||||||
InputCount++;
|
|
||||||
break;
|
|
||||||
case Media media:
|
case Media media:
|
||||||
MediaCount++;
|
|
||||||
MD5Count += (string.IsNullOrEmpty(media.MD5) ? 0 : 1);
|
MD5Count += (string.IsNullOrEmpty(media.MD5) ? 0 : 1);
|
||||||
SHA1Count += (string.IsNullOrEmpty(media.SHA1) ? 0 : 1);
|
SHA1Count += (string.IsNullOrEmpty(media.SHA1) ? 0 : 1);
|
||||||
SHA256Count += (string.IsNullOrEmpty(media.SHA256) ? 0 : 1);
|
SHA256Count += (string.IsNullOrEmpty(media.SHA256) ? 0 : 1);
|
||||||
SpamSumCount += (string.IsNullOrEmpty(media.SpamSum) ? 0 : 1);
|
SpamSumCount += (string.IsNullOrEmpty(media.SpamSum) ? 0 : 1);
|
||||||
break;
|
break;
|
||||||
case Part:
|
|
||||||
PartCount++;
|
|
||||||
break;
|
|
||||||
case PartFeature:
|
|
||||||
PartFeatureCount++;
|
|
||||||
break;
|
|
||||||
case Port:
|
|
||||||
PortCount++;
|
|
||||||
break;
|
|
||||||
case RamOption:
|
|
||||||
RamOptionCount++;
|
|
||||||
break;
|
|
||||||
case Release:
|
|
||||||
ReleaseCount++;
|
|
||||||
break;
|
|
||||||
case ReleaseDetails:
|
|
||||||
ReleaseDetailsCount++;
|
|
||||||
break;
|
|
||||||
case Rom rom:
|
case Rom rom:
|
||||||
RomCount++;
|
|
||||||
if (rom.ItemStatus != ItemStatus.Nodump)
|
if (rom.ItemStatus != ItemStatus.Nodump)
|
||||||
{
|
{
|
||||||
TotalSize += rom.Size ?? 0;
|
TotalSize += rom.Size ?? 0;
|
||||||
@@ -575,27 +315,6 @@ namespace SabreTools.DatFiles
|
|||||||
NodumpCount += (rom.ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
NodumpCount += (rom.ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
||||||
VerifiedCount += (rom.ItemStatus == ItemStatus.Verified ? 1 : 0);
|
VerifiedCount += (rom.ItemStatus == ItemStatus.Verified ? 1 : 0);
|
||||||
break;
|
break;
|
||||||
case Sample:
|
|
||||||
SampleCount++;
|
|
||||||
break;
|
|
||||||
case Serials:
|
|
||||||
SerialsCount++;
|
|
||||||
break;
|
|
||||||
case SharedFeature:
|
|
||||||
SharedFeatureCount++;
|
|
||||||
break;
|
|
||||||
case Slot:
|
|
||||||
SlotCount++;
|
|
||||||
break;
|
|
||||||
case SoftwareList:
|
|
||||||
SoftwareListCount++;
|
|
||||||
break;
|
|
||||||
case Sound:
|
|
||||||
SoundCount++;
|
|
||||||
break;
|
|
||||||
case SourceDetails:
|
|
||||||
SourceDetailsCount++;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -636,14 +355,11 @@ namespace SabreTools.DatFiles
|
|||||||
{
|
{
|
||||||
TotalCount += stats.Count;
|
TotalCount += stats.Count;
|
||||||
|
|
||||||
ArchiveCount += stats.ArchiveCount;
|
// Loop through and add stats for all items
|
||||||
BiosSetCount += stats.BiosSetCount;
|
foreach (var itemCountKvp in stats.ItemCounts)
|
||||||
ChipCount += stats.ChipCount;
|
{
|
||||||
DiskCount += stats.DiskCount;
|
AddItemCount(itemCountKvp.Key, itemCountKvp.Value);
|
||||||
MediaCount += stats.MediaCount;
|
}
|
||||||
ReleaseCount += stats.ReleaseCount;
|
|
||||||
RomCount += stats.RomCount;
|
|
||||||
SampleCount += stats.SampleCount;
|
|
||||||
|
|
||||||
GameCount += stats.GameCount;
|
GameCount += stats.GameCount;
|
||||||
|
|
||||||
@@ -840,44 +556,13 @@ namespace SabreTools.DatFiles
|
|||||||
if (item.Remove)
|
if (item.Remove)
|
||||||
RemovedCount--;
|
RemovedCount--;
|
||||||
|
|
||||||
// Now we do different things for each item type
|
// Decrement the item count for the type
|
||||||
|
RemoveItemCount(item.ItemType);
|
||||||
|
|
||||||
|
// Some item types require special processing
|
||||||
switch (item)
|
switch (item)
|
||||||
{
|
{
|
||||||
case Adjuster:
|
|
||||||
AdjusterCount--;
|
|
||||||
break;
|
|
||||||
case Analog:
|
|
||||||
AnalogCount--;
|
|
||||||
break;
|
|
||||||
case Archive:
|
|
||||||
ArchiveCount--;
|
|
||||||
break;
|
|
||||||
case BiosSet:
|
|
||||||
BiosSetCount--;
|
|
||||||
break;
|
|
||||||
case Chip:
|
|
||||||
ChipCount--;
|
|
||||||
break;
|
|
||||||
case Condition:
|
|
||||||
ConditionCount--;
|
|
||||||
break;
|
|
||||||
case Configuration:
|
|
||||||
ConfigurationCount--;
|
|
||||||
break;
|
|
||||||
case DataArea:
|
|
||||||
DataAreaCount--;
|
|
||||||
break;
|
|
||||||
case Device:
|
|
||||||
DeviceCount--;
|
|
||||||
break;
|
|
||||||
case DeviceReference:
|
|
||||||
DeviceReferenceCount--;
|
|
||||||
break;
|
|
||||||
case DipSwitch:
|
|
||||||
DipSwitchCount--;
|
|
||||||
break;
|
|
||||||
case Disk disk:
|
case Disk disk:
|
||||||
DiskCount--;
|
|
||||||
if (disk.ItemStatus != ItemStatus.Nodump)
|
if (disk.ItemStatus != ItemStatus.Nodump)
|
||||||
{
|
{
|
||||||
MD5Count -= (string.IsNullOrEmpty(disk.MD5) ? 0 : 1);
|
MD5Count -= (string.IsNullOrEmpty(disk.MD5) ? 0 : 1);
|
||||||
@@ -889,47 +574,12 @@ namespace SabreTools.DatFiles
|
|||||||
NodumpCount -= (disk.ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
NodumpCount -= (disk.ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
||||||
VerifiedCount -= (disk.ItemStatus == ItemStatus.Verified ? 1 : 0);
|
VerifiedCount -= (disk.ItemStatus == ItemStatus.Verified ? 1 : 0);
|
||||||
break;
|
break;
|
||||||
case DiskArea:
|
|
||||||
DiskAreaCount--;
|
|
||||||
break;
|
|
||||||
case Display:
|
|
||||||
DisplayCount--;
|
|
||||||
break;
|
|
||||||
case Driver:
|
|
||||||
DriverCount--;
|
|
||||||
break;
|
|
||||||
case Feature:
|
|
||||||
FeatureCount--;
|
|
||||||
break;
|
|
||||||
case Info:
|
|
||||||
InfoCount--;
|
|
||||||
break;
|
|
||||||
case Input:
|
|
||||||
InputCount--;
|
|
||||||
break;
|
|
||||||
case Media media:
|
case Media media:
|
||||||
MediaCount--;
|
|
||||||
MD5Count -= (string.IsNullOrEmpty(media.MD5) ? 0 : 1);
|
MD5Count -= (string.IsNullOrEmpty(media.MD5) ? 0 : 1);
|
||||||
SHA1Count -= (string.IsNullOrEmpty(media.SHA1) ? 0 : 1);
|
SHA1Count -= (string.IsNullOrEmpty(media.SHA1) ? 0 : 1);
|
||||||
SHA256Count -= (string.IsNullOrEmpty(media.SHA256) ? 0 : 1);
|
SHA256Count -= (string.IsNullOrEmpty(media.SHA256) ? 0 : 1);
|
||||||
break;
|
break;
|
||||||
case Part:
|
|
||||||
PartCount--;
|
|
||||||
break;
|
|
||||||
case PartFeature:
|
|
||||||
PartFeatureCount--;
|
|
||||||
break;
|
|
||||||
case Port:
|
|
||||||
PortCount--;
|
|
||||||
break;
|
|
||||||
case RamOption:
|
|
||||||
RamOptionCount--;
|
|
||||||
break;
|
|
||||||
case Release:
|
|
||||||
ReleaseCount--;
|
|
||||||
break;
|
|
||||||
case Rom rom:
|
case Rom rom:
|
||||||
RomCount--;
|
|
||||||
if (rom.ItemStatus != ItemStatus.Nodump)
|
if (rom.ItemStatus != ItemStatus.Nodump)
|
||||||
{
|
{
|
||||||
TotalSize -= rom.Size ?? 0;
|
TotalSize -= rom.Size ?? 0;
|
||||||
@@ -946,25 +596,62 @@ namespace SabreTools.DatFiles
|
|||||||
NodumpCount -= (rom.ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
NodumpCount -= (rom.ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
||||||
VerifiedCount -= (rom.ItemStatus == ItemStatus.Verified ? 1 : 0);
|
VerifiedCount -= (rom.ItemStatus == ItemStatus.Verified ? 1 : 0);
|
||||||
break;
|
break;
|
||||||
case Sample:
|
|
||||||
SampleCount--;
|
|
||||||
break;
|
|
||||||
case SharedFeature:
|
|
||||||
SharedFeatureCount--;
|
|
||||||
break;
|
|
||||||
case Slot:
|
|
||||||
SlotCount--;
|
|
||||||
break;
|
|
||||||
case SoftwareList:
|
|
||||||
SoftwareListCount--;
|
|
||||||
break;
|
|
||||||
case Sound:
|
|
||||||
SoundCount--;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the item count for a given item type, defaulting to 0 if it does not exist
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="itemType">Item type to retrieve</param>
|
||||||
|
/// <returns>The number of items of that type, if it exists</returns>
|
||||||
|
public long GetItemCount(ItemType itemType)
|
||||||
|
{
|
||||||
|
lock (ItemCounts)
|
||||||
|
{
|
||||||
|
if (!ItemCounts.ContainsKey(itemType))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return ItemCounts[itemType];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Increment the item count for a given item type
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="itemType">Item type to increment</param>
|
||||||
|
/// <param name="interval">Amount to increment by, defaults to 1</param>
|
||||||
|
private void AddItemCount(ItemType itemType, long interval = 1)
|
||||||
|
{
|
||||||
|
lock (ItemCounts)
|
||||||
|
{
|
||||||
|
if (!ItemCounts.ContainsKey(itemType))
|
||||||
|
ItemCounts[itemType] = 0;
|
||||||
|
|
||||||
|
ItemCounts[itemType] += interval;
|
||||||
|
if (ItemCounts[itemType] < 0)
|
||||||
|
ItemCounts[itemType] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Decrement the item count for a given item type
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="itemType">Item type to decrement</param>
|
||||||
|
/// <param name="interval">Amount to increment by, defaults to 1</param>
|
||||||
|
private void RemoveItemCount(ItemType itemType, long interval = 1)
|
||||||
|
{
|
||||||
|
lock (ItemCounts)
|
||||||
|
{
|
||||||
|
if (!ItemCounts.ContainsKey(itemType))
|
||||||
|
return;
|
||||||
|
|
||||||
|
ItemCounts[itemType] -= interval;
|
||||||
|
if (ItemCounts[itemType] < 0)
|
||||||
|
ItemCounts[itemType] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Constructors
|
#region Constructors
|
||||||
@@ -1279,14 +966,7 @@ namespace SabreTools.DatFiles
|
|||||||
{
|
{
|
||||||
TotalCount = 0;
|
TotalCount = 0;
|
||||||
|
|
||||||
ArchiveCount = 0;
|
ItemCounts = [];
|
||||||
BiosSetCount = 0;
|
|
||||||
ChipCount = 0;
|
|
||||||
DiskCount = 0;
|
|
||||||
MediaCount = 0;
|
|
||||||
ReleaseCount = 0;
|
|
||||||
RomCount = 0;
|
|
||||||
SampleCount = 0;
|
|
||||||
|
|
||||||
GameCount = 0;
|
GameCount = 0;
|
||||||
|
|
||||||
@@ -1312,24 +992,29 @@ namespace SabreTools.DatFiles
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private ItemKey GetBestAvailable()
|
private ItemKey GetBestAvailable()
|
||||||
{
|
{
|
||||||
|
// Get the item counts for the 3 hashable types
|
||||||
|
long diskCount = GetItemCount(ItemType.Disk);
|
||||||
|
long mediaCount = GetItemCount(ItemType.Media);
|
||||||
|
long romCount = GetItemCount(ItemType.Rom);
|
||||||
|
|
||||||
// If all items are supposed to have a SHA-512, we bucket by that
|
// If all items are supposed to have a SHA-512, we bucket by that
|
||||||
if (DiskCount + MediaCount + RomCount - NodumpCount == SHA512Count)
|
if (diskCount + mediaCount + romCount - NodumpCount == SHA512Count)
|
||||||
return ItemKey.SHA512;
|
return ItemKey.SHA512;
|
||||||
|
|
||||||
// If all items are supposed to have a SHA-384, we bucket by that
|
// If all items are supposed to have a SHA-384, we bucket by that
|
||||||
else if (DiskCount + MediaCount + RomCount - NodumpCount == SHA384Count)
|
else if (diskCount + mediaCount + romCount - NodumpCount == SHA384Count)
|
||||||
return ItemKey.SHA384;
|
return ItemKey.SHA384;
|
||||||
|
|
||||||
// If all items are supposed to have a SHA-256, we bucket by that
|
// If all items are supposed to have a SHA-256, we bucket by that
|
||||||
else if (DiskCount + MediaCount + RomCount - NodumpCount == SHA256Count)
|
else if (diskCount + mediaCount + romCount - NodumpCount == SHA256Count)
|
||||||
return ItemKey.SHA256;
|
return ItemKey.SHA256;
|
||||||
|
|
||||||
// If all items are supposed to have a SHA-1, we bucket by that
|
// If all items are supposed to have a SHA-1, we bucket by that
|
||||||
else if (DiskCount + MediaCount + RomCount - NodumpCount == SHA1Count)
|
else if (diskCount + mediaCount + romCount - NodumpCount == SHA1Count)
|
||||||
return ItemKey.SHA1;
|
return ItemKey.SHA1;
|
||||||
|
|
||||||
// If all items are supposed to have a MD5, we bucket by that
|
// If all items are supposed to have a MD5, we bucket by that
|
||||||
else if (DiskCount + MediaCount + RomCount - NodumpCount == MD5Count)
|
else if (diskCount + mediaCount + romCount - NodumpCount == MD5Count)
|
||||||
return ItemKey.MD5;
|
return ItemKey.MD5;
|
||||||
|
|
||||||
// Otherwise, we bucket by CRC
|
// Otherwise, we bucket by CRC
|
||||||
|
|||||||
@@ -157,202 +157,10 @@ namespace SabreTools.DatFiles
|
|||||||
public long TotalCount { get; private set; } = 0;
|
public long TotalCount { get; private set; } = 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Number of Adjuster items
|
/// Number of items for each item type
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonIgnore, XmlIgnore]
|
[JsonIgnore, XmlIgnore]
|
||||||
public long AdjusterCount { get; private set; } = 0;
|
public Dictionary<ItemType, long> ItemCounts { get; private set; } = [];
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of Analog items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long AnalogCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of Archive items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long ArchiveCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of BiosSet items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long BiosSetCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of Chip items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long ChipCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of top-level Condition items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long ConditionCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of Configuration items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long ConfigurationCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of DataArea items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long DataAreaCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of Device items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long DeviceCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of Device Reference items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long DeviceReferenceCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of DIP Switch items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long DipSwitchCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of Disk items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long DiskCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of DiskArea items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long DiskAreaCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of Display items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long DisplayCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of Driver items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long DriverCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of Feature items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long FeatureCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of Info items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long InfoCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of Input items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long InputCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of Media items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long MediaCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of Part items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long PartCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of PartFeature items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long PartFeatureCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of Port items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long PortCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of RamOption items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long RamOptionCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of Release items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long ReleaseCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of ReleaseDetails items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long ReleaseDetailsCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of Rom items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long RomCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of Sample items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long SampleCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of Serials items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long SerialsCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of SharedFeature items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long SharedFeatureCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of Slot items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long SlotCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of SoftwareList items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long SoftwareListCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of Sound items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long SoundCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of SourceDetails items
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore, XmlIgnore]
|
|
||||||
public long SourceDetailsCount { get; private set; } = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Number of machines
|
/// Number of machines
|
||||||
@@ -584,44 +392,13 @@ namespace SabreTools.DatFiles
|
|||||||
if (item.Remove)
|
if (item.Remove)
|
||||||
RemovedCount++;
|
RemovedCount++;
|
||||||
|
|
||||||
// Now we do different things for each item type
|
// Increment the item count for the type
|
||||||
|
AddItemCount(item.ItemType);
|
||||||
|
|
||||||
|
// Some item types require special processing
|
||||||
switch (item)
|
switch (item)
|
||||||
{
|
{
|
||||||
case Adjuster:
|
|
||||||
AdjusterCount++;
|
|
||||||
break;
|
|
||||||
case Analog:
|
|
||||||
AnalogCount++;
|
|
||||||
break;
|
|
||||||
case Archive:
|
|
||||||
ArchiveCount++;
|
|
||||||
break;
|
|
||||||
case BiosSet:
|
|
||||||
BiosSetCount++;
|
|
||||||
break;
|
|
||||||
case Chip:
|
|
||||||
ChipCount++;
|
|
||||||
break;
|
|
||||||
case Condition:
|
|
||||||
ConditionCount++;
|
|
||||||
break;
|
|
||||||
case Configuration:
|
|
||||||
ConfigurationCount++;
|
|
||||||
break;
|
|
||||||
case DataArea:
|
|
||||||
DataAreaCount++;
|
|
||||||
break;
|
|
||||||
case Device:
|
|
||||||
DeviceCount++;
|
|
||||||
break;
|
|
||||||
case DeviceReference:
|
|
||||||
DeviceReferenceCount++;
|
|
||||||
break;
|
|
||||||
case DipSwitch:
|
|
||||||
DipSwitchCount++;
|
|
||||||
break;
|
|
||||||
case Disk disk:
|
case Disk disk:
|
||||||
DiskCount++;
|
|
||||||
if (disk.ItemStatus != ItemStatus.Nodump)
|
if (disk.ItemStatus != ItemStatus.Nodump)
|
||||||
{
|
{
|
||||||
MD5Count += (string.IsNullOrEmpty(disk.MD5) ? 0 : 1);
|
MD5Count += (string.IsNullOrEmpty(disk.MD5) ? 0 : 1);
|
||||||
@@ -633,51 +410,13 @@ namespace SabreTools.DatFiles
|
|||||||
NodumpCount += (disk.ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
NodumpCount += (disk.ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
||||||
VerifiedCount += (disk.ItemStatus == ItemStatus.Verified ? 1 : 0);
|
VerifiedCount += (disk.ItemStatus == ItemStatus.Verified ? 1 : 0);
|
||||||
break;
|
break;
|
||||||
case DiskArea:
|
|
||||||
DiskAreaCount++;
|
|
||||||
break;
|
|
||||||
case Display:
|
|
||||||
DisplayCount++;
|
|
||||||
break;
|
|
||||||
case Driver:
|
|
||||||
DriverCount++;
|
|
||||||
break;
|
|
||||||
case Feature:
|
|
||||||
FeatureCount++;
|
|
||||||
break;
|
|
||||||
case Info:
|
|
||||||
InfoCount++;
|
|
||||||
break;
|
|
||||||
case Input:
|
|
||||||
InputCount++;
|
|
||||||
break;
|
|
||||||
case Media media:
|
case Media media:
|
||||||
MediaCount++;
|
|
||||||
MD5Count += (string.IsNullOrEmpty(media.MD5) ? 0 : 1);
|
MD5Count += (string.IsNullOrEmpty(media.MD5) ? 0 : 1);
|
||||||
SHA1Count += (string.IsNullOrEmpty(media.SHA1) ? 0 : 1);
|
SHA1Count += (string.IsNullOrEmpty(media.SHA1) ? 0 : 1);
|
||||||
SHA256Count += (string.IsNullOrEmpty(media.SHA256) ? 0 : 1);
|
SHA256Count += (string.IsNullOrEmpty(media.SHA256) ? 0 : 1);
|
||||||
SpamSumCount += (string.IsNullOrEmpty(media.SpamSum) ? 0 : 1);
|
SpamSumCount += (string.IsNullOrEmpty(media.SpamSum) ? 0 : 1);
|
||||||
break;
|
break;
|
||||||
case Part:
|
|
||||||
PartCount++;
|
|
||||||
break;
|
|
||||||
case PartFeature:
|
|
||||||
PartFeatureCount++;
|
|
||||||
break;
|
|
||||||
case Port:
|
|
||||||
PortCount++;
|
|
||||||
break;
|
|
||||||
case RamOption:
|
|
||||||
RamOptionCount++;
|
|
||||||
break;
|
|
||||||
case Release:
|
|
||||||
ReleaseCount++;
|
|
||||||
break;
|
|
||||||
case ReleaseDetails:
|
|
||||||
ReleaseDetailsCount++;
|
|
||||||
break;
|
|
||||||
case Rom rom:
|
case Rom rom:
|
||||||
RomCount++;
|
|
||||||
if (rom.ItemStatus != ItemStatus.Nodump)
|
if (rom.ItemStatus != ItemStatus.Nodump)
|
||||||
{
|
{
|
||||||
TotalSize += rom.Size ?? 0;
|
TotalSize += rom.Size ?? 0;
|
||||||
@@ -695,27 +434,6 @@ namespace SabreTools.DatFiles
|
|||||||
NodumpCount += (rom.ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
NodumpCount += (rom.ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
||||||
VerifiedCount += (rom.ItemStatus == ItemStatus.Verified ? 1 : 0);
|
VerifiedCount += (rom.ItemStatus == ItemStatus.Verified ? 1 : 0);
|
||||||
break;
|
break;
|
||||||
case Sample:
|
|
||||||
SampleCount++;
|
|
||||||
break;
|
|
||||||
case Serials:
|
|
||||||
SerialsCount++;
|
|
||||||
break;
|
|
||||||
case SharedFeature:
|
|
||||||
SharedFeatureCount++;
|
|
||||||
break;
|
|
||||||
case Slot:
|
|
||||||
SlotCount++;
|
|
||||||
break;
|
|
||||||
case SoftwareList:
|
|
||||||
SoftwareListCount++;
|
|
||||||
break;
|
|
||||||
case Sound:
|
|
||||||
SoundCount++;
|
|
||||||
break;
|
|
||||||
case SourceDetails:
|
|
||||||
SourceDetailsCount++;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -755,18 +473,15 @@ namespace SabreTools.DatFiles
|
|||||||
/// Add statistics from another DatStats object
|
/// Add statistics from another DatStats object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="stats">DatStats object to add from</param>
|
/// <param name="stats">DatStats object to add from</param>
|
||||||
public void AddStatistics(ItemDictionary stats)
|
public void AddStatistics(ItemDictionaryDB stats)
|
||||||
{
|
{
|
||||||
TotalCount += stats.Count;
|
TotalCount += stats.Count;
|
||||||
|
|
||||||
ArchiveCount += stats.ArchiveCount;
|
// Loop through and add stats for all items
|
||||||
BiosSetCount += stats.BiosSetCount;
|
foreach (var itemCountKvp in stats.ItemCounts)
|
||||||
ChipCount += stats.ChipCount;
|
{
|
||||||
DiskCount += stats.DiskCount;
|
AddItemCount(itemCountKvp.Key, itemCountKvp.Value);
|
||||||
MediaCount += stats.MediaCount;
|
}
|
||||||
ReleaseCount += stats.ReleaseCount;
|
|
||||||
RomCount += stats.RomCount;
|
|
||||||
SampleCount += stats.SampleCount;
|
|
||||||
|
|
||||||
GameCount += stats.GameCount;
|
GameCount += stats.GameCount;
|
||||||
|
|
||||||
@@ -987,44 +702,13 @@ namespace SabreTools.DatFiles
|
|||||||
if (item.Remove)
|
if (item.Remove)
|
||||||
RemovedCount--;
|
RemovedCount--;
|
||||||
|
|
||||||
// Now we do different things for each item type
|
// Decrement the item count for the type
|
||||||
|
RemoveItemCount(item.ItemType);
|
||||||
|
|
||||||
|
// Some item types require special processing
|
||||||
switch (item)
|
switch (item)
|
||||||
{
|
{
|
||||||
case Adjuster:
|
|
||||||
AdjusterCount--;
|
|
||||||
break;
|
|
||||||
case Analog:
|
|
||||||
AnalogCount--;
|
|
||||||
break;
|
|
||||||
case Archive:
|
|
||||||
ArchiveCount--;
|
|
||||||
break;
|
|
||||||
case BiosSet:
|
|
||||||
BiosSetCount--;
|
|
||||||
break;
|
|
||||||
case Chip:
|
|
||||||
ChipCount--;
|
|
||||||
break;
|
|
||||||
case Condition:
|
|
||||||
ConditionCount--;
|
|
||||||
break;
|
|
||||||
case Configuration:
|
|
||||||
ConfigurationCount--;
|
|
||||||
break;
|
|
||||||
case DataArea:
|
|
||||||
DataAreaCount--;
|
|
||||||
break;
|
|
||||||
case Device:
|
|
||||||
DeviceCount--;
|
|
||||||
break;
|
|
||||||
case DeviceReference:
|
|
||||||
DeviceReferenceCount--;
|
|
||||||
break;
|
|
||||||
case DipSwitch:
|
|
||||||
DipSwitchCount--;
|
|
||||||
break;
|
|
||||||
case Disk disk:
|
case Disk disk:
|
||||||
DiskCount--;
|
|
||||||
if (disk.ItemStatus != ItemStatus.Nodump)
|
if (disk.ItemStatus != ItemStatus.Nodump)
|
||||||
{
|
{
|
||||||
MD5Count -= (string.IsNullOrEmpty(disk.MD5) ? 0 : 1);
|
MD5Count -= (string.IsNullOrEmpty(disk.MD5) ? 0 : 1);
|
||||||
@@ -1036,47 +720,12 @@ namespace SabreTools.DatFiles
|
|||||||
NodumpCount -= (disk.ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
NodumpCount -= (disk.ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
||||||
VerifiedCount -= (disk.ItemStatus == ItemStatus.Verified ? 1 : 0);
|
VerifiedCount -= (disk.ItemStatus == ItemStatus.Verified ? 1 : 0);
|
||||||
break;
|
break;
|
||||||
case DiskArea:
|
|
||||||
DiskAreaCount--;
|
|
||||||
break;
|
|
||||||
case Display:
|
|
||||||
DisplayCount--;
|
|
||||||
break;
|
|
||||||
case Driver:
|
|
||||||
DriverCount--;
|
|
||||||
break;
|
|
||||||
case Feature:
|
|
||||||
FeatureCount--;
|
|
||||||
break;
|
|
||||||
case Info:
|
|
||||||
InfoCount--;
|
|
||||||
break;
|
|
||||||
case Input:
|
|
||||||
InputCount--;
|
|
||||||
break;
|
|
||||||
case Media media:
|
case Media media:
|
||||||
MediaCount--;
|
|
||||||
MD5Count -= (string.IsNullOrEmpty(media.MD5) ? 0 : 1);
|
MD5Count -= (string.IsNullOrEmpty(media.MD5) ? 0 : 1);
|
||||||
SHA1Count -= (string.IsNullOrEmpty(media.SHA1) ? 0 : 1);
|
SHA1Count -= (string.IsNullOrEmpty(media.SHA1) ? 0 : 1);
|
||||||
SHA256Count -= (string.IsNullOrEmpty(media.SHA256) ? 0 : 1);
|
SHA256Count -= (string.IsNullOrEmpty(media.SHA256) ? 0 : 1);
|
||||||
break;
|
break;
|
||||||
case Part:
|
|
||||||
PartCount--;
|
|
||||||
break;
|
|
||||||
case PartFeature:
|
|
||||||
PartFeatureCount--;
|
|
||||||
break;
|
|
||||||
case Port:
|
|
||||||
PortCount--;
|
|
||||||
break;
|
|
||||||
case RamOption:
|
|
||||||
RamOptionCount--;
|
|
||||||
break;
|
|
||||||
case Release:
|
|
||||||
ReleaseCount--;
|
|
||||||
break;
|
|
||||||
case Rom rom:
|
case Rom rom:
|
||||||
RomCount--;
|
|
||||||
if (rom.ItemStatus != ItemStatus.Nodump)
|
if (rom.ItemStatus != ItemStatus.Nodump)
|
||||||
{
|
{
|
||||||
TotalSize -= rom.Size ?? 0;
|
TotalSize -= rom.Size ?? 0;
|
||||||
@@ -1093,25 +742,62 @@ namespace SabreTools.DatFiles
|
|||||||
NodumpCount -= (rom.ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
NodumpCount -= (rom.ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
||||||
VerifiedCount -= (rom.ItemStatus == ItemStatus.Verified ? 1 : 0);
|
VerifiedCount -= (rom.ItemStatus == ItemStatus.Verified ? 1 : 0);
|
||||||
break;
|
break;
|
||||||
case Sample:
|
|
||||||
SampleCount--;
|
|
||||||
break;
|
|
||||||
case SharedFeature:
|
|
||||||
SharedFeatureCount--;
|
|
||||||
break;
|
|
||||||
case Slot:
|
|
||||||
SlotCount--;
|
|
||||||
break;
|
|
||||||
case SoftwareList:
|
|
||||||
SoftwareListCount--;
|
|
||||||
break;
|
|
||||||
case Sound:
|
|
||||||
SoundCount--;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the item count for a given item type, defaulting to 0 if it does not exist
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="itemType">Item type to retrieve</param>
|
||||||
|
/// <returns>The number of items of that type, if it exists</returns>
|
||||||
|
public long GetItemCount(ItemType itemType)
|
||||||
|
{
|
||||||
|
lock (ItemCounts)
|
||||||
|
{
|
||||||
|
if (!ItemCounts.ContainsKey(itemType))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return ItemCounts[itemType];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Increment the item count for a given item type
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="itemType">Item type to increment</param>
|
||||||
|
/// <param name="interval">Amount to increment by, defaults to 1</param>
|
||||||
|
private void AddItemCount(ItemType itemType, long interval = 1)
|
||||||
|
{
|
||||||
|
lock (ItemCounts)
|
||||||
|
{
|
||||||
|
if (!ItemCounts.ContainsKey(itemType))
|
||||||
|
ItemCounts[itemType] = 0;
|
||||||
|
|
||||||
|
ItemCounts[itemType] += interval;
|
||||||
|
if (ItemCounts[itemType] < 0)
|
||||||
|
ItemCounts[itemType] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Decrement the item count for a given item type
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="itemType">Item type to decrement</param>
|
||||||
|
/// <param name="interval">Amount to increment by, defaults to 1</param>
|
||||||
|
private void RemoveItemCount(ItemType itemType, long interval = 1)
|
||||||
|
{
|
||||||
|
lock (ItemCounts)
|
||||||
|
{
|
||||||
|
if (!ItemCounts.ContainsKey(itemType))
|
||||||
|
return;
|
||||||
|
|
||||||
|
ItemCounts[itemType] -= interval;
|
||||||
|
if (ItemCounts[itemType] < 0)
|
||||||
|
ItemCounts[itemType] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Constructors
|
#region Constructors
|
||||||
@@ -1451,14 +1137,7 @@ CREATE TABLE IF NOT EXISTS groups (
|
|||||||
{
|
{
|
||||||
TotalCount = 0;
|
TotalCount = 0;
|
||||||
|
|
||||||
ArchiveCount = 0;
|
ItemCounts = [];
|
||||||
BiosSetCount = 0;
|
|
||||||
ChipCount = 0;
|
|
||||||
DiskCount = 0;
|
|
||||||
MediaCount = 0;
|
|
||||||
ReleaseCount = 0;
|
|
||||||
RomCount = 0;
|
|
||||||
SampleCount = 0;
|
|
||||||
|
|
||||||
GameCount = 0;
|
GameCount = 0;
|
||||||
|
|
||||||
@@ -1484,24 +1163,29 @@ CREATE TABLE IF NOT EXISTS groups (
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private ItemKey GetBestAvailable()
|
private ItemKey GetBestAvailable()
|
||||||
{
|
{
|
||||||
|
// Get the item counts for the 3 hashable types
|
||||||
|
long diskCount = GetItemCount(ItemType.Disk);
|
||||||
|
long mediaCount = GetItemCount(ItemType.Media);
|
||||||
|
long romCount = GetItemCount(ItemType.Rom);
|
||||||
|
|
||||||
// If all items are supposed to have a SHA-512, we bucket by that
|
// If all items are supposed to have a SHA-512, we bucket by that
|
||||||
if (DiskCount + MediaCount + RomCount - NodumpCount == SHA512Count)
|
if (diskCount + mediaCount + romCount - NodumpCount == SHA512Count)
|
||||||
return ItemKey.SHA512;
|
return ItemKey.SHA512;
|
||||||
|
|
||||||
// If all items are supposed to have a SHA-384, we bucket by that
|
// If all items are supposed to have a SHA-384, we bucket by that
|
||||||
else if (DiskCount + MediaCount + RomCount - NodumpCount == SHA384Count)
|
else if (diskCount + mediaCount + romCount - NodumpCount == SHA384Count)
|
||||||
return ItemKey.SHA384;
|
return ItemKey.SHA384;
|
||||||
|
|
||||||
// If all items are supposed to have a SHA-256, we bucket by that
|
// If all items are supposed to have a SHA-256, we bucket by that
|
||||||
else if (DiskCount + MediaCount + RomCount - NodumpCount == SHA256Count)
|
else if (diskCount + mediaCount + romCount - NodumpCount == SHA256Count)
|
||||||
return ItemKey.SHA256;
|
return ItemKey.SHA256;
|
||||||
|
|
||||||
// If all items are supposed to have a SHA-1, we bucket by that
|
// If all items are supposed to have a SHA-1, we bucket by that
|
||||||
else if (DiskCount + MediaCount + RomCount - NodumpCount == SHA1Count)
|
else if (diskCount + mediaCount + romCount - NodumpCount == SHA1Count)
|
||||||
return ItemKey.SHA1;
|
return ItemKey.SHA1;
|
||||||
|
|
||||||
// If all items are supposed to have a MD5, we bucket by that
|
// If all items are supposed to have a MD5, we bucket by that
|
||||||
else if (DiskCount + MediaCount + RomCount - NodumpCount == MD5Count)
|
else if (diskCount + mediaCount + romCount - NodumpCount == MD5Count)
|
||||||
return ItemKey.MD5;
|
return ItemKey.MD5;
|
||||||
|
|
||||||
// Otherwise, we bucket by CRC
|
// Otherwise, we bucket by CRC
|
||||||
|
|||||||
@@ -120,7 +120,11 @@ namespace SabreTools.DatTools
|
|||||||
/// <param name="datFile">Current DatFile object to write from</param>
|
/// <param name="datFile">Current DatFile object to write from</param>
|
||||||
public static void WriteStatsToConsole(DatFile datFile)
|
public static void WriteStatsToConsole(DatFile datFile)
|
||||||
{
|
{
|
||||||
if (datFile.Items.RomCount + datFile.Items.DiskCount == 0)
|
long diskCount = datFile.Items.GetItemCount(ItemType.Disk);
|
||||||
|
long mediaCount = datFile.Items.GetItemCount(ItemType.Media);
|
||||||
|
long romCount = datFile.Items.GetItemCount(ItemType.Rom);
|
||||||
|
|
||||||
|
if (diskCount + mediaCount + romCount == 0)
|
||||||
datFile.Items.RecalculateStats();
|
datFile.Items.RecalculateStats();
|
||||||
|
|
||||||
datFile.Items.BucketBy(ItemKey.Machine, DedupeType.None, norename: true);
|
datFile.Items.BucketBy(ItemKey.Machine, DedupeType.None, norename: true);
|
||||||
|
|||||||
@@ -237,12 +237,12 @@ body {
|
|||||||
|
|
||||||
xtw.WriteStartElement("td");
|
xtw.WriteStartElement("td");
|
||||||
xtw.WriteAttributeString("align", "right");
|
xtw.WriteAttributeString("align", "right");
|
||||||
xtw.WriteString(stat.Statistics.RomCount.ToString());
|
xtw.WriteString(stat.Statistics.GetItemCount(Core.ItemType.Rom).ToString());
|
||||||
xtw.WriteEndElement(); // td
|
xtw.WriteEndElement(); // td
|
||||||
|
|
||||||
xtw.WriteStartElement("td");
|
xtw.WriteStartElement("td");
|
||||||
xtw.WriteAttributeString("align", "right");
|
xtw.WriteAttributeString("align", "right");
|
||||||
xtw.WriteString(stat.Statistics.DiskCount.ToString());
|
xtw.WriteString(stat.Statistics.GetItemCount(Core.ItemType.Disk).ToString());
|
||||||
xtw.WriteEndElement(); // td
|
xtw.WriteEndElement(); // td
|
||||||
|
|
||||||
xtw.WriteStartElement("td");
|
xtw.WriteStartElement("td");
|
||||||
|
|||||||
@@ -131,8 +131,8 @@ namespace SabreTools.Reports.Formats
|
|||||||
stat.DisplayName!,
|
stat.DisplayName!,
|
||||||
stat.Statistics!.TotalSize.ToString(),
|
stat.Statistics!.TotalSize.ToString(),
|
||||||
stat.MachineCount.ToString(),
|
stat.MachineCount.ToString(),
|
||||||
stat.Statistics.RomCount.ToString(),
|
stat.Statistics.GetItemCount(Core.ItemType.Rom).ToString(),
|
||||||
stat.Statistics.DiskCount.ToString(),
|
stat.Statistics.GetItemCount(Core.ItemType.Disk).ToString(),
|
||||||
stat.Statistics.CRCCount.ToString(),
|
stat.Statistics.CRCCount.ToString(),
|
||||||
stat.Statistics.MD5Count.ToString(),
|
stat.Statistics.MD5Count.ToString(),
|
||||||
stat.Statistics.SHA1Count.ToString(),
|
stat.Statistics.SHA1Count.ToString(),
|
||||||
|
|||||||
@@ -93,8 +93,8 @@ namespace SabreTools.Reports.Formats
|
|||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
Uncompressed size: " + GetBytesReadable(stat.Statistics!.TotalSize) + @"
|
Uncompressed size: " + GetBytesReadable(stat.Statistics!.TotalSize) + @"
|
||||||
Games found: " + stat.MachineCount + @"
|
Games found: " + stat.MachineCount + @"
|
||||||
Roms found: " + stat.Statistics.RomCount + @"
|
Roms found: " + stat.Statistics.GetItemCount(Core.ItemType.Rom) + @"
|
||||||
Disks found: " + stat.Statistics.DiskCount + @"
|
Disks found: " + stat.Statistics.GetItemCount(Core.ItemType.Disk) + @"
|
||||||
Roms with CRC: " + stat.Statistics.CRCCount + @"
|
Roms with CRC: " + stat.Statistics.CRCCount + @"
|
||||||
Roms with MD5: " + stat.Statistics.MD5Count + @"
|
Roms with MD5: " + stat.Statistics.MD5Count + @"
|
||||||
Roms with SHA-1: " + stat.Statistics.SHA1Count + @"
|
Roms with SHA-1: " + stat.Statistics.SHA1Count + @"
|
||||||
|
|||||||
Reference in New Issue
Block a user