Use new list input

This commit is contained in:
Matt Nadareski
2020-06-06 13:53:31 -07:00
parent b6e77a31ef
commit f01e47444c
15 changed files with 474 additions and 330 deletions

View File

@@ -321,18 +321,6 @@ namespace SabreTools
longDescription: "This flag allows for a special type of diffing in which the last DAT is considered a base, and for each additional input DAT, it only leaves the files that are not in one of the previous DATs. This can allow for the creation of rollback sets or even just reduce the amount of duplicates across multiple sets.");
}
}
private static Feature _excludeOfFlag
{
get
{
return new Feature(
"exclude-of",
new List<string>() { "-xof", "--exclude-of" },
"Exclude romof, cloneof, sampleof tags",
FeatureType.Flag,
longDescription: "If this flag is enabled, then the romof, cloneof, and sampleof tags will be omitted from the outputted DAT.");
}
} // TODO: Remove
private static Feature _extensionFlag
{
get
@@ -585,78 +573,6 @@ namespace SabreTools
longDescription: "For each item, remove the extension.");
}
}
private static Feature _removeMd5Flag
{
get
{
return new Feature(
"remove-md5",
new List<string>() { "-rmd5", "--remove-md5" },
"Remove MD5 hashes from the output",
FeatureType.Flag,
longDescription: "By default, all available hashes will be written out to the DAT. This will remove all MD5 hashes from the output file(s).");
}
} // TODO: Remove
private static Feature _removeRipeMd160Flag
{
get
{
return new Feature(
"remove-ripemd160",
new List<string>() { "-rripemd160", "--remove-ripemd160" },
"Remove RIPEMD160 hashes from the output",
FeatureType.Flag,
longDescription: "By default, all available hashes will be written out to the DAT. This will remove all MD5 hashes from the output file(s).");
}
} // TODO: Remove
private static Feature _removeSha1Flag
{
get
{
return new Feature(
"remove-sha1",
new List<string>() { "-rsha1", "--remove-sha1" },
"Remove SHA-1 hashes from the output",
FeatureType.Flag,
longDescription: "By default, all available hashes will be written out to the DAT. This will remove all SHA-1 hashes from the output file(s).");
}
} // TODO: Remove
private static Feature _removeSha256Flag
{
get
{
return new Feature(
"remove-sha256",
new List<string>() { "-rsha256", "--remove-sha256" },
"Remove SHA-256 hashes from the output",
FeatureType.Flag,
longDescription: "By default, all available hashes will be written out to the DAT. This will remove all SHA-256 hashes from the output file(s).");
}
} // TODO: Remove
private static Feature _removeSha384Flag
{
get
{
return new Feature(
"remove-sha384",
new List<string>() { "-rsha384", "--remove-sha384" },
"Remove SHA-384 hashes from the output",
FeatureType.Flag,
longDescription: "By default, all available hashes will be written out to the DAT. This will remove all SHA-384 hashes from the output file(s).");
}
} // TODO: Remove
private static Feature _removeSha512Flag
{
get
{
return new Feature(
"remove-sha512",
new List<string>() { "-rsha512", "--remove-sha512" },
"Remove SHA-512 hashes from the output",
FeatureType.Flag,
longDescription: "By default, all available hashes will be written out to the DAT. This will remove all SHA-512 hashes from the output file(s).");
}
} // TODO: Remove
private static Feature _removeUnicodeFlag
{
get
@@ -1677,11 +1593,11 @@ Possible values are: None, Good, BadDump, Nodump, Verified");
return new Feature(
"update-field",
new List<string>() { "-uf", "--update-field" },
"Update a game/rom field from base DAT(s)",
"Update a game/rom field from base DATs",
FeatureType.List,
longDescription: "Update any valid item or machine field from base DAT(s). Examples include: romof, publisher, and offset.");
}
} // TODO: ADD THIS TO USED FLAGS
}
#endregion
@@ -2112,7 +2028,6 @@ Some special strings that can be used:
datFromDir.AddFeature(_urlStringInput);
datFromDir.AddFeature(_commentStringInput);
datFromDir.AddFeature(_superdatFlag);
datFromDir.AddFeature(_excludeOfFlag);
datFromDir.AddFeature(_excludeFieldListInput);
datFromDir.AddFeature(_oneRomPerGameFlag);
datFromDir.AddFeature(_sceneDateStripFlag);
@@ -2339,19 +2254,12 @@ The stats that are outputted are as follows:
update.AddFeature(_forcemergingStringInput);
update.AddFeature(_forcenodumpStringInput);
update.AddFeature(_forcepackingStringInput);
update.AddFeature(_excludeOfFlag);
update.AddFeature(_excludeFieldListInput);
update.AddFeature(_oneRomPerGameFlag);
update.AddFeature(_keepEmptyGamesFlag);
update.AddFeature(_sceneDateStripFlag);
update.AddFeature(_cleanFlag);
update.AddFeature(_removeUnicodeFlag);
update.AddFeature(_removeMd5Flag);
update.AddFeature(_removeRipeMd160Flag);
update.AddFeature(_removeSha1Flag);
update.AddFeature(_removeSha256Flag);
update.AddFeature(_removeSha384Flag);
update.AddFeature(_removeSha512Flag);
update.AddFeature(_descriptionAsNameFlag);
update.AddFeature(_datMergedFlag);
update.AddFeature(_datSplitFlag);
@@ -2377,6 +2285,8 @@ The stats that are outputted are as follows:
update[_diffAgainstFlag].AddFeature(_baseDatListInput);
update.AddFeature(_baseReplaceFlag);
update[_baseReplaceFlag].AddFeature(_baseDatListInput);
update[_baseReplaceFlag].AddFeature(_updateFieldListInput);
update[_baseReplaceFlag][_updateFieldListInput].AddFeature(_onlySameFlag);
update[_baseReplaceFlag].AddFeature(_updateNamesFlag);
update[_baseReplaceFlag].AddFeature(_updateHashesFlag);
update[_baseReplaceFlag].AddFeature(_updateDescriptionFlag);
@@ -2387,6 +2297,8 @@ The stats that are outputted are as follows:
update[_baseReplaceFlag].AddFeature(_updateParentsFlag);
update.AddFeature(_reverseBaseReplaceFlag);
update[_reverseBaseReplaceFlag].AddFeature(_baseDatListInput);
update[_baseReplaceFlag].AddFeature(_updateFieldListInput);
update[_baseReplaceFlag][_updateFieldListInput].AddFeature(_onlySameFlag);
update[_reverseBaseReplaceFlag].AddFeature(_updateNamesFlag);
update[_reverseBaseReplaceFlag].AddFeature(_updateHashesFlag);
update[_reverseBaseReplaceFlag].AddFeature(_updateDescriptionFlag);

