From ff2730a722e9ee106d7579345b62da2edc5c8d74 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Mon, 13 Jul 2026 14:35:24 -0400 Subject: [PATCH] Replace SiteCode enum with SiteCode type --- .../Data/ExtensionsTests.cs | 23 +- .../Tools/FormatterTests.cs | 4 +- SabreTools.RedumpLib/Data/Enumerations.cs | 298 --------- SabreTools.RedumpLib/Data/Extensions.cs | 227 +------ SabreTools.RedumpLib/Data/SiteCode.cs | 568 ++++++++++++++++++ SabreTools.RedumpLib/Tools/Builder.cs | 131 ++-- SabreTools.RedumpLib/Tools/Formatter.cs | 7 +- 7 files changed, 659 insertions(+), 599 deletions(-) create mode 100644 SabreTools.RedumpLib/Data/SiteCode.cs diff --git a/SabreTools.RedumpLib.Test/Data/ExtensionsTests.cs b/SabreTools.RedumpLib.Test/Data/ExtensionsTests.cs index a262437..e221590 100644 --- a/SabreTools.RedumpLib.Test/Data/ExtensionsTests.cs +++ b/SabreTools.RedumpLib.Test/Data/ExtensionsTests.cs @@ -2324,7 +2324,6 @@ namespace SabreTools.RedumpLib.Test.Data SiteCode.InternalSerialName, SiteCode.ISBN, SiteCode.ISSN, - SiteCode.LogsLink, SiteCode.Multisession, SiteCode.PCMacHybrid, SiteCode.PFIHash, @@ -2437,7 +2436,7 @@ namespace SabreTools.RedumpLib.Test.Data [MemberData(nameof(GenerateBooleanSiteCodesTestData))] public void SiteCode_IsBoolean(SiteCode? siteCode, bool expected) { - bool actual = siteCode.IsBoolean(); + bool actual = siteCode?.IsBoolean ?? false; Assert.Equal(expected, actual); } @@ -2450,7 +2449,7 @@ namespace SabreTools.RedumpLib.Test.Data [MemberData(nameof(GenerateCommentSiteCodesTestData))] public void SiteCode_IsCommentCode(SiteCode? siteCode, bool expected) { - bool actual = siteCode.IsCommentCode(); + bool actual = siteCode?.IsCommentCode ?? false; Assert.Equal(expected, actual); } @@ -2463,7 +2462,7 @@ namespace SabreTools.RedumpLib.Test.Data [MemberData(nameof(GenerateContentSiteCodesTestData))] public void SiteCode_IsContentCode(SiteCode? siteCode, bool expected) { - bool actual = siteCode.IsContentCode(); + bool actual = siteCode?.IsContentCode ?? false; Assert.Equal(expected, actual); } @@ -2476,7 +2475,7 @@ namespace SabreTools.RedumpLib.Test.Data [MemberData(nameof(GenerateMultilineSiteCodesTestData))] public void SiteCode_IsMultiLine(SiteCode? siteCode, bool expected) { - bool actual = siteCode.IsMultiLine(); + bool actual = siteCode?.IsMultiLine ?? false; Assert.Equal(expected, actual); } @@ -2489,7 +2488,7 @@ namespace SabreTools.RedumpLib.Test.Data [MemberData(nameof(GenerateSiteCodeTestData))] public void SiteCode_LongName(SiteCode? siteCode, bool expectNull) { - var actual = siteCode.LongName(); + var actual = siteCode?.HTML; if (expectNull) Assert.Null(actual); @@ -2506,7 +2505,7 @@ namespace SabreTools.RedumpLib.Test.Data [MemberData(nameof(GenerateSiteCodeTestData))] public void SiteCode_ShortName(SiteCode? siteCode, bool expectNull) { - var actual = siteCode.ShortName(); + var actual = siteCode?.Code; if (expectNull) Assert.Null(actual); @@ -2521,7 +2520,7 @@ namespace SabreTools.RedumpLib.Test.Data public static TheoryData GenerateSiteCodeTestData() { var testData = new TheoryData() { { null, true } }; - foreach (SiteCode? siteCode in Enum.GetValues().Cast()) + foreach (SiteCode? siteCode in SiteCode.AllSiteCodes) { testData.Add(siteCode, false); } @@ -2536,7 +2535,7 @@ namespace SabreTools.RedumpLib.Test.Data public static TheoryData GenerateBooleanSiteCodesTestData() { var testData = new TheoryData() { { null, false } }; - foreach (SiteCode siteCode in Enum.GetValues()) + foreach (SiteCode siteCode in SiteCode.AllSiteCodes) { if (_booleanSiteCodes.Contains(siteCode)) testData.Add(siteCode, true); @@ -2554,7 +2553,7 @@ namespace SabreTools.RedumpLib.Test.Data public static TheoryData GenerateCommentSiteCodesTestData() { var testData = new TheoryData() { { null, false } }; - foreach (SiteCode siteCode in Enum.GetValues()) + foreach (SiteCode siteCode in SiteCode.AllSiteCodes) { if (_commentSiteCodes.Contains(siteCode)) testData.Add(siteCode, true); @@ -2572,7 +2571,7 @@ namespace SabreTools.RedumpLib.Test.Data public static TheoryData GenerateContentSiteCodesTestData() { var testData = new TheoryData() { { null, false } }; - foreach (SiteCode siteCode in Enum.GetValues()) + foreach (SiteCode siteCode in SiteCode.AllSiteCodes) { if (_contentSiteCodes.Contains(siteCode)) testData.Add(siteCode, true); @@ -2590,7 +2589,7 @@ namespace SabreTools.RedumpLib.Test.Data public static TheoryData GenerateMultilineSiteCodesTestData() { var testData = new TheoryData() { { null, false } }; - foreach (SiteCode siteCode in Enum.GetValues()) + foreach (SiteCode siteCode in SiteCode.AllSiteCodes) { if (_multilineSiteCodes.Contains(siteCode)) testData.Add(siteCode, true); diff --git a/SabreTools.RedumpLib.Test/Tools/FormatterTests.cs b/SabreTools.RedumpLib.Test/Tools/FormatterTests.cs index 2cee677..ba37b0b 100644 --- a/SabreTools.RedumpLib.Test/Tools/FormatterTests.cs +++ b/SabreTools.RedumpLib.Test/Tools/FormatterTests.cs @@ -1068,7 +1068,7 @@ namespace SabreTools.RedumpLib.Test.Tools public void OrderCommentTags_All_Ordered() { Dictionary tags = []; - foreach (SiteCode code in Enum.GetValues()) + foreach (SiteCode code in SiteCode.AllSiteCodes) { tags[code] = "XXXXXX"; } @@ -1107,7 +1107,7 @@ namespace SabreTools.RedumpLib.Test.Tools public void OrderContentTags_All_Ordered() { Dictionary tags = []; - foreach (SiteCode code in Enum.GetValues()) + foreach (SiteCode code in SiteCode.AllSiteCodes) { tags[code] = "XXXXXX"; } diff --git a/SabreTools.RedumpLib/Data/Enumerations.cs b/SabreTools.RedumpLib/Data/Enumerations.cs index 3a43693..7157eed 100644 --- a/SabreTools.RedumpLib/Data/Enumerations.cs +++ b/SabreTools.RedumpLib/Data/Enumerations.cs @@ -292,304 +292,6 @@ namespace SabreTools.RedumpLib.Data #endregion } - /// - /// List of all Redump site codes - /// - /// TODO: Add numeric values or convert to constants - 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 = "Dice Multimedia:", LongName = "Dice Multimedia:")] - DiceMultimedia, - - // 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, - - // This doesn't have a site tag yet - [HumanReadable(ShortName = "Focus Multimedia:", LongName = "Focus Multimedia:")] - FocusMultimedia, - - [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, - - // This doesn't have a site tag yet - [HumanReadable(ShortName = "GSP Software:", LongName = "GSP Software:")] - GSPSoftware, - - [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, promoted to field in redump.info - [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 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, - - [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 476f71e..4ba59e2 100644 --- a/SabreTools.RedumpLib/Data/Extensions.cs +++ b/SabreTools.RedumpLib/Data/Extensions.cs @@ -883,14 +883,14 @@ namespace SabreTools.RedumpLib.Data { var siteCodes = new List(); - foreach (var val in Enum.GetValues(typeof(SiteCode))) + foreach (var val in SiteCode.AllSiteCodes) { - string? shortName = ((SiteCode?)val).ShortName()?.TrimEnd(':'); - string? longName = ((SiteCode?)val).LongName()?.TrimEnd(':'); + string? shortName = val.Code?.TrimEnd(':'); + string longName = val.HTML.TrimEnd(':'); - bool isCommentCode = ((SiteCode?)val).IsCommentCode(); - bool isContentCode = ((SiteCode?)val).IsContentCode(); - bool isMultiline = ((SiteCode?)val).IsMultiLine(); + bool isCommentCode = val.IsCommentCode; + bool isContentCode = val.IsContentCode; + bool isMultiline = val.IsMultiLine; // Invalid codes should be skipped if (shortName is null || longName is null) @@ -924,221 +924,6 @@ namespace SabreTools.RedumpLib.Data 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.RingPerfectAudioOffset => true, - SiteCode.Series => true, - SiteCode.SSHash => true, - SiteCode.SSVersion => true, - SiteCode.SteamAppID => true, - SiteCode.TitleID => 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.DiceMultimedia => true, - SiteCode.DisneyInteractiveID => true, - SiteCode.EidosID => true, - SiteCode.ElectronicArtsID => true, - SiteCode.FocusMultimedia => true, - SiteCode.FoxInteractiveID => true, - SiteCode.GSPSoftware => 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/SiteCode.cs b/SabreTools.RedumpLib/Data/SiteCode.cs new file mode 100644 index 0000000..8163b37 --- /dev/null +++ b/SabreTools.RedumpLib/Data/SiteCode.cs @@ -0,0 +1,568 @@ +namespace SabreTools.RedumpLib.Data +{ + /// + /// Represents a single site code + /// + public sealed class SiteCode + { + #region Properties + + /// + /// HTML tag representing the code + /// + public readonly string HTML; + + /// + /// Short code, if it exists + /// + public readonly string? Code; + + /// + /// Indicates if a site code is boolean + /// + public readonly bool IsBoolean; + + /// + /// Indicates if the site code can go in the comments section + /// + public readonly bool IsCommentCode; + + /// + /// Indicates if the site code can go in the contents section + /// + public readonly bool IsContentCode; + + /// + /// Indicates if the site code can span multiple lines + /// + public readonly bool IsMultiLine; + + #endregion + + #region Constructors + + /// + /// Constructor + /// + private SiteCode(string html, + string? code = null, + bool isBoolean = false, + bool isCommentCode = false, + bool isContentCode = false, + bool isMultiLine = false) + { + HTML = html; + + Code = code; + IsBoolean = isBoolean; + IsCommentCode = isCommentCode; + IsContentCode = isContentCode; + IsMultiLine = isMultiLine; + } + + #endregion + + #region Static Instances + + public static readonly SiteCode AcclaimID = new("Acclaim ID:", + code: "[T:ACC]", + isCommentCode: true); + + // This doesn't have a site tag yet + public static readonly SiteCode AccoladeID = new("Accolade ID:", + code: "Accolade ID:", + isCommentCode: true); + + public static readonly SiteCode ActivisionID = new("Activision ID:", + code: "[T:ACT]", + isCommentCode: true); + + // This doesn't have a site tag yet + public static readonly SiteCode AdditionalBCAData = new("Additional BCA Data:", + code: "Additional BCA Data:", + isCommentCode: true); + + public static readonly SiteCode AlternativeTitle = new("Alternative Title:", + code: "[T:ALT]", + isCommentCode: true); + + public static readonly SiteCode AlternativeForeignTitle = new("Alternative Foreign Title:", + code: "[T:ALTF]", + isCommentCode: true); + + // This doesn't have a site tag yet + public static readonly SiteCode Applications = new("Applications:", + code: "Applications:", + isContentCode: true); + + public static readonly SiteCode BandaiID = new("Bandai ID:", + code: "[T:BID]", + isCommentCode: true); + + public static readonly SiteCode BBFCRegistrationNumber = new("BBFC Reg. No.:", + code: "[T:BBFC]", + isCommentCode: true); + + // This doesn't have a site tag yet + public static readonly SiteCode BethesdaID = new("Bethesda ID:", + code: "Bethesda ID:", + isCommentCode: true); + + // This doesn't have a site tag yet + public static readonly SiteCode CDProjektID = new("CD Projekt ID:", + code: "CD Projekt ID:", + isCommentCode: true); + + // This doesn't have a site tag yet + public static readonly SiteCode CompatibleOS = new("Compatible OS:", + code: "Compatible OS:", + isCommentCode: true); + + // This doesn't have a site tag yet + public static readonly SiteCode CoverID = new("Cover ID:", + code: "Cover ID:", + isCommentCode: true); + + // This doesn't have a site tag yet + public static readonly SiteCode DiceMultimedia = new("Dice Multimedia:", + code: "Dice Multimedia:", + isCommentCode: true); + + // This doesn't have a site tag yet + public static readonly SiteCode DiscHologramID = new("Disc Hologram ID:", + code: "Disc Hologram ID:", + isCommentCode: true); + + // This doesn't have a site tag yet + public static readonly SiteCode DiscID = new("Disc ID:", + code: "Disc ID:", + isCommentCode: true); + + // This doesn't have a site tag yet + public static readonly SiteCode DiscTitleNonLatin = new("Disc Title (non-Latin):", + code: "Disc Title (non-Latin):", + isCommentCode: true); + + // This doesn't have a site tag yet + public static readonly SiteCode DisneyInteractiveID = new("Disney Interactive ID:", + code: "Disney Interactive ID", + isCommentCode: true); + + // This doesn't have a site tag yet + public static readonly SiteCode DMIHash = new("DMI:", + code: "DMI:", + isCommentCode: true); + + public static readonly SiteCode DNASDiscID = new("DNAS Disc ID:", + code: "[T:DNAS]", + isCommentCode: true); + + // This doesn't have a site tag yet + public static readonly SiteCode EditionNonLatin = new("Edition (non-Latin):", + code: "Edition (non-Latin):", + isCommentCode: true); + + // This doesn't have a site tag yet + public static readonly SiteCode EidosID = new("Eidos ID:", + code: "Eidos ID:", + isCommentCode: true); + + public static readonly SiteCode ElectronicArtsID = new("Electronic Arts ID:", + code: "[T:EAID]", + isCommentCode: true); + + public static readonly SiteCode Extras = new("Extras:", + code: "[T:X]", + isContentCode: true, + isMultiLine: true); + + // This doesn't have a site tag yet + public static readonly SiteCode Filename = new("Filename:", + code: "Filename:", + isCommentCode: true, + isMultiLine: true); + + // This doesn't have a site tag yet + public static readonly SiteCode FocusMultimedia = new("Focus Multimedia:", + code: "Focus Multimedia:", + isCommentCode: true); + + public static readonly SiteCode FoxInteractiveID = new("Fox Interactive ID:", + code: "[T:FIID]", + isCommentCode: true); + + public static readonly SiteCode GameFootage = new("Game Footage:", + code: "[T:GF]", + isContentCode: true, + isMultiLine: true); + + // This doesn't have a site tag yet + public static readonly SiteCode Games = new("Games:", + code: "Games:", + isContentCode: true, + isMultiLine: true); + + public static readonly SiteCode Genre = new("Genre:", + code: "[T:G]", + isCommentCode: true); + + // This doesn't have a site tag yet + public static readonly SiteCode GSPSoftware = new("GSP Software:", + code: "GSP Software:", + isCommentCode: true); + + public static readonly SiteCode GTInteractiveID = new("GT Interactive ID:", + code: "[T:GTID]", + isCommentCode: true); + + // This doesn't have a site tag yet + public static readonly SiteCode HighSierraVolumeDescriptor = new("High Sierra Volume Descriptor:", + code: "High Sierra Volume Descriptor:", + isCommentCode: true, + isMultiLine: true); + + // This doesn't have a site tag yet + public static readonly SiteCode InternalName = new("Internal Name:", + code: "Internal Name:", + isCommentCode: true); + + public static readonly SiteCode InternalSerialName = new("Internal Serial:", + code: "[T:ISN]", + isCommentCode: true); + + // This doesn't have a site tag yet + public static readonly SiteCode InterplayID = new("Interplay ID:", + code: "Interplay ID:", + isCommentCode: true); + + public static readonly SiteCode ISBN = new("ISBN:", + code: "[T:ISBN]", + isCommentCode: true); + + public static readonly SiteCode ISSN = new("ISSN:", + code: "[T:ISSN]", + isCommentCode: true); + + public static readonly SiteCode JASRACID = new("JASRAC ID:", + code: "[T:JID]", + isCommentCode: true); + + public static readonly SiteCode KingRecordsID = new("King Records ID:", + code: "[T:KIRZ]", + isCommentCode: true); + + public static readonly SiteCode KoeiID = new("Koei ID:", + code: "[T:KOEI]", + isCommentCode: true); + + public static readonly SiteCode KonamiID = new("Konami ID:", + code: "[T:KID]", + isCommentCode: true); + + public static readonly SiteCode LucasArtsID = new("Lucas Arts ID:", + code: "[T:LAID]", + isCommentCode: true); + + // This doesn't have a site tag yet + public static readonly SiteCode MicrosoftID = new("Microsoft ID:", + code: "Microsoft ID:", + isCommentCode: true); + + // This doesn't have a site tag yet + public static readonly SiteCode Multisession = new("Multisession:", + code: "Multisession:", + isCommentCode: true, + isMultiLine: true); + + public static readonly SiteCode NaganoID = new("Nagano ID:", + code: "[T:NGID]", + isCommentCode: true); + + public static readonly SiteCode NamcoID = new("Namco ID:", + code: "[T:NID]", + isCommentCode: true); + + public static readonly SiteCode NetYarozeGames = new("Net Yaroze Games:", + code: "[T:NYG]", + isContentCode: true, + isMultiLine: true); + + public static readonly SiteCode NipponIchiSoftwareID = new("Nippon Ichi Software ID:", + code: "[T:NPS]", + isCommentCode: true); + + public static readonly SiteCode OriginID = new("Origin ID:", + code: "[T:OID]", + isCommentCode: true); + + public static readonly SiteCode Patches = new("Patches:", + code: "[T:P]", + isContentCode: true, + isMultiLine: true); + + public static readonly SiteCode PCMacHybrid = new("PC/Mac Hybrid", + code: "PC/Mac Hybrid", + isBoolean: true, + isCommentCode: true); + + // This doesn't have a site tag yet + public static readonly SiteCode PFIHash = new("PFI:", + code: "PFI:", + isCommentCode: true); + + public static readonly SiteCode PlayableDemos = new("Playable Demos:", + code: "[T:PD]", + isContentCode: true, + isMultiLine: true); + + public static readonly SiteCode PonyCanyonID = new("Pony Canyon ID:", + code: "[T:PCID]", + isCommentCode: true); + + public static readonly SiteCode PostgapType = new("Postgap type: Form 2", + code: "[T:PT2]", + isBoolean: true, + isCommentCode: true); + + public static readonly SiteCode PPN = new("PPN:", + code: "[T:PPN]", + isCommentCode: true); + + // This doesn't have a site tag for some systems yet + public static readonly SiteCode Protection = new("Protection:", + code: "Protection:", + isCommentCode: true); + + // This doesn't have a site tag yet + public static readonly SiteCode RingPerfectAudioOffset = new("Ring Perfect Audio Offset:", + code: "Ring Perfect Audio Offset:", + isCommentCode: true); + + public static readonly SiteCode RollingDemos = new("Rolling Demos:", + code: "[T:RD]", + isContentCode: true, + isMultiLine: true); + + public static readonly SiteCode Savegames = new("Savegames:", + code: "[T:SG]", + isContentCode: true, + isMultiLine: true); + + public static readonly SiteCode SegaID = new("Sega ID:", + code: "[T:SID]", + isCommentCode: true); + + public static readonly SiteCode SelenID = new("Selen ID:", + code: "[T:SNID]", + isCommentCode: true); + + public static readonly SiteCode Series = new("Series:", + code: "[T:S]", + isCommentCode: true); + + // This doesn't have a site tag yet + public static readonly SiteCode SierraID = new("Sierra ID:", + code: "Sierra ID:", + isCommentCode: true); + + // This doesn't have a site tag yet + public static readonly SiteCode SSHash = new("SS:", + code: "SS:", + isCommentCode: true); + + // This doesn't have a site tag yet + public static readonly SiteCode SSVersion = new("SS version:", + code: "SS version:", + isCommentCode: true); + + // This doesn't have a site tag yet + public static readonly SiteCode SteamAppID = new("Steam AppID:", + code: "Steam App ID:", + isCommentCode: true); + + // This doesn't have a site tag yet + public static readonly SiteCode SteamCsmCsdDepotID = new("Steam Depot ID (.sis/.csm/.csd):", + code: "Steam Depot ID (.sis/.csm/.csd):", + isContentCode: true, + isMultiLine: true); + + // This doesn't have a site tag yet + public static readonly SiteCode SteamSimSidDepotID = new("Steam Depot ID (.sis/.sim/.sid):", + code: "Steam Depot ID (.sis/.sim/.sid):", + isContentCode: true, + isMultiLine: true); + + public static readonly SiteCode TaitoID = new("Taito ID:", + code: "[T:TID]", + isCommentCode: true); + + public static readonly SiteCode TechDemos = new("Tech Demos:", + code: "[T:TD]", + isContentCode: true, + isMultiLine: true); + + // This doesn't have a site tag yet + public static readonly SiteCode TitleID = new("Title ID:", + code: "Title ID:", + isCommentCode: true); + + // This doesn't have a site tag yet + public static readonly SiteCode TwoKGamesID = new("2K Games ID:", + code: "2K Games ID:", + isCommentCode: true); + + public static readonly SiteCode UbisoftID = new("Ubisoft ID:", + code: "[T:UID]", + isCommentCode: true); + + public static readonly SiteCode ValveID = new("Valve ID:", + code: "[T:VID]", + isCommentCode: true); + + public static readonly SiteCode VFCCode = new("VFC code:", + code: "[T:VFC]", + isCommentCode: true); + + public static readonly SiteCode Videos = new("Videos:", + code: "[T:V]", + isContentCode: true, + isMultiLine: true); + + public static readonly SiteCode VolumeLabel = new("Volume Label:", + code: "[T:VOL]", + isCommentCode: true); + + public static readonly SiteCode VCD = new("V-CD", + code: "[T:VCD]", + isBoolean: true, + isCommentCode: true); + + // This doesn't have a site tag yet + public static readonly SiteCode XeMID = new("XeMID:", + code: "XeMID:", + isCommentCode: true); + + // This doesn't have a site tag yet + public static readonly SiteCode XMID = new("XMID:", + code: "XMID:", + isCommentCode: true); + + #endregion + + #region Static Collections + + /// + /// All site codes + /// + /// TODO: Figure out how to remove delimiters + public static readonly SiteCode[] AllSiteCodes = + [ + AcclaimID, + AccoladeID, + ActivisionID, + AdditionalBCAData, + AlternativeTitle, + AlternativeForeignTitle, + Applications, + + BandaiID, + BBFCRegistrationNumber, + BethesdaID, + + CDProjektID, + CompatibleOS, + CoverID, + + DiceMultimedia, + DiscHologramID, + DiscID, + DiscTitleNonLatin, + DisneyInteractiveID, + DMIHash, + DNASDiscID, + + EditionNonLatin, + EidosID, + ElectronicArtsID, + Extras, + + Filename, + FocusMultimedia, + FoxInteractiveID, + + GameFootage, + Games, + Genre, + GSPSoftware, + GTInteractiveID, + + HighSierraVolumeDescriptor, + + InternalName, + InternalSerialName, + InterplayID, + ISBN, + ISSN, + + JASRACID, + + KingRecordsID, + KoeiID, + KonamiID, + + LucasArtsID, + + MicrosoftID, + Multisession, + + NaganoID, + NamcoID, + NetYarozeGames, + + NipponIchiSoftwareID, + + OriginID, + + Patches, + PCMacHybrid, + PFIHash, + PlayableDemos, + PonyCanyonID, + PostgapType, + PPN, + Protection, + + RingPerfectAudioOffset, + RollingDemos, + + Savegames, + SegaID, + SelenID, + Series, + SierraID, + SSHash, + SSVersion, + SteamAppID, + SteamCsmCsdDepotID, + SteamSimSidDepotID, + + TaitoID, + TechDemos, + TitleID, + TwoKGamesID, + + UbisoftID, + + ValveID, + VFCCode, + Videos, + VolumeLabel, + VCD, + + XeMID, + XMID, + ]; + + #endregion + } +} diff --git a/SabreTools.RedumpLib/Tools/Builder.cs b/SabreTools.RedumpLib/Tools/Builder.cs index 42bc0ae..1abbd4e 100644 --- a/SabreTools.RedumpLib/Tools/Builder.cs +++ b/SabreTools.RedumpLib/Tools/Builder.cs @@ -159,7 +159,7 @@ namespace SabreTools.RedumpLib.Tools { match = Constants.SerialRegex.Match(discData); if (match.Success) - info.DiscIdentifiers.DiscSerials = $"(VERIFY THIS) {WebUtility.HtmlDecode(match.Groups[1].Value)}"; + info.DiscIdentifiers.DiscSerials = $"(VERIFY THIS) {WebUtility.HtmlDecode(match.Groups[1].Value)}"; } // Error Count @@ -236,8 +236,7 @@ namespace SabreTools.RedumpLib.Tools continue; // If the line doesn't contain this tag, just skip - var shortName = siteCode.ShortName(); - if (shortName is null || !commentLine.Contains(shortName)) + if (siteCode.Code is null || !commentLine.Contains(siteCode.Code)) continue; // Mark as having found a tag @@ -247,19 +246,19 @@ namespace SabreTools.RedumpLib.Tools lastSiteCode = siteCode; // A subset of tags can be multiline - addToLast = siteCode.IsMultiLine(); + addToLast = siteCode.IsMultiLine; // Skip certain site codes because of data issues if (ShouldSkipSiteCode(siteCode)) continue; // If we don't already have this site code, add it to the dictionary - if (!info.DumpMetadata.CommentsSpecialFields.ContainsKey(siteCode.Value)) - info.DumpMetadata.CommentsSpecialFields[siteCode.Value] = $"(VERIFY THIS) {commentLine.Replace(shortName, string.Empty).Trim()}"; + if (!info.DumpMetadata.CommentsSpecialFields.ContainsKey(siteCode)) + info.DumpMetadata.CommentsSpecialFields[siteCode] = $"(VERIFY THIS) {commentLine.Replace(siteCode.Code, string.Empty).Trim()}"; // Otherwise, append the value to the existing key else - info.DumpMetadata.CommentsSpecialFields[siteCode.Value] += $", {commentLine.Replace(shortName, string.Empty).Trim()}"; + info.DumpMetadata.CommentsSpecialFields[siteCode] += $", {commentLine.Replace(siteCode.Code, string.Empty).Trim()}"; break; } @@ -269,10 +268,10 @@ namespace SabreTools.RedumpLib.Tools { if (addToLast && lastSiteCode is not null && !ShouldSkipSiteCode(lastSiteCode)) { - if (!string.IsNullOrEmpty(info.DumpMetadata.CommentsSpecialFields![lastSiteCode.Value])) - info.DumpMetadata.CommentsSpecialFields[lastSiteCode.Value] += "\n"; + if (!string.IsNullOrEmpty(info.DumpMetadata.CommentsSpecialFields![lastSiteCode])) + info.DumpMetadata.CommentsSpecialFields[lastSiteCode] += "\n"; - info.DumpMetadata.CommentsSpecialFields[lastSiteCode.Value] += commentLine; + info.DumpMetadata.CommentsSpecialFields[lastSiteCode] += commentLine; } else if (!addToLast || lastSiteCode is null) { @@ -333,19 +332,18 @@ namespace SabreTools.RedumpLib.Tools continue; // If the line doesn't contain this tag, just skip - var shortName = siteCode.ShortName(); - if (shortName is null || !contentLine.Contains(shortName)) + if (siteCode.Code is null || !contentLine.Contains(siteCode.Code)) continue; // Cache the current site code lastSiteCode = siteCode; // If we don't already have this site code, add it to the dictionary - if (!info.DumpMetadata.ContentsSpecialFields.ContainsKey(siteCode.Value)) - info.DumpMetadata.ContentsSpecialFields[siteCode.Value] = $"(VERIFY THIS) {contentLine.Replace(shortName, string.Empty).Trim()}"; + if (!info.DumpMetadata.ContentsSpecialFields.ContainsKey(siteCode)) + info.DumpMetadata.ContentsSpecialFields[siteCode] = $"(VERIFY THIS) {contentLine.Replace(siteCode.Code, string.Empty).Trim()}"; // A subset of tags can be multiline - addToLast = siteCode.IsMultiLine(); + addToLast = siteCode.IsMultiLine; // Mark as having found a tag foundTag = true; @@ -357,10 +355,10 @@ namespace SabreTools.RedumpLib.Tools { if (addToLast && lastSiteCode is not null && !ShouldSkipSiteCode(lastSiteCode)) { - if (!string.IsNullOrEmpty(info.DumpMetadata.ContentsSpecialFields![lastSiteCode.Value])) - info.DumpMetadata.ContentsSpecialFields[lastSiteCode.Value] += "\n"; + if (!string.IsNullOrEmpty(info.DumpMetadata.ContentsSpecialFields![lastSiteCode])) + info.DumpMetadata.ContentsSpecialFields[lastSiteCode] += "\n"; - info.DumpMetadata.ContentsSpecialFields[lastSiteCode.Value] += contentLine; + info.DumpMetadata.ContentsSpecialFields[lastSiteCode] += contentLine; } else if (!addToLast || lastSiteCode is null) { @@ -470,39 +468,49 @@ namespace SabreTools.RedumpLib.Tools /// private static bool ShouldSkipSiteCode(SiteCode? siteCode) { -#pragma warning disable IDE0072 - return siteCode switch - { - // Multiple - SiteCode.HighSierraVolumeDescriptor - or SiteCode.InternalSerialName - or SiteCode.Multisession - or SiteCode.VolumeLabel => true, + // Multiple + if (siteCode == SiteCode.HighSierraVolumeDescriptor) + return true; + else if (siteCode == SiteCode.InternalSerialName) + return true; + else if (siteCode == SiteCode.Multisession) + return true; + else if (siteCode == SiteCode.VolumeLabel) + return true; - // Audio CD - SiteCode.RingPerfectAudioOffset => true, + // Audio CD + if (siteCode == SiteCode.RingPerfectAudioOffset) + return true; - // Microsoft Xbox and Xbox 360 - SiteCode.DMIHash - or SiteCode.PFIHash - or SiteCode.SSHash - or SiteCode.SSVersion - or SiteCode.XMID - or SiteCode.XeMID => true, + // Microsoft Xbox and Xbox 360 + if (siteCode == SiteCode.DMIHash) + return true; + else if (siteCode == SiteCode.PFIHash) + return true; + else if (siteCode == SiteCode.SSHash) + return true; + else if (siteCode == SiteCode.SSVersion) + return true; + else if (siteCode == SiteCode.XMID) + return true; + else if (siteCode == SiteCode.XeMID) + return true; - // Microsoft Xbox One and Series X/S - SiteCode.Filename => true, - SiteCode.TitleID => true, + // Microsoft Xbox One and Series X/S + if (siteCode == SiteCode.Filename) + return true; + else if (siteCode == SiteCode.TitleID) + return true; - // Nintendo Gamecube - SiteCode.InternalName => true, + // Nintendo Gamecube + if (siteCode == SiteCode.InternalName) + return true; - // Protection - SiteCode.Protection => true, + // Protection + if (siteCode == SiteCode.Protection) + return true; - _ => false, - }; -#pragma warning restore IDE0072 + return false; } #endregion @@ -520,27 +528,26 @@ namespace SabreTools.RedumpLib.Tools if (text.Length == 0) return text; - foreach (SiteCode? siteCode in Enum.GetValues(typeof(SiteCode))) + foreach (SiteCode? siteCode in SiteCode.AllSiteCodes) { - var longname = siteCode.LongName(); - if (!string.IsNullOrEmpty(longname)) - text = text.Replace(longname, siteCode.ShortName()); + if (!string.IsNullOrEmpty(siteCode.HTML)) + text = text.Replace(siteCode.HTML, siteCode.Code); } // For some outdated tags, we need to use alternate names - text = text.Replace("Demos:", ((SiteCode?)SiteCode.PlayableDemos).ShortName()); - text = text.Replace("Disney ID:", ((SiteCode?)SiteCode.DisneyInteractiveID).ShortName()); - text = text.Replace("DMI:", ((SiteCode?)SiteCode.DMIHash).ShortName()); - text = text.Replace("LucasArts ID:", ((SiteCode?)SiteCode.LucasArtsID).ShortName()); - text = text.Replace("PFI:", ((SiteCode?)SiteCode.PFIHash).ShortName()); - text = text.Replace("SS:", ((SiteCode?)SiteCode.SSHash).ShortName()); - text = text.Replace("SSv1:", ((SiteCode?)SiteCode.SSHash).ShortName()); - text = text.Replace("SSv1:", ((SiteCode?)SiteCode.SSHash).ShortName()); - text = text.Replace("SSv2:", ((SiteCode?)SiteCode.SSHash).ShortName()); - text = text.Replace("SSv2:", ((SiteCode?)SiteCode.SSHash).ShortName()); - text = text.Replace("SS version:", ((SiteCode?)SiteCode.SSVersion).ShortName()); - text = text.Replace("XeMID:", ((SiteCode?)SiteCode.XeMID).ShortName()); - text = text.Replace("XMID:", ((SiteCode?)SiteCode.XMID).ShortName()); + text = text.Replace("Demos:", SiteCode.PlayableDemos.Code); + text = text.Replace("Disney ID:", SiteCode.DisneyInteractiveID.Code); + text = text.Replace("DMI:", SiteCode.DMIHash.Code); + text = text.Replace("LucasArts ID:", SiteCode.LucasArtsID.Code); + text = text.Replace("PFI:", SiteCode.PFIHash.Code); + text = text.Replace("SS:", SiteCode.SSHash.Code); + text = text.Replace("SSv1:", SiteCode.SSHash.Code); + text = text.Replace("SSv1:", SiteCode.SSHash.Code); + text = text.Replace("SSv2:", SiteCode.SSHash.Code); + text = text.Replace("SSv2:", SiteCode.SSHash.Code); + text = text.Replace("SS version:", SiteCode.SSVersion.Code); + text = text.Replace("XeMID:", SiteCode.XeMID.Code); + text = text.Replace("XMID:", SiteCode.XMID.Code); return text; } diff --git a/SabreTools.RedumpLib/Tools/Formatter.cs b/SabreTools.RedumpLib/Tools/Formatter.cs index fd44df3..65c844c 100644 --- a/SabreTools.RedumpLib/Tools/Formatter.cs +++ b/SabreTools.RedumpLib/Tools/Formatter.cs @@ -588,11 +588,10 @@ namespace SabreTools.RedumpLib.Tools if (value.Length == 0) return string.Empty; - bool isMultiLine = code.IsMultiLine(); - string line = $"{code.ShortName()}{(isMultiLine ? "\n" : " ")}"; + string line = $"{code.Code}{(code.IsMultiLine ? "\n" : " ")}"; // Special case for boolean fields - if (code.IsBoolean()) + if (code.IsBoolean) { if (value != true.ToString()) return string.Empty; @@ -600,7 +599,7 @@ namespace SabreTools.RedumpLib.Tools return line.Trim(); } - return $"{line}{value}{(isMultiLine ? "\n" : string.Empty)}"; + return $"{line}{value}{(code.IsMultiLine ? "\n" : string.Empty)}"; } ///