mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Promote Configuration
This commit is contained in:
@@ -105,7 +105,7 @@ namespace SabreTools.Library.DatItems
|
||||
|
||||
public override bool Equals(DatItem other)
|
||||
{
|
||||
// If we don't have a BiosSet, return false
|
||||
// If we don't have a Adjuster, return false
|
||||
if (ItemType != other.ItemType)
|
||||
return false;
|
||||
|
||||
|
||||
@@ -41,32 +41,6 @@ namespace SabreTools.Library.DatItems
|
||||
public string Value { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents one ListXML configuration
|
||||
/// </summary>
|
||||
/// TODO: Promote to DatItem level (contains lists)
|
||||
[JsonObject("configuration")]
|
||||
public class ListXmlConfiguration
|
||||
{
|
||||
[JsonProperty("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[JsonProperty("tag")]
|
||||
public string Tag { get; set; }
|
||||
|
||||
[JsonProperty("mask")]
|
||||
public string Mask { get; set; }
|
||||
|
||||
[JsonProperty("conditions")]
|
||||
public List<ListXmlCondition> Conditions { get; set; }
|
||||
|
||||
[JsonProperty("locations")]
|
||||
public List<ListXmlConfLocation> Locations { get; set; }
|
||||
|
||||
[JsonProperty("settings")]
|
||||
public List<ListXmlConfSetting> Settings { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents one ListXML conflocation
|
||||
/// </summary>
|
||||
|
||||
256
SabreTools.Library/DatItems/Configuration.cs
Normal file
256
SabreTools.Library/DatItems/Configuration.cs
Normal file
@@ -0,0 +1,256 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using SabreTools.Library.Filtering;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace SabreTools.Library.DatItems
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents which Configuration(s) is associated with a set
|
||||
/// </summary>
|
||||
[JsonObject("configuration")]
|
||||
public class Configuration : DatItem
|
||||
{
|
||||
#region Fields
|
||||
|
||||
/// <summary>
|
||||
/// Tag associated with the configuration
|
||||
/// </summary>
|
||||
[JsonProperty("tag", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
public string Tag { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Mask associated with the configuration
|
||||
/// </summary>
|
||||
[JsonProperty("mask", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
public string Mask { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Conditions associated with the configuration
|
||||
/// </summary>
|
||||
[JsonProperty("conditions")]
|
||||
public List<ListXmlCondition> Conditions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Locations associated with the configuration
|
||||
/// </summary>
|
||||
[JsonProperty("locations")]
|
||||
public List<ListXmlConfLocation> Locations { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Settings associated with the configuration
|
||||
/// </summary>
|
||||
[JsonProperty("settings")]
|
||||
public List<ListXmlConfSetting> Settings { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
/// <param name="mappings">Mappings dictionary</param>
|
||||
public override void SetFields(Dictionary<Field, string> mappings)
|
||||
{
|
||||
// Set base fields
|
||||
base.SetFields(mappings);
|
||||
|
||||
// Handle Configuration-specific fields
|
||||
if (mappings.Keys.Contains(Field.DatItem_Tag))
|
||||
Tag = mappings[Field.DatItem_Tag];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Mask))
|
||||
Mask = mappings[Field.DatItem_Mask];
|
||||
|
||||
// TODO: Handle DatItem_Condition*
|
||||
// TODO: Handle DatItem_Location*
|
||||
// TODO: Handle DatItem_Setting*
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Create a default, empty Configuration object
|
||||
/// </summary>
|
||||
public Configuration()
|
||||
{
|
||||
Name = string.Empty;
|
||||
ItemType = ItemType.Configuration;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Cloning Methods
|
||||
|
||||
public override object Clone()
|
||||
{
|
||||
return new Configuration()
|
||||
{
|
||||
Name = this.Name,
|
||||
ItemType = this.ItemType,
|
||||
DupeType = this.DupeType,
|
||||
|
||||
AltName = this.AltName,
|
||||
AltTitle = this.AltTitle,
|
||||
|
||||
Original = this.Original,
|
||||
OpenMSXSubType = this.OpenMSXSubType,
|
||||
OpenMSXType = this.OpenMSXType,
|
||||
Remark = this.Remark,
|
||||
Boot = this.Boot,
|
||||
|
||||
Part = this.Part,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
AreaWidth = this.AreaWidth,
|
||||
AreaEndianness = this.AreaEndianness,
|
||||
Value = this.Value,
|
||||
LoadFlag = this.LoadFlag,
|
||||
|
||||
Machine = this.Machine.Clone() as Machine,
|
||||
Source = this.Source.Clone() as Source,
|
||||
Remove = this.Remove,
|
||||
|
||||
Tag = this.Tag,
|
||||
Mask = this.Mask,
|
||||
Conditions = this.Conditions,
|
||||
Locations = this.Locations,
|
||||
Settings = this.Settings,
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Comparision Methods
|
||||
|
||||
public override bool Equals(DatItem other)
|
||||
{
|
||||
// If we don't have a Configuration, return false
|
||||
if (ItemType != other.ItemType)
|
||||
return false;
|
||||
|
||||
// Otherwise, treat it as a Configuration
|
||||
Configuration newOther = other as Configuration;
|
||||
|
||||
// If the Adjuster information matches
|
||||
return (Name == newOther.Name && Tag == newOther.Tag && Mask == newOther.Mask);
|
||||
|
||||
// TODO: Handle DatItem_Condition*
|
||||
// TODO: Handle DatItem_Location*
|
||||
// TODO: Handle DatItem_Setting*
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Filtering
|
||||
|
||||
/// <summary>
|
||||
/// Check to see if a DatItem passes the filter
|
||||
/// </summary>
|
||||
/// <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)
|
||||
{
|
||||
// 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;
|
||||
|
||||
// Filter on mask
|
||||
if (filter.DatItem_Mask.MatchesPositiveSet(Mask) == false)
|
||||
return false;
|
||||
if (filter.DatItem_Mask.MatchesNegativeSet(Mask) == true)
|
||||
return false;
|
||||
|
||||
// TODO: Handle DatItem_Condition*
|
||||
// TODO: Handle DatItem_Location*
|
||||
// TODO: Handle DatItem_Setting*
|
||||
|
||||
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)
|
||||
{
|
||||
// Remove common fields first
|
||||
base.RemoveFields(fields);
|
||||
|
||||
// Remove the fields
|
||||
if (fields.Contains(Field.DatItem_Tag))
|
||||
Tag = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Mask))
|
||||
Mask = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Conditions))
|
||||
Conditions = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Locations))
|
||||
Locations = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Settings))
|
||||
Settings = null;
|
||||
|
||||
// TODO: Handle DatItem_Condition*
|
||||
// TODO: Handle DatItem_Location*
|
||||
// TODO: Handle DatItem_Setting*
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#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)
|
||||
{
|
||||
// Replace common fields first
|
||||
base.ReplaceFields(item, fields);
|
||||
|
||||
// If we don't have a Configuration to replace from, ignore specific fields
|
||||
if (item.ItemType != ItemType.Configuration)
|
||||
return;
|
||||
|
||||
// Cast for easier access
|
||||
Configuration newItem = item as Configuration;
|
||||
|
||||
// Replace the fields
|
||||
if (fields.Contains(Field.DatItem_Tag))
|
||||
Tag = newItem.Tag;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Mask))
|
||||
Mask = newItem.Mask;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Conditions))
|
||||
Conditions = newItem.Conditions;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Locations))
|
||||
Locations = newItem.Locations;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Settings))
|
||||
Settings = newItem.Settings;
|
||||
|
||||
// TODO: Handle DatItem_Condition*
|
||||
// TODO: Handle DatItem_Location*
|
||||
// TODO: Handle DatItem_Setting*
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -197,24 +197,6 @@ namespace SabreTools.Library.DatItems
|
||||
Machine_DipSwitch_Value_Value,
|
||||
Machine_DipSwitch_Value_Default,
|
||||
|
||||
// Configurations
|
||||
Machine_Configurations,
|
||||
Machine_Configuration_Name,
|
||||
Machine_Configuration_Tag,
|
||||
Machine_Configuration_Mask,
|
||||
|
||||
// Configurations.Locations
|
||||
Machine_Configuration_Locations,
|
||||
Machine_Configuration_Location_Name,
|
||||
Machine_Configuration_Location_Number,
|
||||
Machine_Configuration_Location_Inverted,
|
||||
|
||||
// Configurations.Settings
|
||||
Machine_Configuration_Settings,
|
||||
Machine_Configuration_Setting_Name,
|
||||
Machine_Configuration_Setting_Value,
|
||||
Machine_Configuration_Setting_Default,
|
||||
|
||||
// Ports
|
||||
Machine_Ports,
|
||||
Machine_Port_Tag,
|
||||
@@ -407,6 +389,21 @@ namespace SabreTools.Library.DatItems
|
||||
DatItem_ChipType,
|
||||
DatItem_Clock,
|
||||
|
||||
// Configuration
|
||||
DatItem_Mask,
|
||||
|
||||
// Configuration.Locations
|
||||
DatItem_Locations,
|
||||
DatItem_Location_Name,
|
||||
DatItem_Location_Number,
|
||||
DatItem_Location_Inverted,
|
||||
|
||||
// Configuration.Settings
|
||||
DatItem_Settings,
|
||||
DatItem_Setting_Name,
|
||||
DatItem_Setting_Value,
|
||||
DatItem_Setting_Default,
|
||||
|
||||
// Ram Option
|
||||
DatItem_Content,
|
||||
|
||||
@@ -457,6 +454,7 @@ namespace SabreTools.Library.DatItems
|
||||
Archive,
|
||||
BiosSet,
|
||||
Chip,
|
||||
Configuration,
|
||||
DeviceReference,
|
||||
RamOption,
|
||||
Release,
|
||||
|
||||
@@ -184,12 +184,6 @@ namespace SabreTools.Library.DatItems
|
||||
[JsonProperty("dipswitches", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
public List<ListXmlDipSwitch> DipSwitches { get; set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// List of associated configurations
|
||||
/// </summary>
|
||||
[JsonProperty("configurations", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
public List<ListXmlConfiguration> Configurations { get; set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// List of associated ports
|
||||
/// </summary>
|
||||
@@ -577,7 +571,6 @@ namespace SabreTools.Library.DatItems
|
||||
Conditions = this.Conditions,
|
||||
Inputs = this.Inputs,
|
||||
DipSwitches = this.DipSwitches,
|
||||
Configurations = this.Configurations,
|
||||
Ports = this.Ports,
|
||||
Drivers = this.Drivers,
|
||||
Features = this.Features,
|
||||
|
||||
Reference in New Issue
Block a user