mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Move filtering to new class
This commit is contained in:
@@ -54,7 +54,7 @@ namespace RombaSharp.Features
|
||||
datfile.Header.Name = string.IsNullOrWhiteSpace(name) ? "untitled" : name;
|
||||
datfile.Header.Description = description;
|
||||
DatTool.PopulateFromDir(datfile, source, asFiles: TreatAsFile.NonArchive);
|
||||
datfile.ApplyCleaning(new Cleaner() { ExcludeFields = Hash.DeepHashes.AsFields() });
|
||||
DatTool.ApplyCleaning(datfile, new Cleaner() { ExcludeFields = Hash.DeepHashes.AsFields() });
|
||||
DatTool.Write(datfile, outdat);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
using SabreTools.Logging;
|
||||
|
||||
// TODO: What sort of internal state should this have? Would a single DatFile be appropriate?
|
||||
// TODO: How much of the stuff currently in DatFile should be moved here?
|
||||
// TODO: Should each of the individual pieces of partial classes be their own classes?
|
||||
// TODO: Is a single, consistent internal state needed for this class at all?
|
||||
namespace SabreTools.DatFiles
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -160,7 +160,7 @@ Reset the internal state: reset();";
|
||||
// TODO: We might not want to remove dates in the future
|
||||
Cleaner dfdCleaner = new Cleaner() { ExcludeFields = Hash.DeepHashes.AsFields() };
|
||||
dfdCleaner.ExcludeFields.Add(Field.DatItem_Date);
|
||||
datFile.ApplyCleaning(dfdCleaner);
|
||||
DatTool.ApplyCleaning(datFile, dfdCleaner);
|
||||
|
||||
break;
|
||||
|
||||
@@ -205,7 +205,7 @@ Reset the internal state: reset();";
|
||||
filter.SetFilter(filterField, filterValue, filterRemove.Value);
|
||||
|
||||
// Apply the filter blindly
|
||||
datFile.ApplyFilter(filter, filterPerMachine.Value);
|
||||
DatTool.ApplyFilter(datFile, filter, filterPerMachine.Value);
|
||||
|
||||
// Cleanup after the filter
|
||||
// TODO: We might not want to remove immediately
|
||||
@@ -247,7 +247,7 @@ Reset the internal state: reset();";
|
||||
extraIni.Items.Add(extraIniItem);
|
||||
|
||||
// Apply the extra INI blindly
|
||||
datFile.ApplyExtras(extraIni);
|
||||
DatTool.ApplyExtras(datFile, extraIni);
|
||||
|
||||
break;
|
||||
|
||||
@@ -271,7 +271,7 @@ Reset the internal state: reset();";
|
||||
}
|
||||
|
||||
// Apply the merging flag
|
||||
datFile.ApplySplitting(mergingFlag, false);
|
||||
DatTool.ApplySplitting(datFile, mergingFlag, false);
|
||||
|
||||
break;
|
||||
|
||||
@@ -285,7 +285,7 @@ Reset the internal state: reset();";
|
||||
}
|
||||
|
||||
// Apply the logic
|
||||
datFile.MachineDescriptionToName();
|
||||
DatTool.MachineDescriptionToName(datFile);
|
||||
|
||||
break;
|
||||
|
||||
@@ -299,7 +299,7 @@ Reset the internal state: reset();";
|
||||
}
|
||||
|
||||
// Run the 1G1R functionality
|
||||
datFile.OneGamePerRegion(command.Arguments);
|
||||
DatTool.OneGamePerRegion(datFile, command.Arguments);
|
||||
|
||||
break;
|
||||
|
||||
@@ -313,7 +313,7 @@ Reset the internal state: reset();";
|
||||
}
|
||||
|
||||
// Apply the logic
|
||||
datFile.OneRomPerGame();
|
||||
DatTool.OneRomPerGame(datFile);
|
||||
|
||||
break;
|
||||
|
||||
@@ -327,7 +327,7 @@ Reset the internal state: reset();";
|
||||
}
|
||||
|
||||
// Run the removal functionality
|
||||
datFile.RemoveFieldsFromItems(command.Arguments.Select(s => s.AsField()).ToList());
|
||||
DatTool.RemoveFieldsFromItems(datFile, command.Arguments.Select(s => s.AsField()).ToList());
|
||||
|
||||
break;
|
||||
|
||||
@@ -341,7 +341,7 @@ Reset the internal state: reset();";
|
||||
}
|
||||
|
||||
// Apply the logic
|
||||
datFile.StripSceneDatesFromItems();
|
||||
DatTool.StripSceneDatesFromItems(datFile);
|
||||
|
||||
break;
|
||||
|
||||
|
||||
@@ -100,10 +100,10 @@ namespace SabreTools.Features
|
||||
if (success)
|
||||
{
|
||||
// Perform additional processing steps
|
||||
datdata.ApplyExtras(Extras);
|
||||
datdata.ApplySplitting(splitType, false);
|
||||
datdata.ApplyFilter(Filter);
|
||||
datdata.ApplyCleaning(Cleaner);
|
||||
DatTool.ApplyExtras(datdata, Extras);
|
||||
DatTool.ApplySplitting(datdata, splitType, false);
|
||||
DatTool.ApplyFilter(datdata, Filter);
|
||||
DatTool.ApplyCleaning(datdata, Cleaner);
|
||||
|
||||
// Write out the file
|
||||
DatTool.Write(datdata, OutputDir);
|
||||
|
||||
@@ -167,10 +167,10 @@ namespace SabreTools.Features
|
||||
|| datFile.Header.DatFormat.HasFlag(DatFormat.SSV));
|
||||
|
||||
// Perform additional processing steps
|
||||
datFile.ApplyExtras(Extras);
|
||||
datFile.ApplySplitting(GetSplitType(features), false);
|
||||
datFile.ApplyFilter(Filter);
|
||||
datFile.ApplyCleaning(Cleaner);
|
||||
DatTool.ApplyExtras(datFile, Extras);
|
||||
DatTool.ApplySplitting(datFile, GetSplitType(features), false);
|
||||
DatTool.ApplyFilter(datFile, Filter);
|
||||
DatTool.ApplyCleaning(datFile, Cleaner);
|
||||
|
||||
// Get the correct output path
|
||||
string realOutDir = inputPath.GetOutputPath(OutputDir, GetBoolean(features, InplaceValue));
|
||||
@@ -205,10 +205,10 @@ namespace SabreTools.Features
|
||||
datHeaders = DatTool.PopulateUserData(userInputDat, inputPaths);
|
||||
|
||||
// Perform additional processing steps
|
||||
userInputDat.ApplyExtras(Extras);
|
||||
userInputDat.ApplySplitting(GetSplitType(features), false);
|
||||
userInputDat.ApplyFilter(Filter);
|
||||
userInputDat.ApplyCleaning(Cleaner);
|
||||
DatTool.ApplyExtras(userInputDat, Extras);
|
||||
DatTool.ApplySplitting(userInputDat, GetSplitType(features), false);
|
||||
DatTool.ApplyFilter(userInputDat, Filter);
|
||||
DatTool.ApplyCleaning(userInputDat, Cleaner);
|
||||
|
||||
// Output only DatItems that are duplicated across inputs
|
||||
if (updateMode.HasFlag(UpdateMode.DiffDupesOnly))
|
||||
@@ -297,10 +297,10 @@ namespace SabreTools.Features
|
||||
DatTool.ParseInto(repDat, inputPath, indexId: 1, keep: true);
|
||||
|
||||
// Perform additional processing steps
|
||||
repDat.ApplyExtras(Extras);
|
||||
repDat.ApplySplitting(GetSplitType(features), false);
|
||||
repDat.ApplyFilter(Filter);
|
||||
repDat.ApplyCleaning(Cleaner);
|
||||
DatTool.ApplyExtras(repDat, Extras);
|
||||
DatTool.ApplySplitting(repDat, GetSplitType(features), false);
|
||||
DatTool.ApplyFilter(repDat, Filter);
|
||||
DatTool.ApplyCleaning(repDat, Cleaner);
|
||||
|
||||
// Now replace the fields from the base DatFile
|
||||
DatTool.DiffAgainst(userInputDat, repDat, GetBoolean(Features, ByGameValue));
|
||||
@@ -322,10 +322,10 @@ namespace SabreTools.Features
|
||||
DatTool.ParseInto(repDat, inputPath, indexId: 1, keep: true);
|
||||
|
||||
// Perform additional processing steps
|
||||
repDat.ApplyExtras(Extras);
|
||||
repDat.ApplySplitting(GetSplitType(features), false);
|
||||
repDat.ApplyFilter(Filter);
|
||||
repDat.ApplyCleaning(Cleaner);
|
||||
DatTool.ApplyExtras(repDat, Extras);
|
||||
DatTool.ApplySplitting(repDat, GetSplitType(features), false);
|
||||
DatTool.ApplyFilter(repDat, Filter);
|
||||
DatTool.ApplyCleaning(repDat, Cleaner);
|
||||
|
||||
// Now replace the fields from the base DatFile
|
||||
DatTool.BaseReplace(userInputDat, repDat, updateFields, GetBoolean(features, OnlySameValue));
|
||||
@@ -342,7 +342,7 @@ namespace SabreTools.Features
|
||||
{
|
||||
// If we're in SuperDAT mode, prefix all games with their respective DATs
|
||||
if (string.Equals(userInputDat.Header.Type, "SuperDAT", StringComparison.OrdinalIgnoreCase))
|
||||
userInputDat.ApplySuperDAT(inputPaths);
|
||||
DatTool.ApplySuperDAT(userInputDat, inputPaths);
|
||||
|
||||
DatTool.Write(userInputDat, OutputDir);
|
||||
}
|
||||
|
||||
@@ -61,10 +61,10 @@ namespace SabreTools.Features
|
||||
DatTool.ParseInto(datdata, datfile, int.MaxValue, keep: true);
|
||||
|
||||
// Perform additional processing steps
|
||||
datdata.ApplyExtras(Extras);
|
||||
datdata.ApplySplitting(splitType, true);
|
||||
datdata.ApplyFilter(Filter);
|
||||
datdata.ApplyCleaning(Cleaner);
|
||||
DatTool.ApplyExtras(datdata, Extras);
|
||||
DatTool.ApplySplitting(datdata, splitType, true);
|
||||
DatTool.ApplyFilter(datdata, Filter);
|
||||
DatTool.ApplyCleaning(datdata, Cleaner);
|
||||
|
||||
// Set depot information
|
||||
datdata.Header.InputDepot = Header.InputDepot.Clone() as DepotInformation;
|
||||
@@ -108,10 +108,10 @@ namespace SabreTools.Features
|
||||
}
|
||||
|
||||
// Perform additional processing steps
|
||||
datdata.ApplyExtras(Extras);
|
||||
datdata.ApplySplitting(splitType, true);
|
||||
datdata.ApplyFilter(Filter);
|
||||
datdata.ApplyCleaning(Cleaner);
|
||||
DatTool.ApplyExtras(datdata, Extras);
|
||||
DatTool.ApplySplitting(datdata, splitType, true);
|
||||
DatTool.ApplyFilter(datdata, Filter);
|
||||
DatTool.ApplyCleaning(datdata, Cleaner);
|
||||
|
||||
// Set depot information
|
||||
datdata.Header.InputDepot = Header.InputDepot.Clone() as DepotInformation;
|
||||
|
||||
Reference in New Issue
Block a user