diff --git a/gaseous-identifier/Objects/RomSignatureObject.cs b/gaseous-identifier/Objects/RomSignatureObject.cs index 4843e4e..6d7482c 100644 --- a/gaseous-identifier/Objects/RomSignatureObject.cs +++ b/gaseous-identifier/Objects/RomSignatureObject.cs @@ -10,33 +10,33 @@ namespace gaseous_identifier.objects /// 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 Games { get; set; } + public List Games { get; set; } = new List(); 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 Country { get; set; } public KeyValuePair Language { get; set; } public KeyValuePair Copyright { get; set; } public KeyValuePair DevelopmentStatus { get; set; } - public List Roms { get; set; } + public List Roms { get; set; } = new List(); 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 { diff --git a/gaseous-identifier/Program.cs b/gaseous-identifier/Program.cs index 28b556b..bfdfe5a 100644 --- a/gaseous-identifier/Program.cs +++ b/gaseous-identifier/Program.cs @@ -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 tosecLists = new List(); +List romSignatures = new List(); +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) {