Convert depot information to keys

This commit is contained in:
Matt Nadareski
2024-03-10 22:08:08 -04:00
parent 1d1cbc3357
commit 962fd8baee
10 changed files with 59 additions and 70 deletions

View File

@@ -2149,17 +2149,16 @@ Some special strings that can be used:
/// </summary>
private DatHeader? GetDatHeader(Dictionary<string, Feature?> features)
{
// TODO: Sort this by region, like the actual header
var datHeader = new DatHeader()
{
// Get the depot information
InputDepot = new DepotInformation(
// Get the depot information
var inputDepot = new DepotInformation(
GetBoolean(features, DepotValue),
GetInt32(features, DepotDepthInt32Value)),
OutputDepot = new DepotInformation(
GetInt32(features, DepotDepthInt32Value));
var outputDepot = new DepotInformation(
GetBoolean(features, RombaValue),
GetInt32(features, RombaDepthInt32Value))
};
GetInt32(features, RombaDepthInt32Value));
var datHeader = new DatHeader();
datHeader.SetFieldValue<string?>(DatHeader.AddExtensionKey, GetString(features, AddExtensionStringValue));
datHeader.SetFieldValue<string?>(Models.Metadata.Header.AuthorKey, GetString(features, AuthorStringValue));
datHeader.SetFieldValue<string?>(Models.Metadata.Header.CategoryKey, GetString(features, CategoryStringValue));
datHeader.SetFieldValue<string?>(Models.Metadata.Header.CommentKey, GetString(features, CommentStringValue));
@@ -2170,22 +2169,22 @@ Some special strings that can be used:
datHeader.SetFieldValue<MergingFlag>(Models.Metadata.Header.ForceMergingKey, GetString(features, ForceMergingStringValue).AsEnumValue<MergingFlag>());
datHeader.SetFieldValue<NodumpFlag>(Models.Metadata.Header.ForceNodumpKey, GetString(features, ForceNodumpStringValue).AsEnumValue<NodumpFlag>());
datHeader.SetFieldValue<PackingFlag>(Models.Metadata.Header.ForceNodumpKey, GetString(features, ForcePackingStringValue).AsEnumValue<PackingFlag>());
datHeader.SetFieldValue<bool>(DatHeader.GameNameKey, GetBoolean(features, GamePrefixValue));
datHeader.SetFieldValue<string?>(Models.Metadata.Header.HeaderKey, GetString(features, HeaderStringValue));
datHeader.SetFieldValue<string?>(Models.Metadata.Header.HomepageKey, GetString(features, HomepageStringValue));
datHeader.SetFieldValue<DepotInformation?>(DatHeader.InputDepotKey, inputDepot);
datHeader.SetFieldValue<string?>(Models.Metadata.Header.NameKey, GetString(features, NameStringValue));
datHeader.SetFieldValue<string?>(Models.Metadata.Header.RootDirKey, GetString(features, RootStringValue));
datHeader.SetFieldValue<string?>(Models.Metadata.Header.TypeKey, GetBoolean(features, SuperdatValue) ? "SuperDAT" : null);
datHeader.SetFieldValue<string?>(Models.Metadata.Header.UrlKey, GetString(features, UrlStringValue));
datHeader.SetFieldValue<string?>(Models.Metadata.Header.VersionKey, GetString(features, VersionStringValue));
datHeader.SetFieldValue<string?>(DatHeader.AddExtensionKey, GetString(features, AddExtensionStringValue));
datHeader.SetFieldValue<bool>(DatHeader.GameNameKey, GetBoolean(features, GamePrefixValue));
datHeader.SetFieldValue<DepotInformation?>(DatHeader.OutputDepotKey, outputDepot);
datHeader.SetFieldValue<string?>(DatHeader.PostfixKey, GetString(features, PostfixStringValue));
datHeader.SetFieldValue<string?>(DatHeader.PrefixKey, GetString(features, PrefixStringValue));
datHeader.SetFieldValue<bool>(DatHeader.QuotesKey, GetBoolean(features, QuotesValue));
datHeader.SetFieldValue<bool>(DatHeader.RemoveExtensionKey, GetBoolean(features, RemoveExtensionsValue));
datHeader.SetFieldValue<string?>(DatHeader.ReplaceExtensionKey, GetString(features, ReplaceExtensionStringValue));
datHeader.SetFieldValue<bool>(DatHeader.UseRomNameKey, GetBoolean(features, RomsValue));
datHeader.SetFieldValue<string?>(Models.Metadata.Header.RootDirKey, GetString(features, RootStringValue));
datHeader.SetFieldValue<string?>(Models.Metadata.Header.TypeKey, GetBoolean(features, SuperdatValue) ? "SuperDAT" : null);
datHeader.SetFieldValue<string?>(Models.Metadata.Header.UrlKey, GetString(features, UrlStringValue));
datHeader.SetFieldValue<string?>(Models.Metadata.Header.VersionKey, GetString(features, VersionStringValue));
bool deprecated = GetBoolean(features, DeprecatedValue);
foreach (string ot in GetList(features, OutputTypeListValue))

View File

@@ -74,7 +74,7 @@ namespace SabreTools.Features
var outputFormat = GetOutputFormat(features);
// If we have the romba flag
if (Header!.OutputDepot?.IsActive == true)
if (Header!.GetFieldValue<DepotInformation?>(DatHeader.OutputDepotKey)?.IsActive == true)
{
// Update TorrentGzip output
if (outputFormat == OutputFormat.TorrentGzip)
@@ -98,8 +98,8 @@ namespace SabreTools.Features
Parser.ParseInto(datdata, datfile, int.MaxValue, keep: true);
// Set depot information
datdata.Header.InputDepot = Header.InputDepot?.Clone() as DepotInformation;
datdata.Header.OutputDepot = Header.OutputDepot?.Clone() as DepotInformation;
datdata.Header.SetFieldValue<DepotInformation?>(DatHeader.InputDepotKey, Header.GetFieldValue<DepotInformation?>(DatHeader.InputDepotKey)?.Clone() as DepotInformation);
datdata.Header.SetFieldValue<DepotInformation?>(DatHeader.OutputDepotKey, Header.GetFieldValue<DepotInformation?>(DatHeader.OutputDepotKey)?.Clone() as DepotInformation);
// If we have overridden the header skipper, set it now
if (!string.IsNullOrEmpty(Header.GetFieldValue<string?>(Models.Metadata.Header.HeaderKey)))
@@ -107,7 +107,7 @@ namespace SabreTools.Features
// If we have the depot flag, respect it
bool success;
if (Header.InputDepot?.IsActive ?? false)
if (Header.GetFieldValue<DepotInformation?>(DatHeader.InputDepotKey)?.IsActive ?? false)
success = Rebuilder.RebuildDepot(datdata, Inputs, Path.Combine(OutputDir!, datdata.Header.GetFieldValue<string?>(DatHeader.FileNameKey)!), date, delete, inverse, outputFormat);
else
success = Rebuilder.RebuildGeneric(datdata, Inputs, Path.Combine(OutputDir!, datdata.Header.GetFieldValue<string?>(DatHeader.FileNameKey)!), quickScan, date, delete, inverse, outputFormat, asFiles);
@@ -137,8 +137,8 @@ namespace SabreTools.Features
}
// Set depot information
datdata.Header.InputDepot = Header.InputDepot?.Clone() as DepotInformation;
datdata.Header.OutputDepot = Header.OutputDepot?.Clone() as DepotInformation;
datdata.Header.SetFieldValue<DepotInformation?>(DatHeader.InputDepotKey, Header.GetFieldValue<DepotInformation?>(DatHeader.InputDepotKey)?.Clone() as DepotInformation);
datdata.Header.SetFieldValue<DepotInformation?>(DatHeader.OutputDepotKey, Header.GetFieldValue<DepotInformation?>(DatHeader.OutputDepotKey)?.Clone() as DepotInformation);
// If we have overridden the header skipper, set it now
if (!string.IsNullOrEmpty(Header.GetFieldValue<string?>(Models.Metadata.Header.HeaderKey)))
@@ -148,7 +148,7 @@ namespace SabreTools.Features
// If we have the depot flag, respect it
bool success;
if (Header.InputDepot?.IsActive ?? false)
if (Header.GetFieldValue<DepotInformation?>(DatHeader.InputDepotKey)?.IsActive ?? false)
success = Rebuilder.RebuildDepot(datdata, Inputs, OutputDir!, date, delete, inverse, outputFormat);
else
success = Rebuilder.RebuildGeneric(datdata, Inputs, OutputDir!, quickScan, date, delete, inverse, outputFormat, asFiles);

View File

@@ -72,14 +72,14 @@ namespace SabreTools.Features
Remover!.ApplyRemovals(datdata);
// Set depot information
datdata.Header.InputDepot = Header!.InputDepot?.Clone() as DepotInformation;
datdata.Header.SetFieldValue<DepotInformation?>(DatHeader.InputDepotKey, Header!.GetFieldValue<DepotInformation?>(DatHeader.InputDepotKey)?.Clone() as DepotInformation);
// If we have overridden the header skipper, set it now
if (!string.IsNullOrEmpty(Header.GetFieldValue<string?>(Models.Metadata.Header.HeaderKey)))
datdata.Header.SetFieldValue<string?>(Models.Metadata.Header.HeaderKey, Header.GetFieldValue<string?>(Models.Metadata.Header.HeaderKey));
// If we have the depot flag, respect it
if (Header.InputDepot?.IsActive ?? false)
if (Header.GetFieldValue<DepotInformation?>(DatHeader.InputDepotKey)?.IsActive ?? false)
{
Verification.VerifyDepot(datdata, Inputs);
}
@@ -120,7 +120,7 @@ namespace SabreTools.Features
Remover!.ApplyRemovals(datdata);
// Set depot information
datdata.Header.InputDepot = Header!.InputDepot?.Clone() as DepotInformation;
datdata.Header.SetFieldValue<DepotInformation?>(DatHeader.InputDepotKey, Header!.GetFieldValue<DepotInformation?>(DatHeader.InputDepotKey)?.Clone() as DepotInformation);
// If we have overridden the header skipper, set it now
if (!string.IsNullOrEmpty(Header.GetFieldValue<string?>(Models.Metadata.Header.HeaderKey)))
@@ -129,7 +129,7 @@ namespace SabreTools.Features
watch.Stop();
// If we have the depot flag, respect it
if (Header.InputDepot?.IsActive ?? false)
if (Header.GetFieldValue<DepotInformation?>(DatHeader.InputDepotKey)?.IsActive ?? false)
{
Verification.VerifyDepot(datdata, Inputs);
}