mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Fully decouple split from filter
This commit is contained in:
@@ -812,10 +812,8 @@ namespace SabreTools.Library.DatFiles
|
|||||||
/// Apply a Filter on the DatFile
|
/// Apply a Filter on the DatFile
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filter">Filter to use</param>
|
/// <param name="filter">Filter to use</param>
|
||||||
/// <param name="useTags">True if DatFile tags override splitting, false otherwise</param>
|
|
||||||
/// <returns>True if the DatFile was filtered, false on error</returns>
|
/// <returns>True if the DatFile was filtered, false on error</returns>
|
||||||
/// TODO: Fully decouple splitting
|
public bool ApplyFilter(Filter filter)
|
||||||
public bool ApplyFilter(Filter filter, bool useTags)
|
|
||||||
{
|
{
|
||||||
// If we have a null filter, return false
|
// If we have a null filter, return false
|
||||||
if (filter == null)
|
if (filter == null)
|
||||||
@@ -823,9 +821,6 @@ namespace SabreTools.Library.DatFiles
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Apply splitting, if necessary
|
|
||||||
ApplySplitting(filter.InternalSplit, useTags);
|
|
||||||
|
|
||||||
// Loop over every key in the dictionary
|
// Loop over every key in the dictionary
|
||||||
List<string> keys = Items.Keys.ToList();
|
List<string> keys = Items.Keys.ToList();
|
||||||
foreach (string key in keys)
|
foreach (string key in keys)
|
||||||
|
|||||||
@@ -359,11 +359,6 @@ namespace SabreTools.Library.Filtering
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IncludeOfInGame { get; set; }
|
public bool IncludeOfInGame { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Internally split a DatFile
|
|
||||||
/// </summary>
|
|
||||||
public MergingFlag InternalSplit { get; set; }
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#endregion // Fields
|
#endregion // Fields
|
||||||
|
|||||||
@@ -2529,6 +2529,26 @@ Some special strings that can be used:
|
|||||||
return splittingMode;
|
return splittingMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get SplitType from feature list
|
||||||
|
/// </summary>
|
||||||
|
protected MergingFlag GetSplitType(Dictionary<string, Feature> features)
|
||||||
|
{
|
||||||
|
MergingFlag splitType = MergingFlag.None;
|
||||||
|
if (GetBoolean(features, DatDeviceNonMergedValue))
|
||||||
|
splitType = MergingFlag.Device;
|
||||||
|
else if (GetBoolean(features, DatFullNonMergedValue))
|
||||||
|
splitType = MergingFlag.Full;
|
||||||
|
else if (GetBoolean(features, DatMergedValue))
|
||||||
|
splitType = MergingFlag.Merged;
|
||||||
|
else if (GetBoolean(features, DatNonMergedValue))
|
||||||
|
splitType = MergingFlag.NonMerged;
|
||||||
|
else if (GetBoolean(features, DatSplitValue))
|
||||||
|
splitType = MergingFlag.Split;
|
||||||
|
|
||||||
|
return splitType;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get StatReportFormat from feature list
|
/// Get StatReportFormat from feature list
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -3001,34 +3021,11 @@ Some special strings that can be used:
|
|||||||
// Include 'of" in game filters
|
// Include 'of" in game filters
|
||||||
filter.IncludeOfInGame = GetBoolean(features, MatchOfTagsValue);
|
filter.IncludeOfInGame = GetBoolean(features, MatchOfTagsValue);
|
||||||
|
|
||||||
// Internal splitting
|
|
||||||
filter.InternalSplit = GetSplitType(features);
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
return filter;
|
return filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get SplitType from feature list
|
|
||||||
/// </summary>
|
|
||||||
private MergingFlag GetSplitType(Dictionary<string, Feature> features)
|
|
||||||
{
|
|
||||||
MergingFlag splitType = MergingFlag.None;
|
|
||||||
if (GetBoolean(features, DatDeviceNonMergedValue))
|
|
||||||
splitType = MergingFlag.Device;
|
|
||||||
else if (GetBoolean(features, DatFullNonMergedValue))
|
|
||||||
splitType = MergingFlag.Full;
|
|
||||||
else if (GetBoolean(features, DatMergedValue))
|
|
||||||
splitType = MergingFlag.Merged;
|
|
||||||
else if (GetBoolean(features, DatNonMergedValue))
|
|
||||||
splitType = MergingFlag.NonMerged;
|
|
||||||
else if (GetBoolean(features, DatSplitValue))
|
|
||||||
splitType = MergingFlag.Split;
|
|
||||||
|
|
||||||
return splitType;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ Reset the internal state: reset();";
|
|||||||
filter.SetFilter(filterField, filterValue, filterNegate);
|
filter.SetFilter(filterField, filterValue, filterNegate);
|
||||||
|
|
||||||
// Apply the filter blindly
|
// Apply the filter blindly
|
||||||
datFile.ApplyFilter(filter, false);
|
datFile.ApplyFilter(filter);
|
||||||
datFile.Items.ClearMarked(); // TODO: We might not want to remove immediately
|
datFile.Items.ClearMarked(); // TODO: We might not want to remove immediately
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ namespace SabreTools.Features
|
|||||||
bool noAutomaticDate = GetBoolean(features, NoAutomaticDateValue);
|
bool noAutomaticDate = GetBoolean(features, NoAutomaticDateValue);
|
||||||
var omitFromScan = GetOmitFromScan(features);
|
var omitFromScan = GetOmitFromScan(features);
|
||||||
var skipFileType = GetSkipFileType(features);
|
var skipFileType = GetSkipFileType(features);
|
||||||
|
var splitType = GetSplitType(features);
|
||||||
|
|
||||||
// Create a new DATFromDir object and process the inputs
|
// Create a new DATFromDir object and process the inputs
|
||||||
DatFile basedat = DatFile.Create(Header);
|
DatFile basedat = DatFile.Create(Header);
|
||||||
@@ -94,7 +95,8 @@ namespace SabreTools.Features
|
|||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
datdata.ApplyExtras(Extras);
|
datdata.ApplyExtras(Extras);
|
||||||
datdata.ApplyFilter(Filter, false);
|
datdata.ApplySplitting(splitType, false);
|
||||||
|
datdata.ApplyFilter(Filter);
|
||||||
datdata.ApplyCleaning(Cleaner);
|
datdata.ApplyCleaning(Cleaner);
|
||||||
datdata.Write(OutputDir);
|
datdata.Write(OutputDir);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -167,7 +167,8 @@ namespace SabreTools.Features
|
|||||||
|| datFile.Header.DatFormat.HasFlag(DatFormat.CSV)
|
|| datFile.Header.DatFormat.HasFlag(DatFormat.CSV)
|
||||||
|| datFile.Header.DatFormat.HasFlag(DatFormat.SSV));
|
|| datFile.Header.DatFormat.HasFlag(DatFormat.SSV));
|
||||||
datFile.ApplyExtras(Extras);
|
datFile.ApplyExtras(Extras);
|
||||||
datFile.ApplyFilter(Filter, false);
|
datFile.ApplySplitting(GetSplitType(features), false);
|
||||||
|
datFile.ApplyFilter(Filter);
|
||||||
datFile.ApplyCleaning(Cleaner);
|
datFile.ApplyCleaning(Cleaner);
|
||||||
|
|
||||||
// Get the correct output path
|
// Get the correct output path
|
||||||
@@ -204,7 +205,8 @@ namespace SabreTools.Features
|
|||||||
|
|
||||||
// Apply the extras, filter, and cleaning
|
// Apply the extras, filter, and cleaning
|
||||||
userInputDat.ApplyExtras(Extras);
|
userInputDat.ApplyExtras(Extras);
|
||||||
userInputDat.ApplyFilter(Filter, false);
|
userInputDat.ApplySplitting(GetSplitType(features), false);
|
||||||
|
userInputDat.ApplyFilter(Filter);
|
||||||
userInputDat.ApplyCleaning(Cleaner);
|
userInputDat.ApplyCleaning(Cleaner);
|
||||||
|
|
||||||
// Output only DatItems that are duplicated across inputs
|
// Output only DatItems that are duplicated across inputs
|
||||||
@@ -293,7 +295,8 @@ namespace SabreTools.Features
|
|||||||
DatFile repDat = DatFile.Create(userInputDat.Header.CloneFiltering());
|
DatFile repDat = DatFile.Create(userInputDat.Header.CloneFiltering());
|
||||||
repDat.Parse(inputPath, indexId: 1, keep: true);
|
repDat.Parse(inputPath, indexId: 1, keep: true);
|
||||||
repDat.ApplyExtras(Extras);
|
repDat.ApplyExtras(Extras);
|
||||||
repDat.ApplyFilter(Filter, false);
|
repDat.ApplySplitting(GetSplitType(features), false);
|
||||||
|
repDat.ApplyFilter(Filter);
|
||||||
repDat.ApplyCleaning(Cleaner);
|
repDat.ApplyCleaning(Cleaner);
|
||||||
|
|
||||||
// Now replace the fields from the base DatFile
|
// Now replace the fields from the base DatFile
|
||||||
@@ -315,7 +318,8 @@ namespace SabreTools.Features
|
|||||||
DatFile repDat = DatFile.Create(userInputDat.Header.CloneFiltering());
|
DatFile repDat = DatFile.Create(userInputDat.Header.CloneFiltering());
|
||||||
repDat.Parse(inputPath, indexId: 1, keep: true);
|
repDat.Parse(inputPath, indexId: 1, keep: true);
|
||||||
repDat.ApplyExtras(Extras);
|
repDat.ApplyExtras(Extras);
|
||||||
repDat.ApplyFilter(Filter, false);
|
repDat.ApplySplitting(GetSplitType(features), false);
|
||||||
|
repDat.ApplyFilter(Filter);
|
||||||
repDat.ApplyCleaning(Cleaner);
|
repDat.ApplyCleaning(Cleaner);
|
||||||
|
|
||||||
// Now replace the fields from the base DatFile
|
// Now replace the fields from the base DatFile
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ namespace SabreTools.Features
|
|||||||
TreatAsFiles asFiles = GetTreatAsFiles(features);
|
TreatAsFiles asFiles = GetTreatAsFiles(features);
|
||||||
bool hashOnly = GetBoolean(features, HashOnlyValue);
|
bool hashOnly = GetBoolean(features, HashOnlyValue);
|
||||||
bool quickScan = GetBoolean(features, QuickValue);
|
bool quickScan = GetBoolean(features, QuickValue);
|
||||||
|
var splitType = GetSplitType(features);
|
||||||
|
|
||||||
// If we are in individual mode, process each DAT on their own
|
// If we are in individual mode, process each DAT on their own
|
||||||
if (GetBoolean(features, IndividualValue))
|
if (GetBoolean(features, IndividualValue))
|
||||||
@@ -57,7 +58,8 @@ namespace SabreTools.Features
|
|||||||
DatFile datdata = DatFile.Create();
|
DatFile datdata = DatFile.Create();
|
||||||
datdata.Parse(datfile, 99, keep: true);
|
datdata.Parse(datfile, 99, keep: true);
|
||||||
datdata.ApplyExtras(Extras);
|
datdata.ApplyExtras(Extras);
|
||||||
datdata.ApplyFilter(Filter, true);
|
datdata.ApplySplitting(splitType, true);
|
||||||
|
datdata.ApplyFilter(Filter);
|
||||||
datdata.ApplyCleaning(Cleaner);
|
datdata.ApplyCleaning(Cleaner);
|
||||||
|
|
||||||
// Set depot information
|
// Set depot information
|
||||||
@@ -88,7 +90,8 @@ namespace SabreTools.Features
|
|||||||
{
|
{
|
||||||
datdata.Parse(datfile, 99, keep: true);
|
datdata.Parse(datfile, 99, keep: true);
|
||||||
datdata.ApplyExtras(Extras);
|
datdata.ApplyExtras(Extras);
|
||||||
datdata.ApplyFilter(Filter, true);
|
datdata.ApplySplitting(splitType, true);
|
||||||
|
datdata.ApplyFilter(Filter);
|
||||||
datdata.ApplyCleaning(Cleaner);
|
datdata.ApplyCleaning(Cleaner);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user