diff --git a/SabreTools.Library/DatFiles/AttractMode.cs b/SabreTools.Library/DatFiles/AttractMode.cs index 5eaee600..28de281d 100644 --- a/SabreTools.Library/DatFiles/AttractMode.cs +++ b/SabreTools.Library/DatFiles/AttractMode.cs @@ -233,12 +233,12 @@ namespace SabreTools.Library.DatFiles rom.MachineName = rom.MachineName.Substring(1); } - string state = rom.MachineName + ";" - + rom.MachineDescription + ";" + string state = (!ExcludeFields.Contains(Field.MachineName) ? rom.MachineName : "") + ";" + + (!ExcludeFields.Contains(Field.Description) ? rom.MachineDescription : "") + ";" + FileName + ";" - + rom.CloneOf + ";" - + rom.Year + ";" - + rom.Manufacturer + ";" + + (!ExcludeFields.Contains(Field.CloneOf) ? rom.CloneOf : "") + ";" + + (!ExcludeFields.Contains(Field.Year) ? rom.Year : "") + ";" + + (!ExcludeFields.Contains(Field.Manufacturer) ? rom.Manufacturer : "") + ";" /* + rom.Category */ + ";" /* + rom.Players */ + ";" /* + rom.Rotation */ + ";" @@ -248,7 +248,7 @@ namespace SabreTools.Library.DatFiles /* + rom.DisplayType */ + ";" /* + rom.AltRomname */ + ";" /* + rom.AltTitle */ + ";" - + rom.Comment + ";" + + (!ExcludeFields.Contains(Field.Comment) ? rom.Comment : "") + ";" /* + rom.Buttons */ + "\n"; sw.Write(state); diff --git a/SabreTools.Library/DatFiles/ClrMamePro.cs b/SabreTools.Library/DatFiles/ClrMamePro.cs index e708e67a..4cf43503 100644 --- a/SabreTools.Library/DatFiles/ClrMamePro.cs +++ b/SabreTools.Library/DatFiles/ClrMamePro.cs @@ -826,15 +826,13 @@ namespace SabreTools.Library.DatFiles rom.MachineName = rom.MachineName.Substring(1); } - string state = (rom.MachineType == MachineType.Bios ? "resource" : "game") + " (\n\tname \"" + rom.MachineName + "\"\n" + - (ExcludeOf ? "" : - (String.IsNullOrWhiteSpace(rom.RomOf) ? "" : "\tromof \"" + rom.RomOf + "\"\n") + - (String.IsNullOrWhiteSpace(rom.CloneOf) ? "" : "\tcloneof \"" + rom.CloneOf + "\"\n") + - (String.IsNullOrWhiteSpace(rom.SampleOf) ? "" : "\tsampleof \"" + rom.SampleOf + "\"\n") - ) + - "\tdescription \"" + (String.IsNullOrWhiteSpace(rom.MachineDescription) ? rom.MachineName : rom.MachineDescription) + "\"\n" + - (String.IsNullOrWhiteSpace(rom.Year) ? "" : "\tyear " + rom.Year + "\n") + - (String.IsNullOrWhiteSpace(rom.Manufacturer) ? "" : "\tmanufacturer \"" + rom.Manufacturer + "\"\n"); + string state = (rom.MachineType == MachineType.Bios ? "resource" : "game") + " (\n\tname \"" + (!ExcludeFields[(int)Field.MachineName] ? rom.MachineName : "") + "\"\n" + + (!ExcludeFields[(int)Field.RomOf] && String.IsNullOrWhiteSpace(rom.RomOf) ? "" : "\tromof \"" + rom.RomOf + "\"\n") + + (!ExcludeFields[(int)Field.CloneOf] && String.IsNullOrWhiteSpace(rom.CloneOf) ? "" : "\tcloneof \"" + rom.CloneOf + "\"\n") + + (!ExcludeFields[(int)Field.SampleOf] && String.IsNullOrWhiteSpace(rom.SampleOf) ? "" : "\tsampleof \"" + rom.SampleOf + "\"\n") + + (!ExcludeFields[(int)Field.Description] ? "\tdescription \"" + (String.IsNullOrWhiteSpace(rom.MachineDescription) ? rom.MachineName : rom.MachineDescription) + "\"\n" : "") + + (!ExcludeFields[(int)Field.Year] && String.IsNullOrWhiteSpace(rom.Year) ? "" : "\tyear " + rom.Year + "\n") + + (!ExcludeFields[(int)Field.Manufacturer] && String.IsNullOrWhiteSpace(rom.Manufacturer) ? "" : "\tmanufacturer \"" + rom.Manufacturer + "\"\n"); sw.Write(state); sw.Flush(); @@ -858,7 +856,7 @@ namespace SabreTools.Library.DatFiles { try { - string state = (String.IsNullOrWhiteSpace(rom.SampleOf) ? "" : "\tsampleof \"" + rom.SampleOf + "\"\n") + ")\n"; + string state = (!ExcludeFields[(int)Field.SampleOf] && String.IsNullOrWhiteSpace(rom.SampleOf) ? "" : "\tsampleof \"" + rom.SampleOf + "\"\n") + ")\n"; sw.Write(state); sw.Flush(); @@ -900,52 +898,52 @@ namespace SabreTools.Library.DatFiles switch (rom.Type) { case ItemType.Archive: - state += "\tarchive ( name\"" + rom.Name + "\"" + state += "\tarchive ( name\"" + (!ExcludeFields[(int)Field.Name] ? rom.Name : "") + "\"" + " )\n"; break; case ItemType.BiosSet: - state += "\tbiosset ( name\"" + rom.Name + "\"" - + (!String.IsNullOrWhiteSpace(((BiosSet)rom).Description) ? " description \"" + ((BiosSet)rom).Description + "\"" : "") - + (((BiosSet)rom).Default != null + state += "\tbiosset ( name\"" + (!ExcludeFields[(int)Field.Name] ? rom.Name : "") + "\"" + + (!ExcludeFields[(int)Field.Description] && !String.IsNullOrWhiteSpace(((BiosSet)rom).Description) ? " description \"" + ((BiosSet)rom).Description + "\"" : "") + + (!ExcludeFields[(int)Field.Default] && ((BiosSet)rom).Default != null ? "default " + ((BiosSet)rom).Default.ToString().ToLowerInvariant() : "") + " )\n"; break; case ItemType.Disk: - state += "\tdisk ( name \"" + rom.Name + "\"" - + (!String.IsNullOrWhiteSpace(((Disk)rom).MD5) ? " md5 " + ((Disk)rom).MD5.ToLowerInvariant() : "") - + (!String.IsNullOrWhiteSpace(((Disk)rom).SHA1) ? " sha1 " + ((Disk)rom).SHA1.ToLowerInvariant() : "") - + (!String.IsNullOrWhiteSpace(((Disk)rom).SHA256) ? " sha256 " + ((Disk)rom).SHA256.ToLowerInvariant() : "") - + (!String.IsNullOrWhiteSpace(((Disk)rom).SHA384) ? " sha384 " + ((Disk)rom).SHA384.ToLowerInvariant() : "") - + (!String.IsNullOrWhiteSpace(((Disk)rom).SHA512) ? " sha512 " + ((Disk)rom).SHA512.ToLowerInvariant() : "") - + (((Disk)rom).ItemStatus != ItemStatus.None ? " flags " + ((Disk)rom).ItemStatus.ToString().ToLowerInvariant() : "") + state += "\tdisk ( name \"" + (!ExcludeFields[(int)Field.Name] ? rom.Name : "") + "\"" + + (!ExcludeFields[(int)Field.MD5] && !String.IsNullOrWhiteSpace(((Disk)rom).MD5) ? " md5 " + ((Disk)rom).MD5.ToLowerInvariant() : "") + + (!ExcludeFields[(int)Field.SHA1] && !String.IsNullOrWhiteSpace(((Disk)rom).SHA1) ? " sha1 " + ((Disk)rom).SHA1.ToLowerInvariant() : "") + + (!ExcludeFields[(int)Field.SHA256] && !String.IsNullOrWhiteSpace(((Disk)rom).SHA256) ? " sha256 " + ((Disk)rom).SHA256.ToLowerInvariant() : "") + + (!ExcludeFields[(int)Field.SHA384] && !String.IsNullOrWhiteSpace(((Disk)rom).SHA384) ? " sha384 " + ((Disk)rom).SHA384.ToLowerInvariant() : "") + + (!ExcludeFields[(int)Field.SHA512] && !String.IsNullOrWhiteSpace(((Disk)rom).SHA512) ? " sha512 " + ((Disk)rom).SHA512.ToLowerInvariant() : "") + + (!ExcludeFields[(int)Field.Status] && ((Disk)rom).ItemStatus != ItemStatus.None ? " flags " + ((Disk)rom).ItemStatus.ToString().ToLowerInvariant() : "") + " )\n"; break; case ItemType.Release: - state += "\trelease ( name\"" + rom.Name + "\"" - + (!String.IsNullOrWhiteSpace(((Release)rom).Region) ? " region \"" + ((Release)rom).Region + "\"" : "") - + (!String.IsNullOrWhiteSpace(((Release)rom).Language) ? " language \"" + ((Release)rom).Language + "\"" : "") - + (!String.IsNullOrWhiteSpace(((Release)rom).Date) ? " date \"" + ((Release)rom).Date + "\"" : "") - + (((Release)rom).Default != null + state += "\trelease ( name\"" + (!ExcludeFields[(int)Field.Name] ? rom.Name : "") + "\"" + + (!ExcludeFields[(int)Field.Region] && !String.IsNullOrWhiteSpace(((Release)rom).Region) ? " region \"" + ((Release)rom).Region + "\"" : "") + + (!ExcludeFields[(int)Field.Language] && !String.IsNullOrWhiteSpace(((Release)rom).Language) ? " language \"" + ((Release)rom).Language + "\"" : "") + + (!ExcludeFields[(int)Field.Date] && !String.IsNullOrWhiteSpace(((Release)rom).Date) ? " date \"" + ((Release)rom).Date + "\"" : "") + + (!ExcludeFields[(int)Field.Default] && ((Release)rom).Default != null ? "default " + ((Release)rom).Default.ToString().ToLowerInvariant() : "") + " )\n"; break; case ItemType.Rom: - state += "\trom ( name \"" + rom.Name + "\"" - + (((Rom)rom).Size != -1 ? " size " + ((Rom)rom).Size : "") - + (!String.IsNullOrWhiteSpace(((Rom)rom).CRC) ? " crc " + ((Rom)rom).CRC.ToLowerInvariant() : "") - + (!String.IsNullOrWhiteSpace(((Rom)rom).MD5) ? " md5 " + ((Rom)rom).MD5.ToLowerInvariant() : "") - + (!String.IsNullOrWhiteSpace(((Rom)rom).SHA1) ? " sha1 " + ((Rom)rom).SHA1.ToLowerInvariant() : "") - + (!String.IsNullOrWhiteSpace(((Rom)rom).SHA256) ? " sha256 " + ((Rom)rom).SHA256.ToLowerInvariant() : "") - + (!String.IsNullOrWhiteSpace(((Rom)rom).SHA384) ? " sha384 " + ((Rom)rom).SHA384.ToLowerInvariant() : "") - + (!String.IsNullOrWhiteSpace(((Rom)rom).SHA512) ? " sha512 " + ((Rom)rom).SHA512.ToLowerInvariant() : "") - + (!String.IsNullOrWhiteSpace(((Rom)rom).Date) ? " date \"" + ((Rom)rom).Date + "\"" : "") - + (((Rom)rom).ItemStatus != ItemStatus.None ? " flags " + ((Rom)rom).ItemStatus.ToString().ToLowerInvariant() : "") + state += "\trom ( name \"" + (!ExcludeFields[(int)Field.Name] ? rom.Name : "") + "\"" + + (!ExcludeFields[(int)Field.Size] && ((Rom)rom).Size != -1 ? " size " + ((Rom)rom).Size : "") + + (!ExcludeFields[(int)Field.CRC] && !String.IsNullOrWhiteSpace(((Rom)rom).CRC) ? " crc " + ((Rom)rom).CRC.ToLowerInvariant() : "") + + (!ExcludeFields[(int)Field.MD5] && !String.IsNullOrWhiteSpace(((Disk)rom).MD5) ? " md5 " + ((Disk)rom).MD5.ToLowerInvariant() : "") + + (!ExcludeFields[(int)Field.SHA1] && !String.IsNullOrWhiteSpace(((Disk)rom).SHA1) ? " sha1 " + ((Disk)rom).SHA1.ToLowerInvariant() : "") + + (!ExcludeFields[(int)Field.SHA256] && !String.IsNullOrWhiteSpace(((Disk)rom).SHA256) ? " sha256 " + ((Disk)rom).SHA256.ToLowerInvariant() : "") + + (!ExcludeFields[(int)Field.SHA384] && !String.IsNullOrWhiteSpace(((Disk)rom).SHA384) ? " sha384 " + ((Disk)rom).SHA384.ToLowerInvariant() : "") + + (!ExcludeFields[(int)Field.SHA512] && !String.IsNullOrWhiteSpace(((Disk)rom).SHA512) ? " sha512 " + ((Disk)rom).SHA512.ToLowerInvariant() : "") + + (!ExcludeFields[(int)Field.Date] && !String.IsNullOrWhiteSpace(((Rom)rom).Date) ? " date \"" + ((Rom)rom).Date + "\"" : "") + + (!ExcludeFields[(int)Field.Status] && ((Rom)rom).ItemStatus != ItemStatus.None ? " flags " + ((Rom)rom).ItemStatus.ToString().ToLowerInvariant() : "") + " )\n"; break; case ItemType.Sample: - state += "\tsample ( name\"" + rom.Name + "\"" + state += "\tsample ( name\"" + (!ExcludeFields[(int)Field.Name] ? rom.Name : "") + "\"" + " )\n"; break; } diff --git a/SabreTools.Library/DatFiles/DatFile.cs b/SabreTools.Library/DatFiles/DatFile.cs index 0672db2e..1bcaba1c 100644 --- a/SabreTools.Library/DatFiles/DatFile.cs +++ b/SabreTools.Library/DatFiles/DatFile.cs @@ -286,20 +286,7 @@ namespace SabreTools.Library.DatFiles _datHeader.DatFormat = value; } } - public bool ExcludeOf - { - get - { - EnsureDatHeader(); - return _datHeader.ExcludeOf; - } - set - { - EnsureDatHeader(); - _datHeader.ExcludeOf = value; - } - } - public List ExcludeFields + public bool[] ExcludeFields { get { @@ -1364,7 +1351,7 @@ namespace SabreTools.Library.DatFiles DatFormat = (this.DatFormat != 0 ? this.DatFormat : 0), // Filtering that needs to be copied over - ExcludeOf = this.ExcludeOf, + ExcludeFields = (bool[])this.ExcludeFields.Clone(), OneRom = this.OneRom, KeepEmptyGames = this.KeepEmptyGames, SceneDateStrip = this.SceneDateStrip, @@ -1439,7 +1426,7 @@ namespace SabreTools.Library.DatFiles DatFormat = (this.DatFormat != 0 ? this.DatFormat : 0), // Filtering that needs to be copied over - ExcludeOf = this.ExcludeOf, + ExcludeFields = (bool[])this.ExcludeFields.Clone(), OneRom = this.OneRom, KeepEmptyGames = this.KeepEmptyGames, SceneDateStrip = this.SceneDateStrip, diff --git a/SabreTools.Library/DatFiles/DatHeader.cs b/SabreTools.Library/DatFiles/DatHeader.cs index afa16abf..449f4ccc 100644 --- a/SabreTools.Library/DatFiles/DatHeader.cs +++ b/SabreTools.Library/DatFiles/DatHeader.cs @@ -31,8 +31,7 @@ namespace SabreTools.Library.DatFiles private ForceNodump _forceNodump; private ForcePacking _forcePacking; private DatFormat _datFormat; - private bool _excludeOf; - private List _excludeFields; + private bool[] _excludeFields = new bool[Enum.GetNames(typeof(Field)).Length]; private bool _oneRom; private bool _keepEmptyGames; private bool _sceneDateStrip; @@ -145,12 +144,7 @@ namespace SabreTools.Library.DatFiles get { return _datFormat; } set { _datFormat = value; } } - public bool ExcludeOf - { - get { return _excludeOf; } - set { _excludeOf = value; } - } - public List ExcludeFields + public bool[] ExcludeFields { get { return _excludeFields; } set { _excludeFields = value; } @@ -260,7 +254,6 @@ namespace SabreTools.Library.DatFiles _forceNodump = this._forceNodump, _forcePacking = this._forcePacking, _datFormat = this._datFormat, - _excludeOf = this._excludeOf, _excludeFields = this._excludeFields, _oneRom = this._oneRom, _keepEmptyGames = this._keepEmptyGames, diff --git a/SabreTools.Library/DatFiles/DosCenter.cs b/SabreTools.Library/DatFiles/DosCenter.cs index cb1a63a9..80a1b64a 100644 --- a/SabreTools.Library/DatFiles/DosCenter.cs +++ b/SabreTools.Library/DatFiles/DosCenter.cs @@ -42,6 +42,7 @@ namespace SabreTools.Library.DatFiles /// True if full pathnames are to be kept, false otherwise (default) /// True if game names are sanitized, false otherwise (default) /// True if we should remove non-ASCII characters from output, false otherwise (default) + /// TODO: Pull parsing into this file instead of relying on CMP public override void ParseFile( // Standard Dat parsing string filename, @@ -211,7 +212,7 @@ namespace SabreTools.Library.DatFiles rom.MachineName = rom.MachineName.Substring(1); } - string state = "game (\n\tname \"" + rom.MachineName + ".zip\"\n"; + string state = "game (\n\tname \"" + (!ExcludeFields[(int)Field.MachineName] ? rom.MachineName + ".zip" : "") + "\"\n"; sw.Write(state); sw.Flush(); @@ -235,7 +236,7 @@ namespace SabreTools.Library.DatFiles { try { - string state = (String.IsNullOrWhiteSpace(rom.SampleOf) ? "" : "\tsampleof \"" + rom.SampleOf + "\"\n") + ")\n"; + string state = (!ExcludeFields[(int)Field.SampleOf] && String.IsNullOrWhiteSpace(rom.SampleOf) ? "" : "\tsampleof \"" + rom.SampleOf + "\"\n") + ")\n"; sw.Write(state); sw.Flush(); @@ -283,10 +284,10 @@ namespace SabreTools.Library.DatFiles // We don't output these at all for DosCenter break; case ItemType.Rom: - state += "\tfile ( name " + ((Rom)rom).Name - + (((Rom)rom).Size != -1 ? " size " + ((Rom)rom).Size : "") - + (!String.IsNullOrWhiteSpace(((Rom)rom).Date) ? " date " + ((Rom)rom).Date : "") - + (!String.IsNullOrWhiteSpace(((Rom)rom).CRC) ? " crc " + ((Rom)rom).CRC.ToLowerInvariant() : "") + state += "\tfile ( name " + (!ExcludeFields[(int)Field.Name] ? ((Rom)rom).Name : "") + + (!ExcludeFields[(int)Field.Size] && ((Rom)rom).Size != -1 ? " size " + ((Rom)rom).Size : "") + + (!ExcludeFields[(int)Field.Date] && !String.IsNullOrWhiteSpace(((Rom)rom).Date) ? " date " + ((Rom)rom).Date : "") + + (!ExcludeFields[(int)Field.CRC] && !String.IsNullOrWhiteSpace(((Rom)rom).CRC) ? " crc " + ((Rom)rom).CRC.ToLowerInvariant() : "") + " )\n"; break; } diff --git a/SabreTools.Library/DatFiles/Hashfile.cs b/SabreTools.Library/DatFiles/Hashfile.cs index cc9a8bd6..eb8ae0d5 100644 --- a/SabreTools.Library/DatFiles/Hashfile.cs +++ b/SabreTools.Library/DatFiles/Hashfile.cs @@ -208,57 +208,79 @@ namespace SabreTools.Library.DatFiles case Hash.MD5: if (rom.Type == ItemType.Rom) { - state += ((Rom)rom).MD5 + " *" + (GameName ? rom.MachineName + Path.DirectorySeparatorChar : "") + rom.Name + "\n"; + state += (!ExcludeFields[(int)Field.MD5] ? ((Rom)rom).MD5 : "") + + " *" + (!ExcludeFields[(int)Field.MachineName] && GameName ? rom.MachineName + Path.DirectorySeparatorChar : "") + + (!ExcludeFields[(int)Field.Name] ? rom.Name : "") + "\n"; } else if (rom.Type == ItemType.Disk) { - state += ((Disk)rom).MD5 + " *" + (GameName ? rom.MachineName + Path.DirectorySeparatorChar : "") + rom.Name + "\n"; + state += (!ExcludeFields[(int)Field.MD5] ? ((Disk)rom).MD5 : "") + + " *" + (!ExcludeFields[(int)Field.MachineName] && GameName ? rom.MachineName + Path.DirectorySeparatorChar : "") + + (!ExcludeFields[(int)Field.Name] ? rom.Name : "") + "\n"; } break; case Hash.CRC: if (rom.Type == ItemType.Rom) { - state += (GameName ? rom.MachineName + Path.DirectorySeparatorChar : "") + rom.Name + " " + ((Rom)rom).CRC + "\n"; + state += (!ExcludeFields[(int)Field.MachineName] && GameName ? rom.MachineName + Path.DirectorySeparatorChar : "") + + (!ExcludeFields[(int)Field.Name] ? rom.Name : "") + + " " + (!ExcludeFields[(int)Field.CRC] ? ((Rom)rom).CRC : "") + "\n"; } break; case Hash.SHA1: if (rom.Type == ItemType.Rom) { - state += ((Rom)rom).SHA1 + " *" + (GameName ? rom.MachineName + Path.DirectorySeparatorChar : "") + rom.Name + "\n"; + state += (!ExcludeFields[(int)Field.SHA1] ? ((Rom)rom).SHA1 : "") + + " *" + (!ExcludeFields[(int)Field.MachineName] && GameName ? rom.MachineName + Path.DirectorySeparatorChar : "") + + (!ExcludeFields[(int)Field.Name] ? rom.Name : "") + "\n"; } else if (rom.Type == ItemType.Disk) { - state += ((Disk)rom).SHA1 + " *" + (GameName ? rom.MachineName + Path.DirectorySeparatorChar : "") + rom.Name + "\n"; + state += (!ExcludeFields[(int)Field.SHA1] ? ((Disk)rom).SHA1 : "") + + " *" + (!ExcludeFields[(int)Field.MachineName] && GameName ? rom.MachineName + Path.DirectorySeparatorChar : "") + + (!ExcludeFields[(int)Field.Name] ? rom.Name : "") + "\n"; } break; case Hash.SHA256: if (rom.Type == ItemType.Rom) { - state += ((Rom)rom).SHA256 + " *" + (GameName ? rom.MachineName + Path.DirectorySeparatorChar : "") + rom.Name + "\n"; + state += (!ExcludeFields[(int)Field.SHA256] ? ((Rom)rom).SHA256 : "") + + " *" + (!ExcludeFields[(int)Field.MachineName] && GameName ? rom.MachineName + Path.DirectorySeparatorChar : "") + + (!ExcludeFields[(int)Field.Name] ? rom.Name : "") + "\n"; } else if (rom.Type == ItemType.Disk) { - state += ((Disk)rom).SHA256 + " *" + (GameName ? rom.MachineName + Path.DirectorySeparatorChar : "") + rom.Name + "\n"; + state += (!ExcludeFields[(int)Field.SHA256] ? ((Disk)rom).SHA256 : "") + + " *" + (!ExcludeFields[(int)Field.MachineName] && GameName ? rom.MachineName + Path.DirectorySeparatorChar : "") + + (!ExcludeFields[(int)Field.Name] ? rom.Name : "") + "\n"; } break; case Hash.SHA384: if (rom.Type == ItemType.Rom) { - state += ((Rom)rom).SHA384 + " *" + (GameName ? rom.MachineName + Path.DirectorySeparatorChar : "") + rom.Name + "\n"; + state += (!ExcludeFields[(int)Field.SHA384] ? ((Rom)rom).SHA384 : "") + + " *" + (!ExcludeFields[(int)Field.MachineName] && GameName ? rom.MachineName + Path.DirectorySeparatorChar : "") + + (!ExcludeFields[(int)Field.Name] ? rom.Name : "") + "\n"; } else if (rom.Type == ItemType.Disk) { - state += ((Disk)rom).SHA384 + " *" + (GameName ? rom.MachineName + Path.DirectorySeparatorChar : "") + rom.Name + "\n"; + state += (!ExcludeFields[(int)Field.SHA384] ? ((Disk)rom).SHA384 : "") + + " *" + (!ExcludeFields[(int)Field.MachineName] && GameName ? rom.MachineName + Path.DirectorySeparatorChar : "") + + (!ExcludeFields[(int)Field.Name] ? rom.Name : "") + "\n"; } break; case Hash.SHA512: if (rom.Type == ItemType.Rom) { - state += ((Rom)rom).SHA512 + " *" + (GameName ? rom.MachineName + Path.DirectorySeparatorChar : "") + rom.Name + "\n"; + state += (!ExcludeFields[(int)Field.SHA512] ? ((Rom)rom).SHA512 : "") + + " *" + (!ExcludeFields[(int)Field.MachineName] && GameName ? rom.MachineName + Path.DirectorySeparatorChar : "") + + (!ExcludeFields[(int)Field.Name] ? rom.Name : "") + "\n"; } else if (rom.Type == ItemType.Disk) { - state += ((Disk)rom).SHA512 + " *" + (GameName ? rom.MachineName + Path.DirectorySeparatorChar : "") + rom.Name + "\n"; + state += (!ExcludeFields[(int)Field.SHA512] ? ((Disk)rom).SHA512 : "") + + " *" + (!ExcludeFields[(int)Field.MachineName] && GameName ? rom.MachineName + Path.DirectorySeparatorChar : "") + + (!ExcludeFields[(int)Field.Name] ? rom.Name : "") + "\n"; } break; } diff --git a/SabreTools.Library/DatFiles/Listrom.cs b/SabreTools.Library/DatFiles/Listrom.cs index 417576c8..b86c257e 100644 --- a/SabreTools.Library/DatFiles/Listrom.cs +++ b/SabreTools.Library/DatFiles/Listrom.cs @@ -350,7 +350,7 @@ namespace SabreTools.Library.DatFiles rom.MachineName = rom.MachineName.Substring(1); } - string state = "ROMs required for driver \"" + rom.MachineName + "\".\n" + + string state = "ROMs required for driver \"" + (!ExcludeFields[(int)Field.MachineName] ? rom.MachineName : "") + "\".\n" + "Name Size Checksum\n"; sw.Write(state); @@ -432,24 +432,24 @@ namespace SabreTools.Library.DatFiles } // If we have a baddump, put the first indicator - if (((Disk)rom).ItemStatus == ItemStatus.BadDump) + if (!ExcludeFields[(int)Field.Status] && ((Disk)rom).ItemStatus == ItemStatus.BadDump) { state += " BAD"; } // If we have a nodump, write out the indicator - if (((Disk)rom).ItemStatus == ItemStatus.Nodump) + if (!ExcludeFields[(int)Field.Status] && ((Disk)rom).ItemStatus == ItemStatus.Nodump) { state += " NO GOOD DUMP KNOWN"; } // Otherwise, write out the SHA-1 hash - else + else if (!ExcludeFields[(int)Field.SHA1]) { state += " SHA1(" + ((Disk)rom).SHA1 + ")"; } // If we have a baddump, put the second indicator - if (((Disk)rom).ItemStatus == ItemStatus.BadDump) + if (!ExcludeFields[(int)Field.Status] && ((Disk)rom).ItemStatus == ItemStatus.BadDump) { state += " BAD_DUMP"; } @@ -474,25 +474,25 @@ namespace SabreTools.Library.DatFiles } // If we have a baddump, put the first indicator - if (((Rom)rom).ItemStatus == ItemStatus.BadDump) + if (!ExcludeFields[(int)Field.Status] && ((Rom)rom).ItemStatus == ItemStatus.BadDump) { state += " BAD"; } // If we have a nodump, write out the indicator - if (((Rom)rom).ItemStatus == ItemStatus.Nodump) + if (!ExcludeFields[(int)Field.Status] && ((Rom)rom).ItemStatus == ItemStatus.Nodump) { state += " NO GOOD DUMP KNOWN"; } // Otherwise, write out the CRC and SHA-1 hashes else { - state += " CRC(" + ((Rom)rom).CRC + ")"; - state += " SHA1(" + ((Rom)rom).SHA1 + ")"; + state += (!ExcludeFields[(int)Field.CRC] ? " CRC(" + ((Rom)rom).CRC + ")" : ""); + state += (!ExcludeFields[(int)Field.SHA1] ? " SHA1(" + ((Rom)rom).SHA1 + ")" : ""); } // If we have a baddump, put the second indicator - if (((Rom)rom).ItemStatus == ItemStatus.BadDump) + if (!ExcludeFields[(int)Field.Status] && ((Rom)rom).ItemStatus == ItemStatus.BadDump) { state += " BAD_DUMP"; } diff --git a/SabreTools.Library/DatFiles/Listxml.cs b/SabreTools.Library/DatFiles/Listxml.cs index d9ad8dce..073e6403 100644 --- a/SabreTools.Library/DatFiles/Listxml.cs +++ b/SabreTools.Library/DatFiles/Listxml.cs @@ -695,28 +695,29 @@ namespace SabreTools.Library.DatFiles rom.MachineName = rom.MachineName.Substring(1); } - string state = "\t\n" - + "\t\t" + HttpUtility.HtmlEncode(rom.MachineDescription) + "\n" - + (rom.Year != null ? "\t\t" + HttpUtility.HtmlEncode(rom.Year) + "\n" : "") - + (rom.Publisher != null ? "\t\t" + HttpUtility.HtmlEncode(rom.Publisher) + "\n" : ""); + string state = "\t\n" + + (!ExcludeFields[(int)Field.Description] ? "\t\t" + HttpUtility.HtmlEncode(rom.MachineDescription) + "\n" : "") + + (!ExcludeFields[(int)Field.Year] && rom.Year != null ? "\t\t" + HttpUtility.HtmlEncode(rom.Year) + "\n" : "") + + (!ExcludeFields[(int)Field.Publisher] && rom.Publisher != null ? "\t\t" + HttpUtility.HtmlEncode(rom.Publisher) + "\n" : ""); - if (rom.Infos != null && rom.Infos.Count > 0) + if (!ExcludeFields[(int)Field.Infos] && rom.Infos != null && rom.Infos.Count > 0) { foreach (Tuple kvp in rom.Infos) { @@ -787,48 +788,51 @@ namespace SabreTools.Library.DatFiles { case ItemType.Archive: break; - case ItemType.BiosSet: - state += "\t\t\n"; break; case ItemType.Disk: - state += "\t\t\n"; break; + case ItemType.Release: + //TODO: Am I missing this? + break; case ItemType.Rom: - state += "\t\t\n"; break; case ItemType.Sample: - state += "\t\t\n"; break; } diff --git a/SabreTools.Library/DatFiles/Logiqx.cs b/SabreTools.Library/DatFiles/Logiqx.cs index 12c8d2fa..27253a24 100644 --- a/SabreTools.Library/DatFiles/Logiqx.cs +++ b/SabreTools.Library/DatFiles/Logiqx.cs @@ -810,27 +810,26 @@ namespace SabreTools.Library.DatFiles rom.MachineName = rom.MachineName.Substring(1); } - string state = "\t<" + (_depreciated ? "game" : "machine") + " name=\"" + HttpUtility.HtmlEncode(rom.MachineName) + "\"" - + (ExcludeOf ? "" : - ((rom.MachineType & MachineType.Bios) != 0 ? " isbios=\"yes\"" : "") - + ((rom.MachineType & MachineType.Device) != 0 ? " isdevice=\"yes\"" : "") - + ((rom.MachineType & MachineType.Mechanical) != 0 ? " ismechanical=\"yes\"" : "") - + (rom.Runnable == true ? " runnable=\"yes\"" : (rom.Runnable == false ? " runnable=\"no\"" : "")) - + (String.IsNullOrWhiteSpace(rom.CloneOf) || (rom.MachineName.ToLowerInvariant() == rom.CloneOf.ToLowerInvariant()) - ? "" - : " cloneof=\"" + HttpUtility.HtmlEncode(rom.CloneOf) + "\"") - + (String.IsNullOrWhiteSpace(rom.RomOf) || (rom.MachineName.ToLowerInvariant() == rom.RomOf.ToLowerInvariant()) - ? "" - : " romof=\"" + HttpUtility.HtmlEncode(rom.RomOf) + "\"") - + (String.IsNullOrWhiteSpace(rom.SampleOf) || (rom.MachineName.ToLowerInvariant() == rom.SampleOf.ToLowerInvariant()) - ? "" - : " sampleof=\"" + HttpUtility.HtmlEncode(rom.SampleOf) + "\"") - ) + ">\n" - + (String.IsNullOrWhiteSpace(rom.Comment) ? "" : "\t\t" + HttpUtility.HtmlEncode(rom.Comment) + "\n") - + "\t\t" + HttpUtility.HtmlEncode((String.IsNullOrWhiteSpace(rom.MachineDescription) ? rom.MachineName : rom.MachineDescription)) + "\n" - + (String.IsNullOrWhiteSpace(rom.Year) ? "" : "\t\t" + HttpUtility.HtmlEncode(rom.Year) + "\n") - + (String.IsNullOrWhiteSpace(rom.Publisher) ? "" : "\t\t" + HttpUtility.HtmlEncode(rom.Publisher) + "\n") - + (String.IsNullOrWhiteSpace(rom.Manufacturer) ? "" : "\t\t" + HttpUtility.HtmlEncode(rom.Manufacturer) + "\n"); + string state = "\t<" + (_depreciated ? "game" : "machine") + " name=\"" + (!ExcludeFields[(int)Field.MachineName] ? HttpUtility.HtmlEncode(rom.MachineName) : "") + "\"" + + (!ExcludeFields[(int)Field.MachineType] && (rom.MachineType & MachineType.Bios) != 0 ? " isbios=\"yes\"" : "") + + (!ExcludeFields[(int)Field.MachineType] && (rom.MachineType & MachineType.Device) != 0 ? " isdevice=\"yes\"" : "") + + (!ExcludeFields[(int)Field.MachineType] && (rom.MachineType & MachineType.Mechanical) != 0 ? " ismechanical=\"yes\"" : "") + + (!ExcludeFields[(int)Field.Runnable] && rom.Runnable == true ? " runnable=\"yes\"" : (rom.Runnable == false ? " runnable=\"no\"" : "")) + + (!ExcludeFields[(int)Field.CloneOf] && !String.IsNullOrWhiteSpace(rom.CloneOf) && (rom.MachineName.ToLowerInvariant() != rom.CloneOf.ToLowerInvariant()) + ? " cloneof=\"" + HttpUtility.HtmlEncode(rom.CloneOf) + "\"" + : "") + + (!ExcludeFields[(int)Field.RomOf] && !String.IsNullOrWhiteSpace(rom.RomOf) && (rom.MachineName.ToLowerInvariant() != rom.RomOf.ToLowerInvariant()) + ? " romof=\"" + HttpUtility.HtmlEncode(rom.RomOf) + "\"" + : "") + + (!ExcludeFields[(int)Field.SampleOf] && !String.IsNullOrWhiteSpace(rom.SampleOf) && (rom.MachineName.ToLowerInvariant() != rom.SampleOf.ToLowerInvariant()) + ? " sampleof=\"" + HttpUtility.HtmlEncode(rom.SampleOf) + "\"" + : "") + + ">\n" + + (!ExcludeFields[(int)Field.Comment] && !String.IsNullOrWhiteSpace(rom.Comment) ? "\t\t" + HttpUtility.HtmlEncode(rom.Comment) + "\n" : "") + + (!ExcludeFields[(int)Field.Description] ? "\t\t" + HttpUtility.HtmlEncode((String.IsNullOrWhiteSpace(rom.MachineDescription) ? rom.MachineName : rom.MachineDescription)) + "\n" : "") + + (!ExcludeFields[(int)Field.Year] && !String.IsNullOrWhiteSpace(rom.Year) ? "\t\t" + HttpUtility.HtmlEncode(rom.Year) + "\n" : "") + + (!ExcludeFields[(int)Field.Publisher] && !String.IsNullOrWhiteSpace(rom.Publisher) ? "\t\t" + HttpUtility.HtmlEncode(rom.Publisher) + "\n" : "") + + (!ExcludeFields[(int)Field.Manufacturer] && !String.IsNullOrWhiteSpace(rom.Manufacturer) ? "\t\t" + HttpUtility.HtmlEncode(rom.Manufacturer) + "\n" : ""); sw.Write(state); sw.Flush(); @@ -894,52 +893,52 @@ namespace SabreTools.Library.DatFiles switch (rom.Type) { case ItemType.Archive: - state += "\t\t\n"; break; case ItemType.BiosSet: - state += "\t\t\n"; break; case ItemType.Disk: - state += "\t\t\n"; break; case ItemType.Release: - state += "\t\t\n"; break; case ItemType.Rom: - state += "\t\t\n"; break; case ItemType.Sample: - state += "\t\t\n"; break; } @@ -965,7 +964,7 @@ namespace SabreTools.Library.DatFiles { try { - string footer = "\t\n\n"; + string footer = "\t\n\n"; // Write the footer out sw.Write(footer); diff --git a/SabreTools.Library/DatFiles/Missfile.cs b/SabreTools.Library/DatFiles/Missfile.cs index efebe176..51787ebf 100644 --- a/SabreTools.Library/DatFiles/Missfile.cs +++ b/SabreTools.Library/DatFiles/Missfile.cs @@ -162,19 +162,19 @@ namespace SabreTools.Library.DatFiles // If we're in Romba mode, the state is consistent if (Romba) { - state += rom.Name + "\n"; + state += (!ExcludeFields[(int)Field.Name] ? rom.Name : "") + "\n"; } // Otherwise, use any flags else { if (!UseRomName && rom.MachineName != lastgame) { - state += rom.Name + "\n"; + state += (!ExcludeFields[(int)Field.Name] ? rom.Name : "") + "\n"; lastgame = rom.MachineName; } else if (UseRomName) { - state += rom.Name + "\n"; + state += (!ExcludeFields[(int)Field.Name] ? rom.Name : "") + "\n"; } } diff --git a/SabreTools.Library/DatFiles/OfflineList.cs b/SabreTools.Library/DatFiles/OfflineList.cs index e9cf880d..8d512dfe 100644 --- a/SabreTools.Library/DatFiles/OfflineList.cs +++ b/SabreTools.Library/DatFiles/OfflineList.cs @@ -961,12 +961,12 @@ namespace SabreTools.Library.DatFiles state += "\t\t\n" + "\t\t\t1\n" + "\t\t\t1\n" - + "\t\t\t" + HttpUtility.HtmlEncode(rom.Name) + "\n" + + "\t\t\t" + (!ExcludeFields[(int)Field.Name] ? HttpUtility.HtmlEncode(rom.Name) : "") + "\n" + "\t\t\tNone\n"; if (rom.Type == ItemType.Rom) { - state += "\t\t\t" + ((Rom)rom).Size + "\n"; + state += "\t\t\t" + (!ExcludeFields[(int)Field.Size] ? ((Rom)rom).Size.ToString() : "") + "\n"; } state += "\t\t\tNone\n" @@ -978,8 +978,8 @@ namespace SabreTools.Library.DatFiles { state += "\t\t\t\n" + (((Disk)rom).MD5 != null - ? "\t\t\t\t" + ((Disk)rom).MD5.ToUpperInvariant() + "\n" - : "\t\t\t\t" + ((Disk)rom).SHA1.ToUpperInvariant() + "\n") + ? "\t\t\t\t" + (!ExcludeFields[(int)Field.MD5] ? ((Disk)rom).MD5.ToUpperInvariant() : "") + "\n" + : "\t\t\t\t" + (!ExcludeFields[(int)Field.SHA1] ? ((Disk)rom).SHA1.ToUpperInvariant() : "") + "\n") + "\t\t\t\n"; } else if (rom.Type == ItemType.Rom) @@ -988,10 +988,10 @@ namespace SabreTools.Library.DatFiles state += "\t\t\t\n" + (((Rom)rom).CRC != null - ? "\t\t\t\t" + ((Rom)rom).CRC.ToUpperInvariant() + "\n" + ? "\t\t\t\t" + (!ExcludeFields[(int)Field.CRC] ? ((Rom)rom).CRC.ToUpperInvariant() : "") + "\n" : ((Rom)rom).MD5 != null - ? "\t\t\t\t" + ((Rom)rom).MD5.ToUpperInvariant() + "\n" - : "\t\t\t\t" + ((Rom)rom).SHA1.ToUpperInvariant() + "\n") + ? "\t\t\t\t" + (!ExcludeFields[(int)Field.MD5] ? ((Rom)rom).MD5.ToUpperInvariant() : "") + "\n" + : "\t\t\t\t" + (!ExcludeFields[(int)Field.SHA1] ? ((Rom)rom).SHA1.ToUpperInvariant() : "") + "\n") + "\t\t\t\n"; } diff --git a/SabreTools.Library/DatFiles/OpenMSX.cs b/SabreTools.Library/DatFiles/OpenMSX.cs index a5340218..a1706ca6 100644 --- a/SabreTools.Library/DatFiles/OpenMSX.cs +++ b/SabreTools.Library/DatFiles/OpenMSX.cs @@ -662,12 +662,12 @@ Generation MSXIDs by www.generation-msx.nl } string state = "\n" - + "\t" + HttpUtility.HtmlEncode(rom.MachineName) + "\n" + + "\t" + (!ExcludeFields[(int)Field.MachineName] ? HttpUtility.HtmlEncode(rom.MachineName) : "") + "\n" // + "\t" + msxid + "\n" // + "\t" + system + "\n" - + "\t" + rom.Manufacturer + "\n" - + "\t" + rom.Year + "\n"; - // + "\t" + rom.Year + "\n"; + + "\t" + (!ExcludeFields[(int)Field.Manufacturer] ? rom.Manufacturer : "") + "\n" + + "\t" + (!ExcludeFields[(int)Field.Year] ? rom.Year : "") + "\n"; + // + "\t" + country + "\n"; sw.Write(state); sw.Flush(); @@ -742,9 +742,9 @@ Generation MSXIDs by www.generation-msx.nl state += "\t\t" // + "GoodMSX" + "" - + (!String.IsNullOrWhiteSpace(((Rom)rom).Offset) ? "" + ((Rom)rom).Offset + "" : "") + + (!ExcludeFields[(int)Field.Offset] && !String.IsNullOrWhiteSpace(((Rom)rom).Offset) ? "" + ((Rom)rom).Offset + "" : "") // + "Normal" - + "" + ((Rom)rom).SHA1 + "" + + "" + (!ExcludeFields[(int)Field.SHA1] ? ((Rom)rom).SHA1 : "") + "" // + "" + "\n"; break; diff --git a/SabreTools.Library/DatFiles/RomCenter.cs b/SabreTools.Library/DatFiles/RomCenter.cs index 55f8c561..a04192c8 100644 --- a/SabreTools.Library/DatFiles/RomCenter.cs +++ b/SabreTools.Library/DatFiles/RomCenter.cs @@ -345,21 +345,21 @@ namespace SabreTools.Library.DatFiles if (rom.Type == ItemType.Rom) { - state += "¬" + (String.IsNullOrWhiteSpace(rom.CloneOf) ? "" : HttpUtility.HtmlEncode(rom.CloneOf)) + - "¬" + (String.IsNullOrWhiteSpace(rom.CloneOf) ? "" : HttpUtility.HtmlEncode(rom.CloneOf)) + - "¬" + HttpUtility.HtmlEncode(rom.MachineName) + - "¬" + HttpUtility.HtmlEncode((String.IsNullOrWhiteSpace(rom.MachineDescription) ? rom.MachineName : rom.MachineDescription)) + - "¬" + HttpUtility.HtmlEncode(rom.Name) + - "¬" + ((Rom)rom).CRC.ToLowerInvariant() + - "¬" + (((Rom)rom).Size != -1 ? ((Rom)rom).Size.ToString() : "") + "¬¬¬\n"; + state += "¬" + (!ExcludeFields[(int)Field.CloneOf] && String.IsNullOrWhiteSpace(rom.CloneOf) ? HttpUtility.HtmlEncode(rom.CloneOf) : "") + + "¬" + (!ExcludeFields[(int)Field.CloneOf] && String.IsNullOrWhiteSpace(rom.CloneOf) ? HttpUtility.HtmlEncode(rom.CloneOf) : "") + + "¬" + (!ExcludeFields[(int)Field.MachineName] ? HttpUtility.HtmlEncode(rom.MachineName) : "") + + "¬" + (!ExcludeFields[(int)Field.Description] ? HttpUtility.HtmlEncode((String.IsNullOrWhiteSpace(rom.MachineDescription) ? rom.MachineName : rom.MachineDescription)) : "") + + "¬" + (!ExcludeFields[(int)Field.Name] ? HttpUtility.HtmlEncode(rom.Name) : "") + + "¬" + (!ExcludeFields[(int)Field.CRC] ? ((Rom)rom).CRC.ToLowerInvariant() : "") + + "¬" + (!ExcludeFields[(int)Field.Size] && ((Rom)rom).Size != -1 ? ((Rom)rom).Size.ToString() : "") + "¬¬¬\n"; } else if (rom.Type == ItemType.Disk) { - state += "¬" + (String.IsNullOrWhiteSpace(rom.CloneOf) ? "" : HttpUtility.HtmlEncode(rom.CloneOf)) + - "¬" + (String.IsNullOrWhiteSpace(rom.CloneOf) ? "" : HttpUtility.HtmlEncode(rom.CloneOf)) + - "¬" + HttpUtility.HtmlEncode(rom.MachineName) + - "¬" + HttpUtility.HtmlEncode((String.IsNullOrWhiteSpace(rom.MachineDescription) ? rom.MachineName : rom.MachineDescription)) + - "¬" + HttpUtility.HtmlEncode(rom.Name) + + state += "¬" + (!ExcludeFields[(int)Field.CloneOf] && String.IsNullOrWhiteSpace(rom.CloneOf) ? HttpUtility.HtmlEncode(rom.CloneOf) : "") + + "¬" + (!ExcludeFields[(int)Field.CloneOf] && String.IsNullOrWhiteSpace(rom.CloneOf) ? HttpUtility.HtmlEncode(rom.CloneOf) : "") + + "¬" + (!ExcludeFields[(int)Field.MachineName] ? HttpUtility.HtmlEncode(rom.MachineName) : "") + + "¬" + (!ExcludeFields[(int)Field.Description] ? HttpUtility.HtmlEncode((String.IsNullOrWhiteSpace(rom.MachineDescription) ? rom.MachineName : rom.MachineDescription)) : "") + + "¬" + (!ExcludeFields[(int)Field.Name] ? HttpUtility.HtmlEncode(rom.Name) : "") + "¬¬¬¬¬\n"; } diff --git a/SabreTools.Library/DatFiles/SabreDat.cs b/SabreTools.Library/DatFiles/SabreDat.cs index ca002e38..a14187cb 100644 --- a/SabreTools.Library/DatFiles/SabreDat.cs +++ b/SabreTools.Library/DatFiles/SabreDat.cs @@ -727,7 +727,7 @@ namespace SabreTools.Library.DatFiles { state += "\t"; } - state += "\n"; } depth = depth - (last == -1 ? 0 : last) + newsplit.Count; @@ -835,56 +835,56 @@ namespace SabreTools.Library.DatFiles switch (rom.Type) { case ItemType.Archive: - state += "\n"; break; case ItemType.BiosSet: - state += "\n"; break; case ItemType.Disk: - state += "\n" + prefix + "\t\n" + + state += "\n" + prefix + "\t\n" + prefix + "\t\t\n" + prefix + "\t\n" + prefix + "\n" : "/>\n"); break; case ItemType.Release: - state += "\n"; break; case ItemType.Rom: - state += "\n" + prefix + "\t\n" + + state += "\n" + prefix + "\t\n" + prefix + "\t\t\n" + prefix + "\t\n" + prefix + "\n" : "/>\n"); break; case ItemType.Sample: - state += "\n"; break; } diff --git a/SabreTools.Library/DatFiles/SeparatedValue.cs b/SabreTools.Library/DatFiles/SeparatedValue.cs index 9e999697..e8f6059e 100644 --- a/SabreTools.Library/DatFiles/SeparatedValue.cs +++ b/SabreTools.Library/DatFiles/SeparatedValue.cs @@ -502,18 +502,18 @@ namespace SabreTools.Library.DatFiles string inline = string.Format("\"" + FileName + "\"" + "{0}\"" + Name + "\"" + "{0}\"" + Description + "\"" - + "{0}\"" + rom.MachineName + "\"" - + "{0}\"" + rom.MachineDescription + "\"" + + "{0}\"" + (!ExcludeFields[(int)Field.MachineName] ? rom.MachineName : "") + "\"" + + "{0}\"" + (!ExcludeFields[(int)Field.Description] ? rom.MachineDescription : "") + "\"" + "{0}\"" + type + "\"" - + "{0}\"" + romname + "\"" - + "{0}\"" + diskname + "\"" - + "{0}\"" + size + "\"" - + "{0}\"" + crc + "\"" - + "{0}\"" + md5 + "\"" - + "{0}\"" + sha1 + "\"" - + "{0}\"" + sha256 + "\"" - // + "{0}\"" + sha384 + "\"" - // + "{0}\"" + sha512 + "\"" + + "{0}\"" + (!ExcludeFields[(int)Field.Name] ? romname : "") + "\"" + + "{0}\"" + (!ExcludeFields[(int)Field.Name] ? diskname : "") + "\"" + + "{0}\"" + (!ExcludeFields[(int)Field.Size] ? size : "") + "\"" + + "{0}\"" + (!ExcludeFields[(int)Field.CRC] ? crc : "") + "\"" + + "{0}\"" + (!ExcludeFields[(int)Field.MD5] ? md5 : "") + "\"" + + "{0}\"" + (!ExcludeFields[(int)Field.SHA1] ? sha1 : "") + "\"" + + "{0}\"" + (!ExcludeFields[(int)Field.SHA256] ? sha256 : "") + "\"" + // + "{0}\"" + (!ExcludeFields[(int)Field.SHA384] ? sha384 : "") + "\"" + // + "{0}\"" + (!ExcludeFields[(int)Field.SHA512] ? sha512 : "") + "\"" + "{0}" + status, _delim); state += pre + inline + post + "\n"; diff --git a/SabreTools.Library/DatFiles/SoftwareList.cs b/SabreTools.Library/DatFiles/SoftwareList.cs index ecea5bef..872df4f8 100644 --- a/SabreTools.Library/DatFiles/SoftwareList.cs +++ b/SabreTools.Library/DatFiles/SoftwareList.cs @@ -711,20 +711,20 @@ namespace SabreTools.Library.DatFiles rom.MachineName = rom.MachineName.Substring(1); } - string state = "\t\n" - + "\t\t" + HttpUtility.HtmlEncode(rom.MachineDescription) + "\n" - + (rom.Year != null ? "\t\t" + HttpUtility.HtmlEncode(rom.Year) + "\n" : "") - + (rom.Publisher != null ? "\t\t" + HttpUtility.HtmlEncode(rom.Publisher) + "\n" : ""); + string state = "\t\n" : "") + + (!ExcludeFields[(int)Field.Description] ? "\t\t" + HttpUtility.HtmlEncode(rom.MachineDescription) + "\n" : "") + + (!ExcludeFields[(int)Field.Year] && rom.Year != null ? "\t\t" + HttpUtility.HtmlEncode(rom.Year) + "\n" : "") + + (!ExcludeFields[(int)Field.Publisher] && rom.Publisher != null ? "\t\t" + HttpUtility.HtmlEncode(rom.Publisher) + "\n" : ""); - foreach (Tuple kvp in rom.Infos) + if (!ExcludeFields[(int)Field.Infos]) { - state += "\t\t\n"; + foreach (Tuple kvp in rom.Infos) + { + state += "\t\t\n"; + } } sw.Write(state); @@ -786,44 +786,48 @@ namespace SabreTools.Library.DatFiles // Pre-process the item name ProcessItemName(rom, true); - state += "\t\t\n"; + state += "\t\t\n"; - foreach (Tuple kvp in rom.Features) + if (!ExcludeFields[(int)Field.Features]) { - state += "\t\t\t\n"; + foreach (Tuple kvp in rom.Features) + { + state += "\t\t\t\n"; + } } switch (rom.Type) { case ItemType.Disk: - state += "\t\t\t\n" - + "\t\t\t\t\n" + + "\t\t\t\t\n" + "\t\t\t\n"; break; case ItemType.Rom: - state += "\t\t\t\n" - + "\t\t\t\t\n" + + "\t\t\t\t\n" + "\t\t\t\n"; break; diff --git a/SabreTools.Library/Data/Enums.cs b/SabreTools.Library/Data/Enums.cs index 0f741ff8..eb262c46 100644 --- a/SabreTools.Library/Data/Enums.cs +++ b/SabreTools.Library/Data/Enums.cs @@ -360,9 +360,9 @@ /// /// List of valid field types within a DatItem/Machine /// - public enum Field + public enum Field : int { - NULL, + NULL = 0, // Generic DatItem Name, diff --git a/SabreTools/SabreTools.cs b/SabreTools/SabreTools.cs index c7bccad2..b8c8ea65 100644 --- a/SabreTools/SabreTools.cs +++ b/SabreTools/SabreTools.cs @@ -291,11 +291,9 @@ namespace SabreTools updateMode |= UpdateMode.DiffReverseCascade; break; case "exclude-of": // TODO: Remove entire flag when transitioning to exclude-fields - datHeader.ExcludeOf = true; - - datHeader.ExcludeFields.Add(Field.CloneOf); - datHeader.ExcludeFields.Add(Field.RomOf); - datHeader.ExcludeFields.Add(Field.SampleOf); + datHeader.ExcludeFields[(int)Field.CloneOf] = true; + datHeader.ExcludeFields[(int)Field.RomOf] = true; + datHeader.ExcludeFields[(int)Field.SampleOf] = true; break; case "extension": splittingMode |= SplittingMode.Extension; @@ -645,7 +643,7 @@ namespace SabreTools case "exclude-field": // TODO: Use this foreach (string field in (List)feat.Value.GetValue()) { - datHeader.ExcludeFields.Add(Utilities.GetField(field)); + datHeader.ExcludeFields[(int)Utilities.GetField(field)] = true; } break; case "exta":