From 54da06a16c06369bcb5ee00e8cee2de943a08b64 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Sun, 14 Jun 2026 19:20:19 -0400 Subject: [PATCH] Merge back the last of the enums --- .../RedumpOrg/ExtensionsTests.cs | 3 +- .../RedumpOrg/FormatterTests.cs | 1 - .../SubmissionInfoTests.cs | 1 - SabreTools.RedumpLib/Data/Enumerations.cs | 293 +++++++++++++++++ SabreTools.RedumpLib/Data/Extensions.cs | 266 ++++++++++++++++ .../Data/Sections/CommonDiscInfoSection.cs | 1 - SabreTools.RedumpLib/RedumpInfo/Client.cs | 1 - SabreTools.RedumpLib/RedumpInfo/UrlBuilder.cs | 1 - .../RedumpOrg/Data/Enumerations.cs | 297 ------------------ .../RedumpOrg/Data/Extensions.cs | 272 ---------------- SabreTools.RedumpLib/RedumpOrg/Formatter.cs | 3 +- SabreTools.RedumpLib/Validator.cs | 2 +- 12 files changed, 562 insertions(+), 579 deletions(-) delete mode 100644 SabreTools.RedumpLib/RedumpOrg/Data/Enumerations.cs delete mode 100644 SabreTools.RedumpLib/RedumpOrg/Data/Extensions.cs diff --git a/SabreTools.RedumpLib.Test/RedumpOrg/ExtensionsTests.cs b/SabreTools.RedumpLib.Test/RedumpOrg/ExtensionsTests.cs index 74ef938..acca239 100644 --- a/SabreTools.RedumpLib.Test/RedumpOrg/ExtensionsTests.cs +++ b/SabreTools.RedumpLib.Test/RedumpOrg/ExtensionsTests.cs @@ -2,7 +2,6 @@ using System.Data; using System.Linq; using SabreTools.RedumpLib.Data; -using SabreTools.RedumpLib.RedumpOrg.Data; using Xunit; namespace SabreTools.RedumpLib.Test.RedumpOrg @@ -145,7 +144,7 @@ namespace SabreTools.RedumpLib.Test.RedumpOrg [Fact] public void SiteCode_ListSiteCodes() { - var actual = RedumpLib.RedumpOrg.Data.Extensions.ListSiteCodes(); + var actual = Extensions.ListSiteCodes(); Assert.NotEmpty(actual); } diff --git a/SabreTools.RedumpLib.Test/RedumpOrg/FormatterTests.cs b/SabreTools.RedumpLib.Test/RedumpOrg/FormatterTests.cs index 34048f8..aea13c4 100644 --- a/SabreTools.RedumpLib.Test/RedumpOrg/FormatterTests.cs +++ b/SabreTools.RedumpLib.Test/RedumpOrg/FormatterTests.cs @@ -5,7 +5,6 @@ using System.Text; using SabreTools.RedumpLib.Data; using SabreTools.RedumpLib.Data.Sections; using SabreTools.RedumpLib.RedumpOrg; -using SabreTools.RedumpLib.RedumpOrg.Data; using Xunit; namespace SabreTools.RedumpLib.Test.RedumpOrg diff --git a/SabreTools.RedumpLib.Test/SubmissionInfoTests.cs b/SabreTools.RedumpLib.Test/SubmissionInfoTests.cs index 613b1b8..9246364 100644 --- a/SabreTools.RedumpLib.Test/SubmissionInfoTests.cs +++ b/SabreTools.RedumpLib.Test/SubmissionInfoTests.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using Newtonsoft.Json; using SabreTools.RedumpLib.Data; using SabreTools.RedumpLib.Data.Sections; -using SabreTools.RedumpLib.RedumpOrg.Data; using Xunit; namespace SabreTools.RedumpLib.Test diff --git a/SabreTools.RedumpLib/Data/Enumerations.cs b/SabreTools.RedumpLib/Data/Enumerations.cs index 156da31..d1760e3 100644 --- a/SabreTools.RedumpLib/Data/Enumerations.cs +++ b/SabreTools.RedumpLib/Data/Enumerations.cs @@ -3612,6 +3612,299 @@ namespace SabreTools.RedumpLib.Data #endregion } + /// + /// List of all Redump site codes + /// + public enum SiteCode + { + [HumanReadable(ShortName = "[T:ACC]", LongName = "Acclaim ID:")] + AcclaimID, + + // This doesn't have a site tag yet + [HumanReadable(ShortName = "Accolade ID:", LongName = "Accolade ID:")] + AccoladeID, + + [HumanReadable(ShortName = "[T:ACT]", LongName = "Activision ID:")] + ActivisionID, + + // This doesn't have a site tag yet + [HumanReadable(ShortName = "Additional BCA Data:", LongName = "Additional BCA Data:")] + AdditionalBCAData, + + [HumanReadable(ShortName = "[T:ALT]", LongName = "Alternative Title:")] + AlternativeTitle, + + [HumanReadable(ShortName = "[T:ALTF]", LongName = "Alternative Foreign Title:")] + AlternativeForeignTitle, + + // This doesn't have a site tag yet + [HumanReadable(ShortName = "Applications:", LongName = "Applications:")] + Applications, + + [HumanReadable(ShortName = "[T:BID]", LongName = "Bandai ID:")] + BandaiID, + + [HumanReadable(ShortName = "[T:BBFC]", LongName = "BBFC Reg. No.:")] + BBFCRegistrationNumber, + + // This doesn't have a site tag yet + [HumanReadable(ShortName = "Bethesda ID:", LongName = "Bethesda ID:")] + BethesdaID, + + // This doesn't have a site tag yet + [HumanReadable(ShortName = "CD Projekt ID:", LongName = "CD Projekt ID:")] + CDProjektID, + + // This doesn't have a site tag yet + [HumanReadable(ShortName = "Compatible OS:", LongName = "Compatible OS:")] + CompatibleOS, + + // This doesn't have a site tag yet + [HumanReadable(ShortName = "Cover ID:", LongName = "Cover ID:")] + CoverID, + + // This doesn't have a site tag yet + [HumanReadable(ShortName = "Disc Hologram ID:", LongName = "Disc Hologram ID:")] + DiscHologramID, + + // This doesn't have a site tag yet + [HumanReadable(ShortName = "Disc ID:", LongName = "Disc ID:")] + DiscID, + + // This doesn't have a site tag yet + [HumanReadable(ShortName = "Disc Title (non-Latin):", LongName = "Disc Title (non-Latin):")] + DiscTitleNonLatin, + + // This doesn't have a site tag yet + [HumanReadable(ShortName = "Disney Interactive ID", LongName = "Disney Interactive ID:")] + DisneyInteractiveID, + + // This doesn't have a site tag yet + [HumanReadable(ShortName = "DMI:", LongName = "DMI:")] + DMIHash, + + [HumanReadable(ShortName = "[T:DNAS]", LongName = "DNAS Disc ID:")] + DNASDiscID, + + // This doesn't have a site tag yet + [HumanReadable(ShortName = "Edition (non-Latin):", LongName = "Edition (non-Latin):")] + EditionNonLatin, + + // This doesn't have a site tag yet + [HumanReadable(ShortName = "Eidos ID:", LongName = "Eidos ID:")] + EidosID, + + [HumanReadable(ShortName = "[T:EAID]", LongName = "Electronic Arts ID:")] + ElectronicArtsID, + + [HumanReadable(ShortName = "[T:X]", LongName = "Extras:")] + Extras, + + // This doesn't have a site tag yet + [HumanReadable(ShortName = "Filename:", LongName = "Filename:")] + Filename, + + [HumanReadable(ShortName = "[T:FIID]", LongName = "Fox Interactive ID:")] + FoxInteractiveID, + + [HumanReadable(ShortName = "[T:GF]", LongName = "Game Footage:")] + GameFootage, + + // This doesn't have a site tag yet + [HumanReadable(ShortName = "Games:", LongName = "Games:")] + Games, + + [HumanReadable(ShortName = "[T:G]", LongName = "Genre:")] + Genre, + + [HumanReadable(ShortName = "[T:GTID]", LongName = "GT Interactive ID:")] + GTInteractiveID, + + // This doesn't have a site tag yet + [HumanReadable(ShortName = "High Sierra Volume Descriptor:", LongName = "High Sierra Volume Descriptor:")] + HighSierraVolumeDescriptor, + + // This doesn't have a site tag yet + [HumanReadable(ShortName = "Internal Name:", LongName = "Internal Name:")] + InternalName, + + [HumanReadable(ShortName = "[T:ISN]", LongName = "Internal Serial:")] + InternalSerialName, + + // This doesn't have a site tag yet + [HumanReadable(ShortName = "Interplay ID:", LongName = "Interplay ID:")] + InterplayID, + + [HumanReadable(ShortName = "[T:ISBN]", LongName = "ISBN:")] + ISBN, + + [HumanReadable(ShortName = "[T:ISSN]", LongName = "ISSN:")] + ISSN, + + [HumanReadable(ShortName = "[T:JID]", LongName = "JASRAC ID:")] + JASRACID, + + [HumanReadable(ShortName = "[T:KIRZ]", LongName = "King Records ID:")] + KingRecordsID, + + [HumanReadable(ShortName = "[T:KOEI]", LongName = "Koei ID:")] + KoeiID, + + [HumanReadable(ShortName = "[T:KID]", LongName = "Konami ID:")] + KonamiID, + + // This doesn't have a site tag yet + [HumanReadable(ShortName = "Logs Link:", LongName = "Logs Link:")] + LogsLink, + + [HumanReadable(ShortName = "[T:LAID]", LongName = "Lucas Arts ID:")] + LucasArtsID, + + // This doesn't have a site tag yet + [HumanReadable(ShortName = "Microsoft ID:", LongName = "Microsoft ID:")] + MicrosoftID, + + // This doesn't have a site tag yet + [HumanReadable(ShortName = "Multisession:", LongName = "Multisession:")] + Multisession, + + [HumanReadable(ShortName = "[T:NGID]", LongName = "Nagano ID:")] + NaganoID, + + [HumanReadable(ShortName = "[T:NID]", LongName = "Namco ID:")] + NamcoID, + + [HumanReadable(ShortName = "[T:NYG]", LongName = "Net Yaroze Games:")] + NetYarozeGames, + + [HumanReadable(ShortName = "[T:NPS]", LongName = "Nippon Ichi Software ID:")] + NipponIchiSoftwareID, + + [HumanReadable(ShortName = "[T:OID]", LongName = "Origin ID:")] + OriginID, + + [HumanReadable(ShortName = "[T:P]", LongName = "Patches:")] + Patches, + + // This doesn't have a site tag yet + /// No text value after + [HumanReadable(ShortName = "PC/Mac Hybrid", LongName = "PC/Mac Hybrid")] + PCMacHybrid, + + // This doesn't have a site tag yet + [HumanReadable(ShortName = "PFI:", LongName = "PFI:")] + PFIHash, + + [HumanReadable(ShortName = "[T:PD]", LongName = "Playable Demos:")] + PlayableDemos, + + [HumanReadable(ShortName = "[T:PCID]", LongName = "Pony Canyon ID:")] + PonyCanyonID, + + /// No text value after + [HumanReadable(ShortName = "[T:PT2]", LongName = "Postgap type: Form 2")] + PostgapType, + + [HumanReadable(ShortName = "[T:PPN]", LongName = "PPN:")] + PPN, + + // This doesn't have a site tag for some systems yet + [HumanReadable(ShortName = "Protection:", LongName = "Protection:")] + Protection, + + // This doesn't have a site tag yet + [HumanReadable(ShortName = "Ring non-zero data start:", LongName = "Ring non-zero data start:")] + RingNonZeroDataStart, + + // This doesn't have a site tag yet + [HumanReadable(ShortName = "Ring Perfect Audio Offset:", LongName = "Ring Perfect Audio Offset:")] + RingPerfectAudioOffset, + + [HumanReadable(ShortName = "[T:RD]", LongName = "Rolling Demos:")] + RollingDemos, + + [HumanReadable(ShortName = "[T:SG]", LongName = "Savegames:")] + Savegames, + + [HumanReadable(ShortName = "[T:SID]", LongName = "Sega ID:")] + SegaID, + + [HumanReadable(ShortName = "[T:SNID]", LongName = "Selen ID:")] + SelenID, + + [HumanReadable(ShortName = "[T:S]", LongName = "Series:")] + Series, + + // This doesn't have a site tag yet + [HumanReadable(ShortName = "Sierra ID:", LongName = "Sierra ID:")] + SierraID, + + // This doesn't have a site tag yet + [HumanReadable(ShortName = "SS:", LongName = "SS:")] + SSHash, + + // This doesn't have a site tag yet + [HumanReadable(ShortName = "SS version:", LongName = "SS version:")] + SSVersion, + + // This doesn't have a site tag yet + [HumanReadable(ShortName = "Steam App ID:", LongName = "Steam AppID:")] + SteamAppID, + + // This doesn't have a site tag yet + [HumanReadable(ShortName = "Steam Depot ID (.sis/.csm/.csd):", LongName = "Steam Depot ID (.sis/.csm/.csd):")] + SteamCsmCsdDepotID, + + // This doesn't have a site tag yet + [HumanReadable(ShortName = "Steam Depot ID (.sis/.sim/.sid):", LongName = "Steam Depot ID (.sis/.sim/.sid):")] + SteamSimSidDepotID, + + [HumanReadable(ShortName = "[T:TID]", LongName = "Taito ID:")] + TaitoID, + + [HumanReadable(ShortName = "[T:TD]", LongName = "Tech Demos:")] + TechDemos, + + // This doesn't have a site tag yet + [HumanReadable(ShortName = "Title ID:", LongName = "Title ID:")] + TitleID, + + // This doesn't have a site tag yet + [HumanReadable(ShortName = "2K Games ID:", LongName = "2K Games ID:")] + TwoKGamesID, + + [HumanReadable(ShortName = "[T:UID]", LongName = "Ubisoft ID:")] + UbisoftID, + + // This doesn't have a site tag yet + [HumanReadable(ShortName = "Universal Hash (SHA-1):", LongName = "Universal Hash (SHA-1):")] + UniversalHash, + + [HumanReadable(ShortName = "[T:VID]", LongName = "Valve ID:")] + ValveID, + + [HumanReadable(ShortName = "[T:VFC]", LongName = "VFC code:")] + VFCCode, + + [HumanReadable(ShortName = "[T:V]", LongName = "Videos:")] + Videos, + + [HumanReadable(ShortName = "[T:VOL]", LongName = "Volume Label:")] + VolumeLabel, + + /// No text value after + [HumanReadable(ShortName = "[T:VCD]", LongName = "V-CD")] + VCD, + + // This doesn't have a site tag yet + [HumanReadable(ShortName = "XeMID:", LongName = "XeMID:")] + XeMID, + + // This doesn't have a site tag yet + [HumanReadable(ShortName = "XMID:", LongName = "XMID:")] + XMID, + } + /// /// List of all recognized sort parameters /// diff --git a/SabreTools.RedumpLib/Data/Extensions.cs b/SabreTools.RedumpLib/Data/Extensions.cs index 034bb64..a18487e 100644 --- a/SabreTools.RedumpLib/Data/Extensions.cs +++ b/SabreTools.RedumpLib/Data/Extensions.cs @@ -1877,6 +1877,272 @@ namespace SabreTools.RedumpLib.Data #endregion + #region Site Code + + /// + /// List all site codes with their short usable names + /// + public static List ListSiteCodes() + { + var siteCodes = new List(); + + foreach (var val in Enum.GetValues(typeof(SiteCode))) + { + string? shortName = ((SiteCode?)val).ShortName()?.TrimEnd(':'); + string? longName = ((SiteCode?)val).LongName()?.TrimEnd(':'); + + bool isCommentCode = ((SiteCode?)val).IsCommentCode(); + bool isContentCode = ((SiteCode?)val).IsContentCode(); + bool isMultiline = ((SiteCode?)val).IsMultiLine(); + + // Invalid codes should be skipped + if (shortName is null || longName is null) + continue; + + // Handle site tags + string siteCode; + if (shortName == longName) + siteCode = "***".PadRight(16, ' '); + else + siteCode = shortName.PadRight(16, ' '); + + // Handle expanded tags + siteCode += longName.PadRight(32, ' '); + + // Include special indicators, if necessary + var additionalInfo = new List(); + if (isCommentCode) + additionalInfo.Add("Comment Field"); + if (isContentCode) + additionalInfo.Add("Content Field"); + if (isMultiline) + additionalInfo.Add("Multiline"); + if (additionalInfo.Count > 0) + siteCode += $"[{string.Join(", ", [.. additionalInfo])}]"; + + // Add the formatted site code + siteCodes.Add(siteCode); + } + + return siteCodes; + } + + /// + /// Check if a site code is boolean or not + /// + /// SiteCode to check + /// True if the code field is a flag with no value, false otherwise + public static bool IsBoolean(this SiteCode siteCode) + => ((SiteCode?)siteCode).IsBoolean(); + + /// + /// Check if a site code is boolean or not + /// + /// SiteCode to check + /// True if the code field is a flag with no value, false otherwise + public static bool IsBoolean(this SiteCode? siteCode) + { +#pragma warning disable IDE0072 // Add missing cases + return siteCode switch + { + SiteCode.PCMacHybrid => true, + SiteCode.PostgapType => true, + SiteCode.VCD => true, + _ => false, + }; +#pragma warning restore IDE0072 // Add missing cases + } + + /// + /// Check if a site code should live in the comments section + /// + /// True if the code field is in comments by default, false otherwise + public static bool IsCommentCode(this SiteCode siteCode) + => ((SiteCode?)siteCode).IsCommentCode(); + + /// + /// Check if a site code should live in the comments section + /// + /// True if the code field is in comments by default, false otherwise + public static bool IsCommentCode(this SiteCode? siteCode) + { +#pragma warning disable IDE0072 // Add missing cases + return siteCode switch + { + // Identifying Info + SiteCode.AdditionalBCAData => true, + SiteCode.AlternativeTitle => true, + SiteCode.AlternativeForeignTitle => true, + SiteCode.BBFCRegistrationNumber => true, + SiteCode.CompatibleOS => true, + SiteCode.CoverID => true, + SiteCode.DiscHologramID => true, + SiteCode.DiscID => true, + SiteCode.DiscTitleNonLatin => true, + SiteCode.DMIHash => true, + SiteCode.DNASDiscID => true, + SiteCode.EditionNonLatin => true, + SiteCode.Filename => true, + SiteCode.Genre => true, + SiteCode.HighSierraVolumeDescriptor => true, + SiteCode.InternalName => true, + SiteCode.InternalSerialName => true, + SiteCode.ISBN => true, + SiteCode.ISSN => true, + SiteCode.LogsLink => true, + SiteCode.Multisession => true, + SiteCode.PCMacHybrid => true, + SiteCode.PFIHash => true, + SiteCode.PostgapType => true, + SiteCode.PPN => true, + SiteCode.Protection => true, + SiteCode.RingNonZeroDataStart => true, + SiteCode.RingPerfectAudioOffset => true, + SiteCode.Series => true, + SiteCode.SSHash => true, + SiteCode.SSVersion => true, + SiteCode.SteamAppID => true, + SiteCode.TitleID => true, + SiteCode.UniversalHash => true, + SiteCode.VCD => true, + SiteCode.VFCCode => true, + SiteCode.VolumeLabel => true, + SiteCode.XeMID => true, + SiteCode.XMID => true, + + // Publisher / Company IDs + SiteCode.TwoKGamesID => true, + SiteCode.AcclaimID => true, + SiteCode.AccoladeID => true, + SiteCode.ActivisionID => true, + SiteCode.BandaiID => true, + SiteCode.BethesdaID => true, + SiteCode.CDProjektID => true, + SiteCode.DisneyInteractiveID => true, + SiteCode.EidosID => true, + SiteCode.ElectronicArtsID => true, + SiteCode.FoxInteractiveID => true, + SiteCode.GTInteractiveID => true, + SiteCode.InterplayID => true, + SiteCode.JASRACID => true, + SiteCode.KingRecordsID => true, + SiteCode.KoeiID => true, + SiteCode.KonamiID => true, + SiteCode.LucasArtsID => true, + SiteCode.MicrosoftID => true, + SiteCode.NaganoID => true, + SiteCode.NamcoID => true, + SiteCode.NipponIchiSoftwareID => true, + SiteCode.OriginID => true, + SiteCode.PonyCanyonID => true, + SiteCode.SegaID => true, + SiteCode.SelenID => true, + SiteCode.SierraID => true, + SiteCode.TaitoID => true, + SiteCode.UbisoftID => true, + SiteCode.ValveID => true, + + _ => false, + }; +#pragma warning restore IDE0072 // Add missing cases + } + + /// + /// Check if a site code should live in the contents section + /// + /// True if the code field is in contents by default, false otherwise + public static bool IsContentCode(this SiteCode siteCode) + => ((SiteCode?)siteCode).IsContentCode(); + + /// + /// Check if a site code should live in the contents section + /// + /// True if the code field is in contents by default, false otherwise + public static bool IsContentCode(this SiteCode? siteCode) + { +#pragma warning disable IDE0072 // Add missing cases + return siteCode switch + { + SiteCode.Applications => true, + SiteCode.Extras => true, + SiteCode.GameFootage => true, + SiteCode.Games => true, + SiteCode.NetYarozeGames => true, + SiteCode.Patches => true, + SiteCode.PlayableDemos => true, + SiteCode.RollingDemos => true, + SiteCode.Savegames => true, + SiteCode.SteamSimSidDepotID => true, + SiteCode.SteamCsmCsdDepotID => true, + SiteCode.TechDemos => true, + SiteCode.Videos => true, + _ => false, + }; +#pragma warning restore IDE0072 // Add missing cases + } + + /// + /// Check if a site code is multi-line or not + /// + /// True if the code field is multiline by default, false otherwise + public static bool IsMultiLine(this SiteCode siteCode) + => ((SiteCode?)siteCode).IsMultiLine(); + + /// + /// Check if a site code is multi-line or not + /// + /// True if the code field is multiline by default, false otherwise + public static bool IsMultiLine(this SiteCode? siteCode) + { +#pragma warning disable IDE0072 // Add missing cases + return siteCode switch + { + SiteCode.Extras => true, + SiteCode.Filename => true, + SiteCode.Games => true, + SiteCode.GameFootage => true, + SiteCode.HighSierraVolumeDescriptor => true, + SiteCode.Multisession => true, + SiteCode.NetYarozeGames => true, + SiteCode.Patches => true, + SiteCode.PlayableDemos => true, + SiteCode.RollingDemos => true, + SiteCode.Savegames => true, + SiteCode.SteamSimSidDepotID => true, + SiteCode.SteamCsmCsdDepotID => true, + SiteCode.TechDemos => true, + SiteCode.Videos => true, + _ => false, + }; +#pragma warning restore IDE0072 // Add missing cases + } + + /// + /// Get the HTML version for each known site code + /// + public static string? LongName(this SiteCode siteCode) + => AttributeHelper.GetHumanReadableAttribute(siteCode)?.LongName; + + /// + /// Get the HTML version for each known site code + /// + public static string? LongName(this SiteCode? siteCode) + => AttributeHelper.GetHumanReadableAttribute(siteCode)?.LongName; + + /// + /// Get the short tag for each known site code + /// + public static string? ShortName(this SiteCode siteCode) + => AttributeHelper.GetHumanReadableAttribute(siteCode)?.ShortName; + + /// + /// Get the short tag for each known site code + /// + public static string? ShortName(this SiteCode? siteCode) + => AttributeHelper.GetHumanReadableAttribute(siteCode)?.ShortName; + + #endregion + #region Sort Category /// diff --git a/SabreTools.RedumpLib/Data/Sections/CommonDiscInfoSection.cs b/SabreTools.RedumpLib/Data/Sections/CommonDiscInfoSection.cs index 17e7257..092876f 100644 --- a/SabreTools.RedumpLib/Data/Sections/CommonDiscInfoSection.cs +++ b/SabreTools.RedumpLib/Data/Sections/CommonDiscInfoSection.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using Newtonsoft.Json; using SabreTools.RedumpLib.Converters; using SabreTools.RedumpLib.RedumpOrg.Converters; -using SabreTools.RedumpLib.RedumpOrg.Data; namespace SabreTools.RedumpLib.Data.Sections { diff --git a/SabreTools.RedumpLib/RedumpInfo/Client.cs b/SabreTools.RedumpLib/RedumpInfo/Client.cs index ae7bdbf..de70481 100644 --- a/SabreTools.RedumpLib/RedumpInfo/Client.cs +++ b/SabreTools.RedumpLib/RedumpInfo/Client.cs @@ -11,7 +11,6 @@ using System.Text.RegularExpressions; using System.Threading.Tasks; using SabreTools.RedumpLib.Data; using SabreTools.RedumpLib.Web; -using static SabreTools.RedumpLib.RedumpOrg.Data.Extensions; namespace SabreTools.RedumpLib.RedumpInfo { diff --git a/SabreTools.RedumpLib/RedumpInfo/UrlBuilder.cs b/SabreTools.RedumpLib/RedumpInfo/UrlBuilder.cs index 56e49f3..ef836a8 100644 --- a/SabreTools.RedumpLib/RedumpInfo/UrlBuilder.cs +++ b/SabreTools.RedumpLib/RedumpInfo/UrlBuilder.cs @@ -1,7 +1,6 @@ using System; using System.Text; using SabreTools.RedumpLib.Data; -using static SabreTools.RedumpLib.RedumpOrg.Data.Extensions; namespace SabreTools.RedumpLib.RedumpInfo { diff --git a/SabreTools.RedumpLib/RedumpOrg/Data/Enumerations.cs b/SabreTools.RedumpLib/RedumpOrg/Data/Enumerations.cs deleted file mode 100644 index bf2d3e2..0000000 --- a/SabreTools.RedumpLib/RedumpOrg/Data/Enumerations.cs +++ /dev/null @@ -1,297 +0,0 @@ -using SabreTools.RedumpLib.Attributes; - -namespace SabreTools.RedumpLib.RedumpOrg.Data -{ - /// - /// List of all Redump site codes - /// - public enum SiteCode - { - [HumanReadable(ShortName = "[T:ACC]", LongName = "Acclaim ID:")] - AcclaimID, - - // This doesn't have a site tag yet - [HumanReadable(ShortName = "Accolade ID:", LongName = "Accolade ID:")] - AccoladeID, - - [HumanReadable(ShortName = "[T:ACT]", LongName = "Activision ID:")] - ActivisionID, - - // This doesn't have a site tag yet - [HumanReadable(ShortName = "Additional BCA Data:", LongName = "Additional BCA Data:")] - AdditionalBCAData, - - [HumanReadable(ShortName = "[T:ALT]", LongName = "Alternative Title:")] - AlternativeTitle, - - [HumanReadable(ShortName = "[T:ALTF]", LongName = "Alternative Foreign Title:")] - AlternativeForeignTitle, - - // This doesn't have a site tag yet - [HumanReadable(ShortName = "Applications:", LongName = "Applications:")] - Applications, - - [HumanReadable(ShortName = "[T:BID]", LongName = "Bandai ID:")] - BandaiID, - - [HumanReadable(ShortName = "[T:BBFC]", LongName = "BBFC Reg. No.:")] - BBFCRegistrationNumber, - - // This doesn't have a site tag yet - [HumanReadable(ShortName = "Bethesda ID:", LongName = "Bethesda ID:")] - BethesdaID, - - // This doesn't have a site tag yet - [HumanReadable(ShortName = "CD Projekt ID:", LongName = "CD Projekt ID:")] - CDProjektID, - - // This doesn't have a site tag yet - [HumanReadable(ShortName = "Compatible OS:", LongName = "Compatible OS:")] - CompatibleOS, - - // This doesn't have a site tag yet - [HumanReadable(ShortName = "Cover ID:", LongName = "Cover ID:")] - CoverID, - - // This doesn't have a site tag yet - [HumanReadable(ShortName = "Disc Hologram ID:", LongName = "Disc Hologram ID:")] - DiscHologramID, - - // This doesn't have a site tag yet - [HumanReadable(ShortName = "Disc ID:", LongName = "Disc ID:")] - DiscID, - - // This doesn't have a site tag yet - [HumanReadable(ShortName = "Disc Title (non-Latin):", LongName = "Disc Title (non-Latin):")] - DiscTitleNonLatin, - - // This doesn't have a site tag yet - [HumanReadable(ShortName = "Disney Interactive ID", LongName = "Disney Interactive ID:")] - DisneyInteractiveID, - - // This doesn't have a site tag yet - [HumanReadable(ShortName = "DMI:", LongName = "DMI:")] - DMIHash, - - [HumanReadable(ShortName = "[T:DNAS]", LongName = "DNAS Disc ID:")] - DNASDiscID, - - // This doesn't have a site tag yet - [HumanReadable(ShortName = "Edition (non-Latin):", LongName = "Edition (non-Latin):")] - EditionNonLatin, - - // This doesn't have a site tag yet - [HumanReadable(ShortName = "Eidos ID:", LongName = "Eidos ID:")] - EidosID, - - [HumanReadable(ShortName = "[T:EAID]", LongName = "Electronic Arts ID:")] - ElectronicArtsID, - - [HumanReadable(ShortName = "[T:X]", LongName = "Extras:")] - Extras, - - // This doesn't have a site tag yet - [HumanReadable(ShortName = "Filename:", LongName = "Filename:")] - Filename, - - [HumanReadable(ShortName = "[T:FIID]", LongName = "Fox Interactive ID:")] - FoxInteractiveID, - - [HumanReadable(ShortName = "[T:GF]", LongName = "Game Footage:")] - GameFootage, - - // This doesn't have a site tag yet - [HumanReadable(ShortName = "Games:", LongName = "Games:")] - Games, - - [HumanReadable(ShortName = "[T:G]", LongName = "Genre:")] - Genre, - - [HumanReadable(ShortName = "[T:GTID]", LongName = "GT Interactive ID:")] - GTInteractiveID, - - // This doesn't have a site tag yet - [HumanReadable(ShortName = "High Sierra Volume Descriptor:", LongName = "High Sierra Volume Descriptor:")] - HighSierraVolumeDescriptor, - - // This doesn't have a site tag yet - [HumanReadable(ShortName = "Internal Name:", LongName = "Internal Name:")] - InternalName, - - [HumanReadable(ShortName = "[T:ISN]", LongName = "Internal Serial:")] - InternalSerialName, - - // This doesn't have a site tag yet - [HumanReadable(ShortName = "Interplay ID:", LongName = "Interplay ID:")] - InterplayID, - - [HumanReadable(ShortName = "[T:ISBN]", LongName = "ISBN:")] - ISBN, - - [HumanReadable(ShortName = "[T:ISSN]", LongName = "ISSN:")] - ISSN, - - [HumanReadable(ShortName = "[T:JID]", LongName = "JASRAC ID:")] - JASRACID, - - [HumanReadable(ShortName = "[T:KIRZ]", LongName = "King Records ID:")] - KingRecordsID, - - [HumanReadable(ShortName = "[T:KOEI]", LongName = "Koei ID:")] - KoeiID, - - [HumanReadable(ShortName = "[T:KID]", LongName = "Konami ID:")] - KonamiID, - - // This doesn't have a site tag yet - [HumanReadable(ShortName = "Logs Link:", LongName = "Logs Link:")] - LogsLink, - - [HumanReadable(ShortName = "[T:LAID]", LongName = "Lucas Arts ID:")] - LucasArtsID, - - // This doesn't have a site tag yet - [HumanReadable(ShortName = "Microsoft ID:", LongName = "Microsoft ID:")] - MicrosoftID, - - // This doesn't have a site tag yet - [HumanReadable(ShortName = "Multisession:", LongName = "Multisession:")] - Multisession, - - [HumanReadable(ShortName = "[T:NGID]", LongName = "Nagano ID:")] - NaganoID, - - [HumanReadable(ShortName = "[T:NID]", LongName = "Namco ID:")] - NamcoID, - - [HumanReadable(ShortName = "[T:NYG]", LongName = "Net Yaroze Games:")] - NetYarozeGames, - - [HumanReadable(ShortName = "[T:NPS]", LongName = "Nippon Ichi Software ID:")] - NipponIchiSoftwareID, - - [HumanReadable(ShortName = "[T:OID]", LongName = "Origin ID:")] - OriginID, - - [HumanReadable(ShortName = "[T:P]", LongName = "Patches:")] - Patches, - - // This doesn't have a site tag yet - /// No text value after - [HumanReadable(ShortName = "PC/Mac Hybrid", LongName = "PC/Mac Hybrid")] - PCMacHybrid, - - // This doesn't have a site tag yet - [HumanReadable(ShortName = "PFI:", LongName = "PFI:")] - PFIHash, - - [HumanReadable(ShortName = "[T:PD]", LongName = "Playable Demos:")] - PlayableDemos, - - [HumanReadable(ShortName = "[T:PCID]", LongName = "Pony Canyon ID:")] - PonyCanyonID, - - /// No text value after - [HumanReadable(ShortName = "[T:PT2]", LongName = "Postgap type: Form 2")] - PostgapType, - - [HumanReadable(ShortName = "[T:PPN]", LongName = "PPN:")] - PPN, - - // This doesn't have a site tag for some systems yet - [HumanReadable(ShortName = "Protection:", LongName = "Protection:")] - Protection, - - // This doesn't have a site tag yet - [HumanReadable(ShortName = "Ring non-zero data start:", LongName = "Ring non-zero data start:")] - RingNonZeroDataStart, - - // This doesn't have a site tag yet - [HumanReadable(ShortName = "Ring Perfect Audio Offset:", LongName = "Ring Perfect Audio Offset:")] - RingPerfectAudioOffset, - - [HumanReadable(ShortName = "[T:RD]", LongName = "Rolling Demos:")] - RollingDemos, - - [HumanReadable(ShortName = "[T:SG]", LongName = "Savegames:")] - Savegames, - - [HumanReadable(ShortName = "[T:SID]", LongName = "Sega ID:")] - SegaID, - - [HumanReadable(ShortName = "[T:SNID]", LongName = "Selen ID:")] - SelenID, - - [HumanReadable(ShortName = "[T:S]", LongName = "Series:")] - Series, - - // This doesn't have a site tag yet - [HumanReadable(ShortName = "Sierra ID:", LongName = "Sierra ID:")] - SierraID, - - // This doesn't have a site tag yet - [HumanReadable(ShortName = "SS:", LongName = "SS:")] - SSHash, - - // This doesn't have a site tag yet - [HumanReadable(ShortName = "SS version:", LongName = "SS version:")] - SSVersion, - - // This doesn't have a site tag yet - [HumanReadable(ShortName = "Steam App ID:", LongName = "Steam AppID:")] - SteamAppID, - - // This doesn't have a site tag yet - [HumanReadable(ShortName = "Steam Depot ID (.sis/.csm/.csd):", LongName = "Steam Depot ID (.sis/.csm/.csd):")] - SteamCsmCsdDepotID, - - // This doesn't have a site tag yet - [HumanReadable(ShortName = "Steam Depot ID (.sis/.sim/.sid):", LongName = "Steam Depot ID (.sis/.sim/.sid):")] - SteamSimSidDepotID, - - [HumanReadable(ShortName = "[T:TID]", LongName = "Taito ID:")] - TaitoID, - - [HumanReadable(ShortName = "[T:TD]", LongName = "Tech Demos:")] - TechDemos, - - // This doesn't have a site tag yet - [HumanReadable(ShortName = "Title ID:", LongName = "Title ID:")] - TitleID, - - // This doesn't have a site tag yet - [HumanReadable(ShortName = "2K Games ID:", LongName = "2K Games ID:")] - TwoKGamesID, - - [HumanReadable(ShortName = "[T:UID]", LongName = "Ubisoft ID:")] - UbisoftID, - - // This doesn't have a site tag yet - [HumanReadable(ShortName = "Universal Hash (SHA-1):", LongName = "Universal Hash (SHA-1):")] - UniversalHash, - - [HumanReadable(ShortName = "[T:VID]", LongName = "Valve ID:")] - ValveID, - - [HumanReadable(ShortName = "[T:VFC]", LongName = "VFC code:")] - VFCCode, - - [HumanReadable(ShortName = "[T:V]", LongName = "Videos:")] - Videos, - - [HumanReadable(ShortName = "[T:VOL]", LongName = "Volume Label:")] - VolumeLabel, - - /// No text value after - [HumanReadable(ShortName = "[T:VCD]", LongName = "V-CD")] - VCD, - - // This doesn't have a site tag yet - [HumanReadable(ShortName = "XeMID:", LongName = "XeMID:")] - XeMID, - - // This doesn't have a site tag yet - [HumanReadable(ShortName = "XMID:", LongName = "XMID:")] - XMID, - } -} diff --git a/SabreTools.RedumpLib/RedumpOrg/Data/Extensions.cs b/SabreTools.RedumpLib/RedumpOrg/Data/Extensions.cs deleted file mode 100644 index 65ef248..0000000 --- a/SabreTools.RedumpLib/RedumpOrg/Data/Extensions.cs +++ /dev/null @@ -1,272 +0,0 @@ -using System; -using System.Collections.Generic; -using SabreTools.RedumpLib.Attributes; - -namespace SabreTools.RedumpLib.RedumpOrg.Data -{ - /// - /// Information pertaining to Redump systems - /// -#pragma warning disable IDE0072 - public static class Extensions - { - #region Site Code - - /// - /// List all site codes with their short usable names - /// - public static List ListSiteCodes() - { - var siteCodes = new List(); - - foreach (var val in Enum.GetValues(typeof(SiteCode))) - { - string? shortName = ((SiteCode?)val).ShortName()?.TrimEnd(':'); - string? longName = ((SiteCode?)val).LongName()?.TrimEnd(':'); - - bool isCommentCode = ((SiteCode?)val).IsCommentCode(); - bool isContentCode = ((SiteCode?)val).IsContentCode(); - bool isMultiline = ((SiteCode?)val).IsMultiLine(); - - // Invalid codes should be skipped - if (shortName is null || longName is null) - continue; - - // Handle site tags - string siteCode; - if (shortName == longName) - siteCode = "***".PadRight(16, ' '); - else - siteCode = shortName.PadRight(16, ' '); - - // Handle expanded tags - siteCode += longName.PadRight(32, ' '); - - // Include special indicators, if necessary - var additionalInfo = new List(); - if (isCommentCode) - additionalInfo.Add("Comment Field"); - if (isContentCode) - additionalInfo.Add("Content Field"); - if (isMultiline) - additionalInfo.Add("Multiline"); - if (additionalInfo.Count > 0) - siteCode += $"[{string.Join(", ", [.. additionalInfo])}]"; - - // Add the formatted site code - siteCodes.Add(siteCode); - } - - return siteCodes; - } - - /// - /// Check if a site code is boolean or not - /// - /// SiteCode to check - /// True if the code field is a flag with no value, false otherwise - public static bool IsBoolean(this SiteCode siteCode) - => ((SiteCode?)siteCode).IsBoolean(); - - /// - /// Check if a site code is boolean or not - /// - /// SiteCode to check - /// True if the code field is a flag with no value, false otherwise - public static bool IsBoolean(this SiteCode? siteCode) - { - return siteCode switch - { - SiteCode.PCMacHybrid => true, - SiteCode.PostgapType => true, - SiteCode.VCD => true, - _ => false, - }; - } - - /// - /// Check if a site code should live in the comments section - /// - /// True if the code field is in comments by default, false otherwise - public static bool IsCommentCode(this SiteCode siteCode) - => ((SiteCode?)siteCode).IsCommentCode(); - - /// - /// Check if a site code should live in the comments section - /// - /// True if the code field is in comments by default, false otherwise - public static bool IsCommentCode(this SiteCode? siteCode) - { - return siteCode switch - { - // Identifying Info - SiteCode.AdditionalBCAData => true, - SiteCode.AlternativeTitle => true, - SiteCode.AlternativeForeignTitle => true, - SiteCode.BBFCRegistrationNumber => true, - SiteCode.CompatibleOS => true, - SiteCode.CoverID => true, - SiteCode.DiscHologramID => true, - SiteCode.DiscID => true, - SiteCode.DiscTitleNonLatin => true, - SiteCode.DMIHash => true, - SiteCode.DNASDiscID => true, - SiteCode.EditionNonLatin => true, - SiteCode.Filename => true, - SiteCode.Genre => true, - SiteCode.HighSierraVolumeDescriptor => true, - SiteCode.InternalName => true, - SiteCode.InternalSerialName => true, - SiteCode.ISBN => true, - SiteCode.ISSN => true, - SiteCode.LogsLink => true, - SiteCode.Multisession => true, - SiteCode.PCMacHybrid => true, - SiteCode.PFIHash => true, - SiteCode.PostgapType => true, - SiteCode.PPN => true, - SiteCode.Protection => true, - SiteCode.RingNonZeroDataStart => true, - SiteCode.RingPerfectAudioOffset => true, - SiteCode.Series => true, - SiteCode.SSHash => true, - SiteCode.SSVersion => true, - SiteCode.SteamAppID => true, - SiteCode.TitleID => true, - SiteCode.UniversalHash => true, - SiteCode.VCD => true, - SiteCode.VFCCode => true, - SiteCode.VolumeLabel => true, - SiteCode.XeMID => true, - SiteCode.XMID => true, - - // Publisher / Company IDs - SiteCode.TwoKGamesID => true, - SiteCode.AcclaimID => true, - SiteCode.AccoladeID => true, - SiteCode.ActivisionID => true, - SiteCode.BandaiID => true, - SiteCode.BethesdaID => true, - SiteCode.CDProjektID => true, - SiteCode.DisneyInteractiveID => true, - SiteCode.EidosID => true, - SiteCode.ElectronicArtsID => true, - SiteCode.FoxInteractiveID => true, - SiteCode.GTInteractiveID => true, - SiteCode.InterplayID => true, - SiteCode.JASRACID => true, - SiteCode.KingRecordsID => true, - SiteCode.KoeiID => true, - SiteCode.KonamiID => true, - SiteCode.LucasArtsID => true, - SiteCode.MicrosoftID => true, - SiteCode.NaganoID => true, - SiteCode.NamcoID => true, - SiteCode.NipponIchiSoftwareID => true, - SiteCode.OriginID => true, - SiteCode.PonyCanyonID => true, - SiteCode.SegaID => true, - SiteCode.SelenID => true, - SiteCode.SierraID => true, - SiteCode.TaitoID => true, - SiteCode.UbisoftID => true, - SiteCode.ValveID => true, - - _ => false, - }; - } - - /// - /// Check if a site code should live in the contents section - /// - /// True if the code field is in contents by default, false otherwise - public static bool IsContentCode(this SiteCode siteCode) - => ((SiteCode?)siteCode).IsContentCode(); - - /// - /// Check if a site code should live in the contents section - /// - /// True if the code field is in contents by default, false otherwise - public static bool IsContentCode(this SiteCode? siteCode) - { - return siteCode switch - { - SiteCode.Applications => true, - SiteCode.Extras => true, - SiteCode.GameFootage => true, - SiteCode.Games => true, - SiteCode.NetYarozeGames => true, - SiteCode.Patches => true, - SiteCode.PlayableDemos => true, - SiteCode.RollingDemos => true, - SiteCode.Savegames => true, - SiteCode.SteamSimSidDepotID => true, - SiteCode.SteamCsmCsdDepotID => true, - SiteCode.TechDemos => true, - SiteCode.Videos => true, - _ => false, - }; - } - - /// - /// Check if a site code is multi-line or not - /// - /// True if the code field is multiline by default, false otherwise - public static bool IsMultiLine(this SiteCode siteCode) - => ((SiteCode?)siteCode).IsMultiLine(); - - /// - /// Check if a site code is multi-line or not - /// - /// True if the code field is multiline by default, false otherwise - public static bool IsMultiLine(this SiteCode? siteCode) - { - return siteCode switch - { - SiteCode.Extras => true, - SiteCode.Filename => true, - SiteCode.Games => true, - SiteCode.GameFootage => true, - SiteCode.HighSierraVolumeDescriptor => true, - SiteCode.Multisession => true, - SiteCode.NetYarozeGames => true, - SiteCode.Patches => true, - SiteCode.PlayableDemos => true, - SiteCode.RollingDemos => true, - SiteCode.Savegames => true, - SiteCode.SteamSimSidDepotID => true, - SiteCode.SteamCsmCsdDepotID => true, - SiteCode.TechDemos => true, - SiteCode.Videos => true, - _ => false, - }; - } - - /// - /// Get the HTML version for each known site code - /// - public static string? LongName(this SiteCode siteCode) - => AttributeHelper.GetHumanReadableAttribute(siteCode)?.LongName; - - /// - /// Get the HTML version for each known site code - /// - public static string? LongName(this SiteCode? siteCode) - => AttributeHelper.GetHumanReadableAttribute(siteCode)?.LongName; - - /// - /// Get the short tag for each known site code - /// - public static string? ShortName(this SiteCode siteCode) - => AttributeHelper.GetHumanReadableAttribute(siteCode)?.ShortName; - - /// - /// Get the short tag for each known site code - /// - public static string? ShortName(this SiteCode? siteCode) - => AttributeHelper.GetHumanReadableAttribute(siteCode)?.ShortName; - - #endregion - } -#pragma warning restore IDE0072 -} diff --git a/SabreTools.RedumpLib/RedumpOrg/Formatter.cs b/SabreTools.RedumpLib/RedumpOrg/Formatter.cs index 9e795b7..5a1d84b 100644 --- a/SabreTools.RedumpLib/RedumpOrg/Formatter.cs +++ b/SabreTools.RedumpLib/RedumpOrg/Formatter.cs @@ -4,7 +4,6 @@ using System.Text; using System.Text.RegularExpressions; using SabreTools.RedumpLib.Data; using SabreTools.RedumpLib.Data.Sections; -using SabreTools.RedumpLib.RedumpOrg.Data; namespace SabreTools.RedumpLib.RedumpOrg { @@ -278,7 +277,7 @@ namespace SabreTools.RedumpLib.RedumpOrg bool reverseOrder = system.HasReversedRingcodes(); // Extract the size from the hashes - long size = RedumpLib.Data.Extensions.ExtractSizeFromHashData(tawo?.ClrMameProData); + long size = Extensions.ExtractSizeFromHashData(tawo?.ClrMameProData); output.AppendLine("Common Disc Info:"); diff --git a/SabreTools.RedumpLib/Validator.cs b/SabreTools.RedumpLib/Validator.cs index 4a6c56a..70116a0 100644 --- a/SabreTools.RedumpLib/Validator.cs +++ b/SabreTools.RedumpLib/Validator.cs @@ -37,7 +37,7 @@ namespace SabreTools.RedumpLib case MediaType.BD100: case MediaType.BD128: // Extract the size from the hashes - long size = Data.Extensions.ExtractSizeFromHashData(info.TracksAndWriteOffsets.ClrMameProData); + long size = Extensions.ExtractSizeFromHashData(info.TracksAndWriteOffsets.ClrMameProData); if (info.SizeAndChecksums.Layerbreak3 != default) info.CommonDiscInfo.Media = MediaType.BD128;