Enhanced the loading output on the console

This commit is contained in:
Michael Green
2023-02-17 23:04:05 +11:00
parent af087b4313
commit d76931c949
2 changed files with 55 additions and 37 deletions

View File

@@ -10,33 +10,33 @@ namespace gaseous_identifier.objects
/// </summary>
public class RomSignatureObject
{
public string Name { get; set; }
public string Description { get; set; }
public string Category { get; set; }
public string Version { get; set; }
public string Author { get; set; }
public string Email { get; set; }
public string Homepage { get; set; }
public string? Name { get; set; }
public string? Description { get; set; }
public string? Category { get; set; }
public string? Version { get; set; }
public string? Author { get; set; }
public string? Email { get; set; }
public string? Homepage { get; set; }
public Uri? Url { get; set; }
public string SourceType { get; set; }
public string? SourceType { get; set; }
public List<Game> Games { get; set; }
public List<Game> Games { get; set; } = new List<Game>();
public class Game
{
public string Name { get; set; }
public string Description { get; set; }
public string Year { get; set; }
public string Publisher { get; set; }
public string? Name { get; set; }
public string? Description { get; set; }
public string? Year { get; set; }
public string? Publisher { get; set; }
public DemoTypes Demo { get; set; }
public string System { get; set; }
public string SystemVariant { get; set; }
public string Video { get; set; }
public string? System { get; set; }
public string? SystemVariant { get; set; }
public string? Video { get; set; }
public KeyValuePair<string, string> Country { get; set; }
public KeyValuePair<string, string> Language { get; set; }
public KeyValuePair<string, string> Copyright { get; set; }
public KeyValuePair<string, string> DevelopmentStatus { get; set; }
public List<Rom> Roms { get; set; }
public List<Rom> Roms { get; set; } = new List<Rom>();
public enum DemoTypes
{
@@ -50,17 +50,17 @@ namespace gaseous_identifier.objects
public class Rom
{
public string Name { get; set; }
public UInt64 Size { get; set; }
public string Crc { get; set; }
public string Md5 { get; set; }
public string Sha1 { get; set; }
public string? Name { get; set; }
public UInt64? Size { get; set; }
public string? Crc { get; set; }
public string? Md5 { get; set; }
public string? Sha1 { get; set; }
public string flags { get; set; }
public string? flags { get; set; }
public RomTypes RomType { get; set; }
public string RomTypeMedia { get; set; }
public string MediaLabel { get; set; }
public string? RomTypeMedia { get; set; }
public string? MediaLabel { get; set; }
public enum RomTypes
{

View File

@@ -49,8 +49,10 @@ foreach (string commandLineArg in commandLineArgs)
scanPath = Path.GetFullPath(scanPath);
Console.WriteLine("ROM search path: " + scanPath);
System.Collections.ArrayList TOSEC = new System.Collections.ArrayList();
List<gaseous_identifier.objects.RomSignatureObject> tosecLists = new List<gaseous_identifier.objects.RomSignatureObject>();
List<gaseous_identifier.objects.RomSignatureObject> romSignatures = new List<gaseous_identifier.objects.RomSignatureObject>();
System.Collections.ArrayList availablePlatforms = new System.Collections.ArrayList();
// load TOSEC XML files
if (tosecXML != null && tosecXML.Length > 0)
{
tosecXML = Path.GetFullPath(tosecXML);
@@ -58,27 +60,43 @@ if (tosecXML != null && tosecXML.Length > 0)
Console.WriteLine("TOSEC XML search path: " + tosecXML);
string[] tosecPathContents = Directory.GetFiles(tosecXML);
foreach (string tosecXMLFile in tosecPathContents)
int lastCLILineLength = 0;
for (UInt16 i = 0; i < tosecPathContents.Length; ++i)
{
string tosecXMLFile = tosecPathContents[i];
gaseous_identifier.classes.TosecParser tosecParser = new gaseous_identifier.classes.TosecParser();
gaseous_identifier.objects.RomSignatureObject tosecObject = tosecParser.Parse(tosecXMLFile);
Console.Write(".");
tosecLists.Add(tosecObject);
string statusOutput = i + " / " + tosecPathContents.Length + " : " + Path.GetFileName(tosecXMLFile);
Console.Write("\r " + statusOutput.PadRight(lastCLILineLength, ' ') + "\r");
lastCLILineLength = statusOutput.Length;
foreach (gaseous_identifier.objects.RomSignatureObject.Game gameRom in tosecObject.Games)
{
if (!availablePlatforms.Contains(gameRom.System))
{
availablePlatforms.Add(gameRom.System);
}
}
romSignatures.Add(tosecObject);
}
Console.WriteLine("");
} else
{
Console.WriteLine("TOSEC is disabled, title matching will be by file name only.");
Console.WriteLine("TOSEC is disabled.");
}
Console.WriteLine(tosecLists.Count + " TOSEC files loaded");
Console.WriteLine(romSignatures.Count + " TOSEC files loaded");
if (tosecLists.Count > 0)
// Summarise signatures
if (availablePlatforms.Count > 0)
{
Console.WriteLine("TOSEC lists available:");
foreach (gaseous_identifier.objects.RomSignatureObject tosecList in tosecLists)
availablePlatforms.Sort();
Console.WriteLine("Platforms loaded:");
foreach (string platform in availablePlatforms)
{
Console.WriteLine(" * " + tosecList.Name);
Console.WriteLine(" * " + platform);
}
}
@@ -99,7 +117,7 @@ foreach (string romFile in romPathContents)
string sha1Hash = BitConverter.ToString(md5HashByte).Replace("-", "").ToLowerInvariant();
bool gameFound = false;
foreach (gaseous_identifier.objects.RomSignatureObject tosecList in tosecLists)
foreach (gaseous_identifier.objects.RomSignatureObject tosecList in romSignatures)
{
foreach (gaseous_identifier.objects.RomSignatureObject.Game gameObject in tosecList.Games)
{