mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Handle Configuration; promote Location, Setting
This commit is contained in:
@@ -84,9 +84,32 @@ 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_Setting*
|
||||
// Field.DatItem_Conditions does not apply here
|
||||
if (Conditions != null)
|
||||
{
|
||||
foreach (Condition condition in Conditions)
|
||||
{
|
||||
condition.SetFields(mappings);
|
||||
}
|
||||
}
|
||||
|
||||
// Field.DatItem_Locations does not apply here
|
||||
if (Locations != null)
|
||||
{
|
||||
foreach (Location location in Locations)
|
||||
{
|
||||
location.SetFields(mappings);
|
||||
}
|
||||
}
|
||||
|
||||
// Field.DatItem_Settings does not apply here
|
||||
if (Settings != null)
|
||||
{
|
||||
foreach (Setting setting in Settings)
|
||||
{
|
||||
setting.SetFields(mappings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -158,11 +181,38 @@ namespace SabreTools.Library.DatItems
|
||||
Configuration newOther = other as Configuration;
|
||||
|
||||
// If the Configuration information matches
|
||||
return (Name == newOther.Name && Tag == newOther.Tag && Mask == newOther.Mask);
|
||||
|
||||
// TODO: Handle DatItem_Condition*
|
||||
// TODO: Handle DatItem_Location*
|
||||
// TODO: Handle DatItem_Setting*
|
||||
bool match = (Name == newOther.Name && Tag == newOther.Tag && Mask == newOther.Mask);
|
||||
if (!match)
|
||||
return match;
|
||||
|
||||
// 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 settings match
|
||||
if (Settings != null)
|
||||
{
|
||||
foreach (Setting setting in Settings)
|
||||
{
|
||||
match &= newOther.Settings.Contains(setting);
|
||||
}
|
||||
}
|
||||
|
||||
return match;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -225,9 +275,47 @@ namespace SabreTools.Library.DatItems
|
||||
if (filter.DatItem_Mask.MatchesNegativeSet(Mask) == true)
|
||||
return false;
|
||||
|
||||
// TODO: Handle DatItem_Condition*
|
||||
// TODO: Handle DatItem_Location*
|
||||
// TODO: Handle DatItem_Setting*
|
||||
// Filter on conditions
|
||||
if (filter.DatItem_Conditions.MatchesNeutral(null, Conditions != null ? (bool?)(Conditions.Count > 0) : null) == false)
|
||||
return false;
|
||||
|
||||
// Filter on individual conditions
|
||||
if (Conditions != null)
|
||||
{
|
||||
foreach (Condition condition in Conditions)
|
||||
{
|
||||
if (!condition.PassesFilter(filter))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Filter on locations
|
||||
if (filter.DatItem_Locations.MatchesNeutral(null, Locations != null ? (bool?)(Locations.Count > 0) : null) == false)
|
||||
return false;
|
||||
|
||||
// Filter on individual locations
|
||||
if (Locations != null)
|
||||
{
|
||||
foreach (Location location in Locations)
|
||||
{
|
||||
if (!location.PassesFilter(filter))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Filter on settings
|
||||
if (filter.DatItem_Settings.MatchesNeutral(null, Settings != null ? (bool?)(Settings.Count > 0) : null) == false)
|
||||
return false;
|
||||
|
||||
// Filter on individual conditions
|
||||
if (Settings != null)
|
||||
{
|
||||
foreach (Setting setting in Settings)
|
||||
{
|
||||
if (!setting.PassesFilter(filter))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -254,15 +342,35 @@ namespace SabreTools.Library.DatItems
|
||||
if (fields.Contains(Field.DatItem_Conditions))
|
||||
Conditions = null;
|
||||
|
||||
if (Conditions != null)
|
||||
{
|
||||
foreach (Condition condition in Conditions)
|
||||
{
|
||||
condition.RemoveFields(fields);
|
||||
}
|
||||
}
|
||||
|
||||
if (fields.Contains(Field.DatItem_Locations))
|
||||
Locations = null;
|
||||
|
||||
if (Locations != null)
|
||||
{
|
||||
foreach (Location location in Locations)
|
||||
{
|
||||
location.RemoveFields(fields);
|
||||
}
|
||||
}
|
||||
|
||||
if (fields.Contains(Field.DatItem_Settings))
|
||||
Settings = null;
|
||||
|
||||
// TODO: Handle DatItem_Condition*
|
||||
// TODO: Handle DatItem_Location*
|
||||
// TODO: Handle DatItem_Setting*
|
||||
if (Settings != null)
|
||||
{
|
||||
foreach (Setting setting in Settings)
|
||||
{
|
||||
setting.RemoveFields(fields);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -309,15 +417,17 @@ namespace SabreTools.Library.DatItems
|
||||
if (fields.Contains(Field.DatItem_Conditions))
|
||||
Conditions = newItem.Conditions;
|
||||
|
||||
// Field replacement doesn't make sense for DatItem_Condition*
|
||||
|
||||
if (fields.Contains(Field.DatItem_Locations))
|
||||
Locations = newItem.Locations;
|
||||
|
||||
// Field replacement doesn't make sense for DatItem_Location*
|
||||
|
||||
if (fields.Contains(Field.DatItem_Settings))
|
||||
Settings = newItem.Settings;
|
||||
|
||||
// TODO: Handle DatItem_Condition*
|
||||
// TODO: Handle DatItem_Location*
|
||||
// TODO: Handle DatItem_Setting*
|
||||
// Field replacement doesn't make sense for DatItem_Setting*
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user