diff --git a/SabreTools.Library/DatItems/Adjuster.cs b/SabreTools.Library/DatItems/Adjuster.cs
index 3f24ecec..7e5977c4 100644
--- a/SabreTools.Library/DatItems/Adjuster.cs
+++ b/SabreTools.Library/DatItems/Adjuster.cs
@@ -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
diff --git a/SabreTools.Library/DatItems/Analog.cs b/SabreTools.Library/DatItems/Analog.cs
index 68309b38..568ce31e 100644
--- a/SabreTools.Library/DatItems/Analog.cs
+++ b/SabreTools.Library/DatItems/Analog.cs
@@ -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;
diff --git a/SabreTools.Library/DatItems/BiosSet.cs b/SabreTools.Library/DatItems/BiosSet.cs
index 0ce9adeb..a5dad455 100644
--- a/SabreTools.Library/DatItems/BiosSet.cs
+++ b/SabreTools.Library/DatItems/BiosSet.cs
@@ -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
diff --git a/SabreTools.Library/DatItems/Condition.cs b/SabreTools.Library/DatItems/Condition.cs
index cea5c6a2..b069b440 100644
--- a/SabreTools.Library/DatItems/Condition.cs
+++ b/SabreTools.Library/DatItems/Condition.cs
@@ -47,30 +47,49 @@ namespace SabreTools.Library.DatItems
///
/// Mappings dictionary
public override void SetFields(Dictionary mappings)
+ {
+ SetFields(mappings, false);
+ }
+
+ ///
+ /// Set fields with given values
+ ///
+ /// Mappings dictionary
+ /// True if this is a subitem, false otherwise
+ public void SetFields(Dictionary mappings, bool sub)
{
// Set base fields
base.SetFields(mappings);
// Handle Condition-specific fields
- 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 (sub)
+ {
+ 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_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_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];
+ 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];
+
+ if (mappings.Keys.Contains(Field.DatItem_Mask))
+ Mask = mappings[Field.DatItem_Mask];
+
+ if (mappings.Keys.Contains(Field.DatItem_Relation))
+ Relation = mappings[Field.DatItem_Relation];
+
+ if (mappings.Keys.Contains(Field.DatItem_Value))
+ Value = mappings[Field.DatItem_Value];
+ }
}
#endregion
@@ -137,50 +156,74 @@ namespace SabreTools.Library.DatItems
/// Filter to check against
/// True if the item passed the filter, false otherwise
public override bool PassesFilter(Filter filter)
+ {
+ return PassesFilter(filter, false);
+ }
+
+ ///
+ /// Check to see if a DatItem passes the filter
+ ///
+ /// Filter to check against
+ /// True if this is a subitem, false otherwise
+ /// True if the item passed the filter, false otherwise
+ public bool PassesFilter(Filter filter, bool sub)
{
// Check common fields first
if (!base.PassesFilter(filter))
return false;
- // 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;
+ 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_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
+ if (filter.DatItem_Condition_Mask.MatchesPositiveSet(Mask) == false)
+ return false;
+ if (filter.DatItem_Condition_Mask.MatchesNegativeSet(Mask) == true)
+ return false;
- // Filter on mask
- 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 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_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;
+ // 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;
+
+ // Filter on mask
+ if (filter.DatItem_Mask.MatchesPositiveSet(Mask) == false)
+ return false;
+ if (filter.DatItem_Mask.MatchesNegativeSet(Mask) == true)
+ return false;
+
+ // Filter on relation
+ if (filter.DatItem_Relation.MatchesPositiveSet(Relation) == false)
+ return false;
+ if (filter.DatItem_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;
+ }
return true;
}
@@ -190,30 +233,49 @@ namespace SabreTools.Library.DatItems
///
/// List of Fields to remove
public override void RemoveFields(List fields)
+ {
+ RemoveFields(fields, false);
+ }
+
+ ///
+ /// Remove fields from the DatItem
+ ///
+ /// List of Fields to remove
+ /// True if this is a subitem, false otherwise
+ public void RemoveFields(List fields, bool sub)
{
// Remove common fields first
base.RemoveFields(fields);
// Remove the fields
- if (fields.Contains(Field.DatItem_Tag))
- Tag = null;
- else if (fields.Contains(Field.DatItem_Condition_Tag))
- Tag = null;
+ if (sub)
+ {
+ if (fields.Contains(Field.DatItem_Condition_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_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_Condition_Relation))
+ Relation = null;
- if (fields.Contains(Field.DatItem_Value))
- Value = null;
- else if (fields.Contains(Field.DatItem_Condition_Value))
- Value = 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;
+
+ if (fields.Contains(Field.DatItem_Relation))
+ Relation = null;
+
+ if (fields.Contains(Field.DatItem_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))
diff --git a/SabreTools.Library/DatItems/Configuration.cs b/SabreTools.Library/DatItems/Configuration.cs
index 933560fd..18fc3ab7 100644
--- a/SabreTools.Library/DatItems/Configuration.cs
+++ b/SabreTools.Library/DatItems/Configuration.cs
@@ -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
diff --git a/SabreTools.Library/DatItems/Device.cs b/SabreTools.Library/DatItems/Device.cs
index 8b0111f1..85e711cb 100644
--- a/SabreTools.Library/DatItems/Device.cs
+++ b/SabreTools.Library/DatItems/Device.cs
@@ -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
diff --git a/SabreTools.Library/DatItems/DipSwitch.cs b/SabreTools.Library/DatItems/DipSwitch.cs
index bb4b942d..f453a4ef 100644
--- a/SabreTools.Library/DatItems/DipSwitch.cs
+++ b/SabreTools.Library/DatItems/DipSwitch.cs
@@ -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);
-
- // TODO: Handle DatItem_Condition*
- // TODO: Handle DatItem_Location*
- // TODO: Handle DatItem_Value*
+ bool match = (Name == newOther.Name
+ && Tag == newOther.Tag
+ && Mask == newOther.Mask);
+ if (!match)
+ return match;
+
+ // 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
diff --git a/SabreTools.Library/DatItems/Input.cs b/SabreTools.Library/DatItems/Input.cs
index dd637092..4344d7ec 100644
--- a/SabreTools.Library/DatItems/Input.cs
+++ b/SabreTools.Library/DatItems/Input.cs
@@ -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
diff --git a/SabreTools.Library/DatItems/Port.cs b/SabreTools.Library/DatItems/Port.cs
index c2f6cba8..29003d0e 100644
--- a/SabreTools.Library/DatItems/Port.cs
+++ b/SabreTools.Library/DatItems/Port.cs
@@ -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
diff --git a/SabreTools.Library/DatItems/Setting.cs b/SabreTools.Library/DatItems/Setting.cs
index 7ea98282..7061387e 100644
--- a/SabreTools.Library/DatItems/Setting.cs
+++ b/SabreTools.Library/DatItems/Setting.cs
@@ -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
diff --git a/SabreTools.Library/DatItems/Slot.cs b/SabreTools.Library/DatItems/Slot.cs
index 7bb0da41..25870414 100644
--- a/SabreTools.Library/DatItems/Slot.cs
+++ b/SabreTools.Library/DatItems/Slot.cs
@@ -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);
+ }
+ }
}
///
@@ -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