View File

@@ -302,7 +302,7 @@ namespace SabreTools
/// <param name="clean">True to clean the game names to WoD standard, false otherwise (default)</param>
/// <param name="remUnicode">True if we should remove non-ASCII characters from output, false otherwise (default)</param>
/// <param name="descAsName">True if descriptions should be used as names, false otherwise (default)</param>
/// <param name="replaceMode">ReplaceMode representing what should be updated [only for base replacement]</param>
/// <param name="updateFields">List of Fields representing what should be updated [only for base replacement]</param>
/// <param name="onlySame">True if descriptions should only be replaced if the game name is the same, false otherwise [only for base replacement]</param>
private static void InitUpdate(
List<string> inputPaths,
@@ -326,7 +326,7 @@ namespace SabreTools
bool clean,
bool remUnicode,
bool descAsName,
ReplaceMode replaceMode,
List<Field> updateFields,
bool onlySame)
{
// Normalize the extensions
@@ -371,17 +371,15 @@ namespace SabreTools
}
}
// If no replacement mode is set, default to Names
if (replaceMode == ReplaceMode.None)
{
replaceMode = ReplaceMode.ItemName;
}
// If no update fields are set, default to Names
if (updateFields == null || updateFields.Count == 0)
updateFields = new List<Field>() { Field.Name };
// Populate the DatData object
DatFile userInputDat = new DatFile(datHeader);
userInputDat.DetermineUpdateType(inputPaths, basePaths, outDir, updateMode, inplace, skip, clean,
remUnicode, descAsName, filter, splitType, replaceMode, onlySame);
remUnicode, descAsName, filter, splitType, updateFields, onlySame);
}
/// <summary>

View File

@@ -96,7 +96,6 @@ namespace SabreTools
updateDat = false;
Hash omitFromScan = Hash.DeepHashes; // TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually
OutputFormat outputFormat = OutputFormat.Folder;
ReplaceMode replaceMode = ReplaceMode.None;
SkipFileType skipFileType = SkipFileType.None;
SplittingMode splittingMode = SplittingMode.None;
SplitType splitType = SplitType.None;
@@ -282,14 +281,6 @@ namespace SabreTools
case "diff-reverse-cascade":
updateMode |= UpdateMode.DiffReverseCascade;
break;
case "exclude-of":
Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _excludeFieldListInput.Flags));
datHeader.ExcludeFields[(int)Field.CloneOf] = true;
datHeader.ExcludeFields[(int)Field.MachineType] = true;
datHeader.ExcludeFields[(int)Field.RomOf] = true;
datHeader.ExcludeFields[(int)Field.Runnable] = true;
datHeader.ExcludeFields[(int)Field.SampleOf] = true;
break;
case "extension":
splittingMode |= SplittingMode.Extension;
break;
@@ -353,30 +344,6 @@ namespace SabreTools
case "remove-extensions":
datHeader.RemoveExtension = true;
break;
case "remove-md5":
Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _excludeFieldListInput.Flags));
datHeader.ExcludeFields[(int)Field.MD5] = true;
break;
case "remove-ripemd160":
Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _excludeFieldListInput.Flags));
datHeader.ExcludeFields[(int)Field.RIPEMD160] = true;
break;
case "remove-sha1":
Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _excludeFieldListInput.Flags));
datHeader.ExcludeFields[(int)Field.SHA1] = true;
break;
case "remove-sha256":
Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _excludeFieldListInput.Flags));
datHeader.ExcludeFields[(int)Field.SHA256] = true;
break;
case "remove-sha384":
Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _excludeFieldListInput.Flags));
datHeader.ExcludeFields[(int)Field.SHA384] = true;
break;
case "remove-sha512":
Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _excludeFieldListInput.Flags));
datHeader.ExcludeFields[(int)Field.SHA512] = true;
break;
case "remove-unicode":
removeUnicode = true;
break;
@@ -480,25 +447,40 @@ namespace SabreTools
updateDat = true;
break;
case "update-description":
replaceMode |= ReplaceMode.Description;
Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _updateFieldListInput.Flags));
updateFields.Add(Field.Description);
break;
case "update-game-type":
replaceMode |= ReplaceMode.MachineType;
Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _updateFieldListInput.Flags));
updateFields.Add(Field.MachineType);
break;
case "update-hashes":
replaceMode |= ReplaceMode.Hash;
Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _updateFieldListInput.Flags));
updateFields.Add(Field.CRC);
updateFields.Add(Field.MD5);
updateFields.Add(Field.RIPEMD160);
updateFields.Add(Field.SHA1);
updateFields.Add(Field.SHA256);
updateFields.Add(Field.SHA384);
updateFields.Add(Field.SHA512);
break;
case "update-manufacturer":
replaceMode |= ReplaceMode.Manufacturer;
Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _updateFieldListInput.Flags));
updateFields.Add(Field.Manufacturer);
break;
case "update-names":
replaceMode |= ReplaceMode.ItemName;
Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _updateFieldListInput.Flags));
updateFields.Add(Field.Name);
break;
case "update-parents":
replaceMode |= ReplaceMode.Parents;
Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _updateFieldListInput.Flags));
updateFields.Add(Field.CloneOf);
updateFields.Add(Field.RomOf);
updateFields.Add(Field.SampleOf);
break;
case "update-year":
replaceMode |= ReplaceMode.Year;
Globals.Logger.User("This flag '{0}' is depreciated, please use {1} instead", feat.Key, String.Join(", ", _updateFieldListInput.Flags));
updateFields.Add(Field.Year);
break;
#endregion
@@ -517,9 +499,8 @@ namespace SabreTools
case "threads":
int val = (int)feat.Value.GetValue();
if (val != Int32.MinValue)
{
Globals.MaxThreads = val;
}
break;
case "zip":
zip = (int)feat.Value.GetValue() == Int32.MinValue ? (int)feat.Value.GetValue() : 1;
@@ -546,7 +527,7 @@ namespace SabreTools
case "dat":
datfiles.AddRange((List<string>)feat.Value.GetValue());
break;
case "exclude-field": // TODO: Use this
case "exclude-field":
foreach (string field in (List<string>)feat.Value.GetValue())
{
datHeader.ExcludeFields[(int)Utilities.GetField(field)] = true;
@@ -662,7 +643,7 @@ namespace SabreTools
filter.ItemStatuses.Positive |= Utilities.GetItemStatus(stat);
}
break;
case "update-field": // TODO: Use this
case "update-field":
foreach (string field in (List<string>)feat.Value.GetValue())
{
updateFields.Add(Utilities.GetField(field));
@@ -801,7 +782,7 @@ namespace SabreTools
case "Update":
VerifyInputs(inputs, feature);
InitUpdate(inputs, basePaths, datHeader, updateMode, inplace, skipFirstOutput, noAutomaticDate, filter,
splitType, outDir, cleanGameNames, removeUnicode, descAsName, replaceMode, onlySame);
splitType, outDir, cleanGameNames, removeUnicode, descAsName, updateFields, onlySame);
break;
// If we're using the verifier
case "Verify":