mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Fix everything with subitems
This commit is contained in:
@@ -68,7 +68,7 @@ namespace SabreTools.Library.DatItems
|
||||
{
|
||||
foreach (Condition condition in Conditions)
|
||||
{
|
||||
condition.SetFields(mappings);
|
||||
condition.SetFields(mappings, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -194,7 +194,7 @@ namespace SabreTools.Library.DatItems
|
||||
{
|
||||
foreach (Condition condition in Conditions)
|
||||
{
|
||||
if (!condition.PassesFilter(filter))
|
||||
if (!condition.PassesFilter(filter, true))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -222,7 +222,7 @@ namespace SabreTools.Library.DatItems
|
||||
{
|
||||
foreach (Condition condition in Conditions)
|
||||
{
|
||||
condition.RemoveFields(fields);
|
||||
condition.RemoveFields(fields, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -265,7 +265,9 @@ namespace SabreTools.Library.DatItems
|
||||
if (fields.Contains(Field.DatItem_Default))
|
||||
Default = newItem.Default;
|
||||
|
||||
// Field replacement doesn't make sense for DatItem_Condition*
|
||||
// DatItem_Condition_* doesn't make sense here
|
||||
// since not every condition under the other item
|
||||
// can replace every condition under this item
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -102,9 +102,9 @@ namespace SabreTools.Library.DatItems
|
||||
return false;
|
||||
|
||||
// Filter on mask
|
||||
if (filter.DatItem_Mask.MatchesPositiveSet(Mask) == false)
|
||||
if (filter.DatItem_Analog_Mask.MatchesPositiveSet(Mask) == false)
|
||||
return false;
|
||||
if (filter.DatItem_Mask.MatchesNegativeSet(Mask) == true)
|
||||
if (filter.DatItem_Analog_Mask.MatchesNegativeSet(Mask) == true)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
||||
@@ -60,11 +60,11 @@ namespace SabreTools.Library.DatItems
|
||||
if (mappings.Keys.Contains(Field.DatItem_Name))
|
||||
Name = mappings[Field.DatItem_Name];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Default))
|
||||
Default = mappings[Field.DatItem_Default].AsYesNo();
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Description))
|
||||
Description = mappings[Field.DatItem_Description];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Default))
|
||||
Default = mappings[Field.DatItem_Default].AsYesNo();
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -115,7 +115,9 @@ namespace SabreTools.Library.DatItems
|
||||
BiosSet newOther = other as BiosSet;
|
||||
|
||||
// If the BiosSet information matches
|
||||
return (Name == newOther.Name && Description == newOther.Description && Default == newOther.Default);
|
||||
return (Name == newOther.Name
|
||||
&& Description == newOther.Description
|
||||
&& Default == newOther.Default);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -47,30 +47,49 @@ namespace SabreTools.Library.DatItems
|
||||
/// </summary>
|
||||
/// <param name="mappings">Mappings dictionary</param>
|
||||
public override void SetFields(Dictionary<Field, string> mappings)
|
||||
{
|
||||
SetFields(mappings, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="mappings">Mappings dictionary</param>
|
||||
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
||||
public void SetFields(Dictionary<Field, string> mappings, bool sub)
|
||||
{
|
||||
// Set base fields
|
||||
base.SetFields(mappings);
|
||||
|
||||
// Handle Condition-specific fields
|
||||
if (sub)
|
||||
{
|
||||
if (mappings.Keys.Contains(Field.DatItem_Condition_Tag))
|
||||
Tag = mappings[Field.DatItem_Condition_Tag];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Condition_Mask))
|
||||
Mask = mappings[Field.DatItem_Condition_Mask];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Condition_Relation))
|
||||
Relation = mappings[Field.DatItem_Condition_Relation];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Condition_Value))
|
||||
Value = mappings[Field.DatItem_Condition_Value];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mappings.Keys.Contains(Field.DatItem_Tag))
|
||||
Tag = mappings[Field.DatItem_Tag];
|
||||
else if (mappings.Keys.Contains(Field.DatItem_Condition_Tag))
|
||||
Tag = mappings[Field.DatItem_Condition_Tag];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Mask))
|
||||
Mask = mappings[Field.DatItem_Mask];
|
||||
else if (mappings.Keys.Contains(Field.DatItem_Condition_Mask))
|
||||
Mask = mappings[Field.DatItem_Condition_Mask];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Relation))
|
||||
Relation = mappings[Field.DatItem_Relation];
|
||||
else if (mappings.Keys.Contains(Field.DatItem_Condition_Relation))
|
||||
Relation = mappings[Field.DatItem_Condition_Relation];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Value))
|
||||
Value = mappings[Field.DatItem_Value];
|
||||
else if (mappings.Keys.Contains(Field.DatItem_Condition_Value))
|
||||
Value = mappings[Field.DatItem_Condition_Value];
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -137,50 +156,74 @@ namespace SabreTools.Library.DatItems
|
||||
/// <param name="filter">Filter to check against</param>
|
||||
/// <returns>True if the item passed the filter, false otherwise</returns>
|
||||
public override bool PassesFilter(Filter filter)
|
||||
{
|
||||
return PassesFilter(filter, false);
|
||||
}
|
||||
|
||||
/// <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 bool PassesFilter(Filter filter, bool sub)
|
||||
{
|
||||
// Check common fields first
|
||||
if (!base.PassesFilter(filter))
|
||||
return false;
|
||||
|
||||
if (sub)
|
||||
{
|
||||
// Filter on tag
|
||||
if (filter.DatItem_Condition_Tag.MatchesPositiveSet(Tag) == false)
|
||||
return false;
|
||||
if (filter.DatItem_Condition_Tag.MatchesNegativeSet(Tag) == true)
|
||||
return false;
|
||||
|
||||
// Filter on mask
|
||||
if (filter.DatItem_Condition_Mask.MatchesPositiveSet(Mask) == false)
|
||||
return false;
|
||||
if (filter.DatItem_Condition_Mask.MatchesNegativeSet(Mask) == true)
|
||||
return false;
|
||||
|
||||
// Filter on relation
|
||||
if (filter.DatItem_Condition_Relation.MatchesPositiveSet(Relation) == false)
|
||||
return false;
|
||||
if (filter.DatItem_Condition_Relation.MatchesNegativeSet(Relation) == true)
|
||||
return false;
|
||||
|
||||
// Filter on value
|
||||
if (filter.DatItem_Condition_Value.MatchesPositiveSet(Value) == false)
|
||||
return false;
|
||||
if (filter.DatItem_Condition_Value.MatchesNegativeSet(Value) == true)
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Filter on tag
|
||||
if (filter.DatItem_Tag.MatchesPositiveSet(Tag) == false)
|
||||
return false;
|
||||
if (filter.DatItem_Tag.MatchesNegativeSet(Tag) == true)
|
||||
return false;
|
||||
if (filter.DatItem_Condition_Tag.MatchesPositiveSet(Tag) == false)
|
||||
return false;
|
||||
if (filter.DatItem_Condition_Tag.MatchesNegativeSet(Tag) == true)
|
||||
return false;
|
||||
|
||||
// Filter on mask
|
||||
if (filter.DatItem_Mask.MatchesPositiveSet(Mask) == false)
|
||||
return false;
|
||||
if (filter.DatItem_Mask.MatchesNegativeSet(Mask) == true)
|
||||
return false;
|
||||
if (filter.DatItem_Condition_Mask.MatchesPositiveSet(Mask) == false)
|
||||
return false;
|
||||
if (filter.DatItem_Condition_Mask.MatchesNegativeSet(Mask) == true)
|
||||
return false;
|
||||
|
||||
// Filter on mask
|
||||
// Filter on relation
|
||||
if (filter.DatItem_Relation.MatchesPositiveSet(Relation) == false)
|
||||
return false;
|
||||
if (filter.DatItem_Relation.MatchesNegativeSet(Relation) == true)
|
||||
return false;
|
||||
if (filter.DatItem_Condition_Relation.MatchesPositiveSet(Relation) == false)
|
||||
return false;
|
||||
if (filter.DatItem_Condition_Relation.MatchesNegativeSet(Relation) == true)
|
||||
return false;
|
||||
|
||||
// Filter on value
|
||||
if (filter.DatItem_Value.MatchesPositiveSet(Value) == false)
|
||||
return false;
|
||||
if (filter.DatItem_Value.MatchesNegativeSet(Value) == true)
|
||||
return false;
|
||||
if (filter.DatItem_Condition_Value.MatchesPositiveSet(Value) == false)
|
||||
return false;
|
||||
if (filter.DatItem_Condition_Value.MatchesNegativeSet(Value) == true)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -190,30 +233,49 @@ namespace SabreTools.Library.DatItems
|
||||
/// </summary>
|
||||
/// <param name="fields">List of Fields to remove</param>
|
||||
public override void RemoveFields(List<Field> fields)
|
||||
{
|
||||
RemoveFields(fields, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove fields from the DatItem
|
||||
/// </summary>
|
||||
/// <param name="fields">List of Fields to remove</param>
|
||||
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
||||
public void RemoveFields(List<Field> fields, bool sub)
|
||||
{
|
||||
// Remove common fields first
|
||||
base.RemoveFields(fields);
|
||||
|
||||
// Remove the fields
|
||||
if (fields.Contains(Field.DatItem_Tag))
|
||||
if (sub)
|
||||
{
|
||||
if (fields.Contains(Field.DatItem_Condition_Tag))
|
||||
Tag = null;
|
||||
else if (fields.Contains(Field.DatItem_Condition_Tag))
|
||||
|
||||
if (fields.Contains(Field.DatItem_Condition_Mask))
|
||||
Mask = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Condition_Relation))
|
||||
Relation = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Condition_Value))
|
||||
Value = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fields.Contains(Field.DatItem_Tag))
|
||||
Tag = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Mask))
|
||||
Mask = null;
|
||||
else if (fields.Contains(Field.DatItem_Condition_Mask))
|
||||
Mask = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Relation))
|
||||
Relation = null;
|
||||
else if (fields.Contains(Field.DatItem_Condition_Relation))
|
||||
Relation = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Value))
|
||||
Value = null;
|
||||
else if (fields.Contains(Field.DatItem_Condition_Value))
|
||||
Value = null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -238,6 +300,7 @@ namespace SabreTools.Library.DatItems
|
||||
Condition newItem = item as Condition;
|
||||
|
||||
// Replace the fields
|
||||
// TODO: Would this ever make sense to have these `else` statements?
|
||||
if (fields.Contains(Field.DatItem_Tag))
|
||||
Tag = newItem.Tag;
|
||||
else if (fields.Contains(Field.DatItem_Condition_Tag))
|
||||
|
||||
@@ -84,16 +84,14 @@ namespace SabreTools.Library.DatItems
|
||||
if (mappings.Keys.Contains(Field.DatItem_Mask))
|
||||
Mask = mappings[Field.DatItem_Mask];
|
||||
|
||||
// Field.DatItem_Conditions does not apply here
|
||||
if (Conditions != null)
|
||||
{
|
||||
foreach (Condition condition in Conditions)
|
||||
{
|
||||
condition.SetFields(mappings);
|
||||
condition.SetFields(mappings, true);
|
||||
}
|
||||
}
|
||||
|
||||
// Field.DatItem_Locations does not apply here
|
||||
if (Locations != null)
|
||||
{
|
||||
foreach (Location location in Locations)
|
||||
@@ -102,7 +100,6 @@ namespace SabreTools.Library.DatItems
|
||||
}
|
||||
}
|
||||
|
||||
// Field.DatItem_Settings does not apply here
|
||||
if (Settings != null)
|
||||
{
|
||||
foreach (Setting setting in Settings)
|
||||
@@ -163,7 +160,9 @@ namespace SabreTools.Library.DatItems
|
||||
Configuration newOther = other as Configuration;
|
||||
|
||||
// If the Configuration information matches
|
||||
bool match = (Name == newOther.Name && Tag == newOther.Tag && Mask == newOther.Mask);
|
||||
bool match = (Name == newOther.Name
|
||||
&& Tag == newOther.Tag
|
||||
&& Mask == newOther.Mask);
|
||||
if (!match)
|
||||
return match;
|
||||
|
||||
@@ -262,7 +261,7 @@ namespace SabreTools.Library.DatItems
|
||||
{
|
||||
foreach (Condition condition in Conditions)
|
||||
{
|
||||
if (!condition.PassesFilter(filter))
|
||||
if (!condition.PassesFilter(filter, true))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -313,7 +312,7 @@ namespace SabreTools.Library.DatItems
|
||||
{
|
||||
foreach (Condition condition in Conditions)
|
||||
{
|
||||
condition.RemoveFields(fields);
|
||||
condition.RemoveFields(fields, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -375,9 +374,17 @@ namespace SabreTools.Library.DatItems
|
||||
if (fields.Contains(Field.DatItem_Mask))
|
||||
Mask = newItem.Mask;
|
||||
|
||||
// Field replacement doesn't make sense for DatItem_Condition*
|
||||
// Field replacement doesn't make sense for DatItem_Location*
|
||||
// Field replacement doesn't make sense for DatItem_Setting*
|
||||
// DatItem_Condition_* doesn't make sense here
|
||||
// since not every condition under the other item
|
||||
// can replace every condition under this item
|
||||
|
||||
// DatItem_Location_* doesn't make sense here
|
||||
// since not every location under the other item
|
||||
// can replace every location under this item
|
||||
|
||||
// DatItem_Setting_* doesn't make sense here
|
||||
// since not every setting under the other item
|
||||
// can replace every setting under this item
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -85,8 +85,21 @@ namespace SabreTools.Library.DatItems
|
||||
if (mappings.Keys.Contains(Field.DatItem_Interface))
|
||||
Interface = mappings[Field.DatItem_Interface];
|
||||
|
||||
// TODO: Handle DatItem_Instance*
|
||||
// TODO: Handle DatItem_Extension*
|
||||
if (Instances != null)
|
||||
{
|
||||
foreach (Instance instance in Instances)
|
||||
{
|
||||
instance.SetFields(mappings);
|
||||
}
|
||||
}
|
||||
|
||||
if (Extensions != null)
|
||||
{
|
||||
foreach (Extension extension in Extensions)
|
||||
{
|
||||
extension.SetFields(mappings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -140,14 +153,33 @@ namespace SabreTools.Library.DatItems
|
||||
Device newOther = other as Device;
|
||||
|
||||
// If the Device information matches
|
||||
return (DeviceType == newOther.DeviceType
|
||||
bool match = (DeviceType == newOther.DeviceType
|
||||
&& Tag == newOther.Tag
|
||||
&& FixedImage == newOther.FixedImage
|
||||
&& Mandatory == newOther.Mandatory
|
||||
&& Interface == newOther.Interface);
|
||||
if (!match)
|
||||
return match;
|
||||
|
||||
// TODO: Handle DatItem_Instance*
|
||||
// TODO: Handle DatItem_Extension*
|
||||
// If the instances match
|
||||
if (Instances != null)
|
||||
{
|
||||
foreach (Instance instance in Instances)
|
||||
{
|
||||
match &= newOther.Instances.Contains(instance);
|
||||
}
|
||||
}
|
||||
|
||||
// If the extensions match
|
||||
if (Extensions != null)
|
||||
{
|
||||
foreach (Extension extension in Extensions)
|
||||
{
|
||||
match &= newOther.Extensions.Contains(extension);
|
||||
}
|
||||
}
|
||||
|
||||
return match;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -195,8 +227,25 @@ namespace SabreTools.Library.DatItems
|
||||
if (filter.DatItem_Interface.MatchesNegativeSet(Interface) == true)
|
||||
return false;
|
||||
|
||||
// TODO: Handle DatItem_Instance*
|
||||
// TODO: Handle DatItem_Extension*
|
||||
// Filter on individual instances
|
||||
if (Instances != null)
|
||||
{
|
||||
foreach (Instance instance in Instances)
|
||||
{
|
||||
if (!instance.PassesFilter(filter))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Filter on individual extensions
|
||||
if (Extensions != null)
|
||||
{
|
||||
foreach (Extension extension in Extensions)
|
||||
{
|
||||
if (!extension.PassesFilter(filter))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -226,8 +275,21 @@ namespace SabreTools.Library.DatItems
|
||||
if (fields.Contains(Field.DatItem_Interface))
|
||||
Interface = null;
|
||||
|
||||
// TODO: Handle DatItem_Instance*
|
||||
// TODO: Handle DatItem_Extension*
|
||||
if (Instances != null)
|
||||
{
|
||||
foreach (Instance instance in Instances)
|
||||
{
|
||||
instance.RemoveFields(fields);
|
||||
}
|
||||
}
|
||||
|
||||
if (Extensions != null)
|
||||
{
|
||||
foreach (Extension extension in Extensions)
|
||||
{
|
||||
extension.RemoveFields(fields);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -267,8 +329,13 @@ namespace SabreTools.Library.DatItems
|
||||
if (fields.Contains(Field.DatItem_Interface))
|
||||
Interface = newItem.Interface;
|
||||
|
||||
// TODO: Handle DatItem_Instance*
|
||||
// TODO: Handle DatItem_Extension*
|
||||
// DatItem_Instance_* doesn't make sense here
|
||||
// since not every instance under the other item
|
||||
// can replace every instance under this item
|
||||
|
||||
// DatItem_Extension_* doesn't make sense here
|
||||
// since not every extension under the other item
|
||||
// can replace every extension under this item
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -101,9 +101,29 @@ namespace SabreTools.Library.DatItems
|
||||
if (mappings.Keys.Contains(Field.DatItem_Mask))
|
||||
Mask = mappings[Field.DatItem_Mask];
|
||||
|
||||
// TODO: Handle DatItem_Condition*
|
||||
// TODO: Handle DatItem_Location*
|
||||
// TODO: Handle DatItem_Value*
|
||||
if (Conditions != null)
|
||||
{
|
||||
foreach (Condition condition in Conditions)
|
||||
{
|
||||
condition.SetFields(mappings, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (Locations != null)
|
||||
{
|
||||
foreach (Location location in Locations)
|
||||
{
|
||||
location.SetFields(mappings);
|
||||
}
|
||||
}
|
||||
|
||||
if (Values != null)
|
||||
{
|
||||
foreach (Setting value in Values)
|
||||
{
|
||||
value.SetFields(mappings);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -151,7 +171,6 @@ namespace SabreTools.Library.DatItems
|
||||
{
|
||||
return new DipSwitch()
|
||||
{
|
||||
Name = this.Name,
|
||||
ItemType = this.ItemType,
|
||||
DupeType = this.DupeType,
|
||||
|
||||
@@ -159,6 +178,7 @@ namespace SabreTools.Library.DatItems
|
||||
Source = this.Source.Clone() as Source,
|
||||
Remove = this.Remove,
|
||||
|
||||
Name = this.Name,
|
||||
Tag = this.Tag,
|
||||
Mask = this.Mask,
|
||||
Conditions = this.Conditions,
|
||||
@@ -183,11 +203,42 @@ namespace SabreTools.Library.DatItems
|
||||
DipSwitch newOther = other as DipSwitch;
|
||||
|
||||
// If the DipSwitch information matches
|
||||
return (Name == newOther.Name && Tag == newOther.Tag && Mask == newOther.Mask);
|
||||
bool match = (Name == newOther.Name
|
||||
&& Tag == newOther.Tag
|
||||
&& Mask == newOther.Mask);
|
||||
if (!match)
|
||||
return match;
|
||||
|
||||
// TODO: Handle DatItem_Condition*
|
||||
// TODO: Handle DatItem_Location*
|
||||
// TODO: Handle DatItem_Value*
|
||||
// TODO: Handle Part*
|
||||
|
||||
// If the conditions match
|
||||
if (Conditions != null)
|
||||
{
|
||||
foreach (Condition condition in Conditions)
|
||||
{
|
||||
match &= newOther.Conditions.Contains(condition);
|
||||
}
|
||||
}
|
||||
|
||||
// If the locations match
|
||||
if (Locations != null)
|
||||
{
|
||||
foreach (Location location in Locations)
|
||||
{
|
||||
match &= newOther.Locations.Contains(location);
|
||||
}
|
||||
}
|
||||
|
||||
// If the values match
|
||||
if (Values != null)
|
||||
{
|
||||
foreach (Setting value in Values)
|
||||
{
|
||||
match &= newOther.Values.Contains(value);
|
||||
}
|
||||
}
|
||||
|
||||
return match;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -252,9 +303,35 @@ namespace SabreTools.Library.DatItems
|
||||
if (filter.DatItem_Mask.MatchesNegativeSet(Mask) == true)
|
||||
return false;
|
||||
|
||||
// TODO: Handle DatItem_Condition*
|
||||
// TODO: Handle DatItem_Location*
|
||||
// TODO: Handle DatItem_Value*
|
||||
// Filter on individual conditions
|
||||
if (Conditions != null)
|
||||
{
|
||||
foreach (Condition condition in Conditions)
|
||||
{
|
||||
if (!condition.PassesFilter(filter, true))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Filter on individual locations
|
||||
if (Locations != null)
|
||||
{
|
||||
foreach (Location location in Locations)
|
||||
{
|
||||
if (!location.PassesFilter(filter))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Filter on individual conditions
|
||||
if (Values != null)
|
||||
{
|
||||
foreach (Setting value in Values)
|
||||
{
|
||||
if (!value.PassesFilter(filter))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -301,9 +378,29 @@ namespace SabreTools.Library.DatItems
|
||||
if (fields.Contains(Field.DatItem_Mask))
|
||||
Mask = null;
|
||||
|
||||
// TODO: Handle DatItem_Condition*
|
||||
// TODO: Handle DatItem_Location*
|
||||
// TODO: Handle DatItem_Value*
|
||||
if (Conditions != null)
|
||||
{
|
||||
foreach (Condition condition in Conditions)
|
||||
{
|
||||
condition.RemoveFields(fields, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (Locations != null)
|
||||
{
|
||||
foreach (Location location in Locations)
|
||||
{
|
||||
location.RemoveFields(fields);
|
||||
}
|
||||
}
|
||||
|
||||
if (Values != null)
|
||||
{
|
||||
foreach (Setting value in Values)
|
||||
{
|
||||
value.RemoveFields(fields);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -364,9 +461,17 @@ namespace SabreTools.Library.DatItems
|
||||
if (fields.Contains(Field.DatItem_Mask))
|
||||
Mask = newItem.Mask;
|
||||
|
||||
// TODO: Handle DatItem_Condition*
|
||||
// TODO: Handle DatItem_Location*
|
||||
// TODO: Handle DatItem_Value*
|
||||
// DatItem_Condition_* doesn't make sense here
|
||||
// since not every condition under the other item
|
||||
// can replace every condition under this item
|
||||
|
||||
// DatItem_Location_* doesn't make sense here
|
||||
// since not every location under the other item
|
||||
// can replace every location under this item
|
||||
|
||||
// DatItem_Setting_* doesn't make sense here
|
||||
// since not every value under the other item
|
||||
// can replace every value under this item
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -71,7 +71,13 @@ namespace SabreTools.Library.DatItems
|
||||
if (mappings.Keys.Contains(Field.DatItem_Coins))
|
||||
Coins = mappings[Field.DatItem_Coins];
|
||||
|
||||
// TODO: Handle DatItem_Control*
|
||||
if (Controls != null)
|
||||
{
|
||||
foreach (Control control in Controls)
|
||||
{
|
||||
control.SetFields(mappings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -123,12 +129,23 @@ namespace SabreTools.Library.DatItems
|
||||
Input newOther = other as Input;
|
||||
|
||||
// If the Input information matches
|
||||
return (Service == newOther.Service
|
||||
bool match = (Service == newOther.Service
|
||||
&& Tilt == newOther.Tilt
|
||||
&& Players == newOther.Players
|
||||
&& Coins == newOther.Coins);
|
||||
if (!match)
|
||||
return match;
|
||||
|
||||
// TODO: Handle DatItem_Control*
|
||||
// If the controls match
|
||||
if (Controls != null)
|
||||
{
|
||||
foreach (Control control in Controls)
|
||||
{
|
||||
match &= newOther.Controls.Contains(control);
|
||||
}
|
||||
}
|
||||
|
||||
return match;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -166,7 +183,15 @@ namespace SabreTools.Library.DatItems
|
||||
if (filter.DatItem_Coins.MatchesNegativeSet(Coins) == true)
|
||||
return false;
|
||||
|
||||
// TODO: Handle DatItem_Control*
|
||||
// Filter on individual controls
|
||||
if (Controls != null)
|
||||
{
|
||||
foreach (Control control in Controls)
|
||||
{
|
||||
if (!control.PassesFilter(filter))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -193,7 +218,13 @@ namespace SabreTools.Library.DatItems
|
||||
if (fields.Contains(Field.DatItem_Coins))
|
||||
Coins = null;
|
||||
|
||||
// TODO: Handle DatItem_Control*
|
||||
if (Controls != null)
|
||||
{
|
||||
foreach (Control control in Controls)
|
||||
{
|
||||
control.RemoveFields(fields);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -230,7 +261,9 @@ namespace SabreTools.Library.DatItems
|
||||
if (fields.Contains(Field.DatItem_Coins))
|
||||
Coins = newItem.Coins;
|
||||
|
||||
// TODO: Handle DatItem_Control*
|
||||
// DatItem_Control_* doesn't make sense here
|
||||
// since not every control under the other item
|
||||
// can replace every control under this item
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -43,7 +43,13 @@ namespace SabreTools.Library.DatItems
|
||||
if (mappings.Keys.Contains(Field.DatItem_Tag))
|
||||
Tag = mappings[Field.DatItem_Tag];
|
||||
|
||||
// TODO: Handle DatItem_Analog*
|
||||
if (Analogs != null)
|
||||
{
|
||||
foreach (Analog analog in Analogs)
|
||||
{
|
||||
analog.SetFields(mappings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -92,7 +98,20 @@ namespace SabreTools.Library.DatItems
|
||||
Port newOther = other as Port;
|
||||
|
||||
// If the Port information matches
|
||||
return (Tag == newOther.Tag); // TODO: Handle DatItem_Analog*
|
||||
bool match = (Tag == newOther.Tag);
|
||||
if (!match)
|
||||
return match;
|
||||
|
||||
// If the analogs match
|
||||
if (Analogs != null)
|
||||
{
|
||||
foreach (Analog analog in Analogs)
|
||||
{
|
||||
match &= newOther.Analogs.Contains(analog);
|
||||
}
|
||||
}
|
||||
|
||||
return match;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -116,7 +135,15 @@ namespace SabreTools.Library.DatItems
|
||||
if (filter.DatItem_Tag.MatchesNegativeSet(Tag) == true)
|
||||
return false;
|
||||
|
||||
// TODO: Handle DatItem_Analog*
|
||||
// Filter on individual analogs
|
||||
if (Analogs != null)
|
||||
{
|
||||
foreach (Analog analog in Analogs)
|
||||
{
|
||||
if (!analog.PassesFilter(filter))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -134,7 +161,13 @@ namespace SabreTools.Library.DatItems
|
||||
if (fields.Contains(Field.DatItem_Tag))
|
||||
Tag = null;
|
||||
|
||||
// TODO: Handle DatItem_Analog*
|
||||
if (Analogs != null)
|
||||
{
|
||||
foreach (Analog analog in Analogs)
|
||||
{
|
||||
analog.RemoveFields(fields);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -162,7 +195,9 @@ namespace SabreTools.Library.DatItems
|
||||
if (fields.Contains(Field.DatItem_Name))
|
||||
Tag = newItem.Tag;
|
||||
|
||||
// TODO: Handle DatItem_Analog*
|
||||
// DatItem_Analog_* doesn't make sense here
|
||||
// since not every analog under the other item
|
||||
// can replace every analog under this item
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -72,12 +72,11 @@ namespace SabreTools.Library.DatItems
|
||||
if (mappings.Keys.Contains(Field.DatItem_Setting_Default))
|
||||
Default = mappings[Field.DatItem_Setting_Default].AsYesNo();
|
||||
|
||||
// Field.DatItem_Conditions does not apply here
|
||||
if (Conditions != null)
|
||||
{
|
||||
foreach (Condition condition in Conditions)
|
||||
{
|
||||
condition.SetFields(mappings);
|
||||
condition.SetFields(mappings, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -212,7 +211,7 @@ namespace SabreTools.Library.DatItems
|
||||
{
|
||||
foreach (Condition condition in Conditions)
|
||||
{
|
||||
if (!condition.PassesFilter(filter))
|
||||
if (!condition.PassesFilter(filter, true))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -243,7 +242,7 @@ namespace SabreTools.Library.DatItems
|
||||
{
|
||||
foreach (Condition condition in Conditions)
|
||||
{
|
||||
condition.RemoveFields(fields);
|
||||
condition.RemoveFields(fields, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -289,7 +288,9 @@ namespace SabreTools.Library.DatItems
|
||||
if (fields.Contains(Field.DatItem_Setting_Default))
|
||||
Default = newItem.Default;
|
||||
|
||||
// Field replacement doesn't make sense for DatItem_Condition*
|
||||
// DatItem_Condition_* doesn't make sense here
|
||||
// since not every condition under the other item
|
||||
// can replace every condition under this item
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -54,7 +54,13 @@ namespace SabreTools.Library.DatItems
|
||||
if (mappings.Keys.Contains(Field.DatItem_Name))
|
||||
Name = mappings[Field.DatItem_Name];
|
||||
|
||||
// TODO: Handle DatItem_SlotOption*
|
||||
if (SlotOptions != null)
|
||||
{
|
||||
foreach (SlotOption slotOption in SlotOptions)
|
||||
{
|
||||
slotOption.SetFields(mappings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -104,7 +110,20 @@ namespace SabreTools.Library.DatItems
|
||||
Slot newOther = other as Slot;
|
||||
|
||||
// If the Slot information matches
|
||||
return (Name == newOther.Name); // TODO: Handle DatItem_SlotOption*
|
||||
bool match = (Name == newOther.Name);
|
||||
if (!match)
|
||||
return match;
|
||||
|
||||
// If the slot options match
|
||||
if (SlotOptions != null)
|
||||
{
|
||||
foreach (SlotOption slotOption in SlotOptions)
|
||||
{
|
||||
match &= newOther.SlotOptions.Contains(slotOption);
|
||||
}
|
||||
}
|
||||
|
||||
return match;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -155,7 +174,15 @@ namespace SabreTools.Library.DatItems
|
||||
if (filter.DatItem_Name.MatchesNegativeSet(Name) == true)
|
||||
return false;
|
||||
|
||||
// TODO: Handle DatItem_SlotOption*
|
||||
// Filter on individual slot options
|
||||
if (SlotOptions != null)
|
||||
{
|
||||
foreach (SlotOption slotOption in SlotOptions)
|
||||
{
|
||||
if (!slotOption.PassesFilter(filter))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -173,7 +200,13 @@ namespace SabreTools.Library.DatItems
|
||||
if (fields.Contains(Field.DatItem_Name))
|
||||
Name = null;
|
||||
|
||||
// TODO: Handle DatItem_SlotOption*
|
||||
if (SlotOptions != null)
|
||||
{
|
||||
foreach (SlotOption slotOption in SlotOptions)
|
||||
{
|
||||
slotOption.RemoveFields(fields);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -211,7 +244,9 @@ namespace SabreTools.Library.DatItems
|
||||
if (fields.Contains(Field.DatItem_Name))
|
||||
Name = newItem.Name;
|
||||
|
||||
// TODO: Handle DatItem_SlotOption*
|
||||
// DatItem_SlotOption_* doesn't make sense here
|
||||
// since not every slot option under the other item
|
||||
// can replace every slot option under this item
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user