Add JSON write

This commit is contained in:
Matt Nadareski
2020-06-15 22:31:46 -07:00
parent e95b5d3268
commit e7984b7b74
7 changed files with 838 additions and 9 deletions

View File

@@ -1,6 +1,7 @@
using System;
using SabreTools.Library.Data;
using Newtonsoft.Json;
namespace SabreTools.Library.DatFiles
{
@@ -16,121 +17,145 @@ namespace SabreTools.Library.DatFiles
/// <summary>
/// External name of the DAT
/// </summary>
[JsonProperty("filename")]
public string FileName { get; set; }
/// <summary>
/// Internal name of the DAT
/// </summary>
[JsonProperty("name")]
public string Name { get; set; }
/// <summary>
/// DAT description
/// </summary>
[JsonProperty("description")]
public string Description { get; set; }
/// <summary>
/// Root directory for the files; currently TruRip/EmuARC-exclusive
/// </summary>
[JsonProperty("rootdir")]
public string RootDir { get; set; }
/// <summary>
/// General category of items found in the DAT
/// </summary>
[JsonProperty("category")]
public string Category { get; set; }
/// <summary>
/// Version of the DAT
/// </summary>
[JsonProperty("version")]
public string Version { get; set; }
/// <summary>
/// Creation or modification date
/// </summary>
[JsonProperty("date")]
public string Date { get; set; }
/// <summary>
/// List of authors who contributed to the DAT
/// </summary>
[JsonProperty("author")]
public string Author { get; set; }
/// <summary>
/// Email address for DAT author(s)
/// </summary>
[JsonProperty("email")]
public string Email { get; set; }
/// <summary>
/// Author or distribution homepage name
/// </summary>
[JsonProperty("homepage")]
public string Homepage { get; set; }
/// <summary>
/// Author or distribution URL
/// </summary>
[JsonProperty("url")]
public string Url { get; set; }
/// <summary>
/// Any comment that does not already fit an existing field
/// </summary>
[JsonProperty("comment")]
public string Comment { get; set; }
/// <summary>
/// Header skipper to be used when loading the DAT
/// </summary>
[JsonProperty("header")]
public string Header { get; set; }
/// <summary>
/// Classification of the DAT. Generally only used for SuperDAT
/// </summary>
[JsonProperty("type")]
public string Type { get; set; }
/// <summary>
/// Force a merging style when loaded
/// </summary>
[JsonProperty("forcemerging")]
public ForceMerging ForceMerging { get; set; }
/// <summary>
/// Force nodump handling when loaded
/// </summary>
[JsonProperty("forcenodump")]
public ForceNodump ForceNodump { get; set; }
/// <summary>
/// Force output packing when loaded
/// </summary>
[JsonProperty("forcepacking")]
public ForcePacking ForcePacking { get; set; }
/// <summary>
/// Read or write format
/// </summary>
[JsonIgnore]
public DatFormat DatFormat { get; set; }
/// <summary>
/// List of fields in machine and items to exclude from writing
/// </summary>
[JsonIgnore]
public bool[] ExcludeFields { get; set; } = new bool[Enum.GetNames(typeof(Field)).Length];
/// <summary>
/// Enable "One Rom, One Region (1G1R)" mode
/// </summary>
[JsonIgnore]
public bool OneRom { get; set; }
/// <summary>
/// Keep machines that don't contain any items
/// </summary>
[JsonIgnore]
public bool KeepEmptyGames { get; set; }
/// <summary>
/// Remove scene dates from the beginning of machine names
/// </summary>
[JsonIgnore]
public bool SceneDateStrip { get; set; }
/// <summary>
/// Deduplicate items using the given method
/// </summary>
[JsonIgnore]
public DedupeType DedupeRoms { get; set; }
/// <summary>
/// Strip hash types from items
/// </summary>
[JsonIgnore]
public Hash StripHash { get; private set; }
#endregion
@@ -140,41 +165,49 @@ namespace SabreTools.Library.DatFiles
/// <summary>
/// Text to prepend to all outputted lines
/// </summary>
[JsonIgnore]
public string Prefix { get; set; }
/// <summary>
/// Text to append to all outputted lines
/// </summary>
[JsonIgnore]
public string Postfix { get; set; }
/// <summary>
/// Add a new extension to all items
/// </summary>
[JsonIgnore]
public string AddExtension { get; set; }
/// <summary>
/// Replace all item extensions
/// </summary>
[JsonIgnore]
public string ReplaceExtension { get; set; }
/// <summary>
/// Remove all item extensions
/// </summary>
[JsonIgnore]
public bool RemoveExtension { get; set; }
/// <summary>
/// Romba output mode
/// </summary>
[JsonIgnore]
public bool Romba { get; set; }
/// <summary>
/// Output the machine name
/// </summary>
[JsonIgnore]
public bool GameName { get; set; }
/// <summary>
/// Wrap quotes around the entire line, sans prefix and postfix
/// </summary>
[JsonIgnore]
public bool Quotes { get; set; }
#endregion
@@ -184,6 +217,7 @@ namespace SabreTools.Library.DatFiles
/// <summary>
/// Output the item name
/// </summary>
[JsonIgnore]
public bool UseRomName { get; set; }
#endregion