mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Fix build... (understatement)
This commit is contained in:
@@ -56,7 +56,7 @@ namespace RombaSharp.Features
|
||||
datfile.Header.Name = string.IsNullOrWhiteSpace(name) ? "untitled" : name;
|
||||
datfile.Header.Description = description;
|
||||
DatFromDir.PopulateFromDir(datfile, source, asFiles: TreatAsFile.NonArchive);
|
||||
Modification.ApplyCleaning(datfile, new Cleaner() { ExcludeFields = Hash.DeepHashes.AsFields() });
|
||||
Modification.ApplyCleaning(datfile, new Cleaner() { ExcludeDatItemFields = Hash.DeepHashes.AsDatItemFields() });
|
||||
Writer.Write(datfile, outdat);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,35 +7,6 @@ namespace SabreTools.Core.Tools
|
||||
{
|
||||
#region Enum to Enum
|
||||
|
||||
/// <summary>
|
||||
/// Get the Fields associated with each hash type
|
||||
/// </summary>
|
||||
public static List<Field> AsFields(this Hash hash)
|
||||
{
|
||||
List<Field> fields = new List<Field>();
|
||||
|
||||
if (hash.HasFlag(Hash.CRC))
|
||||
fields.Add(Field.DatItem_CRC);
|
||||
if (hash.HasFlag(Hash.MD5))
|
||||
fields.Add(Field.DatItem_MD5);
|
||||
#if NET_FRAMEWORK
|
||||
if (hash.HasFlag(Hash.RIPEMD160))
|
||||
fields.Add(Field.DatItem_RIPEMD160);
|
||||
#endif
|
||||
if (hash.HasFlag(Hash.SHA1))
|
||||
fields.Add(Field.DatItem_SHA1);
|
||||
if (hash.HasFlag(Hash.SHA256))
|
||||
fields.Add(Field.DatItem_SHA256);
|
||||
if (hash.HasFlag(Hash.SHA384))
|
||||
fields.Add(Field.DatItem_SHA384);
|
||||
if (hash.HasFlag(Hash.SHA512))
|
||||
fields.Add(Field.DatItem_SHA512);
|
||||
if (hash.HasFlag(Hash.SpamSum))
|
||||
fields.Add(Field.DatItem_SpamSum);
|
||||
|
||||
return fields;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the DatItemFields associated with each hash type
|
||||
/// </summary>
|
||||
|
||||
@@ -459,7 +459,7 @@ namespace SabreTools.DatFiles
|
||||
if (!string.IsNullOrWhiteSpace(disk.SHA1))
|
||||
{
|
||||
name = Utilities.GetDepotPath(disk.SHA1, Header.OutputDepot.Depth).Replace('\\', '/');
|
||||
item.SetFields(new Dictionary<Field, string> { [Field.DatItem_Name] = $"{pre}{name}{post}" } );
|
||||
item.SetFields(new Dictionary<DatItemField, string> { [DatItemField.Name] = $"{pre}{name}{post}" }, null);
|
||||
}
|
||||
}
|
||||
else if (item.ItemType == ItemType.Media)
|
||||
@@ -470,7 +470,7 @@ namespace SabreTools.DatFiles
|
||||
if (!string.IsNullOrWhiteSpace(media.SHA1))
|
||||
{
|
||||
name = Utilities.GetDepotPath(media.SHA1, Header.OutputDepot.Depth).Replace('\\', '/');
|
||||
item.SetFields(new Dictionary<Field, string> { [Field.DatItem_Name] = $"{pre}{name}{post}" });
|
||||
item.SetFields(new Dictionary<DatItemField, string> { [DatItemField.Name] = $"{pre}{name}{post}" }, null);
|
||||
}
|
||||
}
|
||||
else if (item.ItemType == ItemType.Rom)
|
||||
@@ -481,7 +481,7 @@ namespace SabreTools.DatFiles
|
||||
if (!string.IsNullOrWhiteSpace(rom.SHA1))
|
||||
{
|
||||
name = Utilities.GetDepotPath(rom.SHA1, Header.OutputDepot.Depth).Replace('\\', '/');
|
||||
item.SetFields(new Dictionary<Field, string> { [Field.DatItem_Name] = $"{pre}{name}{post}" });
|
||||
item.SetFields(new Dictionary<DatItemField, string> { [DatItemField.Name] = $"{pre}{name}{post}" }, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -505,7 +505,7 @@ namespace SabreTools.DatFiles
|
||||
name = Path.Combine(item.Machine.Name, name);
|
||||
|
||||
// Now assign back the item name
|
||||
item.SetFields(new Dictionary<Field, string> { [Field.DatItem_Name] = pre + name + post });
|
||||
item.SetFields(new Dictionary<DatItemField, string> { [DatItemField.Name] = pre + name + post }, null);
|
||||
|
||||
// Restore all relevant values
|
||||
if (forceRemoveQuotes)
|
||||
|
||||
@@ -406,121 +406,121 @@ namespace SabreTools.DatFiles
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="mappings">Mappings dictionary</param>
|
||||
public void SetFields(Dictionary<Field, string> mappings)
|
||||
public void SetFields(Dictionary<DatHeaderField, string> mappings)
|
||||
{
|
||||
#region Common
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatHeader_FileName))
|
||||
FileName = mappings[Field.DatHeader_FileName];
|
||||
if (mappings.Keys.Contains(DatHeaderField.FileName))
|
||||
FileName = mappings[DatHeaderField.FileName];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatHeader_Name))
|
||||
Name = mappings[Field.DatHeader_Name];
|
||||
if (mappings.Keys.Contains(DatHeaderField.Name))
|
||||
Name = mappings[DatHeaderField.Name];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatHeader_Description))
|
||||
Description = mappings[Field.DatHeader_Description];
|
||||
if (mappings.Keys.Contains(DatHeaderField.Description))
|
||||
Description = mappings[DatHeaderField.Description];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatHeader_RootDir))
|
||||
RootDir = mappings[Field.DatHeader_RootDir];
|
||||
if (mappings.Keys.Contains(DatHeaderField.RootDir))
|
||||
RootDir = mappings[DatHeaderField.RootDir];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatHeader_Category))
|
||||
Category = mappings[Field.DatHeader_Category];
|
||||
if (mappings.Keys.Contains(DatHeaderField.Category))
|
||||
Category = mappings[DatHeaderField.Category];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatHeader_Version))
|
||||
Version = mappings[Field.DatHeader_Version];
|
||||
if (mappings.Keys.Contains(DatHeaderField.Version))
|
||||
Version = mappings[DatHeaderField.Version];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatHeader_Date))
|
||||
Date = mappings[Field.DatHeader_Date];
|
||||
if (mappings.Keys.Contains(DatHeaderField.Date))
|
||||
Date = mappings[DatHeaderField.Date];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatHeader_Author))
|
||||
Author = mappings[Field.DatHeader_Author];
|
||||
if (mappings.Keys.Contains(DatHeaderField.Author))
|
||||
Author = mappings[DatHeaderField.Author];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatHeader_Email))
|
||||
Email = mappings[Field.DatHeader_Email];
|
||||
if (mappings.Keys.Contains(DatHeaderField.Email))
|
||||
Email = mappings[DatHeaderField.Email];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatHeader_Homepage))
|
||||
Homepage = mappings[Field.DatHeader_Homepage];
|
||||
if (mappings.Keys.Contains(DatHeaderField.Homepage))
|
||||
Homepage = mappings[DatHeaderField.Homepage];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatHeader_Url))
|
||||
Url = mappings[Field.DatHeader_Url];
|
||||
if (mappings.Keys.Contains(DatHeaderField.Url))
|
||||
Url = mappings[DatHeaderField.Url];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatHeader_Comment))
|
||||
Comment = mappings[Field.DatHeader_Comment];
|
||||
if (mappings.Keys.Contains(DatHeaderField.Comment))
|
||||
Comment = mappings[DatHeaderField.Comment];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatHeader_HeaderSkipper))
|
||||
HeaderSkipper = mappings[Field.DatHeader_HeaderSkipper];
|
||||
if (mappings.Keys.Contains(DatHeaderField.HeaderSkipper))
|
||||
HeaderSkipper = mappings[DatHeaderField.HeaderSkipper];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatHeader_Type))
|
||||
Type = mappings[Field.DatHeader_Type];
|
||||
if (mappings.Keys.Contains(DatHeaderField.Type))
|
||||
Type = mappings[DatHeaderField.Type];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatHeader_ForceMerging))
|
||||
ForceMerging = mappings[Field.DatHeader_ForceMerging].AsMergingFlag();
|
||||
if (mappings.Keys.Contains(DatHeaderField.ForceMerging))
|
||||
ForceMerging = mappings[DatHeaderField.ForceMerging].AsMergingFlag();
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatHeader_ForceNodump))
|
||||
ForceNodump = mappings[Field.DatHeader_ForceNodump].AsNodumpFlag();
|
||||
if (mappings.Keys.Contains(DatHeaderField.ForceNodump))
|
||||
ForceNodump = mappings[DatHeaderField.ForceNodump].AsNodumpFlag();
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatHeader_ForcePacking))
|
||||
ForcePacking = mappings[Field.DatHeader_ForcePacking].AsPackingFlag();
|
||||
if (mappings.Keys.Contains(DatHeaderField.ForcePacking))
|
||||
ForcePacking = mappings[DatHeaderField.ForcePacking].AsPackingFlag();
|
||||
|
||||
#endregion
|
||||
|
||||
#region ListXML
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatHeader_Debug))
|
||||
Debug = mappings[Field.DatHeader_Debug].AsYesNo();
|
||||
if (mappings.Keys.Contains(DatHeaderField.Debug))
|
||||
Debug = mappings[DatHeaderField.Debug].AsYesNo();
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatHeader_MameConfig))
|
||||
MameConfig = mappings[Field.DatHeader_MameConfig];
|
||||
if (mappings.Keys.Contains(DatHeaderField.MameConfig))
|
||||
MameConfig = mappings[DatHeaderField.MameConfig];
|
||||
|
||||
#endregion
|
||||
|
||||
#region Logiqx
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatHeader_Build))
|
||||
Build = mappings[Field.DatHeader_Build];
|
||||
if (mappings.Keys.Contains(DatHeaderField.Build))
|
||||
Build = mappings[DatHeaderField.Build];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatHeader_RomMode))
|
||||
RomMode = mappings[Field.DatHeader_RomMode].AsMergingFlag();
|
||||
if (mappings.Keys.Contains(DatHeaderField.RomMode))
|
||||
RomMode = mappings[DatHeaderField.RomMode].AsMergingFlag();
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatHeader_BiosMode))
|
||||
BiosMode = mappings[Field.DatHeader_BiosMode].AsMergingFlag();
|
||||
if (mappings.Keys.Contains(DatHeaderField.BiosMode))
|
||||
BiosMode = mappings[DatHeaderField.BiosMode].AsMergingFlag();
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatHeader_SampleMode))
|
||||
SampleMode = mappings[Field.DatHeader_SampleMode].AsMergingFlag();
|
||||
if (mappings.Keys.Contains(DatHeaderField.SampleMode))
|
||||
SampleMode = mappings[DatHeaderField.SampleMode].AsMergingFlag();
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatHeader_LockRomMode))
|
||||
LockRomMode = mappings[Field.DatHeader_LockRomMode].AsYesNo();
|
||||
if (mappings.Keys.Contains(DatHeaderField.LockRomMode))
|
||||
LockRomMode = mappings[DatHeaderField.LockRomMode].AsYesNo();
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatHeader_LockBiosMode))
|
||||
LockBiosMode = mappings[Field.DatHeader_LockBiosMode].AsYesNo();
|
||||
if (mappings.Keys.Contains(DatHeaderField.LockBiosMode))
|
||||
LockBiosMode = mappings[DatHeaderField.LockBiosMode].AsYesNo();
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatHeader_LockSampleMode))
|
||||
LockSampleMode = mappings[Field.DatHeader_LockSampleMode].AsYesNo();
|
||||
if (mappings.Keys.Contains(DatHeaderField.LockSampleMode))
|
||||
LockSampleMode = mappings[DatHeaderField.LockSampleMode].AsYesNo();
|
||||
|
||||
#endregion
|
||||
|
||||
#region OfflineList
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatHeader_System))
|
||||
System = mappings[Field.DatHeader_System];
|
||||
if (mappings.Keys.Contains(DatHeaderField.System))
|
||||
System = mappings[DatHeaderField.System];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatHeader_ScreenshotsWidth))
|
||||
ScreenshotsWidth = mappings[Field.DatHeader_ScreenshotsWidth];
|
||||
if (mappings.Keys.Contains(DatHeaderField.ScreenshotsWidth))
|
||||
ScreenshotsWidth = mappings[DatHeaderField.ScreenshotsWidth];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatHeader_ScreenshotsHeight))
|
||||
ScreenshotsHeight = mappings[Field.DatHeader_ScreenshotsHeight];
|
||||
if (mappings.Keys.Contains(DatHeaderField.ScreenshotsHeight))
|
||||
ScreenshotsHeight = mappings[DatHeaderField.ScreenshotsHeight];
|
||||
|
||||
// TODO: Add DatHeader_Info*
|
||||
// TDOO: Add DatHeader_CanOpen*
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatHeader_RomTitle))
|
||||
RomTitle = mappings[Field.DatHeader_RomTitle];
|
||||
if (mappings.Keys.Contains(DatHeaderField.RomTitle))
|
||||
RomTitle = mappings[DatHeaderField.RomTitle];
|
||||
|
||||
#endregion
|
||||
|
||||
#region RomCenter
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatHeader_RomCenterVersion))
|
||||
RomCenterVersion = mappings[Field.DatHeader_RomCenterVersion];
|
||||
if (mappings.Keys.Contains(DatHeaderField.RomCenterVersion))
|
||||
RomCenterVersion = mappings[DatHeaderField.RomCenterVersion];
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -308,7 +308,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
|
||||
// Regular attributes
|
||||
case "name":
|
||||
item.SetFields(new Dictionary<Field, string> { [Field.DatItem_Name] = attrVal } );
|
||||
item.SetFields(new Dictionary<DatItemField, string> { [DatItemField.Name] = attrVal }, null);
|
||||
break;
|
||||
|
||||
case "size":
|
||||
|
||||
@@ -65,27 +65,47 @@ namespace SabreTools.DatFiles.Formats
|
||||
// Get the current line, split and parse
|
||||
svr.ReadNextLine();
|
||||
|
||||
// Create mapping dictionary
|
||||
var mappings = new Dictionary<Field, string>();
|
||||
// Create mapping dictionaries
|
||||
var datHeaderMappings = new Dictionary<DatHeaderField, string>();
|
||||
var machineMappings = new Dictionary<MachineField, string>();
|
||||
var datItemMappings = new Dictionary<DatItemField, string>();
|
||||
|
||||
// Now we loop through and get values for everything
|
||||
for (int i = 0; i < svr.HeaderValues.Count; i++)
|
||||
{
|
||||
Field key = svr.HeaderValues[i].AsField();
|
||||
string value = svr.Line[i];
|
||||
mappings[key] = value;
|
||||
DatHeaderField dhf = svr.HeaderValues[i].AsDatHeaderField();
|
||||
if (dhf != DatHeaderField.NULL)
|
||||
{
|
||||
datHeaderMappings[dhf] = value;
|
||||
continue;
|
||||
}
|
||||
|
||||
MachineField mf = svr.HeaderValues[i].AsMachineField();
|
||||
if (mf != MachineField.NULL)
|
||||
{
|
||||
machineMappings[mf] = value;
|
||||
continue;
|
||||
}
|
||||
|
||||
DatItemField dif = svr.HeaderValues[i].AsDatItemField();
|
||||
if (dif != DatItemField.NULL)
|
||||
{
|
||||
datItemMappings[dif] = value;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Set DatHeader fields
|
||||
DatHeader header = new DatHeader();
|
||||
header.SetFields(mappings);
|
||||
header.SetFields(datHeaderMappings);
|
||||
Header.ConditionalCopy(header);
|
||||
|
||||
// Set Machine and DatItem fields
|
||||
if (mappings.ContainsKey(Field.DatItem_Type))
|
||||
if (datItemMappings.ContainsKey(DatItemField.Type))
|
||||
{
|
||||
DatItem datItem = DatItem.Create(mappings[Field.DatItem_Type].AsItemType());
|
||||
datItem.SetFields(mappings);
|
||||
DatItem datItem = DatItem.Create(datItemMappings[DatItemField.Type].AsItemType());
|
||||
datItem.SetFields(datItemMappings, machineMappings);
|
||||
datItem.Source = new Source(indexId, filename);
|
||||
ParseAddHelper(datItem);
|
||||
}
|
||||
|
||||
@@ -58,28 +58,27 @@ namespace SabreTools.DatItems
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="mappings">Mappings dictionary</param>
|
||||
public override void SetFields(Dictionary<Field, string> mappings)
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
Dictionary<MachineField, string> machineMappings)
|
||||
{
|
||||
// Set base fields
|
||||
base.SetFields(mappings);
|
||||
base.SetFields(datItemMappings, machineMappings);
|
||||
|
||||
// Handle Adjuster-specific fields
|
||||
if (mappings.Keys.Contains(Field.DatItem_Name))
|
||||
Name = mappings[Field.DatItem_Name];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Name))
|
||||
Name = datItemMappings[DatItemField.Name];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Default))
|
||||
Default = mappings[Field.DatItem_Default].AsYesNo();
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Default))
|
||||
Default = datItemMappings[DatItemField.Default].AsYesNo();
|
||||
|
||||
// Field.DatItem_Conditions does not apply here
|
||||
if (ConditionsSpecified)
|
||||
{
|
||||
foreach (Condition condition in Conditions)
|
||||
{
|
||||
condition.SetFields(mappings, true);
|
||||
condition.SetFields(datItemMappings, machineMappings, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -179,24 +178,19 @@ namespace SabreTools.DatItems
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check to see if a DatItem passes the filter
|
||||
/// </summary>
|
||||
/// <param name="filter">Filter to check against</param>
|
||||
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
||||
/// <returns>True if the item passed the filter, false otherwise</returns>
|
||||
public override bool PassesFilter(Filter filter, bool sub = false)
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
// Check common fields first
|
||||
if (!base.PassesFilter(filter, sub))
|
||||
if (!base.PassesFilter(cleaner, sub))
|
||||
return false;
|
||||
|
||||
// Filter on item name
|
||||
if (!filter.PassStringFilter(filter.DatItem_Name, Name))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Name, Name))
|
||||
return false;
|
||||
|
||||
// Filter on default
|
||||
if (!filter.PassBoolFilter(filter.DatItem_Default, Default))
|
||||
if (!Filter.PassBoolFilter(cleaner.DatItemFilter.Default, Default))
|
||||
return false;
|
||||
|
||||
// Filter on individual conditions
|
||||
@@ -204,7 +198,7 @@ namespace SabreTools.DatItems
|
||||
{
|
||||
foreach (Condition condition in Conditions)
|
||||
{
|
||||
if (!condition.PassesFilter(filter, true))
|
||||
if (!condition.PassesFilter(cleaner, true))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -212,27 +206,26 @@ namespace SabreTools.DatItems
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove fields from the DatItem
|
||||
/// </summary>
|
||||
/// <param name="fields">List of Fields to remove</param>
|
||||
public override void RemoveFields(List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void RemoveFields(
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Remove common fields first
|
||||
base.RemoveFields(fields);
|
||||
base.RemoveFields(datItemFields, machineFields);
|
||||
|
||||
// Remove the fields
|
||||
if (fields.Contains(Field.DatItem_Name))
|
||||
if (datItemFields.Contains(DatItemField.Name))
|
||||
Name = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Default))
|
||||
if (datItemFields.Contains(DatItemField.Default))
|
||||
Default = null;
|
||||
|
||||
if (ConditionsSpecified)
|
||||
{
|
||||
foreach (Condition condition in Conditions)
|
||||
{
|
||||
condition.RemoveFields(fields, true);
|
||||
condition.RemoveFields(datItemFields, machineFields, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -251,15 +244,14 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Sorting and Merging
|
||||
|
||||
/// <summary>
|
||||
/// Replace fields from another item
|
||||
/// </summary>
|
||||
/// <param name="item">DatItem to pull new information from</param>
|
||||
/// <param name="fields">List of Fields representing what should be updated</param>
|
||||
public override void ReplaceFields(DatItem item, List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void ReplaceFields(
|
||||
DatItem item,
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Replace common fields first
|
||||
base.ReplaceFields(item, fields);
|
||||
base.ReplaceFields(item, datItemFields, machineFields);
|
||||
|
||||
// If we don't have a Adjuster to replace from, ignore specific fields
|
||||
if (item.ItemType != ItemType.Adjuster)
|
||||
@@ -269,10 +261,10 @@ namespace SabreTools.DatItems
|
||||
Adjuster newItem = item as Adjuster;
|
||||
|
||||
// Replace the fields
|
||||
if (fields.Contains(Field.DatItem_Name))
|
||||
if (datItemFields.Contains(DatItemField.Name))
|
||||
Name = newItem.Name;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Default))
|
||||
if (datItemFields.Contains(DatItemField.Default))
|
||||
Default = newItem.Default;
|
||||
|
||||
// DatItem_Condition_* doesn't make sense here
|
||||
|
||||
@@ -27,18 +27,17 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="mappings">Mappings dictionary</param>
|
||||
public override void SetFields(Dictionary<Field, string> mappings)
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
Dictionary<MachineField, string> machineMappings)
|
||||
{
|
||||
// Set base fields
|
||||
base.SetFields(mappings);
|
||||
base.SetFields(datItemMappings, machineMappings);
|
||||
|
||||
// Handle Analog-specific fields
|
||||
if (mappings.Keys.Contains(Field.DatItem_Analog_Mask))
|
||||
Mask = mappings[Field.DatItem_Analog_Mask];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Analog_Mask))
|
||||
Mask = datItemMappings[DatItemField.Analog_Mask];
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -93,36 +92,30 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Filtering
|
||||
|
||||
/// <summary>
|
||||
/// Check to see if a DatItem passes the filter
|
||||
/// </summary>
|
||||
/// <param name="filter">Filter to check against</param>
|
||||
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
||||
/// <returns>True if the item passed the filter, false otherwise</returns>
|
||||
public override bool PassesFilter(Filter filter, bool sub = false)
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
// Check common fields first
|
||||
if (!base.PassesFilter(filter, sub))
|
||||
if (!base.PassesFilter(cleaner, sub))
|
||||
return false;
|
||||
|
||||
// Filter on mask
|
||||
if (!filter.PassStringFilter(filter.DatItem_Analog_Mask, Mask))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Analog_Mask, Mask))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove fields from the DatItem
|
||||
/// </summary>
|
||||
/// <param name="fields">List of Fields to remove</param>
|
||||
public override void RemoveFields(List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void RemoveFields(
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Remove common fields first
|
||||
base.RemoveFields(fields);
|
||||
base.RemoveFields(datItemFields, machineFields);
|
||||
|
||||
// Remove the fields
|
||||
if (fields.Contains(Field.DatItem_Analog_Mask))
|
||||
if (datItemFields.Contains(DatItemField.Analog_Mask))
|
||||
Mask = null;
|
||||
}
|
||||
|
||||
@@ -130,15 +123,14 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Sorting and Merging
|
||||
|
||||
/// <summary>
|
||||
/// Replace fields from another item
|
||||
/// </summary>
|
||||
/// <param name="item">DatItem to pull new information from</param>
|
||||
/// <param name="fields">List of Fields representing what should be updated</param>
|
||||
public override void ReplaceFields(DatItem item, List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void ReplaceFields(
|
||||
DatItem item,
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Replace common fields first
|
||||
base.ReplaceFields(item, fields);
|
||||
base.ReplaceFields(item, datItemFields, machineFields);
|
||||
|
||||
// If we don't have a Analog to replace from, ignore specific fields
|
||||
if (item.ItemType != ItemType.Analog)
|
||||
@@ -148,7 +140,7 @@ namespace SabreTools.DatItems
|
||||
Analog newItem = item as Analog;
|
||||
|
||||
// Replace the fields
|
||||
if (fields.Contains(Field.DatItem_Analog_Mask))
|
||||
if (datItemFields.Contains(DatItemField.Analog_Mask))
|
||||
Mask = newItem.Mask;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,18 +37,17 @@ namespace SabreTools.DatItems
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="mappings">Mappings dictionary</param>
|
||||
public override void SetFields(Dictionary<Field, string> mappings)
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
Dictionary<MachineField, string> machineMappings)
|
||||
{
|
||||
// Set base fields
|
||||
base.SetFields(mappings);
|
||||
base.SetFields(datItemMappings, machineMappings);
|
||||
|
||||
// Handle Archive-specific fields
|
||||
if (mappings.Keys.Contains(Field.DatItem_Name))
|
||||
Name = mappings[Field.DatItem_Name];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Name))
|
||||
Name = datItemMappings[DatItemField.Name];
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -131,36 +130,30 @@ namespace SabreTools.DatItems
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check to see if a DatItem passes the filter
|
||||
/// </summary>
|
||||
/// <param name="filter">Filter to check against</param>
|
||||
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
||||
/// <returns>True if the item passed the filter, false otherwise</returns>
|
||||
public override bool PassesFilter(Filter filter, bool sub = false)
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
// Check common fields first
|
||||
if (!base.PassesFilter(filter, sub))
|
||||
if (!base.PassesFilter(cleaner, sub))
|
||||
return false;
|
||||
|
||||
// Filter on item name
|
||||
if (!filter.PassStringFilter(filter.DatItem_Name, Name))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Name, Name))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove fields from the DatItem
|
||||
/// </summary>
|
||||
/// <param name="fields">List of Fields to remove</param>
|
||||
public override void RemoveFields(List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void RemoveFields(
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Remove common fields first
|
||||
base.RemoveFields(fields);
|
||||
base.RemoveFields(datItemFields, machineFields);
|
||||
|
||||
// Remove the fields
|
||||
if (fields.Contains(Field.DatItem_Name))
|
||||
if (datItemFields.Contains(DatItemField.Name))
|
||||
Name = null;
|
||||
}
|
||||
|
||||
@@ -178,15 +171,14 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Sorting and Merging
|
||||
|
||||
/// <summary>
|
||||
/// Replace fields from another item
|
||||
/// </summary>
|
||||
/// <param name="item">DatItem to pull new information from</param>
|
||||
/// <param name="fields">List of Fields representing what should be updated</param>
|
||||
public override void ReplaceFields(DatItem item, List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void ReplaceFields(
|
||||
DatItem item,
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Replace common fields first
|
||||
base.ReplaceFields(item, fields);
|
||||
base.ReplaceFields(item, datItemFields, machineFields);
|
||||
|
||||
// If we don't have a Archive to replace from, ignore specific fields
|
||||
if (item.ItemType != ItemType.Archive)
|
||||
@@ -196,7 +188,7 @@ namespace SabreTools.DatItems
|
||||
Archive newItem = item as Archive;
|
||||
|
||||
// Replace the fields
|
||||
if (fields.Contains(Field.DatItem_Name))
|
||||
if (datItemFields.Contains(DatItemField.Name))
|
||||
Name = newItem.Name;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,24 +55,23 @@ namespace SabreTools.DatItems
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="mappings">Mappings dictionary</param>
|
||||
public override void SetFields(Dictionary<Field, string> mappings)
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
Dictionary<MachineField, string> machineMappings)
|
||||
{
|
||||
// Set base fields
|
||||
base.SetFields(mappings);
|
||||
base.SetFields(datItemMappings, machineMappings);
|
||||
|
||||
// Handle BiosSet-specific fields
|
||||
if (mappings.Keys.Contains(Field.DatItem_Name))
|
||||
Name = mappings[Field.DatItem_Name];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Name))
|
||||
Name = datItemMappings[DatItemField.Name];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Description))
|
||||
Description = mappings[Field.DatItem_Description];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Description))
|
||||
Description = datItemMappings[DatItemField.Description];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Default))
|
||||
Default = mappings[Field.DatItem_Default].AsYesNo();
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Default))
|
||||
Default = datItemMappings[DatItemField.Default].AsYesNo();
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -159,50 +158,44 @@ namespace SabreTools.DatItems
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check to see if a DatItem passes the filter
|
||||
/// </summary>
|
||||
/// <param name="filter">Filter to check against</param>
|
||||
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
||||
/// <returns>True if the item passed the filter, false otherwise</returns>
|
||||
public override bool PassesFilter(Filter filter, bool sub = false)
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
// Check common fields first
|
||||
if (!base.PassesFilter(filter, sub))
|
||||
if (!base.PassesFilter(cleaner, sub))
|
||||
return false;
|
||||
|
||||
// Filter on item name
|
||||
if (!filter.PassStringFilter(filter.DatItem_Name, Name))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Name, Name))
|
||||
return false;
|
||||
|
||||
// Filter on description
|
||||
if (!filter.PassStringFilter(filter.DatItem_Description, Description))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Description, Description))
|
||||
return false;
|
||||
|
||||
// Filter on default
|
||||
if (!filter.PassBoolFilter(filter.DatItem_Default, Default))
|
||||
if (!Filter.PassBoolFilter(cleaner.DatItemFilter.Default, Default))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove fields from the DatItem
|
||||
/// </summary>
|
||||
/// <param name="fields">List of Fields to remove</param>
|
||||
public override void RemoveFields(List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void RemoveFields(
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Remove common fields first
|
||||
base.RemoveFields(fields);
|
||||
base.RemoveFields(datItemFields, machineFields);
|
||||
|
||||
// Remove the fields
|
||||
if (fields.Contains(Field.DatItem_Name))
|
||||
if (datItemFields.Contains(DatItemField.Name))
|
||||
Name = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Description))
|
||||
if (datItemFields.Contains(DatItemField.Description))
|
||||
Description = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Default))
|
||||
if (datItemFields.Contains(DatItemField.Default))
|
||||
Default = null;
|
||||
}
|
||||
|
||||
@@ -220,15 +213,14 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Sorting and Merging
|
||||
|
||||
/// <summary>
|
||||
/// Replace fields from another item
|
||||
/// </summary>
|
||||
/// <param name="item">DatItem to pull new information from</param>
|
||||
/// <param name="fields">List of Fields representing what should be updated</param>
|
||||
public override void ReplaceFields(DatItem item, List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void ReplaceFields(
|
||||
DatItem item,
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Replace common fields first
|
||||
base.ReplaceFields(item, fields);
|
||||
base.ReplaceFields(item, datItemFields, machineFields);
|
||||
|
||||
// If we don't have a BiosSet to replace from, ignore specific fields
|
||||
if (item.ItemType != ItemType.BiosSet)
|
||||
@@ -238,13 +230,13 @@ namespace SabreTools.DatItems
|
||||
BiosSet newItem = item as BiosSet;
|
||||
|
||||
// Replace the fields
|
||||
if (fields.Contains(Field.DatItem_Name))
|
||||
if (datItemFields.Contains(DatItemField.Name))
|
||||
Name = newItem.Name;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Description))
|
||||
if (datItemFields.Contains(DatItemField.Description))
|
||||
Description = newItem.Description;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Default))
|
||||
if (datItemFields.Contains(DatItemField.Default))
|
||||
Default = newItem.Default;
|
||||
}
|
||||
|
||||
|
||||
@@ -68,27 +68,26 @@ namespace SabreTools.DatItems
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="mappings">Mappings dictionary</param>
|
||||
public override void SetFields(Dictionary<Field, string> mappings)
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
Dictionary<MachineField, string> machineMappings)
|
||||
{
|
||||
// Set base fields
|
||||
base.SetFields(mappings);
|
||||
base.SetFields(datItemMappings, machineMappings);
|
||||
|
||||
// Handle Chip-specific fields
|
||||
if (mappings.Keys.Contains(Field.DatItem_Name))
|
||||
Name = mappings[Field.DatItem_Name];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Name))
|
||||
Name = datItemMappings[DatItemField.Name];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Tag))
|
||||
Tag = mappings[Field.DatItem_Tag];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Tag))
|
||||
Tag = datItemMappings[DatItemField.Tag];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_ChipType))
|
||||
ChipType = mappings[Field.DatItem_ChipType].AsChipType();
|
||||
if (datItemMappings.Keys.Contains(DatItemField.ChipType))
|
||||
ChipType = datItemMappings[DatItemField.ChipType].AsChipType();
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Clock))
|
||||
Clock = Utilities.CleanLong(mappings[Field.DatItem_Clock]);
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Clock))
|
||||
Clock = Utilities.CleanLong(datItemMappings[DatItemField.Clock]);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -177,59 +176,53 @@ namespace SabreTools.DatItems
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check to see if a DatItem passes the filter
|
||||
/// </summary>
|
||||
/// <param name="filter">Filter to check against</param>
|
||||
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
||||
/// <returns>True if the item passed the filter, false otherwise</returns>
|
||||
public override bool PassesFilter(Filter filter, bool sub = false)
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
// Check common fields first
|
||||
if (!base.PassesFilter(filter, sub))
|
||||
if (!base.PassesFilter(cleaner, sub))
|
||||
return false;
|
||||
|
||||
// Filter on item name
|
||||
if (!filter.PassStringFilter(filter.DatItem_Name, Name))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Name, Name))
|
||||
return false;
|
||||
|
||||
// DatItem_Tag
|
||||
if (!filter.PassStringFilter(filter.DatItem_Tag, Tag))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Tag, Tag))
|
||||
return false;
|
||||
|
||||
// DatItem_ChipType
|
||||
if (filter.DatItem_ChipType.MatchesPositive(ChipType.NULL, ChipType) == false)
|
||||
if (cleaner.DatItemFilter.ChipType.MatchesPositive(ChipType.NULL, ChipType) == false)
|
||||
return false;
|
||||
if (filter.DatItem_ChipType.MatchesNegative(ChipType.NULL, ChipType) == true)
|
||||
if (cleaner.DatItemFilter.ChipType.MatchesNegative(ChipType.NULL, ChipType) == true)
|
||||
return false;
|
||||
|
||||
// DatItem_Clock
|
||||
if (!filter.PassLongFilter(filter.DatItem_Clock, Clock))
|
||||
if (!Filter.PassLongFilter(cleaner.DatItemFilter.Clock, Clock))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove fields from the DatItem
|
||||
/// </summary>
|
||||
/// <param name="fields">List of Fields to remove</param>
|
||||
public override void RemoveFields(List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void RemoveFields(
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Remove common fields first
|
||||
base.RemoveFields(fields);
|
||||
base.RemoveFields(datItemFields, machineFields);
|
||||
|
||||
// Remove the fields
|
||||
if (fields.Contains(Field.DatItem_Name))
|
||||
if (datItemFields.Contains(DatItemField.Name))
|
||||
Name = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Tag))
|
||||
if (datItemFields.Contains(DatItemField.Tag))
|
||||
Tag = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_ChipType))
|
||||
if (datItemFields.Contains(DatItemField.ChipType))
|
||||
ChipType = ChipType.NULL;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Clock))
|
||||
if (datItemFields.Contains(DatItemField.Clock))
|
||||
Clock = null;
|
||||
}
|
||||
|
||||
@@ -247,15 +240,14 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Sorting and Merging
|
||||
|
||||
/// <summary>
|
||||
/// Replace fields from another item
|
||||
/// </summary>
|
||||
/// <param name="item">DatItem to pull new information from</param>
|
||||
/// <param name="fields">List of Fields representing what should be updated</param>
|
||||
public override void ReplaceFields(DatItem item, List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void ReplaceFields(
|
||||
DatItem item,
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Replace common fields first
|
||||
base.ReplaceFields(item, fields);
|
||||
base.ReplaceFields(item, datItemFields, machineFields);
|
||||
|
||||
// If we don't have a Chip to replace from, ignore specific fields
|
||||
if (item.ItemType != ItemType.Chip)
|
||||
@@ -265,16 +257,16 @@ namespace SabreTools.DatItems
|
||||
Chip newItem = item as Chip;
|
||||
|
||||
// Replace the fields
|
||||
if (fields.Contains(Field.DatItem_Name))
|
||||
if (datItemFields.Contains(DatItemField.Name))
|
||||
Name = newItem.Name;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Tag))
|
||||
if (datItemFields.Contains(DatItemField.Tag))
|
||||
Tag = newItem.Tag;
|
||||
|
||||
if (fields.Contains(Field.DatItem_ChipType))
|
||||
if (datItemFields.Contains(DatItemField.ChipType))
|
||||
ChipType = newItem.ChipType;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Clock))
|
||||
if (datItemFields.Contains(DatItemField.Clock))
|
||||
Clock = newItem.Clock;
|
||||
}
|
||||
|
||||
|
||||
@@ -54,53 +54,56 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="mappings">Mappings dictionary</param>
|
||||
public override void SetFields(Dictionary<Field, string> mappings)
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
Dictionary<MachineField, string> machineMappings)
|
||||
{
|
||||
SetFields(mappings, false);
|
||||
SetFields(datItemMappings, machineMappings, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="mappings">Mappings dictionary</param>
|
||||
/// <param name="datItemMappings">DatItem mappings dictionary</param>
|
||||
/// <param name="machineMappings">Machine mappings dictionary</param>
|
||||
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
||||
public void SetFields(Dictionary<Field, string> mappings, bool sub)
|
||||
public void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
Dictionary<MachineField, string> machineMappings,
|
||||
bool sub)
|
||||
{
|
||||
// Set base fields
|
||||
base.SetFields(mappings);
|
||||
base.SetFields(datItemMappings, machineMappings);
|
||||
|
||||
// Handle Condition-specific fields
|
||||
if (sub)
|
||||
{
|
||||
if (mappings.Keys.Contains(Field.DatItem_Condition_Tag))
|
||||
Tag = mappings[Field.DatItem_Condition_Tag];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Condition_Tag))
|
||||
Tag = datItemMappings[DatItemField.Condition_Tag];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Condition_Mask))
|
||||
Mask = mappings[Field.DatItem_Condition_Mask];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Condition_Mask))
|
||||
Mask = datItemMappings[DatItemField.Condition_Mask];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Condition_Relation))
|
||||
Relation = mappings[Field.DatItem_Condition_Relation].AsRelation();
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Condition_Relation))
|
||||
Relation = datItemMappings[DatItemField.Condition_Relation].AsRelation();
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Condition_Value))
|
||||
Value = mappings[Field.DatItem_Condition_Value];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Condition_Value))
|
||||
Value = datItemMappings[DatItemField.Condition_Value];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mappings.Keys.Contains(Field.DatItem_Tag))
|
||||
Tag = mappings[Field.DatItem_Tag];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Tag))
|
||||
Tag = datItemMappings[DatItemField.Tag];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Mask))
|
||||
Mask = mappings[Field.DatItem_Mask];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Mask))
|
||||
Mask = datItemMappings[DatItemField.Mask];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Relation))
|
||||
Relation = mappings[Field.DatItem_Relation].AsRelation();
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Relation))
|
||||
Relation = datItemMappings[DatItemField.Relation].AsRelation();
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Value))
|
||||
Value = mappings[Field.DatItem_Value];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Value))
|
||||
Value = datItemMappings[DatItemField.Value];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,108 +165,106 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Filtering
|
||||
|
||||
/// <summary>
|
||||
/// Check to see if a DatItem passes the filter
|
||||
/// </summary>
|
||||
/// <param name="filter">Filter to check against</param>
|
||||
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
||||
/// <returns>True if the item passed the filter, false otherwise</returns>
|
||||
public override bool PassesFilter(Filter filter, bool sub = false)
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
// Check common fields first
|
||||
if (!base.PassesFilter(filter, sub))
|
||||
if (!base.PassesFilter(cleaner, sub))
|
||||
return false;
|
||||
|
||||
if (sub)
|
||||
{
|
||||
// Filter on tag
|
||||
if (!filter.PassStringFilter(filter.DatItem_Condition_Tag, Tag))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Condition_Tag, Tag))
|
||||
return false;
|
||||
|
||||
// Filter on mask
|
||||
if (!filter.PassStringFilter(filter.DatItem_Condition_Mask, Mask))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Condition_Mask, Mask))
|
||||
return false;
|
||||
|
||||
// Filter on relation
|
||||
if (filter.DatItem_Condition_Relation.MatchesPositive(Relation.NULL, Relation) == false)
|
||||
if (cleaner.DatItemFilter.Condition_Relation.MatchesPositive(Relation.NULL, Relation) == false)
|
||||
return false;
|
||||
if (filter.DatItem_Condition_Relation.MatchesNegative(Relation.NULL, Relation) == true)
|
||||
if (cleaner.DatItemFilter.Condition_Relation.MatchesNegative(Relation.NULL, Relation) == true)
|
||||
return false;
|
||||
|
||||
// Filter on value
|
||||
if (!filter.PassStringFilter(filter.DatItem_Condition_Value, Value))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Condition_Value, Value))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Filter on tag
|
||||
if (!filter.PassStringFilter(filter.DatItem_Tag, Tag))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Tag, Tag))
|
||||
return false;
|
||||
|
||||
// Filter on mask
|
||||
if (!filter.PassStringFilter(filter.DatItem_Mask, Mask))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Mask, Mask))
|
||||
return false;
|
||||
|
||||
// Filter on relation
|
||||
if (filter.DatItem_Relation.MatchesPositive(Relation.NULL, Relation) == false)
|
||||
if (cleaner.DatItemFilter.Relation.MatchesPositive(Relation.NULL, Relation) == false)
|
||||
return false;
|
||||
if (filter.DatItem_Relation.MatchesNegative(Relation.NULL, Relation) == true)
|
||||
if (cleaner.DatItemFilter.Relation.MatchesNegative(Relation.NULL, Relation) == true)
|
||||
return false;
|
||||
|
||||
// Filter on value
|
||||
if (!filter.PassStringFilter(filter.DatItem_Value, Value))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Value, Value))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove fields from the DatItem
|
||||
/// </summary>
|
||||
/// <param name="fields">List of Fields to remove</param>
|
||||
public override void RemoveFields(List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void RemoveFields(
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
RemoveFields(fields, false);
|
||||
RemoveFields(datItemFields, machineFields, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove fields from the DatItem
|
||||
/// </summary>
|
||||
/// <param name="fields">List of Fields to remove</param>
|
||||
/// <param name="datItemMappings">DatItem fields to remove</param>
|
||||
/// <param name="machineMappings">Machine fields to remove</param>
|
||||
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
||||
public void RemoveFields(List<Field> fields, bool sub)
|
||||
public void RemoveFields(
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields,
|
||||
bool sub)
|
||||
{
|
||||
// Remove common fields first
|
||||
base.RemoveFields(fields);
|
||||
base.RemoveFields(datItemFields, machineFields);
|
||||
|
||||
// Remove the fields
|
||||
if (sub)
|
||||
{
|
||||
if (fields.Contains(Field.DatItem_Condition_Tag))
|
||||
if (datItemFields.Contains(DatItemField.Condition_Tag))
|
||||
Tag = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Condition_Mask))
|
||||
if (datItemFields.Contains(DatItemField.Condition_Mask))
|
||||
Mask = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Condition_Relation))
|
||||
if (datItemFields.Contains(DatItemField.Condition_Relation))
|
||||
Relation = Relation.NULL;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Condition_Value))
|
||||
if (datItemFields.Contains(DatItemField.Condition_Value))
|
||||
Value = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fields.Contains(Field.DatItem_Tag))
|
||||
if (datItemFields.Contains(DatItemField.Tag))
|
||||
Tag = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Mask))
|
||||
if (datItemFields.Contains(DatItemField.Mask))
|
||||
Mask = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Relation))
|
||||
if (datItemFields.Contains(DatItemField.Relation))
|
||||
Relation = Relation.NULL;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Value))
|
||||
if (datItemFields.Contains(DatItemField.Value))
|
||||
Value = null;
|
||||
}
|
||||
}
|
||||
@@ -272,15 +273,14 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Sorting and Merging
|
||||
|
||||
/// <summary>
|
||||
/// Replace fields from another item
|
||||
/// </summary>
|
||||
/// <param name="item">DatItem to pull new information from</param>
|
||||
/// <param name="fields">List of Fields representing what should be updated</param>
|
||||
public override void ReplaceFields(DatItem item, List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void ReplaceFields(
|
||||
DatItem item,
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Replace common fields first
|
||||
base.ReplaceFields(item, fields);
|
||||
base.ReplaceFields(item, datItemFields, machineFields);
|
||||
|
||||
// If we don't have a Condition to replace from, ignore specific fields
|
||||
if (item.ItemType != ItemType.Condition)
|
||||
@@ -290,24 +290,24 @@ namespace SabreTools.DatItems
|
||||
Condition newItem = item as Condition;
|
||||
|
||||
// Replace the fields
|
||||
if (fields.Contains(Field.DatItem_Tag))
|
||||
if (datItemFields.Contains(DatItemField.Tag))
|
||||
Tag = newItem.Tag;
|
||||
else if (fields.Contains(Field.DatItem_Condition_Tag))
|
||||
else if (datItemFields.Contains(DatItemField.Condition_Tag))
|
||||
Tag = newItem.Tag;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Mask))
|
||||
if (datItemFields.Contains(DatItemField.Mask))
|
||||
Mask = newItem.Mask;
|
||||
else if (fields.Contains(Field.DatItem_Condition_Mask))
|
||||
else if (datItemFields.Contains(DatItemField.Condition_Mask))
|
||||
Mask = newItem.Mask;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Relation))
|
||||
if (datItemFields.Contains(DatItemField.Relation))
|
||||
Relation = newItem.Relation;
|
||||
else if (fields.Contains(Field.DatItem_Condition_Relation))
|
||||
else if (datItemFields.Contains(DatItemField.Condition_Relation))
|
||||
Relation = newItem.Relation;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Value))
|
||||
if (datItemFields.Contains(DatItemField.Value))
|
||||
Value = newItem.Value;
|
||||
else if (fields.Contains(Field.DatItem_Condition_Value))
|
||||
else if (datItemFields.Contains(DatItemField.Condition_Value))
|
||||
Value = newItem.Value;
|
||||
}
|
||||
|
||||
|
||||
@@ -81,30 +81,29 @@ namespace SabreTools.DatItems
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="mappings">Mappings dictionary</param>
|
||||
public override void SetFields(Dictionary<Field, string> mappings)
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
Dictionary<MachineField, string> machineMappings)
|
||||
{
|
||||
// Set base fields
|
||||
base.SetFields(mappings);
|
||||
base.SetFields(datItemMappings, machineMappings);
|
||||
|
||||
// Handle Configuration-specific fields
|
||||
if (mappings.Keys.Contains(Field.DatItem_Name))
|
||||
Name = mappings[Field.DatItem_Name];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Name))
|
||||
Name = datItemMappings[DatItemField.Name];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Tag))
|
||||
Tag = mappings[Field.DatItem_Tag];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Tag))
|
||||
Tag = datItemMappings[DatItemField.Tag];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Mask))
|
||||
Mask = mappings[Field.DatItem_Mask];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Mask))
|
||||
Mask = datItemMappings[DatItemField.Mask];
|
||||
|
||||
if (ConditionsSpecified)
|
||||
{
|
||||
foreach (Condition condition in Conditions)
|
||||
{
|
||||
condition.SetFields(mappings, true);
|
||||
condition.SetFields(datItemMappings, machineMappings, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +111,7 @@ namespace SabreTools.DatItems
|
||||
{
|
||||
foreach (Location location in Locations)
|
||||
{
|
||||
location.SetFields(mappings);
|
||||
location.SetFields(datItemMappings, machineMappings);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +119,7 @@ namespace SabreTools.DatItems
|
||||
{
|
||||
foreach (Setting setting in Settings)
|
||||
{
|
||||
setting.SetFields(mappings);
|
||||
setting.SetFields(datItemMappings, machineMappings);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -243,28 +242,23 @@ namespace SabreTools.DatItems
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check to see if a DatItem passes the filter
|
||||
/// </summary>
|
||||
/// <param name="filter">Filter to check against</param>
|
||||
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
||||
/// <returns>True if the item passed the filter, false otherwise</returns>
|
||||
public override bool PassesFilter(Filter filter, bool sub = false)
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
// Check common fields first
|
||||
if (!base.PassesFilter(filter, sub))
|
||||
if (!base.PassesFilter(cleaner, sub))
|
||||
return false;
|
||||
|
||||
// Filter on item name
|
||||
if (!filter.PassStringFilter(filter.DatItem_Name, Name))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Name, Name))
|
||||
return false;
|
||||
|
||||
// Filter on tag
|
||||
if (!filter.PassStringFilter(filter.DatItem_Tag, Tag))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Tag, Tag))
|
||||
return false;
|
||||
|
||||
// Filter on mask
|
||||
if (!filter.PassStringFilter(filter.DatItem_Mask, Mask))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Mask, Mask))
|
||||
return false;
|
||||
|
||||
// Filter on individual conditions
|
||||
@@ -272,7 +266,7 @@ namespace SabreTools.DatItems
|
||||
{
|
||||
foreach (Condition condition in Conditions)
|
||||
{
|
||||
if (!condition.PassesFilter(filter, true))
|
||||
if (!condition.PassesFilter(cleaner, true))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -282,7 +276,7 @@ namespace SabreTools.DatItems
|
||||
{
|
||||
foreach (Location location in Locations)
|
||||
{
|
||||
if (!location.PassesFilter(filter, true))
|
||||
if (!location.PassesFilter(cleaner, true))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -292,7 +286,7 @@ namespace SabreTools.DatItems
|
||||
{
|
||||
foreach (Setting setting in Settings)
|
||||
{
|
||||
if (!setting.PassesFilter(filter, true))
|
||||
if (!setting.PassesFilter(cleaner, true))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -300,30 +294,29 @@ namespace SabreTools.DatItems
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove fields from the DatItem
|
||||
/// </summary>
|
||||
/// <param name="fields">List of Fields to remove</param>
|
||||
public override void RemoveFields(List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void RemoveFields(
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Remove common fields first
|
||||
base.RemoveFields(fields);
|
||||
base.RemoveFields(datItemFields, machineFields);
|
||||
|
||||
// Remove the fields
|
||||
if (fields.Contains(Field.DatItem_Name))
|
||||
if (datItemFields.Contains(DatItemField.Name))
|
||||
Name = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Tag))
|
||||
if (datItemFields.Contains(DatItemField.Tag))
|
||||
Tag = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Mask))
|
||||
if (datItemFields.Contains(DatItemField.Mask))
|
||||
Mask = null;
|
||||
|
||||
if (ConditionsSpecified)
|
||||
{
|
||||
foreach (Condition condition in Conditions)
|
||||
{
|
||||
condition.RemoveFields(fields, true);
|
||||
condition.RemoveFields(datItemFields, machineFields, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,7 +324,7 @@ namespace SabreTools.DatItems
|
||||
{
|
||||
foreach (Location location in Locations)
|
||||
{
|
||||
location.RemoveFields(fields);
|
||||
location.RemoveFields(datItemFields, machineFields);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -339,7 +332,7 @@ namespace SabreTools.DatItems
|
||||
{
|
||||
foreach (Setting setting in Settings)
|
||||
{
|
||||
setting.RemoveFields(fields);
|
||||
setting.RemoveFields(datItemFields, machineFields);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -358,15 +351,14 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Sorting and Merging
|
||||
|
||||
/// <summary>
|
||||
/// Replace fields from another item
|
||||
/// </summary>
|
||||
/// <param name="item">DatItem to pull new information from</param>
|
||||
/// <param name="fields">List of Fields representing what should be updated</param>
|
||||
public override void ReplaceFields(DatItem item, List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void ReplaceFields(
|
||||
DatItem item,
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Replace common fields first
|
||||
base.ReplaceFields(item, fields);
|
||||
base.ReplaceFields(item, datItemFields, machineFields);
|
||||
|
||||
// If we don't have a Configuration to replace from, ignore specific fields
|
||||
if (item.ItemType != ItemType.Configuration)
|
||||
@@ -376,13 +368,13 @@ namespace SabreTools.DatItems
|
||||
Configuration newItem = item as Configuration;
|
||||
|
||||
// Replace the fields
|
||||
if (fields.Contains(Field.DatItem_Name))
|
||||
if (datItemFields.Contains(DatItemField.Name))
|
||||
Name = newItem.Name;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Tag))
|
||||
if (datItemFields.Contains(DatItemField.Tag))
|
||||
Tag = newItem.Tag;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Mask))
|
||||
if (datItemFields.Contains(DatItemField.Mask))
|
||||
Mask = newItem.Mask;
|
||||
|
||||
// DatItem_Condition_* doesn't make sense here
|
||||
|
||||
@@ -135,51 +135,50 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="mappings">Mappings dictionary</param>
|
||||
public override void SetFields(Dictionary<Field, string> mappings)
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
Dictionary<MachineField, string> machineMappings)
|
||||
{
|
||||
// Set base fields
|
||||
base.SetFields(mappings);
|
||||
base.SetFields(datItemMappings, machineMappings);
|
||||
|
||||
// Handle Control-specific fields
|
||||
if (mappings.Keys.Contains(Field.DatItem_Control_Type))
|
||||
ControlType = mappings[Field.DatItem_Control_Type].AsControlType();
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Control_Type))
|
||||
ControlType = datItemMappings[DatItemField.Control_Type].AsControlType();
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Control_Player))
|
||||
Player = Utilities.CleanLong(mappings[Field.DatItem_Control_Player]);
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Control_Player))
|
||||
Player = Utilities.CleanLong(datItemMappings[DatItemField.Control_Player]);
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Control_Buttons))
|
||||
Buttons = Utilities.CleanLong(mappings[Field.DatItem_Control_Buttons]);
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Control_Buttons))
|
||||
Buttons = Utilities.CleanLong(datItemMappings[DatItemField.Control_Buttons]);
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Control_RequiredButtons))
|
||||
RequiredButtons = Utilities.CleanLong(mappings[Field.DatItem_Control_RequiredButtons]);
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Control_RequiredButtons))
|
||||
RequiredButtons = Utilities.CleanLong(datItemMappings[DatItemField.Control_RequiredButtons]);
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Control_Minimum))
|
||||
Minimum = Utilities.CleanLong(mappings[Field.DatItem_Control_Minimum]);
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Control_Minimum))
|
||||
Minimum = Utilities.CleanLong(datItemMappings[DatItemField.Control_Minimum]);
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Control_Maximum))
|
||||
Maximum = Utilities.CleanLong(mappings[Field.DatItem_Control_Maximum]);
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Control_Maximum))
|
||||
Maximum = Utilities.CleanLong(datItemMappings[DatItemField.Control_Maximum]);
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Control_Sensitivity))
|
||||
Sensitivity = Utilities.CleanLong(mappings[Field.DatItem_Control_Sensitivity]);
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Control_Sensitivity))
|
||||
Sensitivity = Utilities.CleanLong(datItemMappings[DatItemField.Control_Sensitivity]);
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Control_KeyDelta))
|
||||
KeyDelta = Utilities.CleanLong(mappings[Field.DatItem_Control_KeyDelta]);
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Control_KeyDelta))
|
||||
KeyDelta = Utilities.CleanLong(datItemMappings[DatItemField.Control_KeyDelta]);
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Control_Reverse))
|
||||
Reverse = mappings[Field.DatItem_Control_Reverse].AsYesNo();
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Control_Reverse))
|
||||
Reverse = datItemMappings[DatItemField.Control_Reverse].AsYesNo();
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Control_Ways))
|
||||
Ways = mappings[Field.DatItem_Control_Ways];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Control_Ways))
|
||||
Ways = datItemMappings[DatItemField.Control_Ways];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Control_Ways2))
|
||||
Ways2 = mappings[Field.DatItem_Control_Ways2];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Control_Ways2))
|
||||
Ways2 = datItemMappings[DatItemField.Control_Ways2];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Control_Ways3))
|
||||
Ways3 = mappings[Field.DatItem_Control_Ways3];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Control_Ways3))
|
||||
Ways3 = datItemMappings[DatItemField.Control_Ways3];
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -256,115 +255,109 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Filtering
|
||||
|
||||
/// <summary>
|
||||
/// Check to see if a DatItem passes the filter
|
||||
/// </summary>
|
||||
/// <param name="filter">Filter to check against</param>
|
||||
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
||||
/// <returns>True if the item passed the filter, false otherwise</returns>
|
||||
public override bool PassesFilter(Filter filter, bool sub = false)
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
// Check common fields first
|
||||
if (!base.PassesFilter(filter, sub))
|
||||
if (!base.PassesFilter(cleaner, sub))
|
||||
return false;
|
||||
|
||||
// Filter on control type
|
||||
if (filter.DatItem_Control_Type.MatchesPositive(ControlType.NULL, ControlType) == false)
|
||||
if (cleaner.DatItemFilter.Control_Type.MatchesPositive(ControlType.NULL, ControlType) == false)
|
||||
return false;
|
||||
if (filter.DatItem_Control_Type.MatchesNegative(ControlType.NULL, ControlType) == true)
|
||||
if (cleaner.DatItemFilter.Control_Type.MatchesNegative(ControlType.NULL, ControlType) == true)
|
||||
return false;
|
||||
|
||||
// Filter on player
|
||||
if (!filter.PassLongFilter(filter.DatItem_Control_Player, Player))
|
||||
if (!Filter.PassLongFilter(cleaner.DatItemFilter.Control_Player, Player))
|
||||
return false;
|
||||
|
||||
// Filter on buttons
|
||||
if (!filter.PassLongFilter(filter.DatItem_Control_Buttons, Buttons))
|
||||
if (!Filter.PassLongFilter(cleaner.DatItemFilter.Control_Buttons, Buttons))
|
||||
return false;
|
||||
|
||||
// Filter on reqbuttons
|
||||
if (!filter.PassLongFilter(filter.DatItem_Control_ReqButtons, RequiredButtons))
|
||||
if (!Filter.PassLongFilter(cleaner.DatItemFilter.Control_ReqButtons, RequiredButtons))
|
||||
return false;
|
||||
|
||||
// Filter on minimum
|
||||
if (!filter.PassLongFilter(filter.DatItem_Control_Minimum, Minimum))
|
||||
if (!Filter.PassLongFilter(cleaner.DatItemFilter.Control_Minimum, Minimum))
|
||||
return false;
|
||||
|
||||
// Filter on maximum
|
||||
if (!filter.PassLongFilter(filter.DatItem_Control_Maximum, Maximum))
|
||||
if (!Filter.PassLongFilter(cleaner.DatItemFilter.Control_Maximum, Maximum))
|
||||
return false;
|
||||
|
||||
// Filter on sensitivity
|
||||
if (!filter.PassLongFilter(filter.DatItem_Control_Sensitivity, Sensitivity))
|
||||
if (!Filter.PassLongFilter(cleaner.DatItemFilter.Control_Sensitivity, Sensitivity))
|
||||
return false;
|
||||
|
||||
// Filter on keydelta
|
||||
if (!filter.PassLongFilter(filter.DatItem_Control_KeyDelta, KeyDelta))
|
||||
if (!Filter.PassLongFilter(cleaner.DatItemFilter.Control_KeyDelta, KeyDelta))
|
||||
return false;
|
||||
|
||||
// Filter on reverse
|
||||
if (!filter.PassBoolFilter(filter.DatItem_Control_Reverse, Reverse))
|
||||
if (!Filter.PassBoolFilter(cleaner.DatItemFilter.Control_Reverse, Reverse))
|
||||
return false;
|
||||
|
||||
// Filter on ways
|
||||
if (!filter.PassStringFilter(filter.DatItem_Control_Ways, Ways))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Control_Ways, Ways))
|
||||
return false;
|
||||
|
||||
// Filter on ways2
|
||||
if (!filter.PassStringFilter(filter.DatItem_Control_Ways2, Ways2))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Control_Ways2, Ways2))
|
||||
return false;
|
||||
|
||||
// Filter on ways3
|
||||
if (!filter.PassStringFilter(filter.DatItem_Control_Ways3, Ways3))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Control_Ways3, Ways3))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove fields from the DatItem
|
||||
/// </summary>
|
||||
/// <param name="fields">List of Fields to remove</param>
|
||||
public override void RemoveFields(List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void RemoveFields(
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Remove common fields first
|
||||
base.RemoveFields(fields);
|
||||
base.RemoveFields(datItemFields, machineFields);
|
||||
|
||||
// Remove the fields
|
||||
if (fields.Contains(Field.DatItem_Control_Type))
|
||||
if (datItemFields.Contains(DatItemField.Control_Type))
|
||||
ControlType = ControlType.NULL;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Control_Player))
|
||||
if (datItemFields.Contains(DatItemField.Control_Player))
|
||||
Player = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Control_Buttons))
|
||||
if (datItemFields.Contains(DatItemField.Control_Buttons))
|
||||
Buttons = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Control_RequiredButtons))
|
||||
if (datItemFields.Contains(DatItemField.Control_RequiredButtons))
|
||||
RequiredButtons = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Control_Minimum))
|
||||
if (datItemFields.Contains(DatItemField.Control_Minimum))
|
||||
Minimum = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Control_Maximum))
|
||||
if (datItemFields.Contains(DatItemField.Control_Maximum))
|
||||
Maximum = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Control_Sensitivity))
|
||||
if (datItemFields.Contains(DatItemField.Control_Sensitivity))
|
||||
Sensitivity = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Control_KeyDelta))
|
||||
if (datItemFields.Contains(DatItemField.Control_KeyDelta))
|
||||
KeyDelta = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Control_Reverse))
|
||||
if (datItemFields.Contains(DatItemField.Control_Reverse))
|
||||
Reverse = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Control_Ways))
|
||||
if (datItemFields.Contains(DatItemField.Control_Ways))
|
||||
Ways = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Control_Ways2))
|
||||
if (datItemFields.Contains(DatItemField.Control_Ways2))
|
||||
Ways2 = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Control_Ways3))
|
||||
if (datItemFields.Contains(DatItemField.Control_Ways3))
|
||||
Ways3 = null;
|
||||
}
|
||||
|
||||
@@ -372,15 +365,14 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Sorting and Merging
|
||||
|
||||
/// <summary>
|
||||
/// Replace fields from another item
|
||||
/// </summary>
|
||||
/// <param name="item">DatItem to pull new information from</param>
|
||||
/// <param name="fields">List of Fields representing what should be updated</param>
|
||||
public override void ReplaceFields(DatItem item, List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void ReplaceFields(
|
||||
DatItem item,
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Replace common fields first
|
||||
base.ReplaceFields(item, fields);
|
||||
base.ReplaceFields(item, datItemFields, machineFields);
|
||||
|
||||
// If we don't have a Control to replace from, ignore specific fields
|
||||
if (item.ItemType != ItemType.Control)
|
||||
@@ -390,40 +382,40 @@ namespace SabreTools.DatItems
|
||||
Control newItem = item as Control;
|
||||
|
||||
// Replace the fields
|
||||
if (fields.Contains(Field.DatItem_Control_Type))
|
||||
if (datItemFields.Contains(DatItemField.Control_Type))
|
||||
ControlType = newItem.ControlType;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Control_Player))
|
||||
if (datItemFields.Contains(DatItemField.Control_Player))
|
||||
Player = newItem.Player;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Control_Buttons))
|
||||
if (datItemFields.Contains(DatItemField.Control_Buttons))
|
||||
Buttons = newItem.Buttons;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Control_RequiredButtons))
|
||||
if (datItemFields.Contains(DatItemField.Control_RequiredButtons))
|
||||
RequiredButtons = newItem.RequiredButtons;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Control_Minimum))
|
||||
if (datItemFields.Contains(DatItemField.Control_Minimum))
|
||||
Minimum = newItem.Minimum;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Control_Maximum))
|
||||
if (datItemFields.Contains(DatItemField.Control_Maximum))
|
||||
Maximum = newItem.Maximum;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Control_Sensitivity))
|
||||
if (datItemFields.Contains(DatItemField.Control_Sensitivity))
|
||||
Sensitivity = newItem.Sensitivity;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Control_KeyDelta))
|
||||
if (datItemFields.Contains(DatItemField.Control_KeyDelta))
|
||||
KeyDelta = newItem.KeyDelta;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Control_Reverse))
|
||||
if (datItemFields.Contains(DatItemField.Control_Reverse))
|
||||
Reverse = newItem.Reverse;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Control_Ways))
|
||||
if (datItemFields.Contains(DatItemField.Control_Ways))
|
||||
Ways = newItem.Ways;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Control_Ways2))
|
||||
if (datItemFields.Contains(DatItemField.Control_Ways2))
|
||||
Ways2 = newItem.Ways2;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Control_Ways3))
|
||||
if (datItemFields.Contains(DatItemField.Control_Ways3))
|
||||
Ways3 = newItem.Ways3;
|
||||
}
|
||||
|
||||
|
||||
@@ -103,275 +103,7 @@ namespace SabreTools.DatItems
|
||||
[JsonIgnore, XmlIgnore]
|
||||
public bool Remove { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Static Values
|
||||
|
||||
/// <summary>
|
||||
/// Fields unique to a DatItem
|
||||
/// </summary>
|
||||
public static readonly List<Field> DatItemFields = new List<Field>()
|
||||
{
|
||||
#region Common
|
||||
|
||||
Field.DatItem_Type,
|
||||
|
||||
#endregion
|
||||
|
||||
#region Item-Specific
|
||||
|
||||
#region Actionable
|
||||
|
||||
// Rom
|
||||
Field.DatItem_Name,
|
||||
Field.DatItem_Bios,
|
||||
Field.DatItem_Size,
|
||||
Field.DatItem_CRC,
|
||||
Field.DatItem_MD5,
|
||||
#if NET_FRAMEWORK
|
||||
Field.DatItem_RIPEMD160,
|
||||
#endif
|
||||
Field.DatItem_SHA1,
|
||||
Field.DatItem_SHA256,
|
||||
Field.DatItem_SHA384,
|
||||
Field.DatItem_SHA512,
|
||||
Field.DatItem_SpamSum,
|
||||
Field.DatItem_Merge,
|
||||
Field.DatItem_Region,
|
||||
Field.DatItem_Offset,
|
||||
Field.DatItem_Date,
|
||||
Field.DatItem_Status,
|
||||
Field.DatItem_Optional,
|
||||
Field.DatItem_Inverted,
|
||||
|
||||
// Rom (AttractMode)
|
||||
Field.DatItem_AltName,
|
||||
Field.DatItem_AltTitle,
|
||||
|
||||
// Rom (OpenMSX)
|
||||
Field.DatItem_Original,
|
||||
Field.DatItem_OpenMSXSubType,
|
||||
Field.DatItem_OpenMSXType,
|
||||
Field.DatItem_Remark,
|
||||
Field.DatItem_Boot,
|
||||
|
||||
// Rom (SoftwareList)
|
||||
Field.DatItem_LoadFlag,
|
||||
Field.DatItem_Value,
|
||||
|
||||
// Disk
|
||||
Field.DatItem_Index,
|
||||
Field.DatItem_Writable,
|
||||
|
||||
#endregion
|
||||
|
||||
#region Auxiliary
|
||||
|
||||
// Adjuster
|
||||
Field.DatItem_Default,
|
||||
|
||||
// Analog
|
||||
Field.DatItem_Analog_Mask,
|
||||
|
||||
// BiosSet
|
||||
Field.DatItem_Description,
|
||||
|
||||
// Chip
|
||||
Field.DatItem_Tag,
|
||||
Field.DatItem_ChipType,
|
||||
Field.DatItem_Clock,
|
||||
|
||||
// Condition
|
||||
Field.DatItem_Mask,
|
||||
Field.DatItem_Relation,
|
||||
Field.DatItem_Condition_Tag,
|
||||
Field.DatItem_Condition_Mask,
|
||||
Field.DatItem_Condition_Relation,
|
||||
Field.DatItem_Condition_Value,
|
||||
|
||||
// Control
|
||||
Field.DatItem_Control_Type,
|
||||
Field.DatItem_Control_Player,
|
||||
Field.DatItem_Control_Buttons,
|
||||
Field.DatItem_Control_RequiredButtons,
|
||||
Field.DatItem_Control_Minimum,
|
||||
Field.DatItem_Control_Maximum,
|
||||
Field.DatItem_Control_Sensitivity,
|
||||
Field.DatItem_Control_KeyDelta,
|
||||
Field.DatItem_Control_Reverse,
|
||||
Field.DatItem_Control_Ways,
|
||||
Field.DatItem_Control_Ways2,
|
||||
Field.DatItem_Control_Ways3,
|
||||
|
||||
// DataArea
|
||||
Field.DatItem_AreaName,
|
||||
Field.DatItem_AreaSize,
|
||||
Field.DatItem_AreaWidth,
|
||||
Field.DatItem_AreaEndianness,
|
||||
|
||||
// Device
|
||||
Field.DatItem_DeviceType,
|
||||
Field.DatItem_FixedImage,
|
||||
Field.DatItem_Mandatory,
|
||||
Field.DatItem_Interface,
|
||||
|
||||
// Display
|
||||
Field.DatItem_DisplayType,
|
||||
Field.DatItem_Rotate,
|
||||
Field.DatItem_FlipX,
|
||||
Field.DatItem_Width,
|
||||
Field.DatItem_Height,
|
||||
Field.DatItem_Refresh,
|
||||
Field.DatItem_PixClock,
|
||||
Field.DatItem_HTotal,
|
||||
Field.DatItem_HBEnd,
|
||||
Field.DatItem_HBStart,
|
||||
Field.DatItem_VTotal,
|
||||
Field.DatItem_VBEnd,
|
||||
Field.DatItem_VBStart,
|
||||
|
||||
// Driver
|
||||
Field.DatItem_SupportStatus,
|
||||
Field.DatItem_EmulationStatus,
|
||||
Field.DatItem_CocktailStatus,
|
||||
Field.DatItem_SaveStateStatus,
|
||||
|
||||
// Extension
|
||||
Field.DatItem_Extension_Name,
|
||||
|
||||
// Feature
|
||||
Field.DatItem_FeatureType,
|
||||
Field.DatItem_FeatureStatus,
|
||||
Field.DatItem_FeatureOverall,
|
||||
|
||||
// Input
|
||||
Field.DatItem_Service,
|
||||
Field.DatItem_Tilt,
|
||||
Field.DatItem_Players,
|
||||
Field.DatItem_Coins,
|
||||
|
||||
// Instance
|
||||
Field.DatItem_Instance_Name,
|
||||
Field.DatItem_Instance_BriefName,
|
||||
|
||||
// Location
|
||||
Field.DatItem_Location_Name,
|
||||
Field.DatItem_Location_Number,
|
||||
Field.DatItem_Location_Inverted,
|
||||
|
||||
// Part
|
||||
Field.DatItem_Part_Name,
|
||||
Field.DatItem_Part_Interface,
|
||||
|
||||
// PartFeature
|
||||
Field.DatItem_Part_Feature_Name,
|
||||
Field.DatItem_Part_Feature_Value,
|
||||
|
||||
// RamOption
|
||||
Field.DatItem_Content,
|
||||
|
||||
// Release
|
||||
Field.DatItem_Language,
|
||||
|
||||
// Setting
|
||||
Field.DatItem_Setting_Name,
|
||||
Field.DatItem_Setting_Value,
|
||||
Field.DatItem_Setting_Default,
|
||||
|
||||
// SlotOption
|
||||
Field.DatItem_SlotOption_Name,
|
||||
Field.DatItem_SlotOption_DeviceName,
|
||||
Field.DatItem_SlotOption_Default,
|
||||
|
||||
// SoftwareList
|
||||
Field.DatItem_SoftwareListStatus,
|
||||
Field.DatItem_Filter,
|
||||
|
||||
// Sound
|
||||
Field.DatItem_Channels,
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion // Item-Specific
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Fields unique to a Machine
|
||||
/// </summary>
|
||||
public static readonly List<Field> MachineFields = new List<Field>()
|
||||
{
|
||||
#region Common
|
||||
|
||||
Field.Machine_Name,
|
||||
Field.Machine_Comment,
|
||||
Field.Machine_Description,
|
||||
Field.Machine_Year,
|
||||
Field.Machine_Manufacturer,
|
||||
Field.Machine_Publisher,
|
||||
Field.Machine_Category,
|
||||
Field.Machine_RomOf,
|
||||
Field.Machine_CloneOf,
|
||||
Field.Machine_SampleOf,
|
||||
Field.Machine_Type,
|
||||
|
||||
#endregion
|
||||
|
||||
#region AttractMode
|
||||
|
||||
Field.Machine_Players,
|
||||
Field.Machine_Rotation,
|
||||
Field.Machine_Control,
|
||||
Field.Machine_Status,
|
||||
Field.Machine_DisplayCount,
|
||||
Field.Machine_DisplayType,
|
||||
Field.Machine_Buttons,
|
||||
|
||||
#endregion
|
||||
|
||||
#region ListXML
|
||||
|
||||
Field.Machine_SourceFile,
|
||||
Field.Machine_Runnable,
|
||||
|
||||
#endregion
|
||||
|
||||
#region Logiqx
|
||||
|
||||
Field.Machine_Board,
|
||||
Field.Machine_RebuildTo,
|
||||
|
||||
#endregion
|
||||
|
||||
#region Logiqx EmuArc
|
||||
|
||||
Field.Machine_TitleID,
|
||||
Field.Machine_Developer,
|
||||
Field.Machine_Genre,
|
||||
Field.Machine_Subgenre,
|
||||
Field.Machine_Ratings,
|
||||
Field.Machine_Score,
|
||||
Field.Machine_Enabled,
|
||||
Field.Machine_CRC,
|
||||
Field.Machine_RelatedTo,
|
||||
|
||||
#endregion
|
||||
|
||||
#region OpenMSX
|
||||
|
||||
Field.Machine_GenMSXID,
|
||||
Field.Machine_System,
|
||||
Field.Machine_Country,
|
||||
|
||||
#endregion
|
||||
|
||||
#region SoftwareList
|
||||
|
||||
Field.Machine_Supported,
|
||||
|
||||
#endregion
|
||||
};
|
||||
|
||||
#endregion
|
||||
#endregion // Metadata information
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -407,14 +139,18 @@ namespace SabreTools.DatItems
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="mappings">Mappings dictionary</param>
|
||||
public virtual void SetFields(Dictionary<Field, string> mappings)
|
||||
/// <param name="datItemMappings">DatItem mappings dictionary</param>
|
||||
/// <param name="machineMappings">Machine mappings dictionary</param>
|
||||
/// TODO: Fix case where datItemMappings is null
|
||||
public virtual void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
Dictionary<MachineField, string> machineMappings)
|
||||
{
|
||||
// Set machine fields
|
||||
if (Machine == null)
|
||||
Machine = new Machine();
|
||||
|
||||
Machine.SetFields(mappings);
|
||||
Machine.SetFields(machineMappings);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -746,20 +482,20 @@ namespace SabreTools.DatItems
|
||||
/// <summary>
|
||||
/// Check to see if a DatItem passes the filter
|
||||
/// </summary>
|
||||
/// <param name="filter">Filter to check against</param>
|
||||
/// <param name="cleaner">Cleaner containing filters to check against</param>
|
||||
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
||||
/// <returns>True if the item passed the filter, false otherwise</returns>
|
||||
public virtual bool PassesFilter(Filter filter, bool sub = false)
|
||||
public virtual bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
// Filter on machine fields
|
||||
if (!Machine.PassesFilter(filter))
|
||||
if (!Machine.PassesFilter(cleaner))
|
||||
return false;
|
||||
|
||||
// Filters for if we're a top-level item
|
||||
if (!sub)
|
||||
{
|
||||
// Filter on item type
|
||||
if (!filter.PassStringFilter(filter.DatItem_Type, ItemType.ToString()))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Type, ItemType.ToString()))
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -769,11 +505,15 @@ namespace SabreTools.DatItems
|
||||
/// <summary>
|
||||
/// Remove fields from the DatItem
|
||||
/// </summary>
|
||||
/// <param name="fields">List of Fields to remove</param>
|
||||
public virtual void RemoveFields(List<Field> fields)
|
||||
/// <param name="datItemFields">DatItem fields to remove</param>
|
||||
/// <param name="machineFields">Machine fields to remove</param>
|
||||
/// TODO: Fix case where datItemFields is null
|
||||
public virtual void RemoveFields(
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Remove machine fields
|
||||
Machine.RemoveFields(fields);
|
||||
Machine.RemoveFields(machineFields);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1135,9 +875,19 @@ namespace SabreTools.DatItems
|
||||
/// Replace fields from another item
|
||||
/// </summary>
|
||||
/// <param name="item">DatItem to pull new information from</param>
|
||||
/// <param name="fields">List of Fields representing what should be updated</param>
|
||||
public virtual void ReplaceFields(DatItem item, List<Field> fields)
|
||||
/// <param name="datItemFields">DatItem fields to remove</param>
|
||||
/// <param name="machineFields">Machine fields to remove</param>
|
||||
/// TODO: Fix case where datItemFields is null
|
||||
public virtual void ReplaceFields(
|
||||
DatItem item,
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
if (Machine == null)
|
||||
Machine = new Machine();
|
||||
|
||||
// TODO: Figure out why this wasn't here
|
||||
// Machine.ReplaceFields(item.Machine, machineFields)
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -1248,14 +998,14 @@ namespace SabreTools.DatItems
|
||||
{
|
||||
saveditem.Source = file.Source.Clone() as Source;
|
||||
saveditem.CopyMachineInformation(file);
|
||||
saveditem.SetFields(new Dictionary<Field, string> { [Field.DatItem_Name] = file.GetName() });
|
||||
saveditem.SetFields(new Dictionary<DatItemField, string> { [DatItemField.Name] = file.GetName() }, null);
|
||||
}
|
||||
|
||||
// If the current machine is a child of the new machine, use the new machine instead
|
||||
if (saveditem.Machine.CloneOf == file.Machine.Name || saveditem.Machine.RomOf == file.Machine.Name)
|
||||
{
|
||||
saveditem.CopyMachineInformation(file);
|
||||
saveditem.SetFields(new Dictionary<Field, string> { [Field.DatItem_Name] = file.GetName() });
|
||||
saveditem.SetFields(new Dictionary<DatItemField, string> { [DatItemField.Name] = file.GetName() }, null);
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -1351,7 +1101,7 @@ namespace SabreTools.DatItems
|
||||
}
|
||||
|
||||
// Set the item name back to the datItem
|
||||
datItem.SetFields(new Dictionary<Field, string> { [Field.DatItem_Name] = datItemName });
|
||||
datItem.SetFields(new Dictionary<DatItemField, string> { [DatItemField.Name] = datItemName }, null);
|
||||
|
||||
output.Add(datItem);
|
||||
}
|
||||
|
||||
@@ -70,27 +70,26 @@ namespace SabreTools.DatItems
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="mappings">Mappings dictionary</param>
|
||||
public override void SetFields(Dictionary<Field, string> mappings)
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
Dictionary<MachineField, string> machineMappings)
|
||||
{
|
||||
// Set base fields
|
||||
base.SetFields(mappings);
|
||||
base.SetFields(datItemMappings, machineMappings);
|
||||
|
||||
// Handle DataArea-specific fields
|
||||
if (mappings.Keys.Contains(Field.DatItem_AreaName))
|
||||
Name = mappings[Field.DatItem_AreaName];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.AreaName))
|
||||
Name = datItemMappings[DatItemField.AreaName];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_AreaSize))
|
||||
Size = Utilities.CleanLong(mappings[Field.DatItem_AreaSize]);
|
||||
if (datItemMappings.Keys.Contains(DatItemField.AreaSize))
|
||||
Size = Utilities.CleanLong(datItemMappings[DatItemField.AreaSize]);
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_AreaWidth))
|
||||
Width = Utilities.CleanLong(mappings[Field.DatItem_AreaWidth]);
|
||||
if (datItemMappings.Keys.Contains(DatItemField.AreaWidth))
|
||||
Width = Utilities.CleanLong(datItemMappings[DatItemField.AreaWidth]);
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_AreaEndianness))
|
||||
Endianness = mappings[Field.DatItem_AreaEndianness].AsEndianness();
|
||||
if (datItemMappings.Keys.Contains(DatItemField.AreaEndianness))
|
||||
Endianness = datItemMappings[DatItemField.AreaEndianness].AsEndianness();
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -179,59 +178,53 @@ namespace SabreTools.DatItems
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check to see if a DatItem passes the filter
|
||||
/// </summary>
|
||||
/// <param name="filter">Filter to check against</param>
|
||||
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
||||
/// <returns>True if the item passed the filter, false otherwise</returns>
|
||||
public override bool PassesFilter(Filter filter, bool sub = false)
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
// Check common fields first
|
||||
if (!base.PassesFilter(filter, sub))
|
||||
if (!base.PassesFilter(cleaner, sub))
|
||||
return false;
|
||||
|
||||
// Filter on area name
|
||||
if (!filter.PassStringFilter(filter.DatItem_AreaName, Name))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.AreaName, Name))
|
||||
return false;
|
||||
|
||||
// Filter on area size
|
||||
if (!filter.PassLongFilter(filter.DatItem_AreaSize, Size))
|
||||
if (!Filter.PassLongFilter(cleaner.DatItemFilter.AreaSize, Size))
|
||||
return false;
|
||||
|
||||
// Filter on area width
|
||||
if (!filter.PassLongFilter(filter.DatItem_AreaWidth, Width))
|
||||
if (!Filter.PassLongFilter(cleaner.DatItemFilter.AreaWidth, Width))
|
||||
return false;
|
||||
|
||||
// Filter on area endianness
|
||||
if (filter.DatItem_AreaEndianness.MatchesPositive(Endianness.NULL, Endianness) == false)
|
||||
if (cleaner.DatItemFilter.AreaEndianness.MatchesPositive(Endianness.NULL, Endianness) == false)
|
||||
return false;
|
||||
if (filter.DatItem_AreaEndianness.MatchesNegative(Endianness.NULL, Endianness) == true)
|
||||
if (cleaner.DatItemFilter.AreaEndianness.MatchesNegative(Endianness.NULL, Endianness) == true)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove fields from the DatItem
|
||||
/// </summary>
|
||||
/// <param name="fields">List of Fields to remove</param>
|
||||
public override void RemoveFields(List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void RemoveFields(
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Remove common fields first
|
||||
base.RemoveFields(fields);
|
||||
base.RemoveFields(datItemFields, machineFields);
|
||||
|
||||
// Remove the fields
|
||||
if (fields.Contains(Field.DatItem_AreaName))
|
||||
if (datItemFields.Contains(DatItemField.AreaName))
|
||||
Name = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_AreaSize))
|
||||
if (datItemFields.Contains(DatItemField.AreaSize))
|
||||
Size = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_AreaWidth))
|
||||
if (datItemFields.Contains(DatItemField.AreaWidth))
|
||||
Width = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_AreaEndianness))
|
||||
if (datItemFields.Contains(DatItemField.AreaEndianness))
|
||||
Endianness = Endianness.NULL;
|
||||
}
|
||||
|
||||
@@ -249,15 +242,14 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Sorting and Merging
|
||||
|
||||
/// <summary>
|
||||
/// Replace fields from another item
|
||||
/// </summary>
|
||||
/// <param name="item">DatItem to pull new information from</param>
|
||||
/// <param name="fields">List of Fields representing what should be updated</param>
|
||||
public override void ReplaceFields(DatItem item, List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void ReplaceFields(
|
||||
DatItem item,
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Replace common fields first
|
||||
base.ReplaceFields(item, fields);
|
||||
base.ReplaceFields(item, datItemFields, machineFields);
|
||||
|
||||
// If we don't have a DataArea to replace from, ignore specific fields
|
||||
if (item.ItemType != ItemType.DataArea)
|
||||
@@ -267,16 +259,16 @@ namespace SabreTools.DatItems
|
||||
DataArea newItem = item as DataArea;
|
||||
|
||||
// Replace the fields
|
||||
if (fields.Contains(Field.DatItem_AreaName))
|
||||
if (datItemFields.Contains(DatItemField.AreaName))
|
||||
Name = newItem.Name;
|
||||
|
||||
if (fields.Contains(Field.DatItem_AreaSize))
|
||||
if (datItemFields.Contains(DatItemField.AreaSize))
|
||||
Size = newItem.Size;
|
||||
|
||||
if (fields.Contains(Field.DatItem_AreaWidth))
|
||||
if (datItemFields.Contains(DatItemField.AreaWidth))
|
||||
Width = newItem.Width;
|
||||
|
||||
if (fields.Contains(Field.DatItem_AreaEndianness))
|
||||
if (datItemFields.Contains(DatItemField.AreaEndianness))
|
||||
Endianness = newItem.Endianness;
|
||||
}
|
||||
|
||||
|
||||
@@ -85,36 +85,35 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="mappings">Mappings dictionary</param>
|
||||
public override void SetFields(Dictionary<Field, string> mappings)
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
Dictionary<MachineField, string> machineMappings)
|
||||
{
|
||||
// Set base fields
|
||||
base.SetFields(mappings);
|
||||
base.SetFields(datItemMappings, machineMappings);
|
||||
|
||||
// Handle Device-specific fields
|
||||
if (mappings.Keys.Contains(Field.DatItem_DeviceType))
|
||||
DeviceType = mappings[Field.DatItem_DeviceType].AsDeviceType();
|
||||
if (datItemMappings.Keys.Contains(DatItemField.DeviceType))
|
||||
DeviceType = datItemMappings[DatItemField.DeviceType].AsDeviceType();
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Tag))
|
||||
Tag = mappings[Field.DatItem_Tag];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Tag))
|
||||
Tag = datItemMappings[DatItemField.Tag];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_FixedImage))
|
||||
FixedImage = mappings[Field.DatItem_FixedImage];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.FixedImage))
|
||||
FixedImage = datItemMappings[DatItemField.FixedImage];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Mandatory))
|
||||
Mandatory = Utilities.CleanLong(mappings[Field.DatItem_Mandatory]);
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Mandatory))
|
||||
Mandatory = Utilities.CleanLong(datItemMappings[DatItemField.Mandatory]);
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Interface))
|
||||
Interface = mappings[Field.DatItem_Interface];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Interface))
|
||||
Interface = datItemMappings[DatItemField.Interface];
|
||||
|
||||
if (InstancesSpecified)
|
||||
{
|
||||
foreach (Instance instance in Instances)
|
||||
{
|
||||
instance.SetFields(mappings);
|
||||
instance.SetFields(datItemMappings, machineMappings);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,7 +121,7 @@ namespace SabreTools.DatItems
|
||||
{
|
||||
foreach (Extension extension in Extensions)
|
||||
{
|
||||
extension.SetFields(mappings);
|
||||
extension.SetFields(datItemMappings, machineMappings);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -211,38 +210,33 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Filtering
|
||||
|
||||
/// <summary>
|
||||
/// Check to see if a DatItem passes the filter
|
||||
/// </summary>
|
||||
/// <param name="filter">Filter to check against</param>
|
||||
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
||||
/// <returns>True if the item passed the filter, false otherwise</returns>
|
||||
public override bool PassesFilter(Filter filter, bool sub = false)
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
// Check common fields first
|
||||
if (!base.PassesFilter(filter, sub))
|
||||
if (!base.PassesFilter(cleaner, sub))
|
||||
return false;
|
||||
|
||||
// Filter on device type
|
||||
if (filter.DatItem_DeviceType.MatchesPositive(DeviceType.NULL, DeviceType) == false)
|
||||
if (cleaner.DatItemFilter.DeviceType.MatchesPositive(DeviceType.NULL, DeviceType) == false)
|
||||
return false;
|
||||
if (filter.DatItem_DeviceType.MatchesNegative(DeviceType.NULL, DeviceType) == true)
|
||||
if (cleaner.DatItemFilter.DeviceType.MatchesNegative(DeviceType.NULL, DeviceType) == true)
|
||||
return false;
|
||||
|
||||
// Filter on tag
|
||||
if (!filter.PassStringFilter(filter.DatItem_Tag, Tag))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Tag, Tag))
|
||||
return false;
|
||||
|
||||
// Filter on fixed image
|
||||
if (!filter.PassStringFilter(filter.DatItem_FixedImage, FixedImage))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.FixedImage, FixedImage))
|
||||
return false;
|
||||
|
||||
// Filter on mandatory
|
||||
if (!filter.PassLongFilter(filter.DatItem_Mandatory, Mandatory))
|
||||
if (!Filter.PassLongFilter(cleaner.DatItemFilter.Mandatory, Mandatory))
|
||||
return false;
|
||||
|
||||
// Filter on interface
|
||||
if (!filter.PassStringFilter(filter.DatItem_Interface, Interface))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Interface, Interface))
|
||||
return false;
|
||||
|
||||
// Filter on individual instances
|
||||
@@ -250,7 +244,7 @@ namespace SabreTools.DatItems
|
||||
{
|
||||
foreach (Instance instance in Instances)
|
||||
{
|
||||
if (!instance.PassesFilter(filter, true))
|
||||
if (!instance.PassesFilter(cleaner, true))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -260,7 +254,7 @@ namespace SabreTools.DatItems
|
||||
{
|
||||
foreach (Extension extension in Extensions)
|
||||
{
|
||||
if (!extension.PassesFilter(filter, true))
|
||||
if (!extension.PassesFilter(cleaner, true))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -268,36 +262,35 @@ namespace SabreTools.DatItems
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove fields from the DatItem
|
||||
/// </summary>
|
||||
/// <param name="fields">List of Fields to remove</param>
|
||||
public override void RemoveFields(List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void RemoveFields(
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Remove common fields first
|
||||
base.RemoveFields(fields);
|
||||
base.RemoveFields(datItemFields, machineFields);
|
||||
|
||||
// Remove the fields
|
||||
if (fields.Contains(Field.DatItem_DeviceType))
|
||||
if (datItemFields.Contains(DatItemField.DeviceType))
|
||||
DeviceType = DeviceType.NULL;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Tag))
|
||||
if (datItemFields.Contains(DatItemField.Tag))
|
||||
Tag = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_FixedImage))
|
||||
if (datItemFields.Contains(DatItemField.FixedImage))
|
||||
FixedImage = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Mandatory))
|
||||
if (datItemFields.Contains(DatItemField.Mandatory))
|
||||
Mandatory = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Interface))
|
||||
if (datItemFields.Contains(DatItemField.Interface))
|
||||
Interface = null;
|
||||
|
||||
if (InstancesSpecified)
|
||||
{
|
||||
foreach (Instance instance in Instances)
|
||||
{
|
||||
instance.RemoveFields(fields);
|
||||
instance.RemoveFields(datItemFields, machineFields);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -305,7 +298,7 @@ namespace SabreTools.DatItems
|
||||
{
|
||||
foreach (Extension extension in Extensions)
|
||||
{
|
||||
extension.RemoveFields(fields);
|
||||
extension.RemoveFields(datItemFields, machineFields);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -314,15 +307,14 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Sorting and Merging
|
||||
|
||||
/// <summary>
|
||||
/// Replace fields from another item
|
||||
/// </summary>
|
||||
/// <param name="item">DatItem to pull new information from</param>
|
||||
/// <param name="fields">List of Fields representing what should be updated</param>
|
||||
public override void ReplaceFields(DatItem item, List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void ReplaceFields(
|
||||
DatItem item,
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Replace common fields first
|
||||
base.ReplaceFields(item, fields);
|
||||
base.ReplaceFields(item, datItemFields, machineFields);
|
||||
|
||||
// If we don't have a Device to replace from, ignore specific fields
|
||||
if (item.ItemType != ItemType.Device)
|
||||
@@ -332,19 +324,19 @@ namespace SabreTools.DatItems
|
||||
Device newItem = item as Device;
|
||||
|
||||
// Replace the fields
|
||||
if (fields.Contains(Field.DatItem_DeviceType))
|
||||
if (datItemFields.Contains(DatItemField.DeviceType))
|
||||
DeviceType = newItem.DeviceType;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Tag))
|
||||
if (datItemFields.Contains(DatItemField.Tag))
|
||||
Tag = newItem.Tag;
|
||||
|
||||
if (fields.Contains(Field.DatItem_FixedImage))
|
||||
if (datItemFields.Contains(DatItemField.FixedImage))
|
||||
FixedImage = newItem.FixedImage;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Mandatory))
|
||||
if (datItemFields.Contains(DatItemField.Mandatory))
|
||||
Mandatory = newItem.Mandatory;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Interface))
|
||||
if (datItemFields.Contains(DatItemField.Interface))
|
||||
Interface = newItem.Interface;
|
||||
|
||||
// DatItem_Instance_* doesn't make sense here
|
||||
|
||||
@@ -37,18 +37,17 @@ namespace SabreTools.DatItems
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="mappings">Mappings dictionary</param>
|
||||
public override void SetFields(Dictionary<Field, string> mappings)
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
Dictionary<MachineField, string> machineMappings)
|
||||
{
|
||||
// Set base fields
|
||||
base.SetFields(mappings);
|
||||
base.SetFields(datItemMappings, machineMappings);
|
||||
|
||||
// Handle DeviceReference-specific fields
|
||||
if (mappings.Keys.Contains(Field.DatItem_Name))
|
||||
Name = mappings[Field.DatItem_Name];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Name))
|
||||
Name = datItemMappings[DatItemField.Name];
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -131,36 +130,30 @@ namespace SabreTools.DatItems
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check to see if a DatItem passes the filter
|
||||
/// </summary>
|
||||
/// <param name="filter">Filter to check against</param>
|
||||
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
||||
/// <returns>True if the item passed the filter, false otherwise</returns>
|
||||
public override bool PassesFilter(Filter filter, bool sub = false)
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
// Check common fields first
|
||||
if (!base.PassesFilter(filter, sub))
|
||||
if (!base.PassesFilter(cleaner, sub))
|
||||
return false;
|
||||
|
||||
// Filter on item name
|
||||
if (!filter.PassStringFilter(filter.DatItem_Name, Name))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Name, Name))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove fields from the DatItem
|
||||
/// </summary>
|
||||
/// <param name="fields">List of Fields to remove</param>
|
||||
public override void RemoveFields(List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void RemoveFields(
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Remove common fields first
|
||||
base.RemoveFields(fields);
|
||||
base.RemoveFields(datItemFields, machineFields);
|
||||
|
||||
// Remove the fields
|
||||
if (fields.Contains(Field.DatItem_Name))
|
||||
if (datItemFields.Contains(DatItemField.Name))
|
||||
Name = null;
|
||||
}
|
||||
|
||||
@@ -178,15 +171,14 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Sorting and Merging
|
||||
|
||||
/// <summary>
|
||||
/// Replace fields from another item
|
||||
/// </summary>
|
||||
/// <param name="item">DatItem to pull new information from</param>
|
||||
/// <param name="fields">List of Fields representing what should be updated</param>
|
||||
public override void ReplaceFields(DatItem item, List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void ReplaceFields(
|
||||
DatItem item,
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Replace common fields first
|
||||
base.ReplaceFields(item, fields);
|
||||
base.ReplaceFields(item, datItemFields, machineFields);
|
||||
|
||||
// If we don't have a DeviceReference to replace from, ignore specific fields
|
||||
if (item.ItemType != ItemType.DeviceReference)
|
||||
@@ -196,7 +188,7 @@ namespace SabreTools.DatItems
|
||||
DeviceReference newItem = item as DeviceReference;
|
||||
|
||||
// Replace the fields
|
||||
if (fields.Contains(Field.DatItem_Name))
|
||||
if (datItemFields.Contains(DatItemField.Name))
|
||||
Name = newItem.Name;
|
||||
}
|
||||
|
||||
|
||||
@@ -107,33 +107,32 @@ namespace SabreTools.DatItems
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="mappings">Mappings dictionary</param>
|
||||
public override void SetFields(Dictionary<Field, string> mappings)
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
Dictionary<MachineField, string> machineMappings)
|
||||
{
|
||||
// Set base fields
|
||||
base.SetFields(mappings);
|
||||
base.SetFields(datItemMappings, machineMappings);
|
||||
|
||||
// Handle DipSwitch-specific fields
|
||||
|
||||
#region Common
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Name))
|
||||
Name = mappings[Field.DatItem_Name];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Name))
|
||||
Name = datItemMappings[DatItemField.Name];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Tag))
|
||||
Tag = mappings[Field.DatItem_Tag];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Tag))
|
||||
Tag = datItemMappings[DatItemField.Tag];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Mask))
|
||||
Mask = mappings[Field.DatItem_Mask];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Mask))
|
||||
Mask = datItemMappings[DatItemField.Mask];
|
||||
|
||||
if (ConditionsSpecified)
|
||||
{
|
||||
foreach (Condition condition in Conditions)
|
||||
{
|
||||
condition.SetFields(mappings, true);
|
||||
condition.SetFields(datItemMappings, machineMappings, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,7 +140,7 @@ namespace SabreTools.DatItems
|
||||
{
|
||||
foreach (Location location in Locations)
|
||||
{
|
||||
location.SetFields(mappings);
|
||||
location.SetFields(datItemMappings, machineMappings);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,7 +148,7 @@ namespace SabreTools.DatItems
|
||||
{
|
||||
foreach (Setting value in Values)
|
||||
{
|
||||
value.SetFields(mappings);
|
||||
value.SetFields(datItemMappings, machineMappings);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,7 +160,7 @@ namespace SabreTools.DatItems
|
||||
if (Part == null)
|
||||
Part = new Part();
|
||||
|
||||
Part.SetFields(mappings);
|
||||
Part.SetFields(datItemMappings, machineMappings);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -290,30 +289,25 @@ namespace SabreTools.DatItems
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check to see if a DatItem passes the filter
|
||||
/// </summary>
|
||||
/// <param name="filter">Filter to check against</param>
|
||||
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
||||
/// <returns>True if the item passed the filter, false otherwise</returns>
|
||||
public override bool PassesFilter(Filter filter, bool sub = false)
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
// Check common fields first
|
||||
if (!base.PassesFilter(filter, sub))
|
||||
if (!base.PassesFilter(cleaner, sub))
|
||||
return false;
|
||||
|
||||
#region Common
|
||||
|
||||
// Filter on item name
|
||||
if (!filter.PassStringFilter(filter.DatItem_Name, Name))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Name, Name))
|
||||
return false;
|
||||
|
||||
// Filter on tag
|
||||
if (!filter.PassStringFilter(filter.DatItem_Tag, Tag))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Tag, Tag))
|
||||
return false;
|
||||
|
||||
// Filter on mask
|
||||
if (!filter.PassStringFilter(filter.DatItem_Mask, Mask))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Mask, Mask))
|
||||
return false;
|
||||
|
||||
// Filter on individual conditions
|
||||
@@ -321,7 +315,7 @@ namespace SabreTools.DatItems
|
||||
{
|
||||
foreach (Condition condition in Conditions)
|
||||
{
|
||||
if (!condition.PassesFilter(filter, true))
|
||||
if (!condition.PassesFilter(cleaner, true))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -331,7 +325,7 @@ namespace SabreTools.DatItems
|
||||
{
|
||||
foreach (Location location in Locations)
|
||||
{
|
||||
if (!location.PassesFilter(filter, true))
|
||||
if (!location.PassesFilter(cleaner, true))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -341,7 +335,7 @@ namespace SabreTools.DatItems
|
||||
{
|
||||
foreach (Setting value in Values)
|
||||
{
|
||||
if (!value.PassesFilter(filter, true))
|
||||
if (!value.PassesFilter(cleaner, true))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -353,7 +347,7 @@ namespace SabreTools.DatItems
|
||||
// Filter on Part
|
||||
if (PartSpecified)
|
||||
{
|
||||
if (!Part.PassesFilter(filter, true))
|
||||
if (!Part.PassesFilter(cleaner, true))
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -362,33 +356,32 @@ namespace SabreTools.DatItems
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove fields from the DatItem
|
||||
/// </summary>
|
||||
/// <param name="fields">List of Fields to remove</param>
|
||||
public override void RemoveFields(List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void RemoveFields(
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Remove common fields first
|
||||
base.RemoveFields(fields);
|
||||
base.RemoveFields(datItemFields, machineFields);
|
||||
|
||||
// Remove the fields
|
||||
|
||||
#region Common
|
||||
|
||||
if (fields.Contains(Field.DatItem_Name))
|
||||
if (datItemFields.Contains(DatItemField.Name))
|
||||
Name = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Tag))
|
||||
if (datItemFields.Contains(DatItemField.Tag))
|
||||
Tag = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Mask))
|
||||
if (datItemFields.Contains(DatItemField.Mask))
|
||||
Mask = null;
|
||||
|
||||
if (ConditionsSpecified)
|
||||
{
|
||||
foreach (Condition condition in Conditions)
|
||||
{
|
||||
condition.RemoveFields(fields, true);
|
||||
condition.RemoveFields(datItemFields, machineFields, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -396,7 +389,7 @@ namespace SabreTools.DatItems
|
||||
{
|
||||
foreach (Location location in Locations)
|
||||
{
|
||||
location.RemoveFields(fields);
|
||||
location.RemoveFields(datItemFields, machineFields);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -404,7 +397,7 @@ namespace SabreTools.DatItems
|
||||
{
|
||||
foreach (Setting value in Values)
|
||||
{
|
||||
value.RemoveFields(fields);
|
||||
value.RemoveFields(datItemFields, machineFields);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -413,7 +406,7 @@ namespace SabreTools.DatItems
|
||||
#region SoftwareList
|
||||
|
||||
if (PartSpecified)
|
||||
Part.RemoveFields(fields);
|
||||
Part.RemoveFields(datItemFields, machineFields);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -432,15 +425,14 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Sorting and Merging
|
||||
|
||||
/// <summary>
|
||||
/// Replace fields from another item
|
||||
/// </summary>
|
||||
/// <param name="item">DatItem to pull new information from</param>
|
||||
/// <param name="fields">List of Fields representing what should be updated</param>
|
||||
public override void ReplaceFields(DatItem item, List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void ReplaceFields(
|
||||
DatItem item,
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Replace common fields first
|
||||
base.ReplaceFields(item, fields);
|
||||
base.ReplaceFields(item, datItemFields, machineFields);
|
||||
|
||||
// If we don't have a DipSwitch to replace from, ignore specific fields
|
||||
if (item.ItemType != ItemType.DipSwitch)
|
||||
@@ -453,13 +445,13 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Common
|
||||
|
||||
if (fields.Contains(Field.DatItem_Name))
|
||||
if (datItemFields.Contains(DatItemField.Name))
|
||||
Name = newItem.Name;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Tag))
|
||||
if (datItemFields.Contains(DatItemField.Tag))
|
||||
Tag = newItem.Tag;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Mask))
|
||||
if (datItemFields.Contains(DatItemField.Mask))
|
||||
Mask = newItem.Mask;
|
||||
|
||||
// DatItem_Condition_* doesn't make sense here
|
||||
@@ -479,7 +471,7 @@ namespace SabreTools.DatItems
|
||||
#region SoftwareList
|
||||
|
||||
if (PartSpecified && newItem.PartSpecified)
|
||||
Part.ReplaceFields(newItem.Part, fields);
|
||||
Part.ReplaceFields(newItem.Part, datItemFields, machineFields);
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -164,54 +164,53 @@ namespace SabreTools.DatItems
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="mappings">Mappings dictionary</param>
|
||||
public override void SetFields(Dictionary<Field, string> mappings)
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
Dictionary<MachineField, string> machineMappings)
|
||||
{
|
||||
// Set base fields
|
||||
base.SetFields(mappings);
|
||||
base.SetFields(datItemMappings, machineMappings);
|
||||
|
||||
// Handle Disk-specific fields
|
||||
if (mappings.Keys.Contains(Field.DatItem_Name))
|
||||
Name = mappings[Field.DatItem_Name];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Name))
|
||||
Name = datItemMappings[DatItemField.Name];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_MD5))
|
||||
MD5 = mappings[Field.DatItem_MD5];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.MD5))
|
||||
MD5 = datItemMappings[DatItemField.MD5];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_SHA1))
|
||||
SHA1 = mappings[Field.DatItem_SHA1];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.SHA1))
|
||||
SHA1 = datItemMappings[DatItemField.SHA1];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Merge))
|
||||
MergeTag = mappings[Field.DatItem_Merge];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Merge))
|
||||
MergeTag = datItemMappings[DatItemField.Merge];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Region))
|
||||
Region = mappings[Field.DatItem_Region];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Region))
|
||||
Region = datItemMappings[DatItemField.Region];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Index))
|
||||
Index = mappings[Field.DatItem_Index];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Index))
|
||||
Index = datItemMappings[DatItemField.Index];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Writable))
|
||||
Writable = mappings[Field.DatItem_Writable].AsYesNo();
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Writable))
|
||||
Writable = datItemMappings[DatItemField.Writable].AsYesNo();
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Status))
|
||||
ItemStatus = mappings[Field.DatItem_Status].AsItemStatus();
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Status))
|
||||
ItemStatus = datItemMappings[DatItemField.Status].AsItemStatus();
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Optional))
|
||||
Optional = mappings[Field.DatItem_Optional].AsYesNo();
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Optional))
|
||||
Optional = datItemMappings[DatItemField.Optional].AsYesNo();
|
||||
|
||||
// Handle DiskArea-specific fields
|
||||
if (DiskArea == null)
|
||||
DiskArea = new DiskArea();
|
||||
|
||||
DiskArea.SetFields(mappings);
|
||||
DiskArea.SetFields(datItemMappings, machineMappings);
|
||||
|
||||
// Handle Part-specific fields
|
||||
if (Part == null)
|
||||
Part = new Part();
|
||||
|
||||
Part.SetFields(mappings);
|
||||
Part.SetFields(datItemMappings, machineMappings);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -450,56 +449,51 @@ namespace SabreTools.DatItems
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check to see if a DatItem passes the filter
|
||||
/// </summary>
|
||||
/// <param name="filter">Filter to check against</param>
|
||||
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
||||
/// <returns>True if the item passed the filter, false otherwise</returns>
|
||||
public override bool PassesFilter(Filter filter, bool sub = false)
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
// Check common fields first
|
||||
if (!base.PassesFilter(filter, sub))
|
||||
if (!base.PassesFilter(cleaner, sub))
|
||||
return false;
|
||||
|
||||
#region Common
|
||||
|
||||
// Filter on item name
|
||||
if (!filter.PassStringFilter(filter.DatItem_Name, Name))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Name, Name))
|
||||
return false;
|
||||
|
||||
// Filter on MD5
|
||||
if (!filter.PassStringFilter(filter.DatItem_MD5, MD5))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.MD5, MD5))
|
||||
return false;
|
||||
|
||||
// Filter on SHA-1
|
||||
if (!filter.PassStringFilter(filter.DatItem_SHA1, SHA1))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.SHA1, SHA1))
|
||||
return false;
|
||||
|
||||
// Filter on merge tag
|
||||
if (!filter.PassStringFilter(filter.DatItem_Merge, MergeTag))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Merge, MergeTag))
|
||||
return false;
|
||||
|
||||
// Filter on region
|
||||
if (!filter.PassStringFilter(filter.DatItem_Region, Region))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Region, Region))
|
||||
return false;
|
||||
|
||||
// Filter on index
|
||||
if (!filter.PassStringFilter(filter.DatItem_Index, Index))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Index, Index))
|
||||
return false;
|
||||
|
||||
// Filter on writable
|
||||
if (!filter.PassBoolFilter(filter.DatItem_Writable, Writable))
|
||||
if (!Filter.PassBoolFilter(cleaner.DatItemFilter.Writable, Writable))
|
||||
return false;
|
||||
|
||||
// Filter on status
|
||||
if (filter.DatItem_Status.MatchesPositive(ItemStatus.NULL, ItemStatus) == false)
|
||||
if (cleaner.DatItemFilter.Status.MatchesPositive(ItemStatus.NULL, ItemStatus) == false)
|
||||
return false;
|
||||
if (filter.DatItem_Status.MatchesNegative(ItemStatus.NULL, ItemStatus) == true)
|
||||
if (cleaner.DatItemFilter.Status.MatchesNegative(ItemStatus.NULL, ItemStatus) == true)
|
||||
return false;
|
||||
|
||||
// Filter on optional
|
||||
if (!filter.PassBoolFilter(filter.DatItem_Optional, Optional))
|
||||
if (!Filter.PassBoolFilter(cleaner.DatItemFilter.Optional, Optional))
|
||||
return false;
|
||||
|
||||
#endregion
|
||||
@@ -509,14 +503,14 @@ namespace SabreTools.DatItems
|
||||
// Filter on DiskArea
|
||||
if (DiskAreaSpecified)
|
||||
{
|
||||
if (!DiskArea.PassesFilter(filter, true))
|
||||
if (!DiskArea.PassesFilter(cleaner, true))
|
||||
return false;
|
||||
}
|
||||
|
||||
// Filter on Part
|
||||
if (PartSpecified)
|
||||
{
|
||||
if (!Part.PassesFilter(filter, true))
|
||||
if (!Part.PassesFilter(cleaner, true))
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -525,44 +519,43 @@ namespace SabreTools.DatItems
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove fields from the DatItem
|
||||
/// </summary>
|
||||
/// <param name="fields">List of Fields to remove</param>
|
||||
public override void RemoveFields(List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void RemoveFields(
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Remove common fields first
|
||||
base.RemoveFields(fields);
|
||||
base.RemoveFields(datItemFields, machineFields);
|
||||
|
||||
// Remove the fields
|
||||
|
||||
#region Common
|
||||
|
||||
if (fields.Contains(Field.DatItem_Name))
|
||||
if (datItemFields.Contains(DatItemField.Name))
|
||||
Name = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_MD5))
|
||||
if (datItemFields.Contains(DatItemField.MD5))
|
||||
MD5 = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_SHA1))
|
||||
if (datItemFields.Contains(DatItemField.SHA1))
|
||||
SHA1 = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Merge))
|
||||
if (datItemFields.Contains(DatItemField.Merge))
|
||||
MergeTag = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Region))
|
||||
if (datItemFields.Contains(DatItemField.Region))
|
||||
Region = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Index))
|
||||
if (datItemFields.Contains(DatItemField.Index))
|
||||
Index = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Writable))
|
||||
if (datItemFields.Contains(DatItemField.Writable))
|
||||
Writable = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Status))
|
||||
if (datItemFields.Contains(DatItemField.Status))
|
||||
ItemStatus = ItemStatus.NULL;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Optional))
|
||||
if (datItemFields.Contains(DatItemField.Optional))
|
||||
Optional = null;
|
||||
|
||||
#endregion
|
||||
@@ -570,10 +563,10 @@ namespace SabreTools.DatItems
|
||||
#region SoftwareList
|
||||
|
||||
if (DiskAreaSpecified)
|
||||
DiskArea.RemoveFields(fields);
|
||||
DiskArea.RemoveFields(datItemFields, machineFields);
|
||||
|
||||
if (PartSpecified)
|
||||
Part.RemoveFields(fields);
|
||||
Part.RemoveFields(datItemFields, machineFields);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -627,15 +620,14 @@ namespace SabreTools.DatItems
|
||||
return key;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Replace fields from another item
|
||||
/// </summary>
|
||||
/// <param name="item">DatItem to pull new information from</param>
|
||||
/// <param name="fields">List of Fields representing what should be updated</param>
|
||||
public override void ReplaceFields(DatItem item, List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void ReplaceFields(
|
||||
DatItem item,
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Replace common fields first
|
||||
base.ReplaceFields(item, fields);
|
||||
base.ReplaceFields(item, datItemFields, machineFields);
|
||||
|
||||
// If we don't have a Disk to replace from, ignore specific fields
|
||||
if (item.ItemType != ItemType.Disk)
|
||||
@@ -648,37 +640,37 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Common
|
||||
|
||||
if (fields.Contains(Field.DatItem_Name))
|
||||
if (datItemFields.Contains(DatItemField.Name))
|
||||
Name = newItem.Name;
|
||||
|
||||
if (fields.Contains(Field.DatItem_MD5))
|
||||
if (datItemFields.Contains(DatItemField.MD5))
|
||||
{
|
||||
if (string.IsNullOrEmpty(MD5) && !string.IsNullOrEmpty(newItem.MD5))
|
||||
MD5 = newItem.MD5;
|
||||
}
|
||||
|
||||
if (fields.Contains(Field.DatItem_SHA1))
|
||||
if (datItemFields.Contains(DatItemField.SHA1))
|
||||
{
|
||||
if (string.IsNullOrEmpty(SHA1) && !string.IsNullOrEmpty(newItem.SHA1))
|
||||
SHA1 = newItem.SHA1;
|
||||
}
|
||||
|
||||
if (fields.Contains(Field.DatItem_Merge))
|
||||
if (datItemFields.Contains(DatItemField.Merge))
|
||||
MergeTag = newItem.MergeTag;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Region))
|
||||
if (datItemFields.Contains(DatItemField.Region))
|
||||
Region = newItem.Region;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Index))
|
||||
if (datItemFields.Contains(DatItemField.Index))
|
||||
Index = newItem.Index;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Writable))
|
||||
if (datItemFields.Contains(DatItemField.Writable))
|
||||
Writable = newItem.Writable;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Status))
|
||||
if (datItemFields.Contains(DatItemField.Status))
|
||||
ItemStatus = newItem.ItemStatus;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Optional))
|
||||
if (datItemFields.Contains(DatItemField.Optional))
|
||||
Optional = newItem.Optional;
|
||||
|
||||
#endregion
|
||||
@@ -686,10 +678,10 @@ namespace SabreTools.DatItems
|
||||
#region SoftwareList
|
||||
|
||||
if (DiskAreaSpecified && newItem.DiskAreaSpecified)
|
||||
DiskArea.ReplaceFields(newItem.DiskArea, fields);
|
||||
DiskArea.ReplaceFields(newItem.DiskArea, datItemFields, machineFields);
|
||||
|
||||
if (PartSpecified && newItem.PartSpecified)
|
||||
Part.ReplaceFields(newItem.Part, fields);
|
||||
Part.ReplaceFields(newItem.Part, datItemFields, machineFields);
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -39,18 +39,17 @@ namespace SabreTools.DatItems
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="mappings">Mappings dictionary</param>
|
||||
public override void SetFields(Dictionary<Field, string> mappings)
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
Dictionary<MachineField, string> machineMappings)
|
||||
{
|
||||
// Set base fields
|
||||
base.SetFields(mappings);
|
||||
base.SetFields(datItemMappings, machineMappings);
|
||||
|
||||
// Handle DiskArea-specific fields
|
||||
if (mappings.Keys.Contains(Field.DatItem_AreaName))
|
||||
Name = mappings[Field.DatItem_AreaName];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.AreaName))
|
||||
Name = datItemMappings[DatItemField.AreaName];
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -133,36 +132,30 @@ namespace SabreTools.DatItems
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check to see if a DatItem passes the filter
|
||||
/// </summary>
|
||||
/// <param name="filter">Filter to check against</param>
|
||||
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
||||
/// <returns>True if the item passed the filter, false otherwise</returns>
|
||||
public override bool PassesFilter(Filter filter, bool sub = false)
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
// Check common fields first
|
||||
if (!base.PassesFilter(filter, sub))
|
||||
if (!base.PassesFilter(cleaner, sub))
|
||||
return false;
|
||||
|
||||
// Filter on area name
|
||||
if (!filter.PassStringFilter(filter.DatItem_AreaName, Name))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.AreaName, Name))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove fields from the DatItem
|
||||
/// </summary>
|
||||
/// <param name="fields">List of Fields to remove</param>
|
||||
public override void RemoveFields(List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void RemoveFields(
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Remove common fields first
|
||||
base.RemoveFields(fields);
|
||||
base.RemoveFields(datItemFields, machineFields);
|
||||
|
||||
// Remove the fields
|
||||
if (fields.Contains(Field.DatItem_AreaName))
|
||||
if (datItemFields.Contains(DatItemField.AreaName))
|
||||
Name = null;
|
||||
}
|
||||
|
||||
@@ -180,15 +173,14 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Sorting and Merging
|
||||
|
||||
/// <summary>
|
||||
/// Replace fields from another item
|
||||
/// </summary>
|
||||
/// <param name="item">DatItem to pull new information from</param>
|
||||
/// <param name="fields">List of Fields representing what should be updated</param>
|
||||
public override void ReplaceFields(DatItem item, List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void ReplaceFields(
|
||||
DatItem item,
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Replace common fields first
|
||||
base.ReplaceFields(item, fields);
|
||||
base.ReplaceFields(item, datItemFields, machineFields);
|
||||
|
||||
// If we don't have a DiskArea to replace from, ignore specific fields
|
||||
if (item.ItemType != ItemType.DiskArea)
|
||||
@@ -198,7 +190,7 @@ namespace SabreTools.DatItems
|
||||
DiskArea newItem = item as DiskArea;
|
||||
|
||||
// Replace the fields
|
||||
if (fields.Contains(Field.DatItem_AreaName))
|
||||
if (datItemFields.Contains(DatItemField.AreaName))
|
||||
Name = newItem.Name;
|
||||
}
|
||||
|
||||
|
||||
@@ -161,60 +161,59 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="mappings">Mappings dictionary</param>
|
||||
public override void SetFields(Dictionary<Field, string> mappings)
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
Dictionary<MachineField, string> machineMappings)
|
||||
{
|
||||
// Set base fields
|
||||
base.SetFields(mappings);
|
||||
base.SetFields(datItemMappings, machineMappings);
|
||||
|
||||
// Handle Display-specific fields
|
||||
if (mappings.Keys.Contains(Field.DatItem_Tag))
|
||||
Tag = mappings[Field.DatItem_Tag];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Tag))
|
||||
Tag = datItemMappings[DatItemField.Tag];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_DisplayType))
|
||||
DisplayType = mappings[Field.DatItem_DisplayType].AsDisplayType();
|
||||
if (datItemMappings.Keys.Contains(DatItemField.DisplayType))
|
||||
DisplayType = datItemMappings[DatItemField.DisplayType].AsDisplayType();
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Rotate))
|
||||
Rotate = Utilities.CleanLong(mappings[Field.DatItem_Rotate]);
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Rotate))
|
||||
Rotate = Utilities.CleanLong(datItemMappings[DatItemField.Rotate]);
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_FlipX))
|
||||
FlipX = mappings[Field.DatItem_FlipX].AsYesNo();
|
||||
if (datItemMappings.Keys.Contains(DatItemField.FlipX))
|
||||
FlipX = datItemMappings[DatItemField.FlipX].AsYesNo();
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Width))
|
||||
Width = Utilities.CleanLong(mappings[Field.DatItem_Width]);
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Width))
|
||||
Width = Utilities.CleanLong(datItemMappings[DatItemField.Width]);
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Height))
|
||||
Height = Utilities.CleanLong(mappings[Field.DatItem_Height]);
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Height))
|
||||
Height = Utilities.CleanLong(datItemMappings[DatItemField.Height]);
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Refresh))
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Refresh))
|
||||
{
|
||||
if (Double.TryParse(mappings[Field.DatItem_Refresh], out double refresh))
|
||||
if (Double.TryParse(datItemMappings[DatItemField.Refresh], out double refresh))
|
||||
Refresh = refresh;
|
||||
}
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_PixClock))
|
||||
PixClock = Utilities.CleanLong(mappings[Field.DatItem_PixClock]);
|
||||
if (datItemMappings.Keys.Contains(DatItemField.PixClock))
|
||||
PixClock = Utilities.CleanLong(datItemMappings[DatItemField.PixClock]);
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_HTotal))
|
||||
HTotal = Utilities.CleanLong(mappings[Field.DatItem_HTotal]);
|
||||
if (datItemMappings.Keys.Contains(DatItemField.HTotal))
|
||||
HTotal = Utilities.CleanLong(datItemMappings[DatItemField.HTotal]);
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_HBEnd))
|
||||
HBEnd = Utilities.CleanLong(mappings[Field.DatItem_HBEnd]);
|
||||
if (datItemMappings.Keys.Contains(DatItemField.HBEnd))
|
||||
HBEnd = Utilities.CleanLong(datItemMappings[DatItemField.HBEnd]);
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_HBStart))
|
||||
HBStart = Utilities.CleanLong(mappings[Field.DatItem_HBStart]);
|
||||
if (datItemMappings.Keys.Contains(DatItemField.HBStart))
|
||||
HBStart = Utilities.CleanLong(datItemMappings[DatItemField.HBStart]);
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_VTotal))
|
||||
VTotal = Utilities.CleanLong(mappings[Field.DatItem_VTotal]);
|
||||
if (datItemMappings.Keys.Contains(DatItemField.VTotal))
|
||||
VTotal = Utilities.CleanLong(datItemMappings[DatItemField.VTotal]);
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_VBEnd))
|
||||
VBEnd = Utilities.CleanLong(mappings[Field.DatItem_VBEnd]);
|
||||
if (datItemMappings.Keys.Contains(DatItemField.VBEnd))
|
||||
VBEnd = Utilities.CleanLong(datItemMappings[DatItemField.VBEnd]);
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_VBStart))
|
||||
VBStart = Utilities.CleanLong(mappings[Field.DatItem_VBStart]);
|
||||
if (datItemMappings.Keys.Contains(DatItemField.VBStart))
|
||||
VBStart = Utilities.CleanLong(datItemMappings[DatItemField.VBStart]);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -295,129 +294,123 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Filtering
|
||||
|
||||
/// <summary>
|
||||
/// Check to see if a DatItem passes the filter
|
||||
/// </summary>
|
||||
/// <param name="filter">Filter to check against</param>
|
||||
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
||||
/// <returns>True if the item passed the filter, false otherwise</returns>
|
||||
public override bool PassesFilter(Filter filter, bool sub = false)
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
// Check common fields first
|
||||
if (!base.PassesFilter(filter, sub))
|
||||
if (!base.PassesFilter(cleaner, sub))
|
||||
return false;
|
||||
|
||||
// Filter on tag
|
||||
if (!filter.PassStringFilter(filter.DatItem_Tag, Tag))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Tag, Tag))
|
||||
return false;
|
||||
|
||||
// Filter on display type
|
||||
if (filter.DatItem_DisplayType.MatchesPositive(DisplayType.NULL, DisplayType) == false)
|
||||
if (cleaner.DatItemFilter.DisplayType.MatchesPositive(DisplayType.NULL, DisplayType) == false)
|
||||
return false;
|
||||
if (filter.DatItem_DisplayType.MatchesNegative(DisplayType.NULL, DisplayType) == true)
|
||||
if (cleaner.DatItemFilter.DisplayType.MatchesNegative(DisplayType.NULL, DisplayType) == true)
|
||||
return false;
|
||||
|
||||
// Filter on rotation
|
||||
if (!filter.PassLongFilter(filter.DatItem_Rotate, Rotate))
|
||||
if (!Filter.PassLongFilter(cleaner.DatItemFilter.Rotate, Rotate))
|
||||
return false;
|
||||
|
||||
// Filter on flipx
|
||||
if (!filter.PassBoolFilter(filter.DatItem_FlipX, FlipX))
|
||||
if (!Filter.PassBoolFilter(cleaner.DatItemFilter.FlipX, FlipX))
|
||||
return false;
|
||||
|
||||
// Filter on width
|
||||
if (!filter.PassLongFilter(filter.DatItem_Width, Width))
|
||||
if (!Filter.PassLongFilter(cleaner.DatItemFilter.Width, Width))
|
||||
return false;
|
||||
|
||||
// Filter on height
|
||||
if (!filter.PassLongFilter(filter.DatItem_Height, Height))
|
||||
if (!Filter.PassLongFilter(cleaner.DatItemFilter.Height, Height))
|
||||
return false;
|
||||
|
||||
// Filter on refresh
|
||||
if (!filter.PassDoubleFilter(filter.DatItem_Refresh, Refresh))
|
||||
if (!Filter.PassDoubleFilter(cleaner.DatItemFilter.Refresh, Refresh))
|
||||
return false;
|
||||
|
||||
// Filter on pixclock
|
||||
if (!filter.PassLongFilter(filter.DatItem_PixClock, PixClock))
|
||||
if (!Filter.PassLongFilter(cleaner.DatItemFilter.PixClock, PixClock))
|
||||
return false;
|
||||
|
||||
// Filter on htotal
|
||||
if (!filter.PassLongFilter(filter.DatItem_HTotal, HTotal))
|
||||
if (!Filter.PassLongFilter(cleaner.DatItemFilter.HTotal, HTotal))
|
||||
return false;
|
||||
|
||||
// Filter on hbend
|
||||
if (!filter.PassLongFilter(filter.DatItem_HBEnd, HBEnd))
|
||||
if (!Filter.PassLongFilter(cleaner.DatItemFilter.HBEnd, HBEnd))
|
||||
return false;
|
||||
|
||||
// Filter on hbstart
|
||||
if (!filter.PassLongFilter(filter.DatItem_HBStart, HBStart))
|
||||
if (!Filter.PassLongFilter(cleaner.DatItemFilter.HBStart, HBStart))
|
||||
return false;
|
||||
|
||||
// Filter on vtotal
|
||||
if (!filter.PassLongFilter(filter.DatItem_VTotal, VTotal))
|
||||
if (!Filter.PassLongFilter(cleaner.DatItemFilter.VTotal, VTotal))
|
||||
return false;
|
||||
|
||||
// Filter on vbend
|
||||
if (!filter.PassLongFilter(filter.DatItem_VBEnd, VBEnd))
|
||||
if (!Filter.PassLongFilter(cleaner.DatItemFilter.VBEnd, VBEnd))
|
||||
return false;
|
||||
|
||||
// Filter on vbstart
|
||||
if (!filter.PassLongFilter(filter.DatItem_VBStart, VBStart))
|
||||
if (!Filter.PassLongFilter(cleaner.DatItemFilter.VBStart, VBStart))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove fields from the DatItem
|
||||
/// </summary>
|
||||
/// <param name="fields">List of Fields to remove</param>
|
||||
public override void RemoveFields(List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void RemoveFields(
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Remove common fields first
|
||||
base.RemoveFields(fields);
|
||||
base.RemoveFields(datItemFields, machineFields);
|
||||
|
||||
// Remove the fields
|
||||
if (fields.Contains(Field.DatItem_Tag))
|
||||
if (datItemFields.Contains(DatItemField.Tag))
|
||||
Tag = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_DisplayType))
|
||||
if (datItemFields.Contains(DatItemField.DisplayType))
|
||||
DisplayType = DisplayType.NULL;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Rotate))
|
||||
if (datItemFields.Contains(DatItemField.Rotate))
|
||||
Rotate = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_FlipX))
|
||||
if (datItemFields.Contains(DatItemField.FlipX))
|
||||
FlipX = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Width))
|
||||
if (datItemFields.Contains(DatItemField.Width))
|
||||
Width = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Height))
|
||||
if (datItemFields.Contains(DatItemField.Height))
|
||||
Height = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Refresh))
|
||||
if (datItemFields.Contains(DatItemField.Refresh))
|
||||
Refresh = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_PixClock))
|
||||
if (datItemFields.Contains(DatItemField.PixClock))
|
||||
PixClock = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_HTotal))
|
||||
if (datItemFields.Contains(DatItemField.HTotal))
|
||||
HTotal = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_HBEnd))
|
||||
if (datItemFields.Contains(DatItemField.HBEnd))
|
||||
HBEnd = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_HBStart))
|
||||
if (datItemFields.Contains(DatItemField.HBStart))
|
||||
HBStart = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_VTotal))
|
||||
if (datItemFields.Contains(DatItemField.VTotal))
|
||||
VTotal = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_VBEnd))
|
||||
if (datItemFields.Contains(DatItemField.VBEnd))
|
||||
VBEnd = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_VBStart))
|
||||
if (datItemFields.Contains(DatItemField.VBStart))
|
||||
VBStart = null;
|
||||
}
|
||||
|
||||
@@ -425,15 +418,14 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Sorting and Merging
|
||||
|
||||
/// <summary>
|
||||
/// Replace fields from another item
|
||||
/// </summary>
|
||||
/// <param name="item">DatItem to pull new information from</param>
|
||||
/// <param name="fields">List of Fields representing what should be updated</param>
|
||||
public override void ReplaceFields(DatItem item, List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void ReplaceFields(
|
||||
DatItem item,
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Replace common fields first
|
||||
base.ReplaceFields(item, fields);
|
||||
base.ReplaceFields(item, datItemFields, machineFields);
|
||||
|
||||
// If we don't have a Display to replace from, ignore specific fields
|
||||
if (item.ItemType != ItemType.Display)
|
||||
@@ -443,46 +435,46 @@ namespace SabreTools.DatItems
|
||||
Display newItem = item as Display;
|
||||
|
||||
// Replace the fields
|
||||
if (fields.Contains(Field.DatItem_Tag))
|
||||
if (datItemFields.Contains(DatItemField.Tag))
|
||||
Tag = newItem.Tag;
|
||||
|
||||
if (fields.Contains(Field.DatItem_DisplayType))
|
||||
if (datItemFields.Contains(DatItemField.DisplayType))
|
||||
DisplayType = newItem.DisplayType;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Rotate))
|
||||
if (datItemFields.Contains(DatItemField.Rotate))
|
||||
Rotate = newItem.Rotate;
|
||||
|
||||
if (fields.Contains(Field.DatItem_FlipX))
|
||||
if (datItemFields.Contains(DatItemField.FlipX))
|
||||
FlipX = newItem.FlipX;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Width))
|
||||
if (datItemFields.Contains(DatItemField.Width))
|
||||
Width = newItem.Width;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Height))
|
||||
if (datItemFields.Contains(DatItemField.Height))
|
||||
Height = newItem.Height;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Refresh))
|
||||
if (datItemFields.Contains(DatItemField.Refresh))
|
||||
Refresh = newItem.Refresh;
|
||||
|
||||
if (fields.Contains(Field.DatItem_PixClock))
|
||||
if (datItemFields.Contains(DatItemField.PixClock))
|
||||
PixClock = newItem.PixClock;
|
||||
|
||||
if (fields.Contains(Field.DatItem_HTotal))
|
||||
if (datItemFields.Contains(DatItemField.HTotal))
|
||||
HTotal = newItem.HTotal;
|
||||
|
||||
if (fields.Contains(Field.DatItem_HBEnd))
|
||||
if (datItemFields.Contains(DatItemField.HBEnd))
|
||||
HBEnd = newItem.HBEnd;
|
||||
|
||||
if (fields.Contains(Field.DatItem_HBStart))
|
||||
if (datItemFields.Contains(DatItemField.HBStart))
|
||||
HBStart = newItem.HBStart;
|
||||
|
||||
if (fields.Contains(Field.DatItem_VTotal))
|
||||
if (datItemFields.Contains(DatItemField.VTotal))
|
||||
VTotal = newItem.VTotal;
|
||||
|
||||
if (fields.Contains(Field.DatItem_VBEnd))
|
||||
if (datItemFields.Contains(DatItemField.VBEnd))
|
||||
VBEnd = newItem.VBEnd;
|
||||
|
||||
if (fields.Contains(Field.DatItem_VBStart))
|
||||
if (datItemFields.Contains(DatItemField.VBStart))
|
||||
VBStart = newItem.VBStart;
|
||||
}
|
||||
|
||||
|
||||
@@ -66,27 +66,26 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="mappings">Mappings dictionary</param>
|
||||
public override void SetFields(Dictionary<Field, string> mappings)
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
Dictionary<MachineField, string> machineMappings)
|
||||
{
|
||||
// Set base fields
|
||||
base.SetFields(mappings);
|
||||
base.SetFields(datItemMappings, machineMappings);
|
||||
|
||||
// Handle Feature-specific fields
|
||||
if (mappings.Keys.Contains(Field.DatItem_SupportStatus))
|
||||
Status = mappings[Field.DatItem_SupportStatus].AsSupportStatus();
|
||||
if (datItemMappings.Keys.Contains(DatItemField.SupportStatus))
|
||||
Status = datItemMappings[DatItemField.SupportStatus].AsSupportStatus();
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_EmulationStatus))
|
||||
Emulation = mappings[Field.DatItem_EmulationStatus].AsSupportStatus();
|
||||
if (datItemMappings.Keys.Contains(DatItemField.EmulationStatus))
|
||||
Emulation = datItemMappings[DatItemField.EmulationStatus].AsSupportStatus();
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_CocktailStatus))
|
||||
Cocktail = mappings[Field.DatItem_CocktailStatus].AsSupportStatus();
|
||||
if (datItemMappings.Keys.Contains(DatItemField.CocktailStatus))
|
||||
Cocktail = datItemMappings[DatItemField.CocktailStatus].AsSupportStatus();
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_SaveStateStatus))
|
||||
SaveState = mappings[Field.DatItem_SaveStateStatus].AsSupported();
|
||||
if (datItemMappings.Keys.Contains(DatItemField.SaveStateStatus))
|
||||
SaveState = datItemMappings[DatItemField.SaveStateStatus].AsSupported();
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -147,65 +146,59 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Filtering
|
||||
|
||||
/// <summary>
|
||||
/// Check to see if a DatItem passes the filter
|
||||
/// </summary>
|
||||
/// <param name="filter">Filter to check against</param>
|
||||
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
||||
/// <returns>True if the item passed the filter, false otherwise</returns>
|
||||
public override bool PassesFilter(Filter filter, bool sub = false)
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
// Check common fields first
|
||||
if (!base.PassesFilter(filter, sub))
|
||||
if (!base.PassesFilter(cleaner, sub))
|
||||
return false;
|
||||
|
||||
// Filter on status
|
||||
if (filter.DatItem_SupportStatus.MatchesPositive(SupportStatus.NULL, Status) == false)
|
||||
if (cleaner.DatItemFilter.SupportStatus.MatchesPositive(SupportStatus.NULL, Status) == false)
|
||||
return false;
|
||||
if (filter.DatItem_SupportStatus.MatchesNegative(SupportStatus.NULL, Status) == true)
|
||||
if (cleaner.DatItemFilter.SupportStatus.MatchesNegative(SupportStatus.NULL, Status) == true)
|
||||
return false;
|
||||
|
||||
// Filter on emulation
|
||||
if (filter.DatItem_EmulationStatus.MatchesPositive(SupportStatus.NULL, Emulation) == false)
|
||||
if (cleaner.DatItemFilter.EmulationStatus.MatchesPositive(SupportStatus.NULL, Emulation) == false)
|
||||
return false;
|
||||
if (filter.DatItem_EmulationStatus.MatchesNegative(SupportStatus.NULL, Emulation) == true)
|
||||
if (cleaner.DatItemFilter.EmulationStatus.MatchesNegative(SupportStatus.NULL, Emulation) == true)
|
||||
return false;
|
||||
|
||||
// Filter on cocktail
|
||||
if (filter.DatItem_CocktailStatus.MatchesPositive(SupportStatus.NULL, Cocktail) == false)
|
||||
if (cleaner.DatItemFilter.CocktailStatus.MatchesPositive(SupportStatus.NULL, Cocktail) == false)
|
||||
return false;
|
||||
if (filter.DatItem_CocktailStatus.MatchesNegative(SupportStatus.NULL, Cocktail) == true)
|
||||
if (cleaner.DatItemFilter.CocktailStatus.MatchesNegative(SupportStatus.NULL, Cocktail) == true)
|
||||
return false;
|
||||
|
||||
// Filter on savestate
|
||||
if (filter.DatItem_SaveStateStatus.MatchesPositive(Supported.NULL, SaveState) == false)
|
||||
if (cleaner.DatItemFilter.SaveStateStatus.MatchesPositive(Supported.NULL, SaveState) == false)
|
||||
return false;
|
||||
if (filter.DatItem_SaveStateStatus.MatchesNegative(Supported.NULL, SaveState) == true)
|
||||
if (cleaner.DatItemFilter.SaveStateStatus.MatchesNegative(Supported.NULL, SaveState) == true)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove fields from the DatItem
|
||||
/// </summary>
|
||||
/// <param name="fields">List of Fields to remove</param>
|
||||
public override void RemoveFields(List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void RemoveFields(
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Remove common fields first
|
||||
base.RemoveFields(fields);
|
||||
base.RemoveFields(datItemFields, machineFields);
|
||||
|
||||
// Remove the fields
|
||||
if (fields.Contains(Field.DatItem_SupportStatus))
|
||||
if (datItemFields.Contains(DatItemField.SupportStatus))
|
||||
Status = SupportStatus.NULL;
|
||||
|
||||
if (fields.Contains(Field.DatItem_EmulationStatus))
|
||||
if (datItemFields.Contains(DatItemField.EmulationStatus))
|
||||
Emulation = SupportStatus.NULL;
|
||||
|
||||
if (fields.Contains(Field.DatItem_CocktailStatus))
|
||||
if (datItemFields.Contains(DatItemField.CocktailStatus))
|
||||
Cocktail = SupportStatus.NULL;
|
||||
|
||||
if (fields.Contains(Field.DatItem_SaveStateStatus))
|
||||
if (datItemFields.Contains(DatItemField.SaveStateStatus))
|
||||
SaveState = Supported.NULL;
|
||||
}
|
||||
|
||||
@@ -213,15 +206,14 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Sorting and Merging
|
||||
|
||||
/// <summary>
|
||||
/// Replace fields from another item
|
||||
/// </summary>
|
||||
/// <param name="item">DatItem to pull new information from</param>
|
||||
/// <param name="fields">List of Fields representing what should be updated</param>
|
||||
public override void ReplaceFields(DatItem item, List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void ReplaceFields(
|
||||
DatItem item,
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Replace common fields first
|
||||
base.ReplaceFields(item, fields);
|
||||
base.ReplaceFields(item, datItemFields, machineFields);
|
||||
|
||||
// If we don't have a Driver to replace from, ignore specific fields
|
||||
if (item.ItemType != ItemType.Driver)
|
||||
@@ -231,16 +223,16 @@ namespace SabreTools.DatItems
|
||||
Driver newItem = item as Driver;
|
||||
|
||||
// Replace the fields
|
||||
if (fields.Contains(Field.DatItem_SupportStatus))
|
||||
if (datItemFields.Contains(DatItemField.SupportStatus))
|
||||
Status = newItem.Status;
|
||||
|
||||
if (fields.Contains(Field.DatItem_EmulationStatus))
|
||||
if (datItemFields.Contains(DatItemField.EmulationStatus))
|
||||
Emulation = newItem.Emulation;
|
||||
|
||||
if (fields.Contains(Field.DatItem_CocktailStatus))
|
||||
if (datItemFields.Contains(DatItemField.CocktailStatus))
|
||||
Cocktail = newItem.Cocktail;
|
||||
|
||||
if (fields.Contains(Field.DatItem_SaveStateStatus))
|
||||
if (datItemFields.Contains(DatItemField.SaveStateStatus))
|
||||
SaveState = newItem.SaveState;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,18 +37,17 @@ namespace SabreTools.DatItems
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="mappings">Mappings dictionary</param>
|
||||
public override void SetFields(Dictionary<Field, string> mappings)
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
Dictionary<MachineField, string> machineMappings)
|
||||
{
|
||||
// Set base fields
|
||||
base.SetFields(mappings);
|
||||
base.SetFields(datItemMappings, machineMappings);
|
||||
|
||||
// Handle Sample-specific fields
|
||||
if (mappings.Keys.Contains(Field.DatItem_Extension_Name))
|
||||
Name = mappings[Field.DatItem_Extension_Name];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Extension_Name))
|
||||
Name = datItemMappings[DatItemField.Extension_Name];
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -131,36 +130,30 @@ namespace SabreTools.DatItems
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check to see if a DatItem passes the filter
|
||||
/// </summary>
|
||||
/// <param name="filter">Filter to check against</param>
|
||||
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
||||
/// <returns>True if the item passed the filter, false otherwise</returns>
|
||||
public override bool PassesFilter(Filter filter, bool sub = false)
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
// Check common fields first
|
||||
if (!base.PassesFilter(filter, sub))
|
||||
if (!base.PassesFilter(cleaner, sub))
|
||||
return false;
|
||||
|
||||
// Filter on item name
|
||||
if (!filter.PassStringFilter(filter.DatItem_Extension_Name, Name))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Extension_Name, Name))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove fields from the DatItem
|
||||
/// </summary>
|
||||
/// <param name="fields">List of Fields to remove</param>
|
||||
public override void RemoveFields(List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void RemoveFields(
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Remove common fields first
|
||||
base.RemoveFields(fields);
|
||||
base.RemoveFields(datItemFields, machineFields);
|
||||
|
||||
// Remove the fields
|
||||
if (fields.Contains(Field.DatItem_Extension_Name))
|
||||
if (datItemFields.Contains(DatItemField.Extension_Name))
|
||||
Name = null;
|
||||
}
|
||||
|
||||
@@ -178,15 +171,14 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Sorting and Merging
|
||||
|
||||
/// <summary>
|
||||
/// Replace fields from another item
|
||||
/// </summary>
|
||||
/// <param name="item">DatItem to pull new information from</param>
|
||||
/// <param name="fields">List of Fields representing what should be updated</param>
|
||||
public override void ReplaceFields(DatItem item, List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void ReplaceFields(
|
||||
DatItem item,
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Replace common fields first
|
||||
base.ReplaceFields(item, fields);
|
||||
base.ReplaceFields(item, datItemFields, machineFields);
|
||||
|
||||
// If we don't have a Extension to replace from, ignore specific fields
|
||||
if (item.ItemType != ItemType.Extension)
|
||||
@@ -196,7 +188,7 @@ namespace SabreTools.DatItems
|
||||
Extension newItem = item as Extension;
|
||||
|
||||
// Replace the fields
|
||||
if (fields.Contains(Field.DatItem_Extension_Name))
|
||||
if (datItemFields.Contains(DatItemField.Extension_Name))
|
||||
Name = newItem.Name;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,24 +55,23 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="mappings">Mappings dictionary</param>
|
||||
public override void SetFields(Dictionary<Field, string> mappings)
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
Dictionary<MachineField, string> machineMappings)
|
||||
{
|
||||
// Set base fields
|
||||
base.SetFields(mappings);
|
||||
base.SetFields(datItemMappings, machineMappings);
|
||||
|
||||
// Handle Feature-specific fields
|
||||
if (mappings.Keys.Contains(Field.DatItem_FeatureType))
|
||||
Type = mappings[Field.DatItem_FeatureType].AsFeatureType();
|
||||
if (datItemMappings.Keys.Contains(DatItemField.FeatureType))
|
||||
Type = datItemMappings[DatItemField.FeatureType].AsFeatureType();
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_FeatureStatus))
|
||||
Status = mappings[Field.DatItem_FeatureStatus].AsFeatureStatus();
|
||||
if (datItemMappings.Keys.Contains(DatItemField.FeatureStatus))
|
||||
Status = datItemMappings[DatItemField.FeatureStatus].AsFeatureStatus();
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_FeatureOverall))
|
||||
Overall = mappings[Field.DatItem_FeatureOverall].AsFeatureStatus();
|
||||
if (datItemMappings.Keys.Contains(DatItemField.FeatureOverall))
|
||||
Overall = datItemMappings[DatItemField.FeatureOverall].AsFeatureStatus();
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -129,56 +128,50 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Filtering
|
||||
|
||||
/// <summary>
|
||||
/// Check to see if a DatItem passes the filter
|
||||
/// </summary>
|
||||
/// <param name="filter">Filter to check against</param>
|
||||
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
||||
/// <returns>True if the item passed the filter, false otherwise</returns>
|
||||
public override bool PassesFilter(Filter filter, bool sub = false)
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
// Check common fields first
|
||||
if (!base.PassesFilter(filter, sub))
|
||||
if (!base.PassesFilter(cleaner, sub))
|
||||
return false;
|
||||
|
||||
// Filter on type
|
||||
if (filter.DatItem_FeatureType.MatchesPositive(FeatureType.NULL, Type) == false)
|
||||
if (cleaner.DatItemFilter.FeatureType.MatchesPositive(FeatureType.NULL, Type) == false)
|
||||
return false;
|
||||
if (filter.DatItem_FeatureType.MatchesNegative(FeatureType.NULL, Type) == true)
|
||||
if (cleaner.DatItemFilter.FeatureType.MatchesNegative(FeatureType.NULL, Type) == true)
|
||||
return false;
|
||||
|
||||
// Filter on status
|
||||
if (filter.DatItem_FeatureStatus.MatchesPositive(FeatureStatus.NULL, Status) == false)
|
||||
if (cleaner.DatItemFilter.FeatureStatus.MatchesPositive(FeatureStatus.NULL, Status) == false)
|
||||
return false;
|
||||
if (filter.DatItem_FeatureStatus.MatchesNegative(FeatureStatus.NULL, Status) == true)
|
||||
if (cleaner.DatItemFilter.FeatureStatus.MatchesNegative(FeatureStatus.NULL, Status) == true)
|
||||
return false;
|
||||
|
||||
// Filter on overall
|
||||
if (filter.DatItem_FeatureOverall.MatchesPositive(FeatureStatus.NULL, Overall) == false)
|
||||
if (cleaner.DatItemFilter.FeatureOverall.MatchesPositive(FeatureStatus.NULL, Overall) == false)
|
||||
return false;
|
||||
if (filter.DatItem_FeatureOverall.MatchesNegative(FeatureStatus.NULL, Overall) == true)
|
||||
if (cleaner.DatItemFilter.FeatureOverall.MatchesNegative(FeatureStatus.NULL, Overall) == true)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove fields from the DatItem
|
||||
/// </summary>
|
||||
/// <param name="fields">List of Fields to remove</param>
|
||||
public override void RemoveFields(List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void RemoveFields(
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Remove common fields first
|
||||
base.RemoveFields(fields);
|
||||
base.RemoveFields(datItemFields, machineFields);
|
||||
|
||||
// Remove the fields
|
||||
if (fields.Contains(Field.DatItem_FeatureType))
|
||||
if (datItemFields.Contains(DatItemField.FeatureType))
|
||||
Type = FeatureType.NULL;
|
||||
|
||||
if (fields.Contains(Field.DatItem_FeatureStatus))
|
||||
if (datItemFields.Contains(DatItemField.FeatureStatus))
|
||||
Status = FeatureStatus.NULL;
|
||||
|
||||
if (fields.Contains(Field.DatItem_FeatureOverall))
|
||||
if (datItemFields.Contains(DatItemField.FeatureOverall))
|
||||
Overall = FeatureStatus.NULL;
|
||||
}
|
||||
|
||||
@@ -186,15 +179,14 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Sorting and Merging
|
||||
|
||||
/// <summary>
|
||||
/// Replace fields from another item
|
||||
/// </summary>
|
||||
/// <param name="item">DatItem to pull new information from</param>
|
||||
/// <param name="fields">List of Fields representing what should be updated</param>
|
||||
public override void ReplaceFields(DatItem item, List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void ReplaceFields(
|
||||
DatItem item,
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Replace common fields first
|
||||
base.ReplaceFields(item, fields);
|
||||
base.ReplaceFields(item, datItemFields, machineFields);
|
||||
|
||||
// If we don't have a Feature to replace from, ignore specific fields
|
||||
if (item.ItemType != ItemType.Feature)
|
||||
@@ -204,13 +196,13 @@ namespace SabreTools.DatItems
|
||||
Feature newItem = item as Feature;
|
||||
|
||||
// Replace the fields
|
||||
if (fields.Contains(Field.DatItem_FeatureType))
|
||||
if (datItemFields.Contains(DatItemField.FeatureType))
|
||||
Type = newItem.Type;
|
||||
|
||||
if (fields.Contains(Field.DatItem_FeatureStatus))
|
||||
if (datItemFields.Contains(DatItemField.FeatureStatus))
|
||||
Status = newItem.Status;
|
||||
|
||||
if (fields.Contains(Field.DatItem_FeatureOverall))
|
||||
if (datItemFields.Contains(DatItemField.FeatureOverall))
|
||||
Overall = newItem.Overall;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,21 +44,20 @@ namespace SabreTools.DatItems
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="mappings">Mappings dictionary</param>
|
||||
public override void SetFields(Dictionary<Field, string> mappings)
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
Dictionary<MachineField, string> machineMappings)
|
||||
{
|
||||
// Set base fields
|
||||
base.SetFields(mappings);
|
||||
base.SetFields(datItemMappings, machineMappings);
|
||||
|
||||
// Handle Info-specific fields
|
||||
if (mappings.Keys.Contains(Field.DatItem_Name))
|
||||
Name = mappings[Field.DatItem_Name];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Name))
|
||||
Name = datItemMappings[DatItemField.Name];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Value))
|
||||
Value = mappings[Field.DatItem_Value];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Value))
|
||||
Value = datItemMappings[DatItemField.Value];
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -142,43 +141,37 @@ namespace SabreTools.DatItems
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check to see if a DatItem passes the filter
|
||||
/// </summary>
|
||||
/// <param name="filter">Filter to check against</param>
|
||||
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
||||
/// <returns>True if the item passed the filter, false otherwise</returns>
|
||||
public override bool PassesFilter(Filter filter, bool sub = false)
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
// Check common fields first
|
||||
if (!base.PassesFilter(filter, sub))
|
||||
if (!base.PassesFilter(cleaner, sub))
|
||||
return false;
|
||||
|
||||
// Filter on item name
|
||||
if (!filter.PassStringFilter(filter.DatItem_Name, Name))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Name, Name))
|
||||
return false;
|
||||
|
||||
// Filter on info value
|
||||
if (!filter.PassStringFilter(filter.DatItem_Value, Value))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Value, Value))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove fields from the DatItem
|
||||
/// </summary>
|
||||
/// <param name="fields">List of Fields to remove</param>
|
||||
public override void RemoveFields(List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void RemoveFields(
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Remove common fields first
|
||||
base.RemoveFields(fields);
|
||||
base.RemoveFields(datItemFields, machineFields);
|
||||
|
||||
// Remove the fields
|
||||
if (fields.Contains(Field.DatItem_Name))
|
||||
if (datItemFields.Contains(DatItemField.Name))
|
||||
Name = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Value))
|
||||
if (datItemFields.Contains(DatItemField.Value))
|
||||
Value = null;
|
||||
}
|
||||
|
||||
@@ -196,15 +189,14 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Sorting and Merging
|
||||
|
||||
/// <summary>
|
||||
/// Replace fields from another item
|
||||
/// </summary>
|
||||
/// <param name="item">DatItem to pull new information from</param>
|
||||
/// <param name="fields">List of Fields representing what should be updated</param>
|
||||
public override void ReplaceFields(DatItem item, List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void ReplaceFields(
|
||||
DatItem item,
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Replace common fields first
|
||||
base.ReplaceFields(item, fields);
|
||||
base.ReplaceFields(item, datItemFields, machineFields);
|
||||
|
||||
// If we don't have a Info to replace from, ignore specific fields
|
||||
if (item.ItemType != ItemType.Info)
|
||||
@@ -214,10 +206,10 @@ namespace SabreTools.DatItems
|
||||
Info newItem = item as Info;
|
||||
|
||||
// Replace the fields
|
||||
if (fields.Contains(Field.DatItem_Name))
|
||||
if (datItemFields.Contains(DatItemField.Name))
|
||||
Name = newItem.Name;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Value))
|
||||
if (datItemFields.Contains(DatItemField.Value))
|
||||
Value = newItem.Value;
|
||||
}
|
||||
|
||||
|
||||
@@ -72,33 +72,32 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="mappings">Mappings dictionary</param>
|
||||
public override void SetFields(Dictionary<Field, string> mappings)
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
Dictionary<MachineField, string> machineMappings)
|
||||
{
|
||||
// Set base fields
|
||||
base.SetFields(mappings);
|
||||
base.SetFields(datItemMappings, machineMappings);
|
||||
|
||||
// Handle Input-specific fields
|
||||
if (mappings.Keys.Contains(Field.DatItem_Service))
|
||||
Service = mappings[Field.DatItem_Service].AsYesNo();
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Service))
|
||||
Service = datItemMappings[DatItemField.Service].AsYesNo();
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Tilt))
|
||||
Tilt = mappings[Field.DatItem_Tilt].AsYesNo();
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Tilt))
|
||||
Tilt = datItemMappings[DatItemField.Tilt].AsYesNo();
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Players))
|
||||
Players = Utilities.CleanLong(mappings[Field.DatItem_Players]);
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Players))
|
||||
Players = Utilities.CleanLong(datItemMappings[DatItemField.Players]);
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Coins))
|
||||
Coins = Utilities.CleanLong(mappings[Field.DatItem_Coins]);
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Coins))
|
||||
Coins = Utilities.CleanLong(datItemMappings[DatItemField.Coins]);
|
||||
|
||||
if (ControlsSpecified)
|
||||
{
|
||||
foreach (Control control in Controls)
|
||||
{
|
||||
control.SetFields(mappings);
|
||||
control.SetFields(datItemMappings, machineMappings);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -175,32 +174,27 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Filtering
|
||||
|
||||
/// <summary>
|
||||
/// Check to see if a DatItem passes the filter
|
||||
/// </summary>
|
||||
/// <param name="filter">Filter to check against</param>
|
||||
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
||||
/// <returns>True if the item passed the filter, false otherwise</returns>
|
||||
public override bool PassesFilter(Filter filter, bool sub = false)
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
// Check common fields first
|
||||
if (!base.PassesFilter(filter, sub))
|
||||
if (!base.PassesFilter(cleaner, sub))
|
||||
return false;
|
||||
|
||||
// Filter on service
|
||||
if (!filter.PassBoolFilter(filter.DatItem_Service, Service))
|
||||
if (!Filter.PassBoolFilter(cleaner.DatItemFilter.Service, Service))
|
||||
return false;
|
||||
|
||||
// Filter on tilt
|
||||
if (!filter.PassBoolFilter(filter.DatItem_Tilt, Tilt))
|
||||
if (!Filter.PassBoolFilter(cleaner.DatItemFilter.Tilt, Tilt))
|
||||
return false;
|
||||
|
||||
// Filter on players
|
||||
if (!filter.PassLongFilter(filter.DatItem_Players, Players))
|
||||
if (!Filter.PassLongFilter(cleaner.DatItemFilter.Players, Players))
|
||||
return false;
|
||||
|
||||
// Filter on coins
|
||||
if (!filter.PassLongFilter(filter.DatItem_Coins, Coins))
|
||||
if (!Filter.PassLongFilter(cleaner.DatItemFilter.Coins, Coins))
|
||||
return false;
|
||||
|
||||
// Filter on individual controls
|
||||
@@ -208,7 +202,7 @@ namespace SabreTools.DatItems
|
||||
{
|
||||
foreach (Control control in Controls)
|
||||
{
|
||||
if (!control.PassesFilter(filter, true))
|
||||
if (!control.PassesFilter(cleaner, true))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -216,33 +210,32 @@ namespace SabreTools.DatItems
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove fields from the DatItem
|
||||
/// </summary>
|
||||
/// <param name="fields">List of Fields to remove</param>
|
||||
public override void RemoveFields(List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void RemoveFields(
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Remove common fields first
|
||||
base.RemoveFields(fields);
|
||||
base.RemoveFields(datItemFields, machineFields);
|
||||
|
||||
// Remove the fields
|
||||
if (fields.Contains(Field.DatItem_Service))
|
||||
if (datItemFields.Contains(DatItemField.Service))
|
||||
Service = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Tilt))
|
||||
if (datItemFields.Contains(DatItemField.Tilt))
|
||||
Tilt = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Players))
|
||||
if (datItemFields.Contains(DatItemField.Players))
|
||||
Players = 0;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Coins))
|
||||
if (datItemFields.Contains(DatItemField.Coins))
|
||||
Coins = null;
|
||||
|
||||
if (ControlsSpecified)
|
||||
{
|
||||
foreach (Control control in Controls)
|
||||
{
|
||||
control.RemoveFields(fields);
|
||||
control.RemoveFields(datItemFields, machineFields);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -251,15 +244,14 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Sorting and Merging
|
||||
|
||||
/// <summary>
|
||||
/// Replace fields from another item
|
||||
/// </summary>
|
||||
/// <param name="item">DatItem to pull new information from</param>
|
||||
/// <param name="fields">List of Fields representing what should be updated</param>
|
||||
public override void ReplaceFields(DatItem item, List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void ReplaceFields(
|
||||
DatItem item,
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Replace common fields first
|
||||
base.ReplaceFields(item, fields);
|
||||
base.ReplaceFields(item, datItemFields, machineFields);
|
||||
|
||||
// If we don't have a Input to replace from, ignore specific fields
|
||||
if (item.ItemType != ItemType.Input)
|
||||
@@ -269,16 +261,16 @@ namespace SabreTools.DatItems
|
||||
Input newItem = item as Input;
|
||||
|
||||
// Replace the fields
|
||||
if (fields.Contains(Field.DatItem_Service))
|
||||
if (datItemFields.Contains(DatItemField.Service))
|
||||
Service = newItem.Service;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Tilt))
|
||||
if (datItemFields.Contains(DatItemField.Tilt))
|
||||
Tilt = newItem.Tilt;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Players))
|
||||
if (datItemFields.Contains(DatItemField.Players))
|
||||
Players = newItem.Players;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Coins))
|
||||
if (datItemFields.Contains(DatItemField.Coins))
|
||||
Coins = newItem.Coins;
|
||||
|
||||
// DatItem_Control_* doesn't make sense here
|
||||
|
||||
@@ -44,21 +44,20 @@ namespace SabreTools.DatItems
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="mappings">Mappings dictionary</param>
|
||||
public override void SetFields(Dictionary<Field, string> mappings)
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
Dictionary<MachineField, string> machineMappings)
|
||||
{
|
||||
// Set base fields
|
||||
base.SetFields(mappings);
|
||||
base.SetFields(datItemMappings, machineMappings);
|
||||
|
||||
// Handle Instance-specific fields
|
||||
if (mappings.Keys.Contains(Field.DatItem_Instance_Name))
|
||||
Name = mappings[Field.DatItem_Instance_Name];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Instance_Name))
|
||||
Name = datItemMappings[DatItemField.Instance_Name];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Instance_BriefName))
|
||||
BriefName = mappings[Field.DatItem_Instance_BriefName];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Instance_BriefName))
|
||||
BriefName = datItemMappings[DatItemField.Instance_BriefName];
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -142,43 +141,37 @@ namespace SabreTools.DatItems
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check to see if a DatItem passes the filter
|
||||
/// </summary>
|
||||
/// <param name="filter">Filter to check against</param>
|
||||
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
||||
/// <returns>True if the item passed the filter, false otherwise</returns>
|
||||
public override bool PassesFilter(Filter filter, bool sub = false)
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
// Check common fields first
|
||||
if (!base.PassesFilter(filter, sub))
|
||||
if (!base.PassesFilter(cleaner, sub))
|
||||
return false;
|
||||
|
||||
// Filter on item name
|
||||
if (!filter.PassStringFilter(filter.DatItem_Instance_Name, Name))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Instance_Name, Name))
|
||||
return false;
|
||||
|
||||
// Filter on brief name
|
||||
if (!filter.PassStringFilter(filter.DatItem_Instance_BriefName, BriefName))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Instance_BriefName, BriefName))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove fields from the DatItem
|
||||
/// </summary>
|
||||
/// <param name="fields">List of Fields to remove</param>
|
||||
public override void RemoveFields(List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void RemoveFields(
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Remove common fields first
|
||||
base.RemoveFields(fields);
|
||||
base.RemoveFields(datItemFields, machineFields);
|
||||
|
||||
// Remove the fields
|
||||
if (fields.Contains(Field.DatItem_Instance_Name))
|
||||
if (datItemFields.Contains(DatItemField.Instance_Name))
|
||||
Name = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Instance_BriefName))
|
||||
if (datItemFields.Contains(DatItemField.Instance_BriefName))
|
||||
BriefName = null;
|
||||
}
|
||||
|
||||
@@ -196,15 +189,14 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Sorting and Merging
|
||||
|
||||
/// <summary>
|
||||
/// Replace fields from another item
|
||||
/// </summary>
|
||||
/// <param name="item">DatItem to pull new information from</param>
|
||||
/// <param name="fields">List of Fields representing what should be updated</param>
|
||||
public override void ReplaceFields(DatItem item, List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void ReplaceFields(
|
||||
DatItem item,
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Replace common fields first
|
||||
base.ReplaceFields(item, fields);
|
||||
base.ReplaceFields(item, datItemFields, machineFields);
|
||||
|
||||
// If we don't have a Instance to replace from, ignore specific fields
|
||||
if (item.ItemType != ItemType.Instance)
|
||||
@@ -214,10 +206,10 @@ namespace SabreTools.DatItems
|
||||
Instance newItem = item as Instance;
|
||||
|
||||
// Replace the fields
|
||||
if (fields.Contains(Field.DatItem_Instance_Name))
|
||||
if (datItemFields.Contains(DatItemField.Instance_Name))
|
||||
Name = newItem.Name;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Instance_BriefName))
|
||||
if (datItemFields.Contains(DatItemField.Instance_BriefName))
|
||||
BriefName = newItem.BriefName;
|
||||
}
|
||||
|
||||
|
||||
@@ -58,24 +58,23 @@ namespace SabreTools.DatItems
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="mappings">Mappings dictionary</param>
|
||||
public override void SetFields(Dictionary<Field, string> mappings)
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
Dictionary<MachineField, string> machineMappings)
|
||||
{
|
||||
// Set base fields
|
||||
base.SetFields(mappings);
|
||||
base.SetFields(datItemMappings, machineMappings);
|
||||
|
||||
// Handle Location-specific fields
|
||||
if (mappings.Keys.Contains(Field.DatItem_Location_Name))
|
||||
Name = mappings[Field.DatItem_Location_Name];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Location_Name))
|
||||
Name = datItemMappings[DatItemField.Location_Name];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Location_Number))
|
||||
Number = Utilities.CleanLong(mappings[Field.DatItem_Location_Number]);
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Location_Number))
|
||||
Number = Utilities.CleanLong(datItemMappings[DatItemField.Location_Number]);
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Location_Inverted))
|
||||
Inverted = mappings[Field.DatItem_Location_Inverted].AsYesNo();
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Location_Inverted))
|
||||
Inverted = datItemMappings[DatItemField.Location_Inverted].AsYesNo();
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -162,50 +161,44 @@ namespace SabreTools.DatItems
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check to see if a DatItem passes the filter
|
||||
/// </summary>
|
||||
/// <param name="filter">Filter to check against</param>
|
||||
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
||||
/// <returns>True if the item passed the filter, false otherwise</returns>
|
||||
public override bool PassesFilter(Filter filter, bool sub = false)
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
// Check common fields first
|
||||
if (!base.PassesFilter(filter, sub))
|
||||
if (!base.PassesFilter(cleaner, sub))
|
||||
return false;
|
||||
|
||||
// Filter on item name
|
||||
if (!filter.PassStringFilter(filter.DatItem_Location_Name, Name))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Location_Name, Name))
|
||||
return false;
|
||||
|
||||
// Filter on number
|
||||
if (!filter.PassLongFilter(filter.DatItem_Location_Number, Number))
|
||||
if (!Filter.PassLongFilter(cleaner.DatItemFilter.Location_Number, Number))
|
||||
return false;
|
||||
|
||||
// Filter on inverted
|
||||
if (!filter.PassBoolFilter(filter.DatItem_Location_Inverted, Inverted))
|
||||
if (!Filter.PassBoolFilter(cleaner.DatItemFilter.Location_Inverted, Inverted))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove fields from the DatItem
|
||||
/// </summary>
|
||||
/// <param name="fields">List of Fields to remove</param>
|
||||
public override void RemoveFields(List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void RemoveFields(
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Remove common fields first
|
||||
base.RemoveFields(fields);
|
||||
base.RemoveFields(datItemFields, machineFields);
|
||||
|
||||
// Remove the fields
|
||||
if (fields.Contains(Field.DatItem_Location_Name))
|
||||
if (datItemFields.Contains(DatItemField.Location_Name))
|
||||
Name = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Location_Number))
|
||||
if (datItemFields.Contains(DatItemField.Location_Number))
|
||||
Number = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Location_Inverted))
|
||||
if (datItemFields.Contains(DatItemField.Location_Inverted))
|
||||
Inverted = null;
|
||||
}
|
||||
|
||||
@@ -223,15 +216,14 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Sorting and Merging
|
||||
|
||||
/// <summary>
|
||||
/// Replace fields from another item
|
||||
/// </summary>
|
||||
/// <param name="item">DatItem to pull new information from</param>
|
||||
/// <param name="fields">List of Fields representing what should be updated</param>
|
||||
public override void ReplaceFields(DatItem item, List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void ReplaceFields(
|
||||
DatItem item,
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Replace common fields first
|
||||
base.ReplaceFields(item, fields);
|
||||
base.ReplaceFields(item, datItemFields, machineFields);
|
||||
|
||||
// If we don't have a Location to replace from, ignore specific fields
|
||||
if (item.ItemType != ItemType.Location)
|
||||
@@ -241,13 +233,13 @@ namespace SabreTools.DatItems
|
||||
Location newItem = item as Location;
|
||||
|
||||
// Replace the fields
|
||||
if (fields.Contains(Field.DatItem_Location_Name))
|
||||
if (datItemFields.Contains(DatItemField.Location_Name))
|
||||
Name = newItem.Name;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Location_Number))
|
||||
if (datItemFields.Contains(DatItemField.Location_Number))
|
||||
Number = newItem.Number;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Location_Inverted))
|
||||
if (datItemFields.Contains(DatItemField.Location_Inverted))
|
||||
Inverted = newItem.Inverted;
|
||||
}
|
||||
|
||||
|
||||
@@ -318,138 +318,141 @@ namespace SabreTools.DatItems
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="mappings">Mappings dictionary</param>
|
||||
public void SetFields(Dictionary<Field, string> mappings)
|
||||
public void SetFields(Dictionary<MachineField, string> mappings)
|
||||
{
|
||||
if (mappings == null)
|
||||
return;
|
||||
|
||||
#region Common
|
||||
|
||||
if (mappings.Keys.Contains(Field.Machine_Name))
|
||||
Name = mappings[Field.Machine_Name];
|
||||
if (mappings.Keys.Contains(MachineField.Name))
|
||||
Name = mappings[MachineField.Name];
|
||||
|
||||
if (mappings.Keys.Contains(Field.Machine_Comment))
|
||||
Comment = mappings[Field.Machine_Comment];
|
||||
if (mappings.Keys.Contains(MachineField.Comment))
|
||||
Comment = mappings[MachineField.Comment];
|
||||
|
||||
if (mappings.Keys.Contains(Field.Machine_Description))
|
||||
Description = mappings[Field.Machine_Description];
|
||||
if (mappings.Keys.Contains(MachineField.Description))
|
||||
Description = mappings[MachineField.Description];
|
||||
|
||||
if (mappings.Keys.Contains(Field.Machine_Year))
|
||||
Year = mappings[Field.Machine_Year];
|
||||
if (mappings.Keys.Contains(MachineField.Year))
|
||||
Year = mappings[MachineField.Year];
|
||||
|
||||
if (mappings.Keys.Contains(Field.Machine_Manufacturer))
|
||||
Manufacturer = mappings[Field.Machine_Manufacturer];
|
||||
if (mappings.Keys.Contains(MachineField.Manufacturer))
|
||||
Manufacturer = mappings[MachineField.Manufacturer];
|
||||
|
||||
if (mappings.Keys.Contains(Field.Machine_Publisher))
|
||||
Publisher = mappings[Field.Machine_Publisher];
|
||||
if (mappings.Keys.Contains(MachineField.Publisher))
|
||||
Publisher = mappings[MachineField.Publisher];
|
||||
|
||||
if (mappings.Keys.Contains(Field.Machine_Category))
|
||||
Category = mappings[Field.Machine_Category];
|
||||
if (mappings.Keys.Contains(MachineField.Category))
|
||||
Category = mappings[MachineField.Category];
|
||||
|
||||
if (mappings.Keys.Contains(Field.Machine_RomOf))
|
||||
RomOf = mappings[Field.Machine_RomOf];
|
||||
if (mappings.Keys.Contains(MachineField.RomOf))
|
||||
RomOf = mappings[MachineField.RomOf];
|
||||
|
||||
if (mappings.Keys.Contains(Field.Machine_CloneOf))
|
||||
CloneOf = mappings[Field.Machine_CloneOf];
|
||||
if (mappings.Keys.Contains(MachineField.CloneOf))
|
||||
CloneOf = mappings[MachineField.CloneOf];
|
||||
|
||||
if (mappings.Keys.Contains(Field.Machine_SampleOf))
|
||||
SampleOf = mappings[Field.Machine_SampleOf];
|
||||
if (mappings.Keys.Contains(MachineField.SampleOf))
|
||||
SampleOf = mappings[MachineField.SampleOf];
|
||||
|
||||
if (mappings.Keys.Contains(Field.Machine_Type))
|
||||
MachineType = mappings[Field.Machine_Type].AsMachineType();
|
||||
if (mappings.Keys.Contains(MachineField.Type))
|
||||
MachineType = mappings[MachineField.Type].AsMachineType();
|
||||
|
||||
#endregion
|
||||
|
||||
#region AttractMode
|
||||
|
||||
if (mappings.Keys.Contains(Field.Machine_Players))
|
||||
Players = mappings[Field.Machine_Players];
|
||||
if (mappings.Keys.Contains(MachineField.Players))
|
||||
Players = mappings[MachineField.Players];
|
||||
|
||||
if (mappings.Keys.Contains(Field.Machine_Rotation))
|
||||
Rotation = mappings[Field.Machine_Rotation];
|
||||
if (mappings.Keys.Contains(MachineField.Rotation))
|
||||
Rotation = mappings[MachineField.Rotation];
|
||||
|
||||
if (mappings.Keys.Contains(Field.Machine_Control))
|
||||
Control = mappings[Field.Machine_Control];
|
||||
if (mappings.Keys.Contains(MachineField.Control))
|
||||
Control = mappings[MachineField.Control];
|
||||
|
||||
if (mappings.Keys.Contains(Field.Machine_Status))
|
||||
Status = mappings[Field.Machine_Status];
|
||||
if (mappings.Keys.Contains(MachineField.Status))
|
||||
Status = mappings[MachineField.Status];
|
||||
|
||||
if (mappings.Keys.Contains(Field.Machine_DisplayCount))
|
||||
DisplayCount = mappings[Field.Machine_DisplayCount];
|
||||
if (mappings.Keys.Contains(MachineField.DisplayCount))
|
||||
DisplayCount = mappings[MachineField.DisplayCount];
|
||||
|
||||
if (mappings.Keys.Contains(Field.Machine_DisplayType))
|
||||
DisplayType = mappings[Field.Machine_DisplayType];
|
||||
if (mappings.Keys.Contains(MachineField.DisplayType))
|
||||
DisplayType = mappings[MachineField.DisplayType];
|
||||
|
||||
if (mappings.Keys.Contains(Field.Machine_Buttons))
|
||||
Buttons = mappings[Field.Machine_Buttons];
|
||||
if (mappings.Keys.Contains(MachineField.Buttons))
|
||||
Buttons = mappings[MachineField.Buttons];
|
||||
|
||||
#endregion
|
||||
|
||||
#region ListXML
|
||||
|
||||
if (mappings.Keys.Contains(Field.Machine_SourceFile))
|
||||
SourceFile = mappings[Field.Machine_SourceFile];
|
||||
if (mappings.Keys.Contains(MachineField.SourceFile))
|
||||
SourceFile = mappings[MachineField.SourceFile];
|
||||
|
||||
if (mappings.Keys.Contains(Field.Machine_Runnable))
|
||||
Runnable = mappings[Field.Machine_Runnable].AsRunnable();
|
||||
if (mappings.Keys.Contains(MachineField.Runnable))
|
||||
Runnable = mappings[MachineField.Runnable].AsRunnable();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Logiqx
|
||||
|
||||
if (mappings.Keys.Contains(Field.Machine_Board))
|
||||
Board = mappings[Field.Machine_Board];
|
||||
if (mappings.Keys.Contains(MachineField.Board))
|
||||
Board = mappings[MachineField.Board];
|
||||
|
||||
if (mappings.Keys.Contains(Field.Machine_RebuildTo))
|
||||
RebuildTo = mappings[Field.Machine_RebuildTo];
|
||||
if (mappings.Keys.Contains(MachineField.RebuildTo))
|
||||
RebuildTo = mappings[MachineField.RebuildTo];
|
||||
|
||||
#endregion
|
||||
|
||||
#region Logiqx EmuArc
|
||||
|
||||
if (mappings.Keys.Contains(Field.Machine_TitleID))
|
||||
TitleID = mappings[Field.Machine_TitleID];
|
||||
if (mappings.Keys.Contains(MachineField.TitleID))
|
||||
TitleID = mappings[MachineField.TitleID];
|
||||
|
||||
if (mappings.Keys.Contains(Field.Machine_Developer))
|
||||
Developer = mappings[Field.Machine_Developer];
|
||||
if (mappings.Keys.Contains(MachineField.Developer))
|
||||
Developer = mappings[MachineField.Developer];
|
||||
|
||||
if (mappings.Keys.Contains(Field.Machine_Genre))
|
||||
Genre = mappings[Field.Machine_Genre];
|
||||
if (mappings.Keys.Contains(MachineField.Genre))
|
||||
Genre = mappings[MachineField.Genre];
|
||||
|
||||
if (mappings.Keys.Contains(Field.Machine_Subgenre))
|
||||
Subgenre = mappings[Field.Machine_Subgenre];
|
||||
if (mappings.Keys.Contains(MachineField.Subgenre))
|
||||
Subgenre = mappings[MachineField.Subgenre];
|
||||
|
||||
if (mappings.Keys.Contains(Field.Machine_Ratings))
|
||||
Ratings = mappings[Field.Machine_Ratings];
|
||||
if (mappings.Keys.Contains(MachineField.Ratings))
|
||||
Ratings = mappings[MachineField.Ratings];
|
||||
|
||||
if (mappings.Keys.Contains(Field.Machine_Score))
|
||||
Score = mappings[Field.Machine_Score];
|
||||
if (mappings.Keys.Contains(MachineField.Score))
|
||||
Score = mappings[MachineField.Score];
|
||||
|
||||
if (mappings.Keys.Contains(Field.Machine_Enabled))
|
||||
Enabled = mappings[Field.Machine_Enabled];
|
||||
if (mappings.Keys.Contains(MachineField.Enabled))
|
||||
Enabled = mappings[MachineField.Enabled];
|
||||
|
||||
if (mappings.Keys.Contains(Field.Machine_CRC))
|
||||
Crc = mappings[Field.Machine_CRC].AsYesNo();
|
||||
if (mappings.Keys.Contains(MachineField.CRC))
|
||||
Crc = mappings[MachineField.CRC].AsYesNo();
|
||||
|
||||
if (mappings.Keys.Contains(Field.Machine_RelatedTo))
|
||||
RelatedTo = mappings[Field.Machine_RelatedTo];
|
||||
if (mappings.Keys.Contains(MachineField.RelatedTo))
|
||||
RelatedTo = mappings[MachineField.RelatedTo];
|
||||
|
||||
#endregion
|
||||
|
||||
#region OpenMSX
|
||||
|
||||
if (mappings.Keys.Contains(Field.Machine_GenMSXID))
|
||||
GenMSXID = mappings[Field.Machine_GenMSXID];
|
||||
if (mappings.Keys.Contains(MachineField.GenMSXID))
|
||||
GenMSXID = mappings[MachineField.GenMSXID];
|
||||
|
||||
if (mappings.Keys.Contains(Field.Machine_System))
|
||||
System = mappings[Field.Machine_System];
|
||||
if (mappings.Keys.Contains(MachineField.System))
|
||||
System = mappings[MachineField.System];
|
||||
|
||||
if (mappings.Keys.Contains(Field.Machine_Country))
|
||||
Country = mappings[Field.Machine_Country];
|
||||
if (mappings.Keys.Contains(MachineField.Country))
|
||||
Country = mappings[MachineField.Country];
|
||||
|
||||
#endregion
|
||||
|
||||
#region SoftwareList
|
||||
|
||||
if (mappings.Keys.Contains(Field.Machine_Supported))
|
||||
Supported = mappings[Field.Machine_Supported].AsSupported();
|
||||
if (mappings.Keys.Contains(MachineField.Supported))
|
||||
Supported = mappings[MachineField.Supported].AsSupported();
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -567,62 +570,62 @@ namespace SabreTools.DatItems
|
||||
/// <summary>
|
||||
/// Check to see if a Machine passes the filter
|
||||
/// </summary>
|
||||
/// <param name="filter">Filter to check against</param>
|
||||
/// <param name="cleaner">Cleaner containing filters to check against</param>
|
||||
/// <returns>True if the item passed the filter, false otherwise</returns>
|
||||
public bool PassesFilter(Filter filter)
|
||||
public bool PassesFilter(Cleaner cleaner)
|
||||
{
|
||||
#region Common
|
||||
|
||||
// Machine_Name
|
||||
bool passes = filter.PassStringFilter(filter.Machine_Name, Name);
|
||||
if (filter.IncludeOfInGame)
|
||||
bool passes = Filter.PassStringFilter(cleaner.MachineFilter.Name, Name);
|
||||
if (cleaner.MachineFilter.IncludeOfInGame)
|
||||
{
|
||||
passes |= filter.PassStringFilter(filter.Machine_Name, CloneOf);
|
||||
passes |= filter.PassStringFilter(filter.Machine_Name, RomOf);
|
||||
passes |= Filter.PassStringFilter(cleaner.MachineFilter.Name, CloneOf);
|
||||
passes |= Filter.PassStringFilter(cleaner.MachineFilter.Name, RomOf);
|
||||
}
|
||||
if (!passes)
|
||||
return false;
|
||||
|
||||
// Machine_Comment
|
||||
if (!filter.PassStringFilter(filter.Machine_Comment, Comment))
|
||||
if (!Filter.PassStringFilter(cleaner.MachineFilter.Comment, Comment))
|
||||
return false;
|
||||
|
||||
// Machine_Description
|
||||
if (!filter.PassStringFilter(filter.Machine_Description, Description))
|
||||
if (!Filter.PassStringFilter(cleaner.MachineFilter.Description, Description))
|
||||
return false;
|
||||
|
||||
// Machine_Year
|
||||
if (!filter.PassStringFilter(filter.Machine_Year, Year))
|
||||
if (!Filter.PassStringFilter(cleaner.MachineFilter.Year, Year))
|
||||
return false;
|
||||
|
||||
// Machine_Manufacturer
|
||||
if (!filter.PassStringFilter(filter.Machine_Manufacturer, Manufacturer))
|
||||
if (!Filter.PassStringFilter(cleaner.MachineFilter.Manufacturer, Manufacturer))
|
||||
return false;
|
||||
|
||||
// Machine_Publisher
|
||||
if (!filter.PassStringFilter(filter.Machine_Publisher, Publisher))
|
||||
if (!Filter.PassStringFilter(cleaner.MachineFilter.Publisher, Publisher))
|
||||
return false;
|
||||
|
||||
// Machine_Category
|
||||
if (!filter.PassStringFilter(filter.Machine_Category, Category))
|
||||
if (!Filter.PassStringFilter(cleaner.MachineFilter.Category, Category))
|
||||
return false;
|
||||
|
||||
// Machine_RomOf
|
||||
if (!filter.PassStringFilter(filter.Machine_RomOf, RomOf))
|
||||
if (!Filter.PassStringFilter(cleaner.MachineFilter.RomOf, RomOf))
|
||||
return false;
|
||||
|
||||
// Machine_CloneOf
|
||||
if (!filter.PassStringFilter(filter.Machine_CloneOf, CloneOf))
|
||||
if (!Filter.PassStringFilter(cleaner.MachineFilter.CloneOf, CloneOf))
|
||||
return false;
|
||||
|
||||
// Machine_SampleOf
|
||||
if (!filter.PassStringFilter(filter.Machine_SampleOf, SampleOf))
|
||||
if (!Filter.PassStringFilter(cleaner.MachineFilter.SampleOf, SampleOf))
|
||||
return false;
|
||||
|
||||
// Machine_Type
|
||||
if (filter.Machine_Type.MatchesPositive(0x0, MachineType) == false)
|
||||
if (cleaner.MachineFilter.Type.MatchesPositive(0x0, MachineType) == false)
|
||||
return false;
|
||||
if (filter.Machine_Type.MatchesNegative(0x0, MachineType) == true)
|
||||
if (cleaner.MachineFilter.Type.MatchesNegative(0x0, MachineType) == true)
|
||||
return false;
|
||||
|
||||
#endregion
|
||||
@@ -630,31 +633,31 @@ namespace SabreTools.DatItems
|
||||
#region AttractMode
|
||||
|
||||
// Machine_Players
|
||||
if (!filter.PassStringFilter(filter.Machine_Players, Players))
|
||||
if (!Filter.PassStringFilter(cleaner.MachineFilter.Players, Players))
|
||||
return false;
|
||||
|
||||
// Machine_Rotation
|
||||
if (!filter.PassStringFilter(filter.Machine_Rotation, Rotation))
|
||||
if (!Filter.PassStringFilter(cleaner.MachineFilter.Rotation, Rotation))
|
||||
return false;
|
||||
|
||||
// Machine_Control
|
||||
if (!filter.PassStringFilter(filter.Machine_Control, Control))
|
||||
if (!Filter.PassStringFilter(cleaner.MachineFilter.Control, Control))
|
||||
return false;
|
||||
|
||||
// Machine_Status
|
||||
if (!filter.PassStringFilter(filter.Machine_Status, Status))
|
||||
if (!Filter.PassStringFilter(cleaner.MachineFilter.Status, Status))
|
||||
return false;
|
||||
|
||||
// Machine_DisplayCount
|
||||
if (!filter.PassStringFilter(filter.Machine_DisplayCount, DisplayCount))
|
||||
if (!Filter.PassStringFilter(cleaner.MachineFilter.DisplayCount, DisplayCount))
|
||||
return false;
|
||||
|
||||
// Machine_DisplayType
|
||||
if (!filter.PassStringFilter(filter.Machine_DisplayType, DisplayType))
|
||||
if (!Filter.PassStringFilter(cleaner.MachineFilter.DisplayType, DisplayType))
|
||||
return false;
|
||||
|
||||
// Machine_Buttons
|
||||
if (!filter.PassStringFilter(filter.Machine_Buttons, Buttons))
|
||||
if (!Filter.PassStringFilter(cleaner.MachineFilter.Buttons, Buttons))
|
||||
return false;
|
||||
|
||||
#endregion
|
||||
@@ -662,13 +665,13 @@ namespace SabreTools.DatItems
|
||||
#region ListXML
|
||||
|
||||
// Machine_SourceFile
|
||||
if (!filter.PassStringFilter(filter.Machine_SourceFile, SourceFile))
|
||||
if (!Filter.PassStringFilter(cleaner.MachineFilter.SourceFile, SourceFile))
|
||||
return false;
|
||||
|
||||
// Machine_Runnable
|
||||
if (filter.Machine_Runnable.MatchesPositive(Runnable.NULL, Runnable) == false)
|
||||
if (cleaner.MachineFilter.Runnable.MatchesPositive(Runnable.NULL, Runnable) == false)
|
||||
return false;
|
||||
if (filter.Machine_Runnable.MatchesNegative(Runnable.NULL, Runnable) == true)
|
||||
if (cleaner.MachineFilter.Runnable.MatchesNegative(Runnable.NULL, Runnable) == true)
|
||||
return false;
|
||||
|
||||
#endregion
|
||||
@@ -676,11 +679,11 @@ namespace SabreTools.DatItems
|
||||
#region Logiqx
|
||||
|
||||
// Machine_Board
|
||||
if (!filter.PassStringFilter(filter.Machine_Board, Board))
|
||||
if (!Filter.PassStringFilter(cleaner.MachineFilter.Board, Board))
|
||||
return false;
|
||||
|
||||
// Machine_RebuildTo
|
||||
if (!filter.PassStringFilter(filter.Machine_RebuildTo, RebuildTo))
|
||||
if (!Filter.PassStringFilter(cleaner.MachineFilter.RebuildTo, RebuildTo))
|
||||
return false;
|
||||
|
||||
#endregion
|
||||
@@ -688,39 +691,39 @@ namespace SabreTools.DatItems
|
||||
#region Logiqx EmuArc
|
||||
|
||||
// Machine_TitleID
|
||||
if (!filter.PassStringFilter(filter.Machine_TitleID, TitleID))
|
||||
if (!Filter.PassStringFilter(cleaner.MachineFilter.TitleID, TitleID))
|
||||
return false;
|
||||
|
||||
// Machine_Developer
|
||||
if (!filter.PassStringFilter(filter.Machine_Developer, Developer))
|
||||
if (!Filter.PassStringFilter(cleaner.MachineFilter.Developer, Developer))
|
||||
return false;
|
||||
|
||||
// Machine_Genre
|
||||
if (!filter.PassStringFilter(filter.Machine_Genre, Genre))
|
||||
if (!Filter.PassStringFilter(cleaner.MachineFilter.Genre, Genre))
|
||||
return false;
|
||||
|
||||
// Machine_Subgenre
|
||||
if (!filter.PassStringFilter(filter.Machine_Subgenre, Subgenre))
|
||||
if (!Filter.PassStringFilter(cleaner.MachineFilter.Subgenre, Subgenre))
|
||||
return false;
|
||||
|
||||
// Machine_Ratings
|
||||
if (!filter.PassStringFilter(filter.Machine_Ratings, Ratings))
|
||||
if (!Filter.PassStringFilter(cleaner.MachineFilter.Ratings, Ratings))
|
||||
return false;
|
||||
|
||||
// Machine_Score
|
||||
if (!filter.PassStringFilter(filter.Machine_Score, Score))
|
||||
if (!Filter.PassStringFilter(cleaner.MachineFilter.Score, Score))
|
||||
return false;
|
||||
|
||||
// Machine_Enabled
|
||||
if (!filter.PassStringFilter(filter.Machine_Enabled, Enabled))
|
||||
if (!Filter.PassStringFilter(cleaner.MachineFilter.Enabled, Enabled))
|
||||
return false;
|
||||
|
||||
// Machine_CRC
|
||||
if (!filter.PassBoolFilter(filter.Machine_CRC, Crc))
|
||||
if (!Filter.PassBoolFilter(cleaner.MachineFilter.CRC, Crc))
|
||||
return false;
|
||||
|
||||
// Machine_RelatedTo
|
||||
if (!filter.PassStringFilter(filter.Machine_RelatedTo, RelatedTo))
|
||||
if (!Filter.PassStringFilter(cleaner.MachineFilter.RelatedTo, RelatedTo))
|
||||
return false;
|
||||
|
||||
#endregion
|
||||
@@ -728,15 +731,15 @@ namespace SabreTools.DatItems
|
||||
#region OpenMSX
|
||||
|
||||
// Machine_GenMSXID
|
||||
if (!filter.PassStringFilter(filter.Machine_GenMSXID, GenMSXID))
|
||||
if (!Filter.PassStringFilter(cleaner.MachineFilter.GenMSXID, GenMSXID))
|
||||
return false;
|
||||
|
||||
// Machine_System
|
||||
if (!filter.PassStringFilter(filter.Machine_System, System))
|
||||
if (!Filter.PassStringFilter(cleaner.MachineFilter.System, System))
|
||||
return false;
|
||||
|
||||
// Machine_Country
|
||||
if (!filter.PassStringFilter(filter.Machine_Country, Country))
|
||||
if (!Filter.PassStringFilter(cleaner.MachineFilter.Country, Country))
|
||||
return false;
|
||||
|
||||
#endregion
|
||||
@@ -744,9 +747,9 @@ namespace SabreTools.DatItems
|
||||
#region SoftwareList
|
||||
|
||||
// Machine_Supported
|
||||
if (filter.Machine_Supported.MatchesPositive(Supported.NULL, Supported) == false)
|
||||
if (cleaner.MachineFilter.Supported.MatchesPositive(Supported.NULL, Supported) == false)
|
||||
return false;
|
||||
if (filter.Machine_Supported.MatchesNegative(Supported.NULL, Supported) == true)
|
||||
if (cleaner.MachineFilter.Supported.MatchesNegative(Supported.NULL, Supported) == true)
|
||||
return false;
|
||||
|
||||
#endregion // SoftwareList
|
||||
@@ -758,137 +761,137 @@ namespace SabreTools.DatItems
|
||||
/// Remove fields from the Machine
|
||||
/// </summary>
|
||||
/// <param name="fields">List of Fields to remove</param>
|
||||
public void RemoveFields(List<Field> fields)
|
||||
public void RemoveFields(List<MachineField> fields)
|
||||
{
|
||||
#region Common
|
||||
|
||||
if (fields.Contains(Field.Machine_Name))
|
||||
if (fields.Contains(MachineField.Name))
|
||||
Name = null;
|
||||
|
||||
if (fields.Contains(Field.Machine_Comment))
|
||||
if (fields.Contains(MachineField.Comment))
|
||||
Comment = null;
|
||||
|
||||
if (fields.Contains(Field.Machine_Description))
|
||||
if (fields.Contains(MachineField.Description))
|
||||
Description = null;
|
||||
|
||||
if (fields.Contains(Field.Machine_Year))
|
||||
if (fields.Contains(MachineField.Year))
|
||||
Year = null;
|
||||
|
||||
if (fields.Contains(Field.Machine_Manufacturer))
|
||||
if (fields.Contains(MachineField.Manufacturer))
|
||||
Manufacturer = null;
|
||||
|
||||
if (fields.Contains(Field.Machine_Publisher))
|
||||
if (fields.Contains(MachineField.Publisher))
|
||||
Publisher = null;
|
||||
|
||||
if (fields.Contains(Field.Machine_Category))
|
||||
if (fields.Contains(MachineField.Category))
|
||||
Category = null;
|
||||
|
||||
if (fields.Contains(Field.Machine_RomOf))
|
||||
if (fields.Contains(MachineField.RomOf))
|
||||
RomOf = null;
|
||||
|
||||
if (fields.Contains(Field.Machine_CloneOf))
|
||||
if (fields.Contains(MachineField.CloneOf))
|
||||
CloneOf = null;
|
||||
|
||||
if (fields.Contains(Field.Machine_SampleOf))
|
||||
if (fields.Contains(MachineField.SampleOf))
|
||||
SampleOf = null;
|
||||
|
||||
if (fields.Contains(Field.Machine_Type))
|
||||
if (fields.Contains(MachineField.Type))
|
||||
MachineType = 0x0;
|
||||
|
||||
#endregion
|
||||
|
||||
#region AttractMode
|
||||
|
||||
if (fields.Contains(Field.Machine_Players))
|
||||
if (fields.Contains(MachineField.Players))
|
||||
Players = null;
|
||||
|
||||
if (fields.Contains(Field.Machine_Rotation))
|
||||
if (fields.Contains(MachineField.Rotation))
|
||||
Rotation = null;
|
||||
|
||||
if (fields.Contains(Field.Machine_Control))
|
||||
if (fields.Contains(MachineField.Control))
|
||||
Control = null;
|
||||
|
||||
if (fields.Contains(Field.Machine_Status))
|
||||
if (fields.Contains(MachineField.Status))
|
||||
Status = null;
|
||||
|
||||
if (fields.Contains(Field.Machine_DisplayCount))
|
||||
if (fields.Contains(MachineField.DisplayCount))
|
||||
DisplayCount = null;
|
||||
|
||||
if (fields.Contains(Field.Machine_DisplayType))
|
||||
if (fields.Contains(MachineField.DisplayType))
|
||||
DisplayType = null;
|
||||
|
||||
if (fields.Contains(Field.Machine_Buttons))
|
||||
if (fields.Contains(MachineField.Buttons))
|
||||
Buttons = null;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ListXML
|
||||
|
||||
if (fields.Contains(Field.Machine_SourceFile))
|
||||
if (fields.Contains(MachineField.SourceFile))
|
||||
SourceFile = null;
|
||||
|
||||
if (fields.Contains(Field.Machine_Runnable))
|
||||
if (fields.Contains(MachineField.Runnable))
|
||||
Runnable = Runnable.NULL;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Logiqx
|
||||
|
||||
if (fields.Contains(Field.Machine_Board))
|
||||
if (fields.Contains(MachineField.Board))
|
||||
Board = null;
|
||||
|
||||
if (fields.Contains(Field.Machine_RebuildTo))
|
||||
if (fields.Contains(MachineField.RebuildTo))
|
||||
RebuildTo = null;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Logiqx EmuArc
|
||||
|
||||
if (fields.Contains(Field.Machine_TitleID))
|
||||
if (fields.Contains(MachineField.TitleID))
|
||||
TitleID = null;
|
||||
|
||||
if (fields.Contains(Field.Machine_Developer))
|
||||
if (fields.Contains(MachineField.Developer))
|
||||
Developer = null;
|
||||
|
||||
if (fields.Contains(Field.Machine_Genre))
|
||||
if (fields.Contains(MachineField.Genre))
|
||||
Genre = null;
|
||||
|
||||
if (fields.Contains(Field.Machine_Subgenre))
|
||||
if (fields.Contains(MachineField.Subgenre))
|
||||
Subgenre = null;
|
||||
|
||||
if (fields.Contains(Field.Machine_Ratings))
|
||||
if (fields.Contains(MachineField.Ratings))
|
||||
Ratings = null;
|
||||
|
||||
if (fields.Contains(Field.Machine_Score))
|
||||
if (fields.Contains(MachineField.Score))
|
||||
Score = null;
|
||||
|
||||
if (fields.Contains(Field.Machine_Enabled))
|
||||
if (fields.Contains(MachineField.Enabled))
|
||||
Enabled = null;
|
||||
|
||||
if (fields.Contains(Field.Machine_CRC))
|
||||
if (fields.Contains(MachineField.CRC))
|
||||
Crc = null;
|
||||
|
||||
if (fields.Contains(Field.Machine_RelatedTo))
|
||||
if (fields.Contains(MachineField.RelatedTo))
|
||||
RelatedTo = null;
|
||||
|
||||
#endregion
|
||||
|
||||
#region OpenMSX
|
||||
|
||||
if (fields.Contains(Field.Machine_GenMSXID))
|
||||
if (fields.Contains(MachineField.GenMSXID))
|
||||
GenMSXID = null;
|
||||
|
||||
if (fields.Contains(Field.Machine_System))
|
||||
if (fields.Contains(MachineField.System))
|
||||
System = null;
|
||||
|
||||
if (fields.Contains(Field.Machine_Country))
|
||||
if (fields.Contains(MachineField.Country))
|
||||
Country = null;
|
||||
|
||||
#endregion
|
||||
|
||||
#region SoftwareList
|
||||
|
||||
if (fields.Contains(Field.Machine_Supported))
|
||||
if (fields.Contains(MachineField.Supported))
|
||||
Supported = Supported.NULL;
|
||||
|
||||
#endregion
|
||||
@@ -904,140 +907,140 @@ namespace SabreTools.DatItems
|
||||
/// <param name="item">DatItem to pull new information from</param>
|
||||
/// <param name="fields">List of Fields representing what should be updated</param>
|
||||
/// <param name="onlySame">True if descriptions should only be replaced if the game name is the same, false otherwise</param>
|
||||
public void ReplaceFields(Machine machine, List<Field> fields, bool onlySame)
|
||||
public void ReplaceFields(Machine machine, List<MachineField> fields, bool onlySame)
|
||||
{
|
||||
#region Common
|
||||
|
||||
if (fields.Contains(Field.Machine_Name))
|
||||
if (fields.Contains(MachineField.Name))
|
||||
Name = machine.Name;
|
||||
|
||||
if (fields.Contains(Field.Machine_Comment))
|
||||
if (fields.Contains(MachineField.Comment))
|
||||
Comment = machine.Comment;
|
||||
|
||||
if (fields.Contains(Field.Machine_Description))
|
||||
if (fields.Contains(MachineField.Description))
|
||||
{
|
||||
if (!onlySame || (onlySame && Name == Description))
|
||||
Description = machine.Description;
|
||||
}
|
||||
|
||||
if (fields.Contains(Field.Machine_Year))
|
||||
if (fields.Contains(MachineField.Year))
|
||||
Year = machine.Year;
|
||||
|
||||
if (fields.Contains(Field.Machine_Manufacturer))
|
||||
if (fields.Contains(MachineField.Manufacturer))
|
||||
Manufacturer = machine.Manufacturer;
|
||||
|
||||
if (fields.Contains(Field.Machine_Publisher))
|
||||
if (fields.Contains(MachineField.Publisher))
|
||||
Publisher = machine.Publisher;
|
||||
|
||||
if (fields.Contains(Field.Machine_Category))
|
||||
if (fields.Contains(MachineField.Category))
|
||||
Category = machine.Category;
|
||||
|
||||
if (fields.Contains(Field.Machine_RomOf))
|
||||
if (fields.Contains(MachineField.RomOf))
|
||||
RomOf = machine.RomOf;
|
||||
|
||||
if (fields.Contains(Field.Machine_CloneOf))
|
||||
if (fields.Contains(MachineField.CloneOf))
|
||||
CloneOf = machine.CloneOf;
|
||||
|
||||
if (fields.Contains(Field.Machine_SampleOf))
|
||||
if (fields.Contains(MachineField.SampleOf))
|
||||
SampleOf = machine.SampleOf;
|
||||
|
||||
if (fields.Contains(Field.Machine_Type))
|
||||
if (fields.Contains(MachineField.Type))
|
||||
MachineType = machine.MachineType;
|
||||
|
||||
#endregion
|
||||
|
||||
#region AttractMode
|
||||
|
||||
if (fields.Contains(Field.Machine_Players))
|
||||
if (fields.Contains(MachineField.Players))
|
||||
Players = machine.Players;
|
||||
|
||||
if (fields.Contains(Field.Machine_Rotation))
|
||||
if (fields.Contains(MachineField.Rotation))
|
||||
Rotation = machine.Rotation;
|
||||
|
||||
if (fields.Contains(Field.Machine_Control))
|
||||
if (fields.Contains(MachineField.Control))
|
||||
Control = machine.Control;
|
||||
|
||||
if (fields.Contains(Field.Machine_Status))
|
||||
if (fields.Contains(MachineField.Status))
|
||||
Status = machine.Status;
|
||||
|
||||
if (fields.Contains(Field.Machine_DisplayCount))
|
||||
if (fields.Contains(MachineField.DisplayCount))
|
||||
DisplayCount = machine.DisplayCount;
|
||||
|
||||
if (fields.Contains(Field.Machine_DisplayType))
|
||||
if (fields.Contains(MachineField.DisplayType))
|
||||
DisplayType = machine.DisplayType;
|
||||
|
||||
if (fields.Contains(Field.Machine_Buttons))
|
||||
if (fields.Contains(MachineField.Buttons))
|
||||
Buttons = machine.Buttons;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ListXML
|
||||
|
||||
if (fields.Contains(Field.Machine_SourceFile))
|
||||
if (fields.Contains(MachineField.SourceFile))
|
||||
SourceFile = machine.SourceFile;
|
||||
|
||||
if (fields.Contains(Field.Machine_Runnable))
|
||||
if (fields.Contains(MachineField.Runnable))
|
||||
Runnable = machine.Runnable;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Logiqx
|
||||
|
||||
if (fields.Contains(Field.Machine_Board))
|
||||
if (fields.Contains(MachineField.Board))
|
||||
Board = machine.Board;
|
||||
|
||||
if (fields.Contains(Field.Machine_RebuildTo))
|
||||
if (fields.Contains(MachineField.RebuildTo))
|
||||
RebuildTo = machine.RebuildTo;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Logiqx EmuArc
|
||||
|
||||
if (fields.Contains(Field.Machine_TitleID))
|
||||
if (fields.Contains(MachineField.TitleID))
|
||||
TitleID = machine.TitleID;
|
||||
|
||||
if (fields.Contains(Field.Machine_Developer))
|
||||
if (fields.Contains(MachineField.Developer))
|
||||
Developer = machine.Developer;
|
||||
|
||||
if (fields.Contains(Field.Machine_Genre))
|
||||
if (fields.Contains(MachineField.Genre))
|
||||
Genre = machine.Genre;
|
||||
|
||||
if (fields.Contains(Field.Machine_Subgenre))
|
||||
if (fields.Contains(MachineField.Subgenre))
|
||||
Subgenre = machine.Subgenre;
|
||||
|
||||
if (fields.Contains(Field.Machine_Ratings))
|
||||
if (fields.Contains(MachineField.Ratings))
|
||||
Ratings = machine.Ratings;
|
||||
|
||||
if (fields.Contains(Field.Machine_Score))
|
||||
if (fields.Contains(MachineField.Score))
|
||||
Score = machine.Score;
|
||||
|
||||
if (fields.Contains(Field.Machine_Enabled))
|
||||
if (fields.Contains(MachineField.Enabled))
|
||||
Enabled = machine.Enabled;
|
||||
|
||||
if (fields.Contains(Field.Machine_CRC))
|
||||
if (fields.Contains(MachineField.CRC))
|
||||
Crc = machine.Crc;
|
||||
|
||||
if (fields.Contains(Field.Machine_RelatedTo))
|
||||
if (fields.Contains(MachineField.RelatedTo))
|
||||
RelatedTo = machine.RelatedTo;
|
||||
|
||||
#endregion
|
||||
|
||||
#region OpenMSX
|
||||
|
||||
if (fields.Contains(Field.Machine_GenMSXID))
|
||||
if (fields.Contains(MachineField.GenMSXID))
|
||||
GenMSXID = machine.GenMSXID;
|
||||
|
||||
if (fields.Contains(Field.Machine_System))
|
||||
if (fields.Contains(MachineField.System))
|
||||
System = machine.System;
|
||||
|
||||
if (fields.Contains(Field.Machine_Country))
|
||||
if (fields.Contains(MachineField.Country))
|
||||
Country = machine.Country;
|
||||
|
||||
#endregion
|
||||
|
||||
#region SoftwareList
|
||||
|
||||
if (fields.Contains(Field.Machine_Supported))
|
||||
if (fields.Contains(MachineField.Supported))
|
||||
Supported = machine.Supported;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -93,30 +93,29 @@ namespace SabreTools.DatItems
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="mappings">Mappings dictionary</param>
|
||||
public override void SetFields(Dictionary<Field, string> mappings)
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
Dictionary<MachineField, string> machineMappings)
|
||||
{
|
||||
// Set base fields
|
||||
base.SetFields(mappings);
|
||||
base.SetFields(datItemMappings, machineMappings);
|
||||
|
||||
// Handle Media-specific fields
|
||||
if (mappings.Keys.Contains(Field.DatItem_Name))
|
||||
Name = mappings[Field.DatItem_Name];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Name))
|
||||
Name = datItemMappings[DatItemField.Name];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_MD5))
|
||||
MD5 = mappings[Field.DatItem_MD5];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.MD5))
|
||||
MD5 = datItemMappings[DatItemField.MD5];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_SHA1))
|
||||
SHA1 = mappings[Field.DatItem_SHA1];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.SHA1))
|
||||
SHA1 = datItemMappings[DatItemField.SHA1];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_SHA256))
|
||||
SHA256 = mappings[Field.DatItem_SHA256];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.SHA256))
|
||||
SHA256 = datItemMappings[DatItemField.SHA256];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_SpamSum))
|
||||
SpamSum = mappings[Field.DatItem_SpamSum];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.SpamSum))
|
||||
SpamSum = datItemMappings[DatItemField.SpamSum];
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -349,64 +348,58 @@ namespace SabreTools.DatItems
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check to see if a DatItem passes the filter
|
||||
/// </summary>
|
||||
/// <param name="filter">Filter to check against</param>
|
||||
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
||||
/// <returns>True if the item passed the filter, false otherwise</returns>
|
||||
public override bool PassesFilter(Filter filter, bool sub = false)
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
// Check common fields first
|
||||
if (!base.PassesFilter(filter, sub))
|
||||
if (!base.PassesFilter(cleaner, sub))
|
||||
return false;
|
||||
|
||||
// Filter on item name
|
||||
if (!filter.PassStringFilter(filter.DatItem_Name, Name))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Name, Name))
|
||||
return false;
|
||||
|
||||
// Filter on MD5
|
||||
if (!filter.PassStringFilter(filter.DatItem_MD5, MD5))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.MD5, MD5))
|
||||
return false;
|
||||
|
||||
// Filter on SHA-1
|
||||
if (!filter.PassStringFilter(filter.DatItem_SHA1, SHA1))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.SHA1, SHA1))
|
||||
return false;
|
||||
|
||||
// Filter on SHA-256
|
||||
if (!filter.PassStringFilter(filter.DatItem_SHA256, SHA256))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.SHA256, SHA256))
|
||||
return false;
|
||||
|
||||
// Filter on SpamSum
|
||||
if (!filter.PassStringFilter(filter.DatItem_SpamSum, SpamSum))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.SpamSum, SpamSum))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove fields from the DatItem
|
||||
/// </summary>
|
||||
/// <param name="fields">List of Fields to remove</param>
|
||||
public override void RemoveFields(List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void RemoveFields(
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Remove common fields first
|
||||
base.RemoveFields(fields);
|
||||
base.RemoveFields(datItemFields, machineFields);
|
||||
|
||||
// Remove the fields
|
||||
if (fields.Contains(Field.DatItem_Name))
|
||||
if (datItemFields.Contains(DatItemField.Name))
|
||||
Name = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_MD5))
|
||||
if (datItemFields.Contains(DatItemField.MD5))
|
||||
MD5 = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_SHA1))
|
||||
if (datItemFields.Contains(DatItemField.SHA1))
|
||||
SHA1 = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_SHA256))
|
||||
if (datItemFields.Contains(DatItemField.SHA256))
|
||||
SHA256 = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_SpamSum))
|
||||
if (datItemFields.Contains(DatItemField.SpamSum))
|
||||
SpamSum = null;
|
||||
}
|
||||
|
||||
@@ -467,15 +460,14 @@ namespace SabreTools.DatItems
|
||||
return key;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Replace fields from another item
|
||||
/// </summary>
|
||||
/// <param name="item">DatItem to pull new information from</param>
|
||||
/// <param name="fields">List of Fields representing what should be updated</param>
|
||||
public override void ReplaceFields(DatItem item, List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void ReplaceFields(
|
||||
DatItem item,
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Replace common fields first
|
||||
base.ReplaceFields(item, fields);
|
||||
base.ReplaceFields(item, datItemFields, machineFields);
|
||||
|
||||
// If we don't have a Media to replace from, ignore specific fields
|
||||
if (item.ItemType != ItemType.Media)
|
||||
@@ -485,28 +477,28 @@ namespace SabreTools.DatItems
|
||||
Media newItem = item as Media;
|
||||
|
||||
// Replace the fields
|
||||
if (fields.Contains(Field.DatItem_Name))
|
||||
if (datItemFields.Contains(DatItemField.Name))
|
||||
Name = newItem.Name;
|
||||
|
||||
if (fields.Contains(Field.DatItem_MD5))
|
||||
if (datItemFields.Contains(DatItemField.MD5))
|
||||
{
|
||||
if (string.IsNullOrEmpty(MD5) && !string.IsNullOrEmpty(newItem.MD5))
|
||||
MD5 = newItem.MD5;
|
||||
}
|
||||
|
||||
if (fields.Contains(Field.DatItem_SHA1))
|
||||
if (datItemFields.Contains(DatItemField.SHA1))
|
||||
{
|
||||
if (string.IsNullOrEmpty(SHA1) && !string.IsNullOrEmpty(newItem.SHA1))
|
||||
SHA1 = newItem.SHA1;
|
||||
}
|
||||
|
||||
if (fields.Contains(Field.DatItem_SHA256))
|
||||
if (datItemFields.Contains(DatItemField.SHA256))
|
||||
{
|
||||
if (string.IsNullOrEmpty(SHA256) && !string.IsNullOrEmpty(newItem.SHA256))
|
||||
SHA256 = newItem.SHA256;
|
||||
}
|
||||
|
||||
if (fields.Contains(Field.DatItem_SpamSum))
|
||||
if (datItemFields.Contains(DatItemField.SpamSum))
|
||||
{
|
||||
if (string.IsNullOrEmpty(SpamSum) && !string.IsNullOrEmpty(newItem.SpamSum))
|
||||
SpamSum = newItem.SpamSum;
|
||||
|
||||
@@ -47,28 +47,27 @@ namespace SabreTools.DatItems
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="mappings">Mappings dictionary</param>
|
||||
public override void SetFields(Dictionary<Field, string> mappings)
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
Dictionary<MachineField, string> machineMappings)
|
||||
{
|
||||
// Set base fields
|
||||
base.SetFields(mappings);
|
||||
base.SetFields(datItemMappings, machineMappings);
|
||||
|
||||
// Handle Part-specific fields
|
||||
if (mappings.Keys.Contains(Field.DatItem_Part_Name))
|
||||
Name = mappings[Field.DatItem_Part_Name];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Part_Name))
|
||||
Name = datItemMappings[DatItemField.Part_Name];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Part_Interface))
|
||||
Interface = mappings[Field.DatItem_Part_Interface];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Part_Interface))
|
||||
Interface = datItemMappings[DatItemField.Part_Interface];
|
||||
|
||||
// Handle Feature-specific fields
|
||||
if (FeaturesSpecified)
|
||||
{
|
||||
foreach (PartFeature partFeature in Features)
|
||||
{
|
||||
partFeature.SetFields(mappings);
|
||||
partFeature.SetFields(datItemMappings, machineMappings);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -169,24 +168,19 @@ namespace SabreTools.DatItems
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check to see if a DatItem passes the filter
|
||||
/// </summary>
|
||||
/// <param name="filter">Filter to check against</param>
|
||||
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
||||
/// <returns>True if the item passed the filter, false otherwise</returns>
|
||||
public override bool PassesFilter(Filter filter, bool sub = false)
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
// Check common fields first
|
||||
if (!base.PassesFilter(filter, sub))
|
||||
if (!base.PassesFilter(cleaner, sub))
|
||||
return false;
|
||||
|
||||
// Filter on part name
|
||||
if (!filter.PassStringFilter(filter.DatItem_Part_Name, Name))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Part_Name, Name))
|
||||
return false;
|
||||
|
||||
// Filter on part interface
|
||||
if (!filter.PassStringFilter(filter.DatItem_Part_Interface, Interface))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Part_Interface, Interface))
|
||||
return false;
|
||||
|
||||
// Filter on features
|
||||
@@ -194,7 +188,7 @@ namespace SabreTools.DatItems
|
||||
{
|
||||
foreach (PartFeature partFeature in Features)
|
||||
{
|
||||
if (!partFeature.PassesFilter(filter, true))
|
||||
if (!partFeature.PassesFilter(cleaner, true))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -202,27 +196,26 @@ namespace SabreTools.DatItems
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove fields from the DatItem
|
||||
/// </summary>
|
||||
/// <param name="fields">List of Fields to remove</param>
|
||||
public override void RemoveFields(List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void RemoveFields(
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Remove common fields first
|
||||
base.RemoveFields(fields);
|
||||
base.RemoveFields(datItemFields, machineFields);
|
||||
|
||||
// Remove the fields
|
||||
if (fields.Contains(Field.DatItem_Part_Name))
|
||||
if (datItemFields.Contains(DatItemField.Part_Name))
|
||||
Name = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Part_Interface))
|
||||
if (datItemFields.Contains(DatItemField.Part_Interface))
|
||||
Interface = null;
|
||||
|
||||
if (FeaturesSpecified)
|
||||
{
|
||||
foreach (PartFeature partFeature in Features)
|
||||
{
|
||||
partFeature.RemoveFields(fields);
|
||||
partFeature.RemoveFields(datItemFields, machineFields);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -241,15 +234,14 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Sorting and Merging
|
||||
|
||||
/// <summary>
|
||||
/// Replace fields from another item
|
||||
/// </summary>
|
||||
/// <param name="item">DatItem to pull new information from</param>
|
||||
/// <param name="fields">List of Fields representing what should be updated</param>
|
||||
public override void ReplaceFields(DatItem item, List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void ReplaceFields(
|
||||
DatItem item,
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Replace common fields first
|
||||
base.ReplaceFields(item, fields);
|
||||
base.ReplaceFields(item, datItemFields, machineFields);
|
||||
|
||||
// If we don't have a Part to replace from, ignore specific fields
|
||||
if (item.ItemType != ItemType.Part)
|
||||
@@ -259,10 +251,10 @@ namespace SabreTools.DatItems
|
||||
Part newItem = item as Part;
|
||||
|
||||
// Replace the fields
|
||||
if (fields.Contains(Field.DatItem_Part_Name))
|
||||
if (datItemFields.Contains(DatItemField.Part_Name))
|
||||
Name = newItem.Name;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Part_Interface))
|
||||
if (datItemFields.Contains(DatItemField.Part_Interface))
|
||||
Interface = newItem.Interface;
|
||||
|
||||
// DatItem_Part_Feature_* doesn't make sense here
|
||||
|
||||
@@ -44,21 +44,20 @@ namespace SabreTools.DatItems
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="mappings">Mappings dictionary</param>
|
||||
public override void SetFields(Dictionary<Field, string> mappings)
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
Dictionary<MachineField, string> machineMappings)
|
||||
{
|
||||
// Set base fields
|
||||
base.SetFields(mappings);
|
||||
base.SetFields(datItemMappings, machineMappings);
|
||||
|
||||
// Handle PartFeature-specific fields
|
||||
if (mappings.Keys.Contains(Field.DatItem_Part_Feature_Name))
|
||||
Name = mappings[Field.DatItem_Part_Feature_Name];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Part_Feature_Name))
|
||||
Name = datItemMappings[DatItemField.Part_Feature_Name];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Part_Feature_Value))
|
||||
Value = mappings[Field.DatItem_Part_Feature_Value];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Part_Feature_Value))
|
||||
Value = datItemMappings[DatItemField.Part_Feature_Value];
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -142,43 +141,37 @@ namespace SabreTools.DatItems
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check to see if a DatItem passes the filter
|
||||
/// </summary>
|
||||
/// <param name="filter">Filter to check against</param>
|
||||
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
||||
/// <returns>True if the item passed the filter, false otherwise</returns>
|
||||
public override bool PassesFilter(Filter filter, bool sub = false)
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
// Check common fields first
|
||||
if (!base.PassesFilter(filter, sub))
|
||||
if (!base.PassesFilter(cleaner, sub))
|
||||
return false;
|
||||
|
||||
// Filter on name
|
||||
if (!filter.PassStringFilter(filter.DatItem_Part_Feature_Name, Name))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Part_Feature_Name, Name))
|
||||
return false;
|
||||
|
||||
// Filter on value
|
||||
if (!filter.PassStringFilter(filter.DatItem_Part_Feature_Value, Value))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Part_Feature_Value, Value))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove fields from the DatItem
|
||||
/// </summary>
|
||||
/// <param name="fields">List of Fields to remove</param>
|
||||
public override void RemoveFields(List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void RemoveFields(
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Remove common fields first
|
||||
base.RemoveFields(fields);
|
||||
base.RemoveFields(datItemFields, machineFields);
|
||||
|
||||
// Remove the fields
|
||||
if (fields.Contains(Field.DatItem_Part_Feature_Name))
|
||||
if (datItemFields.Contains(DatItemField.Part_Feature_Name))
|
||||
Name = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Part_Feature_Value))
|
||||
if (datItemFields.Contains(DatItemField.Part_Feature_Value))
|
||||
Value = null;
|
||||
}
|
||||
|
||||
@@ -196,15 +189,14 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Sorting and Merging
|
||||
|
||||
/// <summary>
|
||||
/// Replace fields from another item
|
||||
/// </summary>
|
||||
/// <param name="item">DatItem to pull new information from</param>
|
||||
/// <param name="fields">List of Fields representing what should be updated</param>
|
||||
public override void ReplaceFields(DatItem item, List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void ReplaceFields(
|
||||
DatItem item,
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Replace common fields first
|
||||
base.ReplaceFields(item, fields);
|
||||
base.ReplaceFields(item, datItemFields, machineFields);
|
||||
|
||||
// If we don't have a PartFeature to replace from, ignore specific fields
|
||||
if (item.ItemType != ItemType.PartFeature)
|
||||
@@ -214,10 +206,10 @@ namespace SabreTools.DatItems
|
||||
PartFeature newItem = item as PartFeature;
|
||||
|
||||
// Replace the fields
|
||||
if (fields.Contains(Field.DatItem_Part_Feature_Name))
|
||||
if (datItemFields.Contains(DatItemField.Part_Feature_Name))
|
||||
Name = newItem.Name;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Part_Feature_Value))
|
||||
if (datItemFields.Contains(DatItemField.Part_Feature_Value))
|
||||
Value = newItem.Value;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,24 +37,23 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="mappings">Mappings dictionary</param>
|
||||
public override void SetFields(Dictionary<Field, string> mappings)
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
Dictionary<MachineField, string> machineMappings)
|
||||
{
|
||||
// Set base fields
|
||||
base.SetFields(mappings);
|
||||
base.SetFields(datItemMappings, machineMappings);
|
||||
|
||||
// Handle Port-specific fields
|
||||
if (mappings.Keys.Contains(Field.DatItem_Tag))
|
||||
Tag = mappings[Field.DatItem_Tag];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Tag))
|
||||
Tag = datItemMappings[DatItemField.Tag];
|
||||
|
||||
if (AnalogsSpecified)
|
||||
{
|
||||
foreach (Analog analog in Analogs)
|
||||
{
|
||||
analog.SetFields(mappings);
|
||||
analog.SetFields(datItemMappings, machineMappings);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -125,20 +124,15 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Filtering
|
||||
|
||||
/// <summary>
|
||||
/// Check to see if a DatItem passes the filter
|
||||
/// </summary>
|
||||
/// <param name="filter">Filter to check against</param>
|
||||
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
||||
/// <returns>True if the item passed the filter, false otherwise</returns>
|
||||
public override bool PassesFilter(Filter filter, bool sub = false)
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
// Check common fields first
|
||||
if (!base.PassesFilter(filter, sub))
|
||||
if (!base.PassesFilter(cleaner, sub))
|
||||
return false;
|
||||
|
||||
// Filter on tag
|
||||
if (!filter.PassStringFilter(filter.DatItem_Tag, Tag))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Tag, Tag))
|
||||
return false;
|
||||
|
||||
// Filter on individual analogs
|
||||
@@ -146,7 +140,7 @@ namespace SabreTools.DatItems
|
||||
{
|
||||
foreach (Analog analog in Analogs)
|
||||
{
|
||||
if (!analog.PassesFilter(filter, true))
|
||||
if (!analog.PassesFilter(cleaner, true))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -154,24 +148,23 @@ namespace SabreTools.DatItems
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove fields from the DatItem
|
||||
/// </summary>
|
||||
/// <param name="fields">List of Fields to remove</param>
|
||||
public override void RemoveFields(List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void RemoveFields(
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Remove common fields first
|
||||
base.RemoveFields(fields);
|
||||
base.RemoveFields(datItemFields, machineFields);
|
||||
|
||||
// Remove the fields
|
||||
if (fields.Contains(Field.DatItem_Tag))
|
||||
if (datItemFields.Contains(DatItemField.Tag))
|
||||
Tag = null;
|
||||
|
||||
if (AnalogsSpecified)
|
||||
{
|
||||
foreach (Analog analog in Analogs)
|
||||
{
|
||||
analog.RemoveFields(fields);
|
||||
analog.RemoveFields(datItemFields, machineFields);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -180,15 +173,14 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Sorting and Merging
|
||||
|
||||
/// <summary>
|
||||
/// Replace fields from another item
|
||||
/// </summary>
|
||||
/// <param name="item">DatItem to pull new information from</param>
|
||||
/// <param name="fields">List of Fields representing what should be updated</param>
|
||||
public override void ReplaceFields(DatItem item, List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void ReplaceFields(
|
||||
DatItem item,
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Replace common fields first
|
||||
base.ReplaceFields(item, fields);
|
||||
base.ReplaceFields(item, datItemFields, machineFields);
|
||||
|
||||
// If we don't have a Port to replace from, ignore specific fields
|
||||
if (item.ItemType != ItemType.Port)
|
||||
@@ -198,7 +190,7 @@ namespace SabreTools.DatItems
|
||||
Port newItem = item as Port;
|
||||
|
||||
// Replace the fields
|
||||
if (fields.Contains(Field.DatItem_Name))
|
||||
if (datItemFields.Contains(DatItemField.Name))
|
||||
Tag = newItem.Tag;
|
||||
|
||||
// DatItem_Analog_* doesn't make sense here
|
||||
|
||||
@@ -55,24 +55,23 @@ namespace SabreTools.DatItems
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="mappings">Mappings dictionary</param>
|
||||
public override void SetFields(Dictionary<Field, string> mappings)
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
Dictionary<MachineField, string> machineMappings)
|
||||
{
|
||||
// Set base fields
|
||||
base.SetFields(mappings);
|
||||
base.SetFields(datItemMappings, machineMappings);
|
||||
|
||||
// Handle BiosSet-specific fields
|
||||
if (mappings.Keys.Contains(Field.DatItem_Name))
|
||||
Name = mappings[Field.DatItem_Name];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Name))
|
||||
Name = datItemMappings[DatItemField.Name];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Default))
|
||||
Default = mappings[Field.DatItem_Default].AsYesNo();
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Default))
|
||||
Default = datItemMappings[DatItemField.Default].AsYesNo();
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Content))
|
||||
Content = mappings[Field.DatItem_Content];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Content))
|
||||
Content = datItemMappings[DatItemField.Content];
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -157,50 +156,44 @@ namespace SabreTools.DatItems
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check to see if a DatItem passes the filter
|
||||
/// </summary>
|
||||
/// <param name="filter">Filter to check against</param>
|
||||
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
||||
/// <returns>True if the item passed the filter, false otherwise</returns>
|
||||
public override bool PassesFilter(Filter filter, bool sub = false)
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
// Check common fields first
|
||||
if (!base.PassesFilter(filter, sub))
|
||||
if (!base.PassesFilter(cleaner, sub))
|
||||
return false;
|
||||
|
||||
// Filter on item name
|
||||
if (!filter.PassStringFilter(filter.DatItem_Name, Name))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Name, Name))
|
||||
return false;
|
||||
|
||||
// Filter on default
|
||||
if (!filter.PassBoolFilter(filter.DatItem_Default, Default))
|
||||
if (!Filter.PassBoolFilter(cleaner.DatItemFilter.Default, Default))
|
||||
return false;
|
||||
|
||||
// Filter on content
|
||||
if (!filter.PassStringFilter(filter.DatItem_Content, Content))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Content, Content))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove fields from the DatItem
|
||||
/// </summary>
|
||||
/// <param name="fields">List of Fields to remove</param>
|
||||
public override void RemoveFields(List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void RemoveFields(
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Remove common fields first
|
||||
base.RemoveFields(fields);
|
||||
base.RemoveFields(datItemFields, machineFields);
|
||||
|
||||
// Remove the fields
|
||||
if (fields.Contains(Field.DatItem_Name))
|
||||
if (datItemFields.Contains(DatItemField.Name))
|
||||
Name = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Default))
|
||||
if (datItemFields.Contains(DatItemField.Default))
|
||||
Default = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Content))
|
||||
if (datItemFields.Contains(DatItemField.Content))
|
||||
Content = null;
|
||||
}
|
||||
|
||||
@@ -218,15 +211,14 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Sorting and Merging
|
||||
|
||||
/// <summary>
|
||||
/// Replace fields from another item
|
||||
/// </summary>
|
||||
/// <param name="item">DatItem to pull new information from</param>
|
||||
/// <param name="fields">List of Fields representing what should be updated</param>
|
||||
public override void ReplaceFields(DatItem item, List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void ReplaceFields(
|
||||
DatItem item,
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Replace common fields first
|
||||
base.ReplaceFields(item, fields);
|
||||
base.ReplaceFields(item, datItemFields, machineFields);
|
||||
|
||||
// If we don't have a RamOption to replace from, ignore specific fields
|
||||
if (item.ItemType != ItemType.RamOption)
|
||||
@@ -236,13 +228,13 @@ namespace SabreTools.DatItems
|
||||
RamOption newItem = item as RamOption;
|
||||
|
||||
// Replace the fields
|
||||
if (fields.Contains(Field.DatItem_Name))
|
||||
if (datItemFields.Contains(DatItemField.Name))
|
||||
Name = newItem.Name;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Default))
|
||||
if (datItemFields.Contains(DatItemField.Default))
|
||||
Default = newItem.Default;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Content))
|
||||
if (datItemFields.Contains(DatItemField.Content))
|
||||
Content = newItem.Content;
|
||||
}
|
||||
|
||||
|
||||
@@ -69,30 +69,29 @@ namespace SabreTools.DatItems
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="mappings">Mappings dictionary</param>
|
||||
public override void SetFields(Dictionary<Field, string> mappings)
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
Dictionary<MachineField, string> machineMappings)
|
||||
{
|
||||
// Set base fields
|
||||
base.SetFields(mappings);
|
||||
base.SetFields(datItemMappings, machineMappings);
|
||||
|
||||
// Handle Release-specific fields
|
||||
if (mappings.Keys.Contains(Field.DatItem_Name))
|
||||
Name = mappings[Field.DatItem_Name];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Name))
|
||||
Name = datItemMappings[DatItemField.Name];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Region))
|
||||
Region = mappings[Field.DatItem_Region];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Region))
|
||||
Region = datItemMappings[DatItemField.Region];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Language))
|
||||
Language = mappings[Field.DatItem_Language];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Language))
|
||||
Language = datItemMappings[DatItemField.Language];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Date))
|
||||
Date = mappings[Field.DatItem_Date];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Date))
|
||||
Date = datItemMappings[DatItemField.Date];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Default))
|
||||
Default = mappings[Field.DatItem_Default].AsYesNo();
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Default))
|
||||
Default = datItemMappings[DatItemField.Default].AsYesNo();
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -187,64 +186,58 @@ namespace SabreTools.DatItems
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check to see if a DatItem passes the filter
|
||||
/// </summary>
|
||||
/// <param name="filter">Filter to check against</param>
|
||||
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
||||
/// <returns>True if the item passed the filter, false otherwise</returns>
|
||||
public override bool PassesFilter(Filter filter, bool sub = false)
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
// Check common fields first
|
||||
if (!base.PassesFilter(filter, sub))
|
||||
if (!base.PassesFilter(cleaner, sub))
|
||||
return false;
|
||||
|
||||
// Filter on item name
|
||||
if (!filter.PassStringFilter(filter.DatItem_Name, Name))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Name, Name))
|
||||
return false;
|
||||
|
||||
// Filter on region
|
||||
if (!filter.PassStringFilter(filter.DatItem_Region, Region))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Region, Region))
|
||||
return false;
|
||||
|
||||
// Filter on language
|
||||
if (!filter.PassStringFilter(filter.DatItem_Language, Language))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Language, Language))
|
||||
return false;
|
||||
|
||||
// Filter on date
|
||||
if (!filter.PassStringFilter(filter.DatItem_Date, Date))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Date, Date))
|
||||
return false;
|
||||
|
||||
// Filter on default
|
||||
if (!filter.PassBoolFilter(filter.DatItem_Default, Default))
|
||||
if (!Filter.PassBoolFilter(cleaner.DatItemFilter.Default, Default))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove fields from the DatItem
|
||||
/// </summary>
|
||||
/// <param name="fields">List of Fields to remove</param>
|
||||
public override void RemoveFields(List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void RemoveFields(
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Remove common fields first
|
||||
base.RemoveFields(fields);
|
||||
base.RemoveFields(datItemFields, machineFields);
|
||||
|
||||
// Remove the fields
|
||||
if (fields.Contains(Field.DatItem_Name))
|
||||
if (datItemFields.Contains(DatItemField.Name))
|
||||
Name = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Region))
|
||||
if (datItemFields.Contains(DatItemField.Region))
|
||||
Region = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Language))
|
||||
if (datItemFields.Contains(DatItemField.Language))
|
||||
Language = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Date))
|
||||
if (datItemFields.Contains(DatItemField.Date))
|
||||
Date = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Default))
|
||||
if (datItemFields.Contains(DatItemField.Default))
|
||||
Default = null;
|
||||
}
|
||||
|
||||
@@ -262,15 +255,14 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Sorting and Merging
|
||||
|
||||
/// <summary>
|
||||
/// Replace fields from another item
|
||||
/// </summary>
|
||||
/// <param name="item">DatItem to pull new information from</param>
|
||||
/// <param name="fields">List of Fields representing what should be updated</param>
|
||||
public override void ReplaceFields(DatItem item, List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void ReplaceFields(
|
||||
DatItem item,
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Replace common fields first
|
||||
base.ReplaceFields(item, fields);
|
||||
base.ReplaceFields(item, datItemFields, machineFields);
|
||||
|
||||
// If we don't have a Release to replace from, ignore specific fields
|
||||
if (item.ItemType != ItemType.Release)
|
||||
@@ -280,19 +272,19 @@ namespace SabreTools.DatItems
|
||||
Release newItem = item as Release;
|
||||
|
||||
// Replace the fields
|
||||
if (fields.Contains(Field.DatItem_Name))
|
||||
if (datItemFields.Contains(DatItemField.Name))
|
||||
Name = newItem.Name;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Region))
|
||||
if (datItemFields.Contains(DatItemField.Region))
|
||||
Region = newItem.Region;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Language))
|
||||
if (datItemFields.Contains(DatItemField.Language))
|
||||
Language = newItem.Language;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Date))
|
||||
if (datItemFields.Contains(DatItemField.Date))
|
||||
Date = newItem.Date;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Default))
|
||||
if (datItemFields.Contains(DatItemField.Default))
|
||||
Default = newItem.Default;
|
||||
}
|
||||
|
||||
|
||||
@@ -352,125 +352,124 @@ namespace SabreTools.DatItems
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="mappings">Mappings dictionary</param>
|
||||
public override void SetFields(Dictionary<Field, string> mappings)
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
Dictionary<MachineField, string> machineMappings)
|
||||
{
|
||||
// Set base fields
|
||||
base.SetFields(mappings);
|
||||
base.SetFields(datItemMappings, machineMappings);
|
||||
|
||||
// Handle Rom-specific fields
|
||||
|
||||
#region Common
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Name))
|
||||
Name = mappings[Field.DatItem_Name];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Name))
|
||||
Name = datItemMappings[DatItemField.Name];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Bios))
|
||||
Bios = mappings[Field.DatItem_Bios];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Bios))
|
||||
Bios = datItemMappings[DatItemField.Bios];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Size))
|
||||
Size = Utilities.CleanLong(mappings[Field.DatItem_Size]);
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Size))
|
||||
Size = Utilities.CleanLong(datItemMappings[DatItemField.Size]);
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_CRC))
|
||||
CRC = mappings[Field.DatItem_CRC];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.CRC))
|
||||
CRC = datItemMappings[DatItemField.CRC];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_MD5))
|
||||
MD5 = mappings[Field.DatItem_MD5];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.MD5))
|
||||
MD5 = datItemMappings[DatItemField.MD5];
|
||||
|
||||
#if NET_FRAMEWORK
|
||||
if (mappings.Keys.Contains(Field.DatItem_RIPEMD160))
|
||||
RIPEMD160 = mappings[Field.DatItem_RIPEMD160];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.RIPEMD160))
|
||||
RIPEMD160 = datItemMappings[DatItemField.RIPEMD160];
|
||||
#endif
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_SHA1))
|
||||
SHA1 = mappings[Field.DatItem_SHA1];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.SHA1))
|
||||
SHA1 = datItemMappings[DatItemField.SHA1];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_SHA256))
|
||||
SHA256 = mappings[Field.DatItem_SHA256];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.SHA256))
|
||||
SHA256 = datItemMappings[DatItemField.SHA256];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_SHA384))
|
||||
SHA384 = mappings[Field.DatItem_SHA384];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.SHA384))
|
||||
SHA384 = datItemMappings[DatItemField.SHA384];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_SHA512))
|
||||
SHA512 = mappings[Field.DatItem_SHA512];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.SHA512))
|
||||
SHA512 = datItemMappings[DatItemField.SHA512];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_SpamSum))
|
||||
SpamSum = mappings[Field.DatItem_SpamSum];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.SpamSum))
|
||||
SpamSum = datItemMappings[DatItemField.SpamSum];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Merge))
|
||||
MergeTag = mappings[Field.DatItem_Merge];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Merge))
|
||||
MergeTag = datItemMappings[DatItemField.Merge];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Region))
|
||||
Region = mappings[Field.DatItem_Region];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Region))
|
||||
Region = datItemMappings[DatItemField.Region];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Offset))
|
||||
Offset = mappings[Field.DatItem_Offset];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Offset))
|
||||
Offset = datItemMappings[DatItemField.Offset];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Date))
|
||||
Date = mappings[Field.DatItem_Date];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Date))
|
||||
Date = datItemMappings[DatItemField.Date];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Status))
|
||||
ItemStatus = mappings[Field.DatItem_Status].AsItemStatus();
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Status))
|
||||
ItemStatus = datItemMappings[DatItemField.Status].AsItemStatus();
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Optional))
|
||||
Optional = mappings[Field.DatItem_Optional].AsYesNo();
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Optional))
|
||||
Optional = datItemMappings[DatItemField.Optional].AsYesNo();
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Inverted))
|
||||
Inverted = mappings[Field.DatItem_Optional].AsYesNo();
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Inverted))
|
||||
Inverted = datItemMappings[DatItemField.Optional].AsYesNo();
|
||||
|
||||
#endregion
|
||||
|
||||
#region AttractMode
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_AltName))
|
||||
AltName = mappings[Field.DatItem_AltName];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.AltName))
|
||||
AltName = datItemMappings[DatItemField.AltName];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_AltTitle))
|
||||
AltTitle = mappings[Field.DatItem_AltTitle];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.AltTitle))
|
||||
AltTitle = datItemMappings[DatItemField.AltTitle];
|
||||
|
||||
#endregion
|
||||
|
||||
#region OpenMSX
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Original))
|
||||
Original = new Original() { Content = mappings[Field.DatItem_Original] };
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Original))
|
||||
Original = new Original() { Content = datItemMappings[DatItemField.Original] };
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_OpenMSXSubType))
|
||||
OpenMSXSubType = mappings[Field.DatItem_OpenMSXSubType].AsOpenMSXSubType();
|
||||
if (datItemMappings.Keys.Contains(DatItemField.OpenMSXSubType))
|
||||
OpenMSXSubType = datItemMappings[DatItemField.OpenMSXSubType].AsOpenMSXSubType();
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_OpenMSXType))
|
||||
OpenMSXType = mappings[Field.DatItem_OpenMSXType];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.OpenMSXType))
|
||||
OpenMSXType = datItemMappings[DatItemField.OpenMSXType];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Remark))
|
||||
Remark = mappings[Field.DatItem_Remark];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Remark))
|
||||
Remark = datItemMappings[DatItemField.Remark];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Boot))
|
||||
Boot = mappings[Field.DatItem_Boot];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Boot))
|
||||
Boot = datItemMappings[DatItemField.Boot];
|
||||
|
||||
#endregion
|
||||
|
||||
#region SoftwareList
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_LoadFlag))
|
||||
LoadFlag = mappings[Field.DatItem_LoadFlag].AsLoadFlag();
|
||||
if (datItemMappings.Keys.Contains(DatItemField.LoadFlag))
|
||||
LoadFlag = datItemMappings[DatItemField.LoadFlag].AsLoadFlag();
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Value))
|
||||
Value = mappings[Field.DatItem_Value];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Value))
|
||||
Value = datItemMappings[DatItemField.Value];
|
||||
|
||||
// Handle DataArea-specific fields
|
||||
if (DataArea == null)
|
||||
DataArea = new DataArea();
|
||||
|
||||
DataArea.SetFields(mappings);
|
||||
DataArea.SetFields(datItemMappings, machineMappings);
|
||||
|
||||
// Handle Part-specific fields
|
||||
if (Part == null)
|
||||
Part = new Part();
|
||||
|
||||
Part.SetFields(mappings);
|
||||
Part.SetFields(datItemMappings, machineMappings);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -823,94 +822,89 @@ namespace SabreTools.DatItems
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check to see if a DatItem passes the filter
|
||||
/// </summary>
|
||||
/// <param name="filter">Filter to check against</param>
|
||||
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
||||
/// <returns>True if the item passed the filter, false otherwise</returns>
|
||||
public override bool PassesFilter(Filter filter, bool sub = false)
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
// Check common fields first
|
||||
if (!base.PassesFilter(filter, sub))
|
||||
if (!base.PassesFilter(cleaner, sub))
|
||||
return false;
|
||||
|
||||
#region Common
|
||||
|
||||
// Filter on item name
|
||||
if (!filter.PassStringFilter(filter.DatItem_Name, Name))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Name, Name))
|
||||
return false;
|
||||
|
||||
// Filter on bios
|
||||
if (!filter.PassStringFilter(filter.DatItem_Bios, Bios))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Bios, Bios))
|
||||
return false;
|
||||
|
||||
// Filter on rom size
|
||||
if (!filter.PassLongFilter(filter.DatItem_Size, Size))
|
||||
if (!Filter.PassLongFilter(cleaner.DatItemFilter.Size, Size))
|
||||
return false;
|
||||
|
||||
// Filter on CRC
|
||||
if (!filter.PassStringFilter(filter.DatItem_CRC, CRC))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.CRC, CRC))
|
||||
return false;
|
||||
|
||||
// Filter on MD5
|
||||
if (!filter.PassStringFilter(filter.DatItem_MD5, MD5))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.MD5, MD5))
|
||||
return false;
|
||||
|
||||
#if NET_FRAMEWORK
|
||||
// Filter on RIPEMD160
|
||||
if (!filter.PassStringFilter(filter.DatItem_RIPEMD160, RIPEMD160))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.RIPEMD160, RIPEMD160))
|
||||
return false;
|
||||
#endif
|
||||
|
||||
// Filter on SHA-1
|
||||
if (!filter.PassStringFilter(filter.DatItem_SHA1, SHA1))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.SHA1, SHA1))
|
||||
return false;
|
||||
|
||||
// Filter on SHA-256
|
||||
if (!filter.PassStringFilter(filter.DatItem_SHA256, SHA256))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.SHA256, SHA256))
|
||||
return false;
|
||||
|
||||
// Filter on SHA-384
|
||||
if (!filter.PassStringFilter(filter.DatItem_SHA384, SHA384))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.SHA384, SHA384))
|
||||
return false;
|
||||
|
||||
// Filter on SHA-512
|
||||
if (!filter.PassStringFilter(filter.DatItem_SHA512, SHA512))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.SHA512, SHA512))
|
||||
return false;
|
||||
|
||||
// Filter on SpamSum
|
||||
if (!filter.PassStringFilter(filter.DatItem_SpamSum, SpamSum))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.SpamSum, SpamSum))
|
||||
return false;
|
||||
|
||||
// Filter on merge tag
|
||||
if (!filter.PassStringFilter(filter.DatItem_Merge, MergeTag))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Merge, MergeTag))
|
||||
return false;
|
||||
|
||||
// Filter on region
|
||||
if (!filter.PassStringFilter(filter.DatItem_Region, Region))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Region, Region))
|
||||
return false;
|
||||
|
||||
// Filter on offset
|
||||
if (!filter.PassStringFilter(filter.DatItem_Offset, Offset))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Offset, Offset))
|
||||
return false;
|
||||
|
||||
// Filter on date
|
||||
if (!filter.PassStringFilter(filter.DatItem_Date, Date))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Date, Date))
|
||||
return false;
|
||||
|
||||
// Filter on status
|
||||
if (filter.DatItem_Status.MatchesPositive(ItemStatus.NULL, ItemStatus) == false)
|
||||
if (cleaner.DatItemFilter.Status.MatchesPositive(ItemStatus.NULL, ItemStatus) == false)
|
||||
return false;
|
||||
if (filter.DatItem_Status.MatchesNegative(ItemStatus.NULL, ItemStatus) == true)
|
||||
if (cleaner.DatItemFilter.Status.MatchesNegative(ItemStatus.NULL, ItemStatus) == true)
|
||||
return false;
|
||||
|
||||
// Filter on optional
|
||||
if (!filter.PassBoolFilter(filter.DatItem_Optional, Optional))
|
||||
if (!Filter.PassBoolFilter(cleaner.DatItemFilter.Optional, Optional))
|
||||
return false;
|
||||
|
||||
// Filter on inverted
|
||||
if (!filter.PassBoolFilter(filter.DatItem_Inverted, Inverted))
|
||||
if (!Filter.PassBoolFilter(cleaner.DatItemFilter.Inverted, Inverted))
|
||||
return false;
|
||||
|
||||
#endregion
|
||||
@@ -918,11 +912,11 @@ namespace SabreTools.DatItems
|
||||
#region AttractMode
|
||||
|
||||
// Filter on alt name
|
||||
if (!filter.PassStringFilter(filter.DatItem_AltName, AltName))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.AltName, AltName))
|
||||
return false;
|
||||
|
||||
// Filter on alt title
|
||||
if (!filter.PassStringFilter(filter.DatItem_AltTitle, AltTitle))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.AltTitle, AltTitle))
|
||||
return false;
|
||||
|
||||
#endregion
|
||||
@@ -930,25 +924,25 @@ namespace SabreTools.DatItems
|
||||
#region OpenMSX
|
||||
|
||||
// Filter on original
|
||||
if (!filter.PassStringFilter(filter.DatItem_Original, Original?.Content))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Original, Original?.Content))
|
||||
return false;
|
||||
|
||||
// Filter on OpenMSX subtype
|
||||
if (filter.DatItem_OpenMSXSubType.MatchesPositive(OpenMSXSubType.NULL, OpenMSXSubType) == false)
|
||||
if (cleaner.DatItemFilter.OpenMSXSubType.MatchesPositive(OpenMSXSubType.NULL, OpenMSXSubType) == false)
|
||||
return false;
|
||||
if (filter.DatItem_OpenMSXSubType.MatchesNegative(OpenMSXSubType.NULL, OpenMSXSubType) == true)
|
||||
if (cleaner.DatItemFilter.OpenMSXSubType.MatchesNegative(OpenMSXSubType.NULL, OpenMSXSubType) == true)
|
||||
return false;
|
||||
|
||||
// Filter on OpenMSX type
|
||||
if (!filter.PassStringFilter(filter.DatItem_OpenMSXType, OpenMSXType))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.OpenMSXType, OpenMSXType))
|
||||
return false;
|
||||
|
||||
// Filter on remark
|
||||
if (!filter.PassStringFilter(filter.DatItem_Remark, Remark))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Remark, Remark))
|
||||
return false;
|
||||
|
||||
// Filter on boot
|
||||
if (!filter.PassStringFilter(filter.DatItem_Boot, Boot))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Boot, Boot))
|
||||
return false;
|
||||
|
||||
#endregion
|
||||
@@ -956,26 +950,26 @@ namespace SabreTools.DatItems
|
||||
#region SoftwareList
|
||||
|
||||
// Filter on load flag
|
||||
if (filter.DatItem_LoadFlag.MatchesPositive(LoadFlag.NULL, LoadFlag) == false)
|
||||
if (cleaner.DatItemFilter.LoadFlag.MatchesPositive(LoadFlag.NULL, LoadFlag) == false)
|
||||
return false;
|
||||
if (filter.DatItem_LoadFlag.MatchesNegative(LoadFlag.NULL, LoadFlag) == true)
|
||||
if (cleaner.DatItemFilter.LoadFlag.MatchesNegative(LoadFlag.NULL, LoadFlag) == true)
|
||||
return false;
|
||||
|
||||
// Filter on value
|
||||
if (!filter.PassStringFilter(filter.DatItem_Value, Value))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Value, Value))
|
||||
return false;
|
||||
|
||||
// Filter on DataArea
|
||||
if (DataAreaSpecified)
|
||||
{
|
||||
if (!DataArea.PassesFilter(filter, true))
|
||||
if (!DataArea.PassesFilter(cleaner, true))
|
||||
return false;
|
||||
}
|
||||
|
||||
// Filter on Part
|
||||
if (PartSpecified)
|
||||
{
|
||||
if (!Part.PassesFilter(filter, true))
|
||||
if (!Part.PassesFilter(cleaner, true))
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -984,119 +978,118 @@ namespace SabreTools.DatItems
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove fields from the DatItem
|
||||
/// </summary>
|
||||
/// <param name="fields">List of Fields to remove</param>
|
||||
public override void RemoveFields(List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void RemoveFields(
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Remove common fields first
|
||||
base.RemoveFields(fields);
|
||||
base.RemoveFields(datItemFields, machineFields);
|
||||
|
||||
// Remove the fields
|
||||
|
||||
#region Common
|
||||
|
||||
if (fields.Contains(Field.DatItem_Name))
|
||||
if (datItemFields.Contains(DatItemField.Name))
|
||||
Name = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Bios))
|
||||
if (datItemFields.Contains(DatItemField.Bios))
|
||||
Bios = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Size))
|
||||
if (datItemFields.Contains(DatItemField.Size))
|
||||
Size = 0;
|
||||
|
||||
if (fields.Contains(Field.DatItem_CRC))
|
||||
if (datItemFields.Contains(DatItemField.CRC))
|
||||
CRC = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_MD5))
|
||||
if (datItemFields.Contains(DatItemField.MD5))
|
||||
MD5 = null;
|
||||
|
||||
#if NET_FRAMEWORK
|
||||
if (fields.Contains(Field.DatItem_RIPEMD160))
|
||||
if (datItemFields.Contains(DatItemField.RIPEMD160))
|
||||
RIPEMD160 = null;
|
||||
#endif
|
||||
|
||||
if (fields.Contains(Field.DatItem_SHA1))
|
||||
if (datItemFields.Contains(DatItemField.SHA1))
|
||||
SHA1 = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_SHA256))
|
||||
if (datItemFields.Contains(DatItemField.SHA256))
|
||||
SHA256 = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_SHA384))
|
||||
if (datItemFields.Contains(DatItemField.SHA384))
|
||||
SHA384 = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_SHA512))
|
||||
if (datItemFields.Contains(DatItemField.SHA512))
|
||||
SHA512 = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_SpamSum))
|
||||
if (datItemFields.Contains(DatItemField.SpamSum))
|
||||
SpamSum = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Merge))
|
||||
if (datItemFields.Contains(DatItemField.Merge))
|
||||
MergeTag = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Region))
|
||||
if (datItemFields.Contains(DatItemField.Region))
|
||||
Region = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Offset))
|
||||
if (datItemFields.Contains(DatItemField.Offset))
|
||||
Offset = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Date))
|
||||
if (datItemFields.Contains(DatItemField.Date))
|
||||
Date = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Status))
|
||||
if (datItemFields.Contains(DatItemField.Status))
|
||||
ItemStatus = ItemStatus.NULL;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Optional))
|
||||
if (datItemFields.Contains(DatItemField.Optional))
|
||||
Optional = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Inverted))
|
||||
if (datItemFields.Contains(DatItemField.Inverted))
|
||||
Inverted = null;
|
||||
|
||||
#endregion
|
||||
|
||||
#region AttractMode
|
||||
|
||||
if (fields.Contains(Field.DatItem_AltName))
|
||||
if (datItemFields.Contains(DatItemField.AltName))
|
||||
AltName = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_AltTitle))
|
||||
if (datItemFields.Contains(DatItemField.AltTitle))
|
||||
AltTitle = null;
|
||||
|
||||
#endregion
|
||||
|
||||
#region OpenMSX
|
||||
|
||||
if (fields.Contains(Field.DatItem_Original))
|
||||
if (datItemFields.Contains(DatItemField.Original))
|
||||
Original = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_OpenMSXSubType))
|
||||
if (datItemFields.Contains(DatItemField.OpenMSXSubType))
|
||||
OpenMSXSubType = OpenMSXSubType.NULL;
|
||||
|
||||
if (fields.Contains(Field.DatItem_OpenMSXType))
|
||||
if (datItemFields.Contains(DatItemField.OpenMSXType))
|
||||
OpenMSXType = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Remark))
|
||||
if (datItemFields.Contains(DatItemField.Remark))
|
||||
Remark = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Boot))
|
||||
if (datItemFields.Contains(DatItemField.Boot))
|
||||
Boot = null;
|
||||
|
||||
#endregion
|
||||
|
||||
#region SoftwareList
|
||||
|
||||
if (fields.Contains(Field.DatItem_LoadFlag))
|
||||
if (datItemFields.Contains(DatItemField.LoadFlag))
|
||||
LoadFlag = LoadFlag.NULL;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Value))
|
||||
if (datItemFields.Contains(DatItemField.Value))
|
||||
Value = null;
|
||||
|
||||
if (DataAreaSpecified)
|
||||
DataArea.RemoveFields(fields);
|
||||
DataArea.RemoveFields(datItemFields, machineFields);
|
||||
|
||||
if (PartSpecified)
|
||||
Part.RemoveFields(fields);
|
||||
Part.RemoveFields(datItemFields, machineFields);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -1176,15 +1169,14 @@ namespace SabreTools.DatItems
|
||||
return key;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Replace fields from another item
|
||||
/// </summary>
|
||||
/// <param name="item">DatItem to pull new information from</param>
|
||||
/// <param name="fields">List of Fields representing what should be updated</param>
|
||||
public override void ReplaceFields(DatItem item, List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void ReplaceFields(
|
||||
DatItem item,
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Replace common fields first
|
||||
base.ReplaceFields(item, fields);
|
||||
base.ReplaceFields(item, datItemFields, machineFields);
|
||||
|
||||
// If we don't have a Rom to replace from, ignore specific fields
|
||||
if (item.ItemType != ItemType.Rom)
|
||||
@@ -1197,130 +1189,130 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Common
|
||||
|
||||
if (fields.Contains(Field.DatItem_Name))
|
||||
if (datItemFields.Contains(DatItemField.Name))
|
||||
Name = newItem.Name;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Bios))
|
||||
if (datItemFields.Contains(DatItemField.Bios))
|
||||
Bios = newItem.Bios;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Size))
|
||||
if (datItemFields.Contains(DatItemField.Size))
|
||||
Size = newItem.Size;
|
||||
|
||||
if (fields.Contains(Field.DatItem_CRC))
|
||||
if (datItemFields.Contains(DatItemField.CRC))
|
||||
{
|
||||
if (string.IsNullOrEmpty(CRC) && !string.IsNullOrEmpty(newItem.CRC))
|
||||
CRC = newItem.CRC;
|
||||
}
|
||||
|
||||
if (fields.Contains(Field.DatItem_MD5))
|
||||
if (datItemFields.Contains(DatItemField.MD5))
|
||||
{
|
||||
if (string.IsNullOrEmpty(MD5) && !string.IsNullOrEmpty(newItem.MD5))
|
||||
MD5 = newItem.MD5;
|
||||
}
|
||||
|
||||
#if NET_FRAMEWORK
|
||||
if (fields.Contains(Field.DatItem_RIPEMD160))
|
||||
if (datItemFields.Contains(DatItemField.RIPEMD160))
|
||||
{
|
||||
if (string.IsNullOrEmpty(RIPEMD160) && !string.IsNullOrEmpty(newItem.RIPEMD160))
|
||||
RIPEMD160 = newItem.RIPEMD160;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (fields.Contains(Field.DatItem_SHA1))
|
||||
if (datItemFields.Contains(DatItemField.SHA1))
|
||||
{
|
||||
if (string.IsNullOrEmpty(SHA1) && !string.IsNullOrEmpty(newItem.SHA1))
|
||||
SHA1 = newItem.SHA1;
|
||||
}
|
||||
|
||||
if (fields.Contains(Field.DatItem_SHA256))
|
||||
if (datItemFields.Contains(DatItemField.SHA256))
|
||||
{
|
||||
if (string.IsNullOrEmpty(SHA256) && !string.IsNullOrEmpty(newItem.SHA256))
|
||||
SHA256 = newItem.SHA256;
|
||||
}
|
||||
|
||||
if (fields.Contains(Field.DatItem_SHA384))
|
||||
if (datItemFields.Contains(DatItemField.SHA384))
|
||||
{
|
||||
if (string.IsNullOrEmpty(SHA384) && !string.IsNullOrEmpty(newItem.SHA384))
|
||||
SHA384 = newItem.SHA384;
|
||||
}
|
||||
|
||||
if (fields.Contains(Field.DatItem_SHA512))
|
||||
if (datItemFields.Contains(DatItemField.SHA512))
|
||||
{
|
||||
if (string.IsNullOrEmpty(SHA512) && !string.IsNullOrEmpty(newItem.SHA512))
|
||||
SHA512 = newItem.SHA512;
|
||||
}
|
||||
|
||||
if (fields.Contains(Field.DatItem_SpamSum))
|
||||
if (datItemFields.Contains(DatItemField.SpamSum))
|
||||
{
|
||||
if (string.IsNullOrEmpty(SpamSum) && !string.IsNullOrEmpty(newItem.SpamSum))
|
||||
SpamSum = newItem.SpamSum;
|
||||
}
|
||||
|
||||
if (fields.Contains(Field.DatItem_Merge))
|
||||
if (datItemFields.Contains(DatItemField.Merge))
|
||||
MergeTag = newItem.MergeTag;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Region))
|
||||
if (datItemFields.Contains(DatItemField.Region))
|
||||
Region = newItem.Region;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Offset))
|
||||
if (datItemFields.Contains(DatItemField.Offset))
|
||||
Offset = newItem.Offset;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Date))
|
||||
if (datItemFields.Contains(DatItemField.Date))
|
||||
Date = newItem.Date;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Status))
|
||||
if (datItemFields.Contains(DatItemField.Status))
|
||||
ItemStatus = newItem.ItemStatus;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Optional))
|
||||
if (datItemFields.Contains(DatItemField.Optional))
|
||||
Optional = newItem.Optional;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Inverted))
|
||||
if (datItemFields.Contains(DatItemField.Inverted))
|
||||
Inverted = newItem.Inverted;
|
||||
|
||||
#endregion
|
||||
|
||||
#region AttractMode
|
||||
|
||||
if (fields.Contains(Field.DatItem_AltName))
|
||||
if (datItemFields.Contains(DatItemField.AltName))
|
||||
AltName = newItem.AltName;
|
||||
|
||||
if (fields.Contains(Field.DatItem_AltTitle))
|
||||
if (datItemFields.Contains(DatItemField.AltTitle))
|
||||
AltTitle = newItem.AltTitle;
|
||||
|
||||
#endregion
|
||||
|
||||
#region OpenMSX
|
||||
|
||||
if (fields.Contains(Field.DatItem_Original))
|
||||
if (datItemFields.Contains(DatItemField.Original))
|
||||
Original = newItem.Original;
|
||||
|
||||
if (fields.Contains(Field.DatItem_OpenMSXSubType))
|
||||
if (datItemFields.Contains(DatItemField.OpenMSXSubType))
|
||||
OpenMSXSubType = newItem.OpenMSXSubType;
|
||||
|
||||
if (fields.Contains(Field.DatItem_OpenMSXType))
|
||||
if (datItemFields.Contains(DatItemField.OpenMSXType))
|
||||
OpenMSXType = newItem.OpenMSXType;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Remark))
|
||||
if (datItemFields.Contains(DatItemField.Remark))
|
||||
Remark = newItem.Remark;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Boot))
|
||||
if (datItemFields.Contains(DatItemField.Boot))
|
||||
Boot = newItem.Boot;
|
||||
|
||||
#endregion
|
||||
|
||||
#region SoftwareList
|
||||
|
||||
if (fields.Contains(Field.DatItem_LoadFlag))
|
||||
if (datItemFields.Contains(DatItemField.LoadFlag))
|
||||
LoadFlag = newItem.LoadFlag;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Value))
|
||||
if (datItemFields.Contains(DatItemField.Value))
|
||||
Value = newItem.Value;
|
||||
|
||||
if (DataAreaSpecified && newItem.DataAreaSpecified)
|
||||
DataArea.ReplaceFields(newItem.DataArea, fields);
|
||||
DataArea.ReplaceFields(newItem.DataArea, datItemFields, machineFields);
|
||||
|
||||
if (PartSpecified && newItem.PartSpecified)
|
||||
Part.ReplaceFields(newItem.Part, fields);
|
||||
Part.ReplaceFields(newItem.Part, datItemFields, machineFields);
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -37,18 +37,17 @@ namespace SabreTools.DatItems
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="mappings">Mappings dictionary</param>
|
||||
public override void SetFields(Dictionary<Field, string> mappings)
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
Dictionary<MachineField, string> machineMappings)
|
||||
{
|
||||
// Set base fields
|
||||
base.SetFields(mappings);
|
||||
base.SetFields(datItemMappings, machineMappings);
|
||||
|
||||
// Handle Sample-specific fields
|
||||
if (mappings.Keys.Contains(Field.DatItem_Name))
|
||||
Name = mappings[Field.DatItem_Name];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Name))
|
||||
Name = datItemMappings[DatItemField.Name];
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -131,36 +130,30 @@ namespace SabreTools.DatItems
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check to see if a DatItem passes the filter
|
||||
/// </summary>
|
||||
/// <param name="filter">Filter to check against</param>
|
||||
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
||||
/// <returns>True if the item passed the filter, false otherwise</returns>
|
||||
public override bool PassesFilter(Filter filter, bool sub = false)
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
// Check common fields first
|
||||
if (!base.PassesFilter(filter, sub))
|
||||
if (!base.PassesFilter(cleaner, sub))
|
||||
return false;
|
||||
|
||||
// Filter on item name
|
||||
if (!filter.PassStringFilter(filter.DatItem_Name, Name))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Name, Name))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove fields from the DatItem
|
||||
/// </summary>
|
||||
/// <param name="fields">List of Fields to remove</param>
|
||||
public override void RemoveFields(List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void RemoveFields(
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Remove common fields first
|
||||
base.RemoveFields(fields);
|
||||
base.RemoveFields(datItemFields, machineFields);
|
||||
|
||||
// Remove the fields
|
||||
if (fields.Contains(Field.DatItem_Name))
|
||||
if (datItemFields.Contains(DatItemField.Name))
|
||||
Name = null;
|
||||
}
|
||||
|
||||
@@ -178,15 +171,14 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Sorting and Merging
|
||||
|
||||
/// <summary>
|
||||
/// Replace fields from another item
|
||||
/// </summary>
|
||||
/// <param name="item">DatItem to pull new information from</param>
|
||||
/// <param name="fields">List of Fields representing what should be updated</param>
|
||||
public override void ReplaceFields(DatItem item, List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void ReplaceFields(
|
||||
DatItem item,
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Replace common fields first
|
||||
base.ReplaceFields(item, fields);
|
||||
base.ReplaceFields(item, datItemFields, machineFields);
|
||||
|
||||
// If we don't have a Sample to replace from, ignore specific fields
|
||||
if (item.ItemType != ItemType.Sample)
|
||||
@@ -196,7 +188,7 @@ namespace SabreTools.DatItems
|
||||
Sample newItem = item as Sample;
|
||||
|
||||
// Replace the fields
|
||||
if (fields.Contains(Field.DatItem_Name))
|
||||
if (datItemFields.Contains(DatItemField.Name))
|
||||
Name = newItem.Name;
|
||||
}
|
||||
|
||||
|
||||
@@ -65,30 +65,29 @@ namespace SabreTools.DatItems
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="mappings">Mappings dictionary</param>
|
||||
public override void SetFields(Dictionary<Field, string> mappings)
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
Dictionary<MachineField, string> machineMappings)
|
||||
{
|
||||
// Set base fields
|
||||
base.SetFields(mappings);
|
||||
base.SetFields(datItemMappings, machineMappings);
|
||||
|
||||
// Handle Setting-specific fields
|
||||
if (mappings.Keys.Contains(Field.DatItem_Setting_Name))
|
||||
Name = mappings[Field.DatItem_Setting_Name];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Setting_Name))
|
||||
Name = datItemMappings[DatItemField.Setting_Name];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Setting_Value))
|
||||
Value = mappings[Field.DatItem_Setting_Value];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Setting_Value))
|
||||
Value = datItemMappings[DatItemField.Setting_Value];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Setting_Default))
|
||||
Default = mappings[Field.DatItem_Setting_Default].AsYesNo();
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Setting_Default))
|
||||
Default = datItemMappings[DatItemField.Setting_Default].AsYesNo();
|
||||
|
||||
if (ConditionsSpecified)
|
||||
{
|
||||
foreach (Condition condition in Conditions)
|
||||
{
|
||||
condition.SetFields(mappings, true);
|
||||
condition.SetFields(datItemMappings, machineMappings, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -191,28 +190,23 @@ namespace SabreTools.DatItems
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check to see if a DatItem passes the filter
|
||||
/// </summary>
|
||||
/// <param name="filter">Filter to check against</param>
|
||||
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
||||
/// <returns>True if the item passed the filter, false otherwise</returns>
|
||||
public override bool PassesFilter(Filter filter, bool sub = false)
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
// Check common fields first
|
||||
if (!base.PassesFilter(filter, sub))
|
||||
if (!base.PassesFilter(cleaner, sub))
|
||||
return false;
|
||||
|
||||
// Filter on item name
|
||||
if (!filter.PassStringFilter(filter.DatItem_Setting_Name, Name))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Setting_Name, Name))
|
||||
return false;
|
||||
|
||||
// Filter on value
|
||||
if (!filter.PassStringFilter(filter.DatItem_Setting_Value, Value))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Setting_Value, Value))
|
||||
return false;
|
||||
|
||||
// Filter on default
|
||||
if (!filter.PassBoolFilter(filter.DatItem_Setting_Default, Default))
|
||||
if (!Filter.PassBoolFilter(cleaner.DatItemFilter.Setting_Default, Default))
|
||||
return false;
|
||||
|
||||
// Filter on individual conditions
|
||||
@@ -220,7 +214,7 @@ namespace SabreTools.DatItems
|
||||
{
|
||||
foreach (Condition condition in Conditions)
|
||||
{
|
||||
if (!condition.PassesFilter(filter, true))
|
||||
if (!condition.PassesFilter(cleaner, true))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -228,30 +222,29 @@ namespace SabreTools.DatItems
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove fields from the DatItem
|
||||
/// </summary>
|
||||
/// <param name="fields">List of Fields to remove</param>
|
||||
public override void RemoveFields(List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void RemoveFields(
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Remove common fields first
|
||||
base.RemoveFields(fields);
|
||||
base.RemoveFields(datItemFields, machineFields);
|
||||
|
||||
// Remove the fields
|
||||
if (fields.Contains(Field.DatItem_Setting_Name))
|
||||
if (datItemFields.Contains(DatItemField.Setting_Name))
|
||||
Name = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Setting_Value))
|
||||
if (datItemFields.Contains(DatItemField.Setting_Value))
|
||||
Value = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Setting_Default))
|
||||
if (datItemFields.Contains(DatItemField.Setting_Default))
|
||||
Default = null;
|
||||
|
||||
if (ConditionsSpecified)
|
||||
{
|
||||
foreach (Condition condition in Conditions)
|
||||
{
|
||||
condition.RemoveFields(fields, true);
|
||||
condition.RemoveFields(datItemFields, machineFields, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -270,15 +263,14 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Sorting and Merging
|
||||
|
||||
/// <summary>
|
||||
/// Replace fields from another item
|
||||
/// </summary>
|
||||
/// <param name="item">DatItem to pull new information from</param>
|
||||
/// <param name="fields">List of Fields representing what should be updated</param>
|
||||
public override void ReplaceFields(DatItem item, List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void ReplaceFields(
|
||||
DatItem item,
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Replace common fields first
|
||||
base.ReplaceFields(item, fields);
|
||||
base.ReplaceFields(item, datItemFields, machineFields);
|
||||
|
||||
// If we don't have a Setting to replace from, ignore specific fields
|
||||
if (item.ItemType != ItemType.Setting)
|
||||
@@ -288,13 +280,13 @@ namespace SabreTools.DatItems
|
||||
Setting newItem = item as Setting;
|
||||
|
||||
// Replace the fields
|
||||
if (fields.Contains(Field.DatItem_Setting_Name))
|
||||
if (datItemFields.Contains(DatItemField.Setting_Name))
|
||||
Name = newItem.Name;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Setting_Value))
|
||||
if (datItemFields.Contains(DatItemField.Setting_Value))
|
||||
Value = newItem.Value;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Setting_Default))
|
||||
if (datItemFields.Contains(DatItemField.Setting_Default))
|
||||
Default = newItem.Default;
|
||||
|
||||
// DatItem_Condition_* doesn't make sense here
|
||||
|
||||
@@ -44,21 +44,20 @@ namespace SabreTools.DatItems
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="mappings">Mappings dictionary</param>
|
||||
public override void SetFields(Dictionary<Field, string> mappings)
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
Dictionary<MachineField, string> machineMappings)
|
||||
{
|
||||
// Set base fields
|
||||
base.SetFields(mappings);
|
||||
base.SetFields(datItemMappings, machineMappings);
|
||||
|
||||
// Handle SharedFeature-specific fields
|
||||
if (mappings.Keys.Contains(Field.DatItem_Name))
|
||||
Name = mappings[Field.DatItem_Name];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Name))
|
||||
Name = datItemMappings[DatItemField.Name];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Value))
|
||||
Value = mappings[Field.DatItem_Value];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Value))
|
||||
Value = datItemMappings[DatItemField.Value];
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -142,43 +141,37 @@ namespace SabreTools.DatItems
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check to see if a DatItem passes the filter
|
||||
/// </summary>
|
||||
/// <param name="filter">Filter to check against</param>
|
||||
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
||||
/// <returns>True if the item passed the filter, false otherwise</returns>
|
||||
public override bool PassesFilter(Filter filter, bool sub = false)
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
// Check common fields first
|
||||
if (!base.PassesFilter(filter, sub))
|
||||
if (!base.PassesFilter(cleaner, sub))
|
||||
return false;
|
||||
|
||||
// Filter on item name
|
||||
if (!filter.PassStringFilter(filter.DatItem_Name, Name))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Name, Name))
|
||||
return false;
|
||||
|
||||
// Filter on value
|
||||
if (!filter.PassStringFilter(filter.DatItem_Value, Value))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Value, Value))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove fields from the DatItem
|
||||
/// </summary>
|
||||
/// <param name="fields">List of Fields to remove</param>
|
||||
public override void RemoveFields(List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void RemoveFields(
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Remove common fields first
|
||||
base.RemoveFields(fields);
|
||||
base.RemoveFields(datItemFields, machineFields);
|
||||
|
||||
// Remove the fields
|
||||
if (fields.Contains(Field.DatItem_Name))
|
||||
if (datItemFields.Contains(DatItemField.Name))
|
||||
Name = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Value))
|
||||
if (datItemFields.Contains(DatItemField.Value))
|
||||
Value = null;
|
||||
}
|
||||
|
||||
@@ -196,15 +189,14 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Sorting and Merging
|
||||
|
||||
/// <summary>
|
||||
/// Replace fields from another item
|
||||
/// </summary>
|
||||
/// <param name="item">DatItem to pull new information from</param>
|
||||
/// <param name="fields">List of Fields representing what should be updated</param>
|
||||
public override void ReplaceFields(DatItem item, List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void ReplaceFields(
|
||||
DatItem item,
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Replace common fields first
|
||||
base.ReplaceFields(item, fields);
|
||||
base.ReplaceFields(item, datItemFields, machineFields);
|
||||
|
||||
// If we don't have a SharedFeature to replace from, ignore specific fields
|
||||
if (item.ItemType != ItemType.SharedFeature)
|
||||
@@ -214,10 +206,10 @@ namespace SabreTools.DatItems
|
||||
SharedFeature newItem = item as SharedFeature;
|
||||
|
||||
// Replace the fields
|
||||
if (fields.Contains(Field.DatItem_Name))
|
||||
if (datItemFields.Contains(DatItemField.Name))
|
||||
Name = newItem.Name;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Value))
|
||||
if (datItemFields.Contains(DatItemField.Value))
|
||||
Value = newItem.Value;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,24 +47,23 @@ namespace SabreTools.DatItems
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="mappings">Mappings dictionary</param>
|
||||
public override void SetFields(Dictionary<Field, string> mappings)
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
Dictionary<MachineField, string> machineMappings)
|
||||
{
|
||||
// Set base fields
|
||||
base.SetFields(mappings);
|
||||
base.SetFields(datItemMappings, machineMappings);
|
||||
|
||||
// Handle Slot-specific fields
|
||||
if (mappings.Keys.Contains(Field.DatItem_Name))
|
||||
Name = mappings[Field.DatItem_Name];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Name))
|
||||
Name = datItemMappings[DatItemField.Name];
|
||||
|
||||
if (SlotOptionsSpecified)
|
||||
{
|
||||
foreach (SlotOption slotOption in SlotOptions)
|
||||
{
|
||||
slotOption.SetFields(mappings);
|
||||
slotOption.SetFields(datItemMappings, machineMappings);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -163,20 +162,15 @@ namespace SabreTools.DatItems
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check to see if a DatItem passes the filter
|
||||
/// </summary>
|
||||
/// <param name="filter">Filter to check against</param>
|
||||
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
||||
/// <returns>True if the item passed the filter, false otherwise</returns>
|
||||
public override bool PassesFilter(Filter filter, bool sub = false)
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
// Check common fields first
|
||||
if (!base.PassesFilter(filter, sub))
|
||||
if (!base.PassesFilter(cleaner, sub))
|
||||
return false;
|
||||
|
||||
// Filter on item name
|
||||
if (!filter.PassStringFilter(filter.DatItem_Name, Name))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.Name, Name))
|
||||
return false;
|
||||
|
||||
// Filter on individual slot options
|
||||
@@ -184,7 +178,7 @@ namespace SabreTools.DatItems
|
||||
{
|
||||
foreach (SlotOption slotOption in SlotOptions)
|
||||
{
|
||||
if (!slotOption.PassesFilter(filter, true))
|
||||
if (!slotOption.PassesFilter(cleaner, true))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -192,24 +186,23 @@ namespace SabreTools.DatItems
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove fields from the DatItem
|
||||
/// </summary>
|
||||
/// <param name="fields">List of Fields to remove</param>
|
||||
public override void RemoveFields(List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void RemoveFields(
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Remove common fields first
|
||||
base.RemoveFields(fields);
|
||||
base.RemoveFields(datItemFields, machineFields);
|
||||
|
||||
// Remove the fields
|
||||
if (fields.Contains(Field.DatItem_Name))
|
||||
if (datItemFields.Contains(DatItemField.Name))
|
||||
Name = null;
|
||||
|
||||
if (SlotOptionsSpecified)
|
||||
{
|
||||
foreach (SlotOption slotOption in SlotOptions)
|
||||
{
|
||||
slotOption.RemoveFields(fields);
|
||||
slotOption.RemoveFields(datItemFields, machineFields);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -228,15 +221,14 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Sorting and Merging
|
||||
|
||||
/// <summary>
|
||||
/// Replace fields from another item
|
||||
/// </summary>
|
||||
/// <param name="item">DatItem to pull new information from</param>
|
||||
/// <param name="fields">List of Fields representing what should be updated</param>
|
||||
public override void ReplaceFields(DatItem item, List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void ReplaceFields(
|
||||
DatItem item,
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Replace common fields first
|
||||
base.ReplaceFields(item, fields);
|
||||
base.ReplaceFields(item, datItemFields, machineFields);
|
||||
|
||||
// If we don't have a Slot to replace from, ignore specific fields
|
||||
if (item.ItemType != ItemType.Slot)
|
||||
@@ -246,7 +238,7 @@ namespace SabreTools.DatItems
|
||||
Slot newItem = item as Slot;
|
||||
|
||||
// Replace the fields
|
||||
if (fields.Contains(Field.DatItem_Name))
|
||||
if (datItemFields.Contains(DatItemField.Name))
|
||||
Name = newItem.Name;
|
||||
|
||||
// DatItem_SlotOption_* doesn't make sense here
|
||||
|
||||
@@ -55,24 +55,23 @@ namespace SabreTools.DatItems
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="mappings">Mappings dictionary</param>
|
||||
public override void SetFields(Dictionary<Field, string> mappings)
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
Dictionary<MachineField, string> machineMappings)
|
||||
{
|
||||
// Set base fields
|
||||
base.SetFields(mappings);
|
||||
base.SetFields(datItemMappings, machineMappings);
|
||||
|
||||
// Handle SlotOption-specific fields
|
||||
if (mappings.Keys.Contains(Field.DatItem_SlotOption_Name))
|
||||
Name = mappings[Field.DatItem_SlotOption_Name];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.SlotOption_Name))
|
||||
Name = datItemMappings[DatItemField.SlotOption_Name];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_SlotOption_DeviceName))
|
||||
DeviceName = mappings[Field.DatItem_SlotOption_DeviceName];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.SlotOption_DeviceName))
|
||||
DeviceName = datItemMappings[DatItemField.SlotOption_DeviceName];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_SlotOption_Default))
|
||||
Default = mappings[Field.DatItem_SlotOption_Default].AsYesNo();
|
||||
if (datItemMappings.Keys.Contains(DatItemField.SlotOption_Default))
|
||||
Default = datItemMappings[DatItemField.SlotOption_Default].AsYesNo();
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -159,50 +158,44 @@ namespace SabreTools.DatItems
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check to see if a DatItem passes the filter
|
||||
/// </summary>
|
||||
/// <param name="filter">Filter to check against</param>
|
||||
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
||||
/// <returns>True if the item passed the filter, false otherwise</returns>
|
||||
public override bool PassesFilter(Filter filter, bool sub = false)
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
// Check common fields first
|
||||
if (!base.PassesFilter(filter, sub))
|
||||
if (!base.PassesFilter(cleaner, sub))
|
||||
return false;
|
||||
|
||||
// Filter on item name
|
||||
if (!filter.PassStringFilter(filter.DatItem_SlotOption_Name, Name))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.SlotOption_Name, Name))
|
||||
return false;
|
||||
|
||||
// Filter on device name
|
||||
if (!filter.PassStringFilter(filter.DatItem_SlotOption_DeviceName, DeviceName))
|
||||
if (!Filter.PassStringFilter(cleaner.DatItemFilter.SlotOption_DeviceName, DeviceName))
|
||||
return false;
|
||||
|
||||
// Filter on default
|
||||
if (!filter.PassBoolFilter(filter.DatItem_SlotOption_Default, Default))
|
||||
if (!Filter.PassBoolFilter(cleaner.DatItemFilter.SlotOption_Default, Default))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove fields from the DatItem
|
||||
/// </summary>
|
||||
/// <param name="fields">List of Fields to remove</param>
|
||||
public override void RemoveFields(List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void RemoveFields(
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Remove common fields first
|
||||
base.RemoveFields(fields);
|
||||
base.RemoveFields(datItemFields, machineFields);
|
||||
|
||||
// Remove the fields
|
||||
if (fields.Contains(Field.DatItem_SlotOption_Name))
|
||||
if (datItemFields.Contains(DatItemField.SlotOption_Name))
|
||||
Name = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_SlotOption_DeviceName))
|
||||
if (datItemFields.Contains(DatItemField.SlotOption_DeviceName))
|
||||
DeviceName = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_SlotOption_Default))
|
||||
if (datItemFields.Contains(DatItemField.SlotOption_Default))
|
||||
Default = null;
|
||||
}
|
||||
|
||||
@@ -220,15 +213,14 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Sorting and Merging
|
||||
|
||||
/// <summary>
|
||||
/// Replace fields from another item
|
||||
/// </summary>
|
||||
/// <param name="item">DatItem to pull new information from</param>
|
||||
/// <param name="fields">List of Fields representing what should be updated</param>
|
||||
public override void ReplaceFields(DatItem item, List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void ReplaceFields(
|
||||
DatItem item,
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Replace common fields first
|
||||
base.ReplaceFields(item, fields);
|
||||
base.ReplaceFields(item, datItemFields, machineFields);
|
||||
|
||||
// If we don't have a SlotOption to replace from, ignore specific fields
|
||||
if (item.ItemType != ItemType.SlotOption)
|
||||
@@ -238,13 +230,13 @@ namespace SabreTools.DatItems
|
||||
SlotOption newItem = item as SlotOption;
|
||||
|
||||
// Replace the fields
|
||||
if (fields.Contains(Field.DatItem_SlotOption_Name))
|
||||
if (datItemFields.Contains(DatItemField.SlotOption_Name))
|
||||
Name = newItem.Name;
|
||||
|
||||
if (fields.Contains(Field.DatItem_SlotOption_DeviceName))
|
||||
if (datItemFields.Contains(DatItemField.SlotOption_DeviceName))
|
||||
DeviceName = newItem.DeviceName;
|
||||
|
||||
if (fields.Contains(Field.DatItem_SlotOption_Default))
|
||||
if (datItemFields.Contains(DatItemField.SlotOption_Default))
|
||||
Default = newItem.Default;
|
||||
}
|
||||
|
||||
|
||||
@@ -57,24 +57,23 @@ namespace SabreTools.DatItems
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="mappings">Mappings dictionary</param>
|
||||
public override void SetFields(Dictionary<Field, string> mappings)
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
Dictionary<MachineField, string> machineMappings)
|
||||
{
|
||||
// Set base fields
|
||||
base.SetFields(mappings);
|
||||
base.SetFields(datItemMappings, machineMappings);
|
||||
|
||||
// Handle SoftwareList-specific fields
|
||||
if (mappings.Keys.Contains(Field.DatItem_Name))
|
||||
Name = mappings[Field.DatItem_Name];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Name))
|
||||
Name = datItemMappings[DatItemField.Name];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_SoftwareListStatus))
|
||||
Status = mappings[Field.DatItem_SoftwareListStatus].AsSoftwareListStatus();
|
||||
if (datItemMappings.Keys.Contains(DatItemField.SoftwareListStatus))
|
||||
Status = datItemMappings[DatItemField.SoftwareListStatus].AsSoftwareListStatus();
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Filter))
|
||||
Filter = mappings[Field.DatItem_Filter];
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Filter))
|
||||
Filter = datItemMappings[DatItemField.Filter];
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -161,52 +160,46 @@ namespace SabreTools.DatItems
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check to see if a DatItem passes the filter
|
||||
/// </summary>
|
||||
/// <param name="filter">Filter to check against</param>
|
||||
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
||||
/// <returns>True if the item passed the filter, false otherwise</returns>
|
||||
public override bool PassesFilter(Filter filter, bool sub = false)
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
// Check common fields first
|
||||
if (!base.PassesFilter(filter, sub))
|
||||
if (!base.PassesFilter(cleaner, sub))
|
||||
return false;
|
||||
|
||||
// Filter on item name
|
||||
if (!filter.PassStringFilter(filter.DatItem_Name, Name))
|
||||
if (!Filtering.Filter.PassStringFilter(cleaner.DatItemFilter.Name, Name))
|
||||
return false;
|
||||
|
||||
// Filter on status
|
||||
if (filter.DatItem_SoftwareListStatus.MatchesPositive(SoftwareListStatus.NULL, Status) == false)
|
||||
if (cleaner.DatItemFilter.SoftwareListStatus.MatchesPositive(SoftwareListStatus.NULL, Status) == false)
|
||||
return false;
|
||||
if (filter.DatItem_SoftwareListStatus.MatchesNegative(SoftwareListStatus.NULL, Status) == true)
|
||||
if (cleaner.DatItemFilter.SoftwareListStatus.MatchesNegative(SoftwareListStatus.NULL, Status) == true)
|
||||
return false;
|
||||
|
||||
// Filter on filter
|
||||
if (!filter.PassStringFilter(filter.DatItem_Filter, Filter))
|
||||
if (!Filtering.Filter.PassStringFilter(cleaner.DatItemFilter.Filter, Filter))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove fields from the DatItem
|
||||
/// </summary>
|
||||
/// <param name="fields">List of Fields to remove</param>
|
||||
public override void RemoveFields(List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void RemoveFields(
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Remove common fields first
|
||||
base.RemoveFields(fields);
|
||||
base.RemoveFields(datItemFields, machineFields);
|
||||
|
||||
// Remove the fields
|
||||
if (fields.Contains(Field.DatItem_Name))
|
||||
if (datItemFields.Contains(DatItemField.Name))
|
||||
Name = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_SoftwareListStatus))
|
||||
if (datItemFields.Contains(DatItemField.SoftwareListStatus))
|
||||
Status = SoftwareListStatus.NULL;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Filter))
|
||||
if (datItemFields.Contains(DatItemField.Filter))
|
||||
Filter = null;
|
||||
}
|
||||
|
||||
@@ -224,15 +217,14 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Sorting and Merging
|
||||
|
||||
/// <summary>
|
||||
/// Replace fields from another item
|
||||
/// </summary>
|
||||
/// <param name="item">DatItem to pull new information from</param>
|
||||
/// <param name="fields">List of Fields representing what should be updated</param>
|
||||
public override void ReplaceFields(DatItem item, List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void ReplaceFields(
|
||||
DatItem item,
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Replace common fields first
|
||||
base.ReplaceFields(item, fields);
|
||||
base.ReplaceFields(item, datItemFields, machineFields);
|
||||
|
||||
// If we don't have a SoftwareList to replace from, ignore specific fields
|
||||
if (item.ItemType != ItemType.SoftwareList)
|
||||
@@ -242,13 +234,13 @@ namespace SabreTools.DatItems
|
||||
SoftwareList newItem = item as SoftwareList;
|
||||
|
||||
// Replace the fields
|
||||
if (fields.Contains(Field.DatItem_Name))
|
||||
if (datItemFields.Contains(DatItemField.Name))
|
||||
Name = newItem.Name;
|
||||
|
||||
if (fields.Contains(Field.DatItem_SoftwareListStatus))
|
||||
if (datItemFields.Contains(DatItemField.SoftwareListStatus))
|
||||
Status = newItem.Status;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Filter))
|
||||
if (datItemFields.Contains(DatItemField.Filter))
|
||||
Filter = newItem.Filter;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,18 +32,17 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="mappings">Mappings dictionary</param>
|
||||
public override void SetFields(Dictionary<Field, string> mappings)
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
Dictionary<MachineField, string> machineMappings)
|
||||
{
|
||||
// Set base fields
|
||||
base.SetFields(mappings);
|
||||
base.SetFields(datItemMappings, machineMappings);
|
||||
|
||||
// Handle Sound-specific fields
|
||||
if (mappings.Keys.Contains(Field.DatItem_Channels))
|
||||
Channels = Utilities.CleanLong(mappings[Field.DatItem_Channels]);
|
||||
if (datItemMappings.Keys.Contains(DatItemField.Channels))
|
||||
Channels = Utilities.CleanLong(datItemMappings[DatItemField.Channels]);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -98,36 +97,30 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Filtering
|
||||
|
||||
/// <summary>
|
||||
/// Check to see if a DatItem passes the filter
|
||||
/// </summary>
|
||||
/// <param name="filter">Filter to check against</param>
|
||||
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
||||
/// <returns>True if the item passed the filter, false otherwise</returns>
|
||||
public override bool PassesFilter(Filter filter, bool sub = false)
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
// Check common fields first
|
||||
if (!base.PassesFilter(filter, sub))
|
||||
if (!base.PassesFilter(cleaner, sub))
|
||||
return false;
|
||||
|
||||
// Filter on channels
|
||||
if (!filter.PassLongFilter(filter.DatItem_Channels, Channels))
|
||||
if (!Filter.PassLongFilter(cleaner.DatItemFilter.Channels, Channels))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove fields from the DatItem
|
||||
/// </summary>
|
||||
/// <param name="fields">List of Fields to remove</param>
|
||||
public override void RemoveFields(List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void RemoveFields(
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Remove common fields first
|
||||
base.RemoveFields(fields);
|
||||
base.RemoveFields(datItemFields, machineFields);
|
||||
|
||||
// Remove the fields
|
||||
if (fields.Contains(Field.DatItem_Channels))
|
||||
if (datItemFields.Contains(DatItemField.Channels))
|
||||
Channels = null;
|
||||
}
|
||||
|
||||
@@ -135,15 +128,14 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Sorting and Merging
|
||||
|
||||
/// <summary>
|
||||
/// Replace fields from another item
|
||||
/// </summary>
|
||||
/// <param name="item">DatItem to pull new information from</param>
|
||||
/// <param name="fields">List of Fields representing what should be updated</param>
|
||||
public override void ReplaceFields(DatItem item, List<Field> fields)
|
||||
/// <inheritdoc/>
|
||||
public override void ReplaceFields(
|
||||
DatItem item,
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// Replace common fields first
|
||||
base.ReplaceFields(item, fields);
|
||||
base.ReplaceFields(item, datItemFields, machineFields);
|
||||
|
||||
// If we don't have a Sound to replace from, ignore specific fields
|
||||
if (item.ItemType != ItemType.Sound)
|
||||
@@ -153,7 +145,7 @@ namespace SabreTools.DatItems
|
||||
Sound newItem = item as Sound;
|
||||
|
||||
// Replace the fields
|
||||
if (fields.Contains(Field.DatItem_Channels))
|
||||
if (datItemFields.Contains(DatItemField.Channels))
|
||||
Channels = newItem.Channels;
|
||||
}
|
||||
|
||||
|
||||
@@ -434,7 +434,7 @@ namespace SabreTools.DatTools
|
||||
}
|
||||
|
||||
// Set the item name back
|
||||
datItem.SetFields(new Dictionary<Field, string> { [Field.DatItem_Name] = itemName });
|
||||
datItem.SetFields(new Dictionary<DatItemField, string> { [DatItemField.Name] = itemName }, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,14 +28,20 @@ namespace SabreTools.DatTools
|
||||
/// </summary>
|
||||
/// <param name="datFile">Current DatFile object to use for updating</param>
|
||||
/// <param name="intDat">DatFile to replace the values in</param>
|
||||
/// <param name="updateFields">List of Fields representing what should be updated</param>
|
||||
/// <param name="machineFields">List of MachineFields representing what should be updated</param>
|
||||
/// <param name="datItemFields">List of DatItemFields representing what should be updated</param>
|
||||
/// <param name="onlySame">True if descriptions should only be replaced if the game name is the same, false otherwise</param>
|
||||
public static void BaseReplace(DatFile datFile, DatFile intDat, List<Field> updateFields, bool onlySame)
|
||||
public static void BaseReplace(
|
||||
DatFile datFile,
|
||||
DatFile intDat,
|
||||
List<MachineField> machineFields,
|
||||
List<DatItemField> datItemFields,
|
||||
bool onlySame)
|
||||
{
|
||||
logger.User($"Replacing items in '{intDat.Header.FileName}' from the base DAT");
|
||||
|
||||
// If we are matching based on DatItem fields of any sort
|
||||
if (updateFields.Intersect(DatItem.DatItemFields).Any())
|
||||
if (datItemFields.Any())
|
||||
{
|
||||
// For comparison's sake, we want to use CRC as the base bucketing
|
||||
datFile.Items.BucketBy(Field.DatItem_CRC, DedupeType.Full);
|
||||
@@ -53,7 +59,7 @@ namespace SabreTools.DatTools
|
||||
|
||||
// Replace fields from the first duplicate, if we have one
|
||||
if (dupes.Count > 0)
|
||||
newDatItem.ReplaceFields(dupes.First(), updateFields);
|
||||
newDatItem.ReplaceFields(dupes.First(), datItemFields, null);
|
||||
|
||||
newDatItems.Add(newDatItem);
|
||||
}
|
||||
@@ -65,7 +71,7 @@ namespace SabreTools.DatTools
|
||||
}
|
||||
|
||||
// If we are matching based on Machine fields of any sort
|
||||
if (updateFields.Intersect(DatItem.MachineFields).Any())
|
||||
if (machineFields.Any())
|
||||
{
|
||||
// For comparison's sake, we want to use Machine Name as the base bucketing
|
||||
datFile.Items.BucketBy(Field.Machine_Name, DedupeType.Full);
|
||||
@@ -80,7 +86,7 @@ namespace SabreTools.DatTools
|
||||
{
|
||||
DatItem newDatItem = datItem.Clone() as DatItem;
|
||||
if (datFile.Items.ContainsKey(key) && datFile.Items[key].Count() > 0)
|
||||
newDatItem.Machine.ReplaceFields(datFile.Items[key][0].Machine, updateFields, onlySame);
|
||||
newDatItem.Machine.ReplaceFields(datFile.Items[key][0].Machine, machineFields, onlySame);
|
||||
|
||||
newDatItems.Add(newDatItem);
|
||||
}
|
||||
|
||||
@@ -64,8 +64,11 @@ namespace SabreTools.DatTools
|
||||
OneRomPerGame(datFile);
|
||||
|
||||
// If we are removing fields, do that now
|
||||
if (cleaner.ExcludeFields != null && cleaner.ExcludeFields.Any())
|
||||
RemoveFieldsFromItems(datFile, cleaner.ExcludeFields);
|
||||
if ((cleaner.ExcludeMachineFields != null && cleaner.ExcludeMachineFields.Any())
|
||||
|| cleaner.ExcludeDatItemFields != null && cleaner.ExcludeDatItemFields.Any())
|
||||
{
|
||||
RemoveFieldsFromItems(datFile, cleaner.ExcludeDatItemFields, cleaner.ExcludeMachineFields);
|
||||
}
|
||||
|
||||
// Remove all marked items
|
||||
datFile.Items.ClearMarked();
|
||||
@@ -99,7 +102,8 @@ namespace SabreTools.DatTools
|
||||
datFile.Items.BucketBy(Field.Machine_Name, DedupeType.None);
|
||||
|
||||
// Create a new set of mappings based on the items
|
||||
var map = new Dictionary<string, Dictionary<Field, string>>();
|
||||
var machineMap = new Dictionary<string, Dictionary<MachineField, string>>();
|
||||
var datItemMap = new Dictionary<string, Dictionary<DatItemField, string>>();
|
||||
|
||||
// Loop through each of the extras
|
||||
foreach (ExtraIniItem item in extras.Items)
|
||||
@@ -112,27 +116,53 @@ namespace SabreTools.DatTools
|
||||
// Loop through the machines and add the new mappings
|
||||
foreach (string machine in machineNames)
|
||||
{
|
||||
if (!map.ContainsKey(machine))
|
||||
map[machine] = new Dictionary<Field, string>();
|
||||
if (item.MachineField != MachineField.NULL)
|
||||
{
|
||||
if (!machineMap.ContainsKey(machine))
|
||||
machineMap[machine] = new Dictionary<MachineField, string>();
|
||||
|
||||
map[machine][item.Field] = key;
|
||||
machineMap[machine][item.MachineField] = key;
|
||||
}
|
||||
else if (item.DatItemField != DatItemField.NULL)
|
||||
{
|
||||
if (!datItemMap.ContainsKey(machine))
|
||||
datItemMap[machine] = new Dictionary<DatItemField, string>();
|
||||
|
||||
datItemMap[machine][item.DatItemField] = key;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now apply the new set of mappings
|
||||
foreach (string key in map.Keys)
|
||||
// Now apply the new set of Machine mappings
|
||||
foreach (string key in machineMap.Keys)
|
||||
{
|
||||
// If the key doesn't exist, continue
|
||||
if (!datFile.Items.ContainsKey(key))
|
||||
continue;
|
||||
|
||||
List<DatItem> datItems = datFile.Items[key];
|
||||
var mappings = map[key];
|
||||
var mappings = machineMap[key];
|
||||
|
||||
foreach (var datItem in datItems)
|
||||
{
|
||||
datItem.SetFields(mappings);
|
||||
datItem.SetFields(null, mappings);
|
||||
}
|
||||
}
|
||||
|
||||
// Now apply the new set of DatItem mappings
|
||||
foreach (string key in datItemMap.Keys)
|
||||
{
|
||||
// If the key doesn't exist, continue
|
||||
if (!datFile.Items.ContainsKey(key))
|
||||
continue;
|
||||
|
||||
List<DatItem> datItems = datFile.Items[key];
|
||||
var mappings = datItemMap[key];
|
||||
|
||||
foreach (var datItem in datItems)
|
||||
{
|
||||
datItem.SetFields(mappings, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -147,17 +177,17 @@ namespace SabreTools.DatTools
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Apply a Filter on the DatFile
|
||||
/// Apply a set of Filters on the DatFile
|
||||
/// </summary>
|
||||
/// <param name="datFile">Current DatFile object to run operations on</param>
|
||||
/// <param name="filter">Filter to use</param>
|
||||
/// <param name="cleaner">Cleaner to use</param>
|
||||
/// <param name="perMachine">True if entire machines are considered, false otherwise (default)</param>
|
||||
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
|
||||
/// <returns>True if the DatFile was filtered, false on error</returns>
|
||||
public static bool ApplyFilter(DatFile datFile, Filter filter, bool perMachine = false, bool throwOnError = false)
|
||||
public static bool ApplyFilters(DatFile datFile, Cleaner cleaner, bool perMachine = false, bool throwOnError = false)
|
||||
{
|
||||
// If we have a null filter, return false
|
||||
if (filter == null)
|
||||
// If we have a null cleaner or filters, return false
|
||||
if (cleaner == null || cleaner.DatHeaderFilter == null || cleaner.MachineFilter == null || cleaner.DatItemFilter == null)
|
||||
return false;
|
||||
|
||||
// If we're filtering per machine, bucket by machine first
|
||||
@@ -184,7 +214,7 @@ namespace SabreTools.DatTools
|
||||
continue;
|
||||
|
||||
// If the rom doesn't pass the filter, mark for removal
|
||||
if (!item.PassesFilter(filter))
|
||||
if (!item.PassesFilter(cleaner))
|
||||
{
|
||||
item.Remove = true;
|
||||
|
||||
@@ -472,12 +502,18 @@ namespace SabreTools.DatTools
|
||||
/// Remove fields as per the header
|
||||
/// </summary>
|
||||
/// <param name="datFile">Current DatFile object to run operations on</param>
|
||||
/// <param name="fields">List of fields to use</param>
|
||||
public static void RemoveFieldsFromItems(DatFile datFile, List<Field> fields)
|
||||
/// <param name="datItemFields">DatItem fields to remove</param>
|
||||
/// <param name="machineFields">Machine fields to remove</param>
|
||||
public static void RemoveFieldsFromItems(
|
||||
DatFile datFile,
|
||||
List<DatItemField> datItemFields,
|
||||
List<MachineField> machineFields)
|
||||
{
|
||||
// If we have null field list, make it empty
|
||||
if (fields == null)
|
||||
fields = new List<Field>();
|
||||
if (datItemFields == null)
|
||||
datItemFields = new List<DatItemField>();
|
||||
if (machineFields == null)
|
||||
machineFields = new List<MachineField>();
|
||||
|
||||
// Output the logging statement
|
||||
logger.User("Removing filtered fields");
|
||||
@@ -488,7 +524,7 @@ namespace SabreTools.DatTools
|
||||
List<DatItem> items = datFile.Items[key];
|
||||
for (int j = 0; j < items.Count; j++)
|
||||
{
|
||||
items[j].RemoveFields(fields);
|
||||
items[j].RemoveFields(datItemFields, machineFields);
|
||||
}
|
||||
|
||||
datFile.Items.Remove(key);
|
||||
@@ -997,7 +1033,7 @@ namespace SabreTools.DatTools
|
||||
else if (!datFile.Items[parent].Contains(item))
|
||||
{
|
||||
if (subfolder)
|
||||
item.SetFields(new Dictionary<Field, string> { [Field.DatItem_Name] = $"{item.Machine.Name}\\{item.GetName()}" });
|
||||
item.SetFields(new Dictionary<DatItemField, string> { [DatItemField.Name] = $"{item.Machine.Name}\\{item.GetName()}" }, null);
|
||||
|
||||
item.CopyMachineInformation(copyFrom);
|
||||
datFile.Items.Add(parent, item);
|
||||
|
||||
@@ -441,7 +441,7 @@ namespace SabreTools.DatTools
|
||||
{
|
||||
// Create a headered item to use as well
|
||||
datItem.CopyMachineInformation(item);
|
||||
datItem.SetFields(new Dictionary<Field, string> { [Field.DatItem_Name] = $"{datItem.GetName()}_{crc}" });
|
||||
datItem.SetFields(new Dictionary<DatItemField, string> { [DatItemField.Name] = $"{datItem.GetName()}_{crc}" }, null);
|
||||
|
||||
// Get the output archive, if possible
|
||||
Folder outputArchive = GetPreconfiguredFolder(datFile, date, outputFormat);
|
||||
|
||||
@@ -9,6 +9,27 @@ namespace SabreTools.Filtering
|
||||
/// </summary>
|
||||
public class Cleaner
|
||||
{
|
||||
#region Filter Fields
|
||||
|
||||
/// <summary>
|
||||
/// Filter for DatHeader fields
|
||||
/// </summary>
|
||||
public DatHeaderFilter DatHeaderFilter { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Filter for DatItem fields
|
||||
/// </summary>
|
||||
public DatItemFilter DatItemFilter { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Filter for Machine fields
|
||||
/// </summary>
|
||||
public MachineFilter MachineFilter { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Flag Fields
|
||||
|
||||
/// <summary>
|
||||
/// Clean all names to WoD standards
|
||||
/// </summary>
|
||||
@@ -25,9 +46,19 @@ namespace SabreTools.Filtering
|
||||
public bool DescriptionAsName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Dictionary of fields in machine and items to exclude from writing
|
||||
/// Dictionary of DatHeader fields to exclude from writing
|
||||
/// </summary>
|
||||
public List<Field> ExcludeFields { get; set; } = new List<Field>();
|
||||
public List<DatHeaderField> ExcludeDatHeaderFields { get; set; } = new List<DatHeaderField>();
|
||||
|
||||
/// <summary>
|
||||
/// Dictionary of DatItem fields to exclude from writing
|
||||
/// </summary>
|
||||
public List<DatItemField> ExcludeDatItemFields { get; set; } = new List<DatItemField>();
|
||||
|
||||
/// <summary>
|
||||
/// Dictionary of Machine fields to exclude from writing
|
||||
/// </summary>
|
||||
public List<MachineField> ExcludeMachineFields { get; set; } = new List<MachineField>();
|
||||
|
||||
/// <summary>
|
||||
/// Keep machines that don't contain any items
|
||||
@@ -73,5 +104,7 @@ namespace SabreTools.Filtering
|
||||
/// Trim total machine and item name to not exceed NTFS limits
|
||||
/// </summary>
|
||||
public bool Trim { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,8 @@ namespace SabreTools.Filtering
|
||||
string fieldString = inputTrimmed.Split(':')[0].ToLowerInvariant().Trim('"', ' ', '\t');
|
||||
string fileString = inputTrimmed.Substring(fieldString.Length + 1).Trim('"', ' ', '\t');
|
||||
|
||||
item.Field = fieldString.AsField();
|
||||
item.DatItemField = fieldString.AsDatItemField();
|
||||
item.MachineField = fieldString.AsMachineField();
|
||||
if (item.PopulateFromFile(fileString))
|
||||
Items.Add(item);
|
||||
}
|
||||
|
||||
@@ -12,9 +12,14 @@ namespace SabreTools.Filtering
|
||||
#region Fields
|
||||
|
||||
/// <summary>
|
||||
/// Field to update with INI information
|
||||
/// MachineField to update with INI information
|
||||
/// </summary>
|
||||
public Field Field { get; set; }
|
||||
public MachineField MachineField { get; set; } = MachineField.NULL;
|
||||
|
||||
/// <summary>
|
||||
/// DatItemField to update with INI information
|
||||
/// </summary>
|
||||
public DatItemField DatItemField { get; set; } = DatItemField.NULL;
|
||||
|
||||
/// <summary>
|
||||
/// Mappings from value to machine name
|
||||
|
||||
@@ -219,7 +219,7 @@ namespace SabreTools.Filtering
|
||||
/// <param name="filterItem">Filter item to check</param>
|
||||
/// <param name="value">Value to check</param>
|
||||
/// <returns>True if the value passes, false otherwise</returns>
|
||||
public bool PassBoolFilter(FilterItem<bool?> filterItem, bool? value)
|
||||
public static bool PassBoolFilter(FilterItem<bool?> filterItem, bool? value)
|
||||
{
|
||||
if (filterItem.MatchesNeutral(null, value) == false)
|
||||
return false;
|
||||
@@ -233,7 +233,7 @@ namespace SabreTools.Filtering
|
||||
/// <param name="filterItem">Filter item to check</param>
|
||||
/// <param name="value">Value to check</param>
|
||||
/// <returns>True if the value passes, false otherwise</returns>
|
||||
public bool PassDoubleFilter(FilterItem<double?> filterItem, double? value)
|
||||
public static bool PassDoubleFilter(FilterItem<double?> filterItem, double? value)
|
||||
{
|
||||
if (filterItem.MatchesNeutral(null, value) == false)
|
||||
return false;
|
||||
@@ -251,7 +251,7 @@ namespace SabreTools.Filtering
|
||||
/// <param name="filterItem">Filter item to check</param>
|
||||
/// <param name="value">Value to check</param>
|
||||
/// <returns>True if the value passes, false otherwise</returns>
|
||||
public bool PassLongFilter(FilterItem<long?> filterItem, long? value)
|
||||
public static bool PassLongFilter(FilterItem<long?> filterItem, long? value)
|
||||
{
|
||||
if (filterItem.MatchesNeutral(null, value) == false)
|
||||
return false;
|
||||
@@ -269,7 +269,7 @@ namespace SabreTools.Filtering
|
||||
/// <param name="filterItem">Filter item to check</param>
|
||||
/// <param name="value">Value to check</param>
|
||||
/// <returns>True if the value passes, false otherwise</returns>
|
||||
public bool PassStringFilter(FilterItem<string> filterItem, string value)
|
||||
public static bool PassStringFilter(FilterItem<string> filterItem, string value)
|
||||
{
|
||||
if (filterItem.MatchesPositiveSet(value) == false)
|
||||
return false;
|
||||
|
||||
@@ -2345,11 +2345,6 @@ Some special strings that can be used:
|
||||
/// </summary>
|
||||
protected ExtraIni Extras { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Pre-configured Filter
|
||||
/// </summary>
|
||||
protected Filter Filter { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Pre-configured DatHeader
|
||||
/// </summary>
|
||||
@@ -2459,7 +2454,6 @@ Some special strings that can be used:
|
||||
// Generic feature flags
|
||||
Cleaner = GetCleaner(features);
|
||||
Extras = GetExtras(features);
|
||||
Filter = GetFilter(features);
|
||||
Header = GetDatHeader(features);
|
||||
OutputDir = GetString(features, OutputDirStringValue);
|
||||
|
||||
@@ -2612,68 +2606,83 @@ Some special strings that can be used:
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get update fields from feature list
|
||||
/// Get update DatItem fields from feature list
|
||||
/// </summary>
|
||||
protected List<Field> GetUpdateFields(Dictionary<string, Feature> features)
|
||||
protected List<DatItemField> GetUpdateDatItemFields(Dictionary<string, Feature> features)
|
||||
{
|
||||
List<Field> updateFields = new List<Field>();
|
||||
|
||||
if (GetBoolean(features, UpdateDescriptionValue))
|
||||
{
|
||||
logger.User($"This flag '{(UpdateDescriptionValue)}' is deprecated, please use {(string.Join(", ", UpdateFieldListInput.Flags))} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
updateFields.Add(Field.Machine_Description);
|
||||
}
|
||||
|
||||
if (GetBoolean(features, UpdateGameTypeValue))
|
||||
{
|
||||
logger.User($"This flag '{(UpdateGameTypeValue)}' is deprecated, please use {(string.Join(", ", UpdateFieldListInput.Flags))} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
updateFields.Add(Field.Machine_Type);
|
||||
}
|
||||
List<DatItemField> updateFields = new List<DatItemField>();
|
||||
|
||||
if (GetBoolean(features, UpdateHashesValue))
|
||||
{
|
||||
logger.User($"This flag '{(UpdateHashesValue)}' is deprecated, please use {(string.Join(", ", UpdateFieldListInput.Flags))} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
updateFields.Add(Field.DatItem_CRC);
|
||||
updateFields.Add(Field.DatItem_MD5);
|
||||
updateFields.Add(DatItemField.CRC);
|
||||
updateFields.Add(DatItemField.MD5);
|
||||
#if NET_FRAMEWORK
|
||||
updateFields.Add(Field.DatItem_RIPEMD160);
|
||||
updateFields.Add(DatItemField.RIPEMD160);
|
||||
#endif
|
||||
updateFields.Add(Field.DatItem_SHA1);
|
||||
updateFields.Add(Field.DatItem_SHA256);
|
||||
updateFields.Add(Field.DatItem_SHA384);
|
||||
updateFields.Add(Field.DatItem_SHA512);
|
||||
updateFields.Add(Field.DatItem_SpamSum);
|
||||
}
|
||||
|
||||
if (GetBoolean(features, UpdateManufacturerValue))
|
||||
{
|
||||
logger.User($"This flag '{(UpdateManufacturerValue)}' is deprecated, please use {(string.Join(", ", UpdateFieldListInput.Flags))} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
updateFields.Add(Field.Machine_Manufacturer);
|
||||
updateFields.Add(DatItemField.SHA1);
|
||||
updateFields.Add(DatItemField.SHA256);
|
||||
updateFields.Add(DatItemField.SHA384);
|
||||
updateFields.Add(DatItemField.SHA512);
|
||||
updateFields.Add(DatItemField.SpamSum);
|
||||
}
|
||||
|
||||
if (GetBoolean(features, UpdateNamesValue))
|
||||
{
|
||||
logger.User($"This flag '{(UpdateNamesValue)}' is deprecated, please use {(string.Join(", ", UpdateFieldListInput.Flags))} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
updateFields.Add(Field.DatItem_Name);
|
||||
updateFields.Add(DatItemField.Name);
|
||||
}
|
||||
|
||||
foreach (string fieldName in GetList(features, UpdateFieldListValue))
|
||||
{
|
||||
updateFields.Add(fieldName.AsDatItemField());
|
||||
}
|
||||
|
||||
return updateFields;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get update Machine fields from feature list
|
||||
/// </summary>
|
||||
protected List<MachineField> GetUpdateMachineFields(Dictionary<string, Feature> features)
|
||||
{
|
||||
List<MachineField> updateFields = new List<MachineField>();
|
||||
|
||||
if (GetBoolean(features, UpdateDescriptionValue))
|
||||
{
|
||||
logger.User($"This flag '{(UpdateDescriptionValue)}' is deprecated, please use {(string.Join(", ", UpdateFieldListInput.Flags))} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
updateFields.Add(MachineField.Description);
|
||||
}
|
||||
|
||||
if (GetBoolean(features, UpdateGameTypeValue))
|
||||
{
|
||||
logger.User($"This flag '{(UpdateGameTypeValue)}' is deprecated, please use {(string.Join(", ", UpdateFieldListInput.Flags))} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
updateFields.Add(MachineField.Type);
|
||||
}
|
||||
|
||||
if (GetBoolean(features, UpdateManufacturerValue))
|
||||
{
|
||||
logger.User($"This flag '{(UpdateManufacturerValue)}' is deprecated, please use {(string.Join(", ", UpdateFieldListInput.Flags))} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
updateFields.Add(MachineField.Manufacturer);
|
||||
}
|
||||
|
||||
if (GetBoolean(features, UpdateParentsValue))
|
||||
{
|
||||
logger.User($"This flag '{(UpdateParentsValue)}' is deprecated, please use {(string.Join(", ", UpdateFieldListInput.Flags))} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
updateFields.Add(Field.Machine_CloneOf);
|
||||
updateFields.Add(Field.Machine_RomOf);
|
||||
updateFields.Add(Field.Machine_SampleOf);
|
||||
updateFields.Add(MachineField.CloneOf);
|
||||
updateFields.Add(MachineField.RomOf);
|
||||
updateFields.Add(MachineField.SampleOf);
|
||||
}
|
||||
|
||||
if (GetBoolean(features, UpdateYearValue))
|
||||
{
|
||||
logger.User($"This flag '{(UpdateYearValue)}' is deprecated, please use {(string.Join(", ", UpdateFieldListInput.Flags))} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
updateFields.Add(Field.Machine_Year);
|
||||
updateFields.Add(MachineField.Year);
|
||||
}
|
||||
|
||||
foreach (string fieldName in GetList(features, UpdateFieldListValue))
|
||||
{
|
||||
updateFields.Add(fieldName.AsField());
|
||||
updateFields.Add(fieldName.AsMachineField());
|
||||
}
|
||||
|
||||
return updateFields;
|
||||
@@ -2730,6 +2739,10 @@ Some special strings that can be used:
|
||||
{
|
||||
Cleaner cleaner = new Cleaner()
|
||||
{
|
||||
DatHeaderFilter = new DatHeaderFilter(),
|
||||
DatItemFilter = new DatItemFilter(),
|
||||
MachineFilter = new MachineFilter(),
|
||||
|
||||
Clean = GetBoolean(features, CleanValue),
|
||||
DedupeRoms = GetDedupeType(features),
|
||||
DescriptionAsName = GetBoolean(features, DescriptionAsNameValue),
|
||||
@@ -2744,9 +2757,223 @@ Some special strings that can be used:
|
||||
Trim = GetBoolean(features, TrimValue),
|
||||
};
|
||||
|
||||
// Add field exclusions
|
||||
foreach (string fieldName in GetList(features, ExcludeFieldListValue))
|
||||
{
|
||||
cleaner.ExcludeFields.Add(fieldName.AsField());
|
||||
cleaner.ExcludeDatHeaderFields.Add(fieldName.AsDatHeaderField());
|
||||
cleaner.ExcludeMachineFields.Add(fieldName.AsMachineField());
|
||||
cleaner.ExcludeDatItemFields.Add(fieldName.AsDatItemField());
|
||||
}
|
||||
|
||||
// Populate filters
|
||||
List<string> filterPairs = GetList(features, FilterListValue);
|
||||
cleaner.DatHeaderFilter.PopulateFromList(filterPairs);
|
||||
cleaner.DatItemFilter.PopulateFromList(filterPairs);
|
||||
cleaner.MachineFilter.PopulateFromList(filterPairs);
|
||||
|
||||
// Include 'of" in game filters
|
||||
cleaner.MachineFilter.IncludeOfInGame = GetBoolean(features, MatchOfTagsValue);
|
||||
|
||||
// Category
|
||||
if (features.ContainsKey(NotCategoryListValue))
|
||||
{
|
||||
logger.User($"This flag '{(NotCategoryListValue)}' is deprecated, please use {(string.Join(", ", FilterListInput.Flags))} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
cleaner.MachineFilter.SetFilter(MachineField.Category, GetList(features, NotCategoryListValue), true);
|
||||
}
|
||||
if (features.ContainsKey(CategoryListValue))
|
||||
{
|
||||
logger.User($"This flag '{(CategoryListValue)}' is deprecated, please use {(string.Join(", ", FilterListInput.Flags))} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
cleaner.MachineFilter.SetFilter(MachineField.Category, GetList(features, CategoryListValue), false);
|
||||
}
|
||||
|
||||
// CRC
|
||||
if (features.ContainsKey(NotCrcListValue))
|
||||
{
|
||||
logger.User($"This flag '{(NotCrcListValue)}' is deprecated, please use {(string.Join(", ", FilterListInput.Flags))} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
cleaner.DatItemFilter.SetFilter(DatItemField.CRC, GetList(features, NotCrcListValue), true);
|
||||
}
|
||||
if (features.ContainsKey(CrcListValue))
|
||||
{
|
||||
logger.User($"This flag '{(CrcListValue)}' is deprecated, please use {(string.Join(", ", FilterListInput.Flags))} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
cleaner.DatItemFilter.SetFilter(DatItemField.CRC, GetList(features, NotCrcListValue), false);
|
||||
}
|
||||
|
||||
// Item name
|
||||
if (features.ContainsKey(NotItemNameListValue))
|
||||
{
|
||||
logger.User($"This flag '{(NotItemNameListValue)}' is deprecated, please use {(string.Join(", ", FilterListInput.Flags))} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
cleaner.DatItemFilter.SetFilter(DatItemField.Name, GetList(features, NotItemNameListValue), true);
|
||||
}
|
||||
if (features.ContainsKey(ItemNameListValue))
|
||||
{
|
||||
logger.User($"This flag '{(ItemNameListValue)}' is deprecated, please use {(string.Join(", ", FilterListInput.Flags))} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
cleaner.DatItemFilter.SetFilter(DatItemField.Name, GetList(features, ItemNameListValue), false);
|
||||
}
|
||||
|
||||
// Item status
|
||||
if (features.ContainsKey(NotStatusListValue))
|
||||
{
|
||||
logger.User($"This flag '{(NotStatusListValue)}' is deprecated, please use {(string.Join(", ", FilterListInput.Flags))} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
cleaner.DatItemFilter.SetFilter(DatItemField.Status, GetList(features, NotStatusListValue), true);
|
||||
}
|
||||
if (features.ContainsKey(StatusListValue))
|
||||
{
|
||||
logger.User($"This flag '{(StatusListValue)}' is deprecated, please use {(string.Join(", ", FilterListInput.Flags))} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
cleaner.DatItemFilter.SetFilter(DatItemField.Status, GetList(features, StatusListValue), false);
|
||||
}
|
||||
|
||||
// Item type
|
||||
if (features.ContainsKey(NotItemTypeListValue))
|
||||
{
|
||||
logger.User($"This flag '{(NotItemTypeListValue)}' is deprecated, please use {(string.Join(", ", FilterListInput.Flags))} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
cleaner.DatItemFilter.SetFilter(DatItemField.Type, GetList(features, NotItemTypeListValue), true);
|
||||
}
|
||||
if (features.ContainsKey(ItemTypeListValue))
|
||||
{
|
||||
logger.User($"This flag '{(ItemTypeListValue)}' is deprecated, please use {(string.Join(", ", FilterListInput.Flags))} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
cleaner.DatItemFilter.SetFilter(DatItemField.Type, GetList(features, ItemTypeListValue), false);
|
||||
}
|
||||
|
||||
// Machine description
|
||||
if (features.ContainsKey(NotGameDescriptionListValue))
|
||||
{
|
||||
logger.User($"This flag '{(NotGameDescriptionListValue)}' is deprecated, please use {(string.Join(", ", FilterListInput.Flags))} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
cleaner.MachineFilter.SetFilter(MachineField.Description, GetList(features, NotGameDescriptionListValue), true);
|
||||
}
|
||||
if (features.ContainsKey(GameDescriptionListValue))
|
||||
{
|
||||
logger.User($"This flag '{(GameDescriptionListValue)}' is deprecated, please use {(string.Join(", ", FilterListInput.Flags))} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
cleaner.MachineFilter.SetFilter(MachineField.Description, GetList(features, GameDescriptionListValue), false);
|
||||
}
|
||||
|
||||
// Machine name
|
||||
if (features.ContainsKey(NotGameNameListValue))
|
||||
{
|
||||
logger.User($"This flag '{(NotGameNameListValue)}' is deprecated, please use {(string.Join(", ", FilterListInput.Flags))} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
cleaner.MachineFilter.SetFilter(MachineField.Name, GetList(features, NotGameNameListValue), true);
|
||||
}
|
||||
if (features.ContainsKey(GameNameListValue))
|
||||
{
|
||||
logger.User($"This flag '{(GameNameListValue)}' is deprecated, please use {(string.Join(", ", FilterListInput.Flags))} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
cleaner.MachineFilter.SetFilter(MachineField.Name, GetList(features, GameNameListValue), false);
|
||||
}
|
||||
|
||||
// Machine type
|
||||
if (features.ContainsKey(NotGameTypeListValue))
|
||||
{
|
||||
logger.User($"This flag '{(NotGameTypeListValue)}' is deprecated, please use {(string.Join(", ", FilterListInput.Flags))} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
cleaner.MachineFilter.SetFilter(MachineField.Type, GetList(features, NotGameTypeListValue), true);
|
||||
}
|
||||
if (features.ContainsKey(GameTypeListValue))
|
||||
{
|
||||
logger.User($"This flag '{(GameTypeListValue)}' is deprecated, please use {(string.Join(", ", FilterListInput.Flags))} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
cleaner.MachineFilter.SetFilter(MachineField.Type, GetList(features, GameTypeListValue), false);
|
||||
}
|
||||
|
||||
// MD5
|
||||
if (features.ContainsKey(NotMd5ListValue))
|
||||
{
|
||||
logger.User($"This flag '{(NotMd5ListValue)}' is deprecated, please use {(string.Join(", ", FilterListInput.Flags))} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
cleaner.DatItemFilter.SetFilter(DatItemField.MD5, GetList(features, NotMd5ListValue), true);
|
||||
}
|
||||
if (features.ContainsKey(Md5ListValue))
|
||||
{
|
||||
logger.User($"This flag '{Md5ListValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
cleaner.DatItemFilter.SetFilter(DatItemField.MD5, GetList(features, Md5ListValue), false);
|
||||
}
|
||||
|
||||
#if NET_FRAMEWORK
|
||||
// RIPEMD160
|
||||
if (features.ContainsKey(NotRipeMd160ListValue))
|
||||
{
|
||||
logger.User($"This flag '{NotRipeMd160ListValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
cleaner.DatItemFilter.SetFilter(DatItemField.RIPEMD160, GetList(features, NotRipeMd160ListValue), true);
|
||||
}
|
||||
if (features.ContainsKey(RipeMd160ListValue))
|
||||
{
|
||||
logger.User($"This flag '{RipeMd160ListValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
cleaner.DatItemFilter.SetFilter(DatItemField.RIPEMD160, GetList(features, RipeMd160ListValue), false);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Runnable
|
||||
if (features.ContainsKey(NotRunnableValue))
|
||||
{
|
||||
logger.User($"This flag '{NotRunnableValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
cleaner.MachineFilter.SetFilter(MachineField.Runnable, string.Empty, true);
|
||||
}
|
||||
if (features.ContainsKey(RunnableValue))
|
||||
{
|
||||
logger.User($"This flag '{RunnableValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
cleaner.MachineFilter.SetFilter(MachineField.Runnable, string.Empty, false);
|
||||
}
|
||||
|
||||
// SHA1
|
||||
if (features.ContainsKey(NotSha1ListValue))
|
||||
{
|
||||
logger.User($"This flag '{NotSha1ListValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
cleaner.DatItemFilter.SetFilter(DatItemField.SHA1, GetList(features, NotSha1ListValue), true);
|
||||
}
|
||||
if (features.ContainsKey(Sha1ListValue))
|
||||
{
|
||||
logger.User($"This flag '{Sha1ListValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
cleaner.DatItemFilter.SetFilter(DatItemField.SHA1, GetList(features, Sha1ListValue), false);
|
||||
}
|
||||
|
||||
// SHA256
|
||||
if (features.ContainsKey(NotSha256ListValue))
|
||||
{
|
||||
logger.User($"This flag '{NotSha256ListValue}' is deprecated, please use {string.Join(",", FilterListInput.Flags)} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
cleaner.DatItemFilter.SetFilter(DatItemField.SHA256, GetList(features, NotSha256ListValue), true);
|
||||
}
|
||||
if (features.ContainsKey(Sha256ListValue))
|
||||
{
|
||||
logger.User($"This flag '{Sha256ListValue}' is deprecated, please use {string.Join(",", FilterListInput.Flags)} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
cleaner.DatItemFilter.SetFilter(DatItemField.SHA256, GetList(features, Sha256ListValue), false);
|
||||
}
|
||||
|
||||
// SHA384
|
||||
if (features.ContainsKey(NotSha384ListValue))
|
||||
{
|
||||
logger.User($"This flag '{NotSha384ListValue}' is deprecated, please use {string.Join(",", FilterListInput.Flags)} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
cleaner.DatItemFilter.SetFilter(DatItemField.SHA384, GetList(features, NotSha384ListValue), true);
|
||||
}
|
||||
if (features.ContainsKey(Sha384ListValue))
|
||||
{
|
||||
logger.User($"This flag '{Sha384ListValue}' is deprecated, please use {string.Join(",", FilterListInput.Flags)} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
cleaner.DatItemFilter.SetFilter(DatItemField.SHA384, GetList(features, Sha384ListValue), false);
|
||||
}
|
||||
|
||||
// SHA512
|
||||
if (features.ContainsKey(NotSha512ListValue))
|
||||
{
|
||||
logger.User($"This flag '{NotSha512ListValue}' is deprecated, please use {string.Join(",", FilterListInput.Flags)} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
cleaner.DatItemFilter.SetFilter(DatItemField.SHA512, GetList(features, NotSha512ListValue), true);
|
||||
}
|
||||
if (features.ContainsKey(Sha512ListValue))
|
||||
{
|
||||
logger.User($"This flag '{Sha512ListValue}' is deprecated, please use {string.Join(",", FilterListInput.Flags)} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
cleaner.DatItemFilter.SetFilter(DatItemField.SHA512, GetList(features, Sha512ListValue), false);
|
||||
}
|
||||
|
||||
// Size
|
||||
if (features.ContainsKey(LessStringValue))
|
||||
{
|
||||
logger.User($"This flag '{LessStringValue}' is deprecated, please use {string.Join(",", FilterListInput.Flags)} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
var value = ToSize(GetString(features, LessStringValue));
|
||||
cleaner.DatItemFilter.SetFilter(DatItemField.Size, $"<{value}", false);
|
||||
}
|
||||
if (features.ContainsKey(EqualStringValue))
|
||||
{
|
||||
logger.User($"This flag '{EqualStringValue}' is deprecated, please use {string.Join(",", FilterListInput.Flags)} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
var value = ToSize(GetString(features, EqualStringValue));
|
||||
cleaner.DatItemFilter.SetFilter(DatItemField.Size, $"={value}", false);
|
||||
}
|
||||
if (features.ContainsKey(GreaterStringValue))
|
||||
{
|
||||
logger.User($"This flag '{GreaterStringValue}' is deprecated, please use {string.Join(",", FilterListInput.Flags)} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
var value = ToSize(GetString(features, GreaterStringValue));
|
||||
cleaner.DatItemFilter.SetFilter(DatItemField.Size, $">{value}", false);
|
||||
}
|
||||
|
||||
return cleaner;
|
||||
@@ -2831,233 +3058,6 @@ Some special strings that can be used:
|
||||
return extraIni;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Filter from feature list
|
||||
/// </summary>
|
||||
private Filter GetFilter(Dictionary<string, Feature> features)
|
||||
{
|
||||
Filter filter = new Filter();
|
||||
|
||||
// Use the Filter flag first
|
||||
List<string> filterPairs = GetList(features, FilterListValue);
|
||||
filter.PopulateFromList(filterPairs);
|
||||
|
||||
#region Obsoleted Inputs
|
||||
|
||||
// Category
|
||||
if (features.ContainsKey(NotCategoryListValue))
|
||||
{
|
||||
logger.User($"This flag '{(NotCategoryListValue)}' is deprecated, please use {(string.Join(", ", FilterListInput.Flags))} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
filter.SetFilter(Field.Machine_Category, GetList(features, NotCategoryListValue), true);
|
||||
}
|
||||
if (features.ContainsKey(CategoryListValue))
|
||||
{
|
||||
logger.User($"This flag '{(CategoryListValue)}' is deprecated, please use {(string.Join(", ", FilterListInput.Flags))} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
filter.SetFilter(Field.Machine_Category, GetList(features, CategoryListValue), false);
|
||||
}
|
||||
|
||||
// CRC
|
||||
if (features.ContainsKey(NotCrcListValue))
|
||||
{
|
||||
logger.User($"This flag '{(NotCrcListValue)}' is deprecated, please use {(string.Join(", ", FilterListInput.Flags))} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
filter.SetFilter(Field.DatItem_CRC, GetList(features, NotCrcListValue), true);
|
||||
}
|
||||
if (features.ContainsKey(CrcListValue))
|
||||
{
|
||||
logger.User($"This flag '{(CrcListValue)}' is deprecated, please use {(string.Join(", ", FilterListInput.Flags))} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
filter.SetFilter(Field.DatItem_CRC, GetList(features, NotCrcListValue), false);
|
||||
}
|
||||
|
||||
// Item name
|
||||
if (features.ContainsKey(NotItemNameListValue))
|
||||
{
|
||||
logger.User($"This flag '{(NotItemNameListValue)}' is deprecated, please use {(string.Join(", ", FilterListInput.Flags))} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
filter.SetFilter(Field.DatItem_Name, GetList(features, NotItemNameListValue), true);
|
||||
}
|
||||
if (features.ContainsKey(ItemNameListValue))
|
||||
{
|
||||
logger.User($"This flag '{(ItemNameListValue)}' is deprecated, please use {(string.Join(", ", FilterListInput.Flags))} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
filter.SetFilter(Field.DatItem_Name, GetList(features, ItemNameListValue), false);
|
||||
}
|
||||
|
||||
// Item status
|
||||
if (features.ContainsKey(NotStatusListValue))
|
||||
{
|
||||
logger.User($"This flag '{(NotStatusListValue)}' is deprecated, please use {(string.Join(", ", FilterListInput.Flags))} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
filter.SetFilter(Field.DatItem_Status, GetList(features, NotStatusListValue), true);
|
||||
}
|
||||
if (features.ContainsKey(StatusListValue))
|
||||
{
|
||||
logger.User($"This flag '{(StatusListValue)}' is deprecated, please use {(string.Join(", ", FilterListInput.Flags))} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
filter.SetFilter(Field.DatItem_Status, GetList(features, StatusListValue), false);
|
||||
}
|
||||
|
||||
// Item type
|
||||
if (features.ContainsKey(NotItemTypeListValue))
|
||||
{
|
||||
logger.User($"This flag '{(NotItemTypeListValue)}' is deprecated, please use {(string.Join(", ", FilterListInput.Flags))} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
filter.SetFilter(Field.DatItem_Type, GetList(features, NotItemTypeListValue), true);
|
||||
}
|
||||
if (features.ContainsKey(ItemTypeListValue))
|
||||
{
|
||||
logger.User($"This flag '{(ItemTypeListValue)}' is deprecated, please use {(string.Join(", ", FilterListInput.Flags))} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
filter.SetFilter(Field.DatItem_Type, GetList(features, ItemTypeListValue), false);
|
||||
}
|
||||
|
||||
// Machine description
|
||||
if (features.ContainsKey(NotGameDescriptionListValue))
|
||||
{
|
||||
logger.User($"This flag '{(NotGameDescriptionListValue)}' is deprecated, please use {(string.Join(", ", FilterListInput.Flags))} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
filter.SetFilter(Field.Machine_Description, GetList(features, NotGameDescriptionListValue), true);
|
||||
}
|
||||
if (features.ContainsKey(GameDescriptionListValue))
|
||||
{
|
||||
logger.User($"This flag '{(GameDescriptionListValue)}' is deprecated, please use {(string.Join(", ", FilterListInput.Flags))} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
filter.SetFilter(Field.Machine_Description, GetList(features, GameDescriptionListValue), false);
|
||||
}
|
||||
|
||||
// Machine name
|
||||
if (features.ContainsKey(NotGameNameListValue))
|
||||
{
|
||||
logger.User($"This flag '{(NotGameNameListValue)}' is deprecated, please use {(string.Join(", ", FilterListInput.Flags))} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
filter.SetFilter(Field.Machine_Name, GetList(features, NotGameNameListValue), true);
|
||||
}
|
||||
if (features.ContainsKey(GameNameListValue))
|
||||
{
|
||||
logger.User($"This flag '{(GameNameListValue)}' is deprecated, please use {(string.Join(", ", FilterListInput.Flags))} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
filter.SetFilter(Field.Machine_Name, GetList(features, GameNameListValue), false);
|
||||
}
|
||||
|
||||
// Machine type
|
||||
if (features.ContainsKey(NotGameTypeListValue))
|
||||
{
|
||||
logger.User($"This flag '{(NotGameTypeListValue)}' is deprecated, please use {(string.Join(", ", FilterListInput.Flags))} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
filter.SetFilter(Field.Machine_Type, GetList(features, NotGameTypeListValue), true);
|
||||
}
|
||||
if (features.ContainsKey(GameTypeListValue))
|
||||
{
|
||||
logger.User($"This flag '{(GameTypeListValue)}' is deprecated, please use {(string.Join(", ", FilterListInput.Flags))} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
filter.SetFilter(Field.Machine_Type, GetList(features, GameTypeListValue), false);
|
||||
}
|
||||
|
||||
// MD5
|
||||
if (features.ContainsKey(NotMd5ListValue))
|
||||
{
|
||||
logger.User($"This flag '{(NotMd5ListValue)}' is deprecated, please use {(string.Join(", ", FilterListInput.Flags))} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
filter.SetFilter(Field.DatItem_MD5, GetList(features, NotMd5ListValue), true);
|
||||
}
|
||||
if (features.ContainsKey(Md5ListValue))
|
||||
{
|
||||
logger.User($"This flag '{Md5ListValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
filter.SetFilter(Field.DatItem_MD5, GetList(features, Md5ListValue), false);
|
||||
}
|
||||
|
||||
#if NET_FRAMEWORK
|
||||
// RIPEMD160
|
||||
if (features.ContainsKey(NotRipeMd160ListValue))
|
||||
{
|
||||
logger.User($"This flag '{NotRipeMd160ListValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
filter.SetFilter(Field.DatItem_RIPEMD160, GetList(features, NotRipeMd160ListValue), true);
|
||||
}
|
||||
if (features.ContainsKey(RipeMd160ListValue))
|
||||
{
|
||||
logger.User($"This flag '{RipeMd160ListValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
filter.SetFilter(Field.DatItem_RIPEMD160, GetList(features, RipeMd160ListValue), false);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Runnable
|
||||
if (features.ContainsKey(NotRunnableValue))
|
||||
{
|
||||
logger.User($"This flag '{NotRunnableValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
filter.SetFilter(Field.Machine_Runnable, string.Empty, true);
|
||||
}
|
||||
if (features.ContainsKey(RunnableValue))
|
||||
{
|
||||
logger.User($"This flag '{RunnableValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
filter.SetFilter(Field.Machine_Runnable, string.Empty, false);
|
||||
}
|
||||
|
||||
// SHA1
|
||||
if (features.ContainsKey(NotSha1ListValue))
|
||||
{
|
||||
logger.User($"This flag '{NotSha1ListValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
filter.SetFilter(Field.DatItem_SHA1, GetList(features, NotSha1ListValue), true);
|
||||
}
|
||||
if (features.ContainsKey(Sha1ListValue))
|
||||
{
|
||||
logger.User($"This flag '{Sha1ListValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
filter.SetFilter(Field.DatItem_SHA1, GetList(features, Sha1ListValue), false);
|
||||
}
|
||||
|
||||
// SHA256
|
||||
if (features.ContainsKey(NotSha256ListValue))
|
||||
{
|
||||
logger.User($"This flag '{NotSha256ListValue}' is deprecated, please use {string.Join(",", FilterListInput.Flags)} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
filter.SetFilter(Field.DatItem_SHA256, GetList(features, NotSha256ListValue), true);
|
||||
}
|
||||
if (features.ContainsKey(Sha256ListValue))
|
||||
{
|
||||
logger.User($"This flag '{Sha256ListValue}' is deprecated, please use {string.Join(",", FilterListInput.Flags)} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
filter.SetFilter(Field.DatItem_SHA256, GetList(features, Sha256ListValue), false);
|
||||
}
|
||||
|
||||
// SHA384
|
||||
if (features.ContainsKey(NotSha384ListValue))
|
||||
{
|
||||
logger.User($"This flag '{NotSha384ListValue}' is deprecated, please use {string.Join(",", FilterListInput.Flags)} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
filter.SetFilter(Field.DatItem_SHA384, GetList(features, NotSha384ListValue), true);
|
||||
}
|
||||
if (features.ContainsKey(Sha384ListValue))
|
||||
{
|
||||
logger.User($"This flag '{Sha384ListValue}' is deprecated, please use {string.Join(",", FilterListInput.Flags)} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
filter.SetFilter(Field.DatItem_SHA384, GetList(features, Sha384ListValue), false);
|
||||
}
|
||||
|
||||
// SHA512
|
||||
if (features.ContainsKey(NotSha512ListValue))
|
||||
{
|
||||
logger.User($"This flag '{NotSha512ListValue}' is deprecated, please use {string.Join(",", FilterListInput.Flags)} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
filter.SetFilter(Field.DatItem_SHA512, GetList(features, NotSha512ListValue), true);
|
||||
}
|
||||
if (features.ContainsKey(Sha512ListValue))
|
||||
{
|
||||
logger.User($"This flag '{Sha512ListValue}' is deprecated, please use {string.Join(",", FilterListInput.Flags)} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
filter.SetFilter(Field.DatItem_SHA512, GetList(features, Sha512ListValue), false);
|
||||
}
|
||||
|
||||
// Size
|
||||
if (features.ContainsKey(LessStringValue))
|
||||
{
|
||||
logger.User($"This flag '{LessStringValue}' is deprecated, please use {string.Join(",", FilterListInput.Flags)} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
var value = ToSize(GetString(features, LessStringValue));
|
||||
filter.SetFilter(Field.DatItem_Size, $"<{value}", false);
|
||||
}
|
||||
if (features.ContainsKey(EqualStringValue))
|
||||
{
|
||||
logger.User($"This flag '{EqualStringValue}' is deprecated, please use {string.Join(",", FilterListInput.Flags)} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
var value = ToSize(GetString(features, EqualStringValue));
|
||||
filter.SetFilter(Field.DatItem_Size, $"={value}", false);
|
||||
}
|
||||
if (features.ContainsKey(GreaterStringValue))
|
||||
{
|
||||
logger.User($"This flag '{GreaterStringValue}' is deprecated, please use {string.Join(",", FilterListInput.Flags)} instead. Please refer to README.1ST or the help feature for more details.");
|
||||
var value = ToSize(GetString(features, GreaterStringValue));
|
||||
filter.SetFilter(Field.DatItem_Size, $">{value}", false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Additional Filter flags
|
||||
|
||||
// Include 'of" in game filters
|
||||
filter.IncludeOfInGame = GetBoolean(features, MatchOfTagsValue);
|
||||
|
||||
#endregion
|
||||
|
||||
return filter;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Protected Helpers
|
||||
|
||||
@@ -104,18 +104,18 @@ Reset the internal state: reset();";
|
||||
}
|
||||
|
||||
// Read in the individual arguments
|
||||
Field field = command.Arguments[0].AsField();
|
||||
DatHeaderField field = command.Arguments[0].AsDatHeaderField();
|
||||
string value = command.Arguments[1];
|
||||
|
||||
// If we had an invalid input, log and continue
|
||||
if (field == Field.NULL)
|
||||
if (field == DatHeaderField.NULL)
|
||||
{
|
||||
logger.User($"{command.Arguments[0]} was an invalid field name");
|
||||
continue;
|
||||
}
|
||||
|
||||
// Set the header field
|
||||
datFile.Header.SetFields(new Dictionary<Field, string> { [field] = value });
|
||||
datFile.Header.SetFields(new Dictionary<DatHeaderField, string> { [field] = value });
|
||||
|
||||
break;
|
||||
|
||||
@@ -159,8 +159,8 @@ Reset the internal state: reset();";
|
||||
|
||||
// TODO: We might not want to remove higher order hashes in the future
|
||||
// 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);
|
||||
Cleaner dfdCleaner = new Cleaner() { ExcludeDatItemFields = Hash.DeepHashes.AsDatItemFields() };
|
||||
dfdCleaner.ExcludeDatItemFields.Add(DatItemField.Date);
|
||||
Modification.ApplyCleaning(datFile, dfdCleaner);
|
||||
|
||||
break;
|
||||
@@ -201,12 +201,21 @@ Reset the internal state: reset();";
|
||||
continue;
|
||||
}
|
||||
|
||||
// Create a filter with this new set of fields
|
||||
Filter filter = new Filter();
|
||||
filter.SetFilter(filterField, filterValue, filterRemove.Value);
|
||||
// Create cleaner to run filters from
|
||||
Cleaner cleaner = new Cleaner
|
||||
{
|
||||
DatHeaderFilter = new DatHeaderFilter(),
|
||||
MachineFilter = new MachineFilter(),
|
||||
DatItemFilter = new DatItemFilter(),
|
||||
};
|
||||
|
||||
// Apply the filter blindly
|
||||
Modification.ApplyFilter(datFile, filter, filterPerMachine.Value);
|
||||
// Set the possible filters
|
||||
cleaner.DatHeaderFilter.SetFilter(command.Arguments[0].AsDatHeaderField(), filterValue, filterRemove.Value);
|
||||
cleaner.MachineFilter.SetFilter(command.Arguments[0].AsMachineField(), filterValue, filterRemove.Value);
|
||||
cleaner.DatItemFilter.SetFilter(command.Arguments[0].AsDatItemField(), filterValue, filterRemove.Value);
|
||||
|
||||
// Apply the filters blindly
|
||||
Modification.ApplyFilters(datFile, cleaner, filterPerMachine.Value);
|
||||
|
||||
// Cleanup after the filter
|
||||
// TODO: We might not want to remove immediately
|
||||
@@ -244,7 +253,8 @@ Reset the internal state: reset();";
|
||||
ExtraIni extraIni = new ExtraIni();
|
||||
ExtraIniItem extraIniItem = new ExtraIniItem();
|
||||
extraIniItem.PopulateFromFile(extraFile);
|
||||
extraIniItem.Field = extraField;
|
||||
extraIniItem.MachineField = command.Arguments[0].AsMachineField();
|
||||
extraIniItem.DatItemField = command.Arguments[0].AsDatItemField();
|
||||
extraIni.Items.Add(extraIniItem);
|
||||
|
||||
// Apply the extra INI blindly
|
||||
@@ -328,7 +338,9 @@ Reset the internal state: reset();";
|
||||
}
|
||||
|
||||
// Run the removal functionality
|
||||
Modification.RemoveFieldsFromItems(datFile, command.Arguments.Select(s => s.AsField()).ToList());
|
||||
var removeDatItemFields = command.Arguments.Select(s => s.AsDatItemField()).ToList();
|
||||
var removeMachineFields = command.Arguments.Select(s => s.AsMachineField()).ToList();
|
||||
Modification.RemoveFieldsFromItems(datFile, removeDatItemFields, removeMachineFields);
|
||||
|
||||
break;
|
||||
|
||||
|
||||
@@ -68,11 +68,11 @@ namespace SabreTools.Features
|
||||
var splitType = GetSplitType(features);
|
||||
|
||||
// Apply the specialized field removals to the cleaner
|
||||
if (Cleaner.ExcludeFields == null)
|
||||
Cleaner.ExcludeFields = new List<Field>();
|
||||
if (Cleaner.ExcludeDatItemFields == null)
|
||||
Cleaner.ExcludeDatItemFields = new List<DatItemField>();
|
||||
|
||||
if (!addFileDates)
|
||||
Cleaner.ExcludeFields.Add(Field.DatItem_Date);
|
||||
Cleaner.ExcludeDatItemFields.Add(DatItemField.Date);
|
||||
|
||||
// Create a new DATFromDir object and process the inputs
|
||||
DatFile basedat = DatFile.Create(Header);
|
||||
@@ -104,7 +104,7 @@ namespace SabreTools.Features
|
||||
// Perform additional processing steps
|
||||
Modification.ApplyExtras(datdata, Extras);
|
||||
Modification.ApplySplitting(datdata, splitType, false);
|
||||
Modification.ApplyFilter(datdata, Filter);
|
||||
Modification.ApplyFilters(datdata, Cleaner);
|
||||
Modification.ApplyCleaning(datdata, Cleaner);
|
||||
|
||||
// Write out the file
|
||||
|
||||
@@ -103,7 +103,8 @@ namespace SabreTools.Features
|
||||
base.ProcessFeatures(features);
|
||||
|
||||
// Get feature flags
|
||||
var updateFields = GetUpdateFields(features);
|
||||
var updateDatItemFields = GetUpdateDatItemFields(features);
|
||||
var updateMachineFields = GetUpdateMachineFields(features);
|
||||
var updateMode = GetUpdateMode(features);
|
||||
|
||||
// Normalize the extensions
|
||||
@@ -146,8 +147,8 @@ namespace SabreTools.Features
|
||||
}
|
||||
|
||||
// If no update fields are set, default to Names
|
||||
if (updateFields == null || updateFields.Count == 0)
|
||||
updateFields = new List<Field>() { Field.DatItem_Name };
|
||||
if (updateDatItemFields == null || updateDatItemFields.Count == 0)
|
||||
updateDatItemFields = new List<DatItemField>() { DatItemField.Name };
|
||||
|
||||
// Ensure we only have files in the inputs
|
||||
List<ParentablePath> inputPaths = PathTool.GetFilesOnly(Inputs, appendparent: true);
|
||||
@@ -170,7 +171,7 @@ namespace SabreTools.Features
|
||||
// Perform additional processing steps
|
||||
Modification.ApplyExtras(datFile, Extras);
|
||||
Modification.ApplySplitting(datFile, GetSplitType(features), false);
|
||||
Modification.ApplyFilter(datFile, Filter);
|
||||
Modification.ApplyFilters(datFile, Cleaner);
|
||||
Modification.ApplyCleaning(datFile, Cleaner);
|
||||
|
||||
// Get the correct output path
|
||||
@@ -208,7 +209,7 @@ namespace SabreTools.Features
|
||||
// Perform additional processing steps
|
||||
Modification.ApplyExtras(userInputDat, Extras);
|
||||
Modification.ApplySplitting(userInputDat, GetSplitType(features), false);
|
||||
Modification.ApplyFilter(userInputDat, Filter);
|
||||
Modification.ApplyFilters(userInputDat, Cleaner);
|
||||
Modification.ApplyCleaning(userInputDat, Cleaner);
|
||||
|
||||
// Output only DatItems that are duplicated across inputs
|
||||
@@ -300,7 +301,7 @@ namespace SabreTools.Features
|
||||
// Perform additional processing steps
|
||||
Modification.ApplyExtras(repDat, Extras);
|
||||
Modification.ApplySplitting(repDat, GetSplitType(features), false);
|
||||
Modification.ApplyFilter(repDat, Filter);
|
||||
Modification.ApplyFilters(repDat, Cleaner);
|
||||
Modification.ApplyCleaning(repDat, Cleaner);
|
||||
|
||||
// Now replace the fields from the base DatFile
|
||||
@@ -325,11 +326,16 @@ namespace SabreTools.Features
|
||||
// Perform additional processing steps
|
||||
Modification.ApplyExtras(repDat, Extras);
|
||||
Modification.ApplySplitting(repDat, GetSplitType(features), false);
|
||||
Modification.ApplyFilter(repDat, Filter);
|
||||
Modification.ApplyFilters(repDat, Cleaner);
|
||||
Modification.ApplyCleaning(repDat, Cleaner);
|
||||
|
||||
// Now replace the fields from the base DatFile
|
||||
DatTool.BaseReplace(userInputDat, repDat, updateFields, GetBoolean(features, OnlySameValue));
|
||||
DatTool.BaseReplace(
|
||||
userInputDat,
|
||||
repDat,
|
||||
updateMachineFields,
|
||||
updateDatItemFields,
|
||||
GetBoolean(features, OnlySameValue));
|
||||
|
||||
// Finally output the replaced DatFile
|
||||
string interOutDir = inputPath.GetOutputPath(OutputDir, GetBoolean(features, InplaceValue));
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace SabreTools.Features
|
||||
// Perform additional processing steps
|
||||
Modification.ApplyExtras(datdata, Extras);
|
||||
Modification.ApplySplitting(datdata, splitType, true);
|
||||
Modification.ApplyFilter(datdata, Filter);
|
||||
Modification.ApplyFilters(datdata, Cleaner);
|
||||
Modification.ApplyCleaning(datdata, Cleaner);
|
||||
|
||||
// Set depot information
|
||||
@@ -111,7 +111,7 @@ namespace SabreTools.Features
|
||||
// Perform additional processing steps
|
||||
Modification.ApplyExtras(datdata, Extras);
|
||||
Modification.ApplySplitting(datdata, splitType, true);
|
||||
Modification.ApplyFilter(datdata, Filter);
|
||||
Modification.ApplyFilters(datdata, Cleaner);
|
||||
Modification.ApplyCleaning(datdata, Cleaner);
|
||||
|
||||
// Set depot information
|
||||
|
||||
Reference in New Issue
Block a user