Files
SabreTools/SabreTools.DatItems/Formats/Display.cs

233 lines
7.7 KiB
C#
Raw Normal View History

using System.Xml.Serialization;
2020-09-03 13:20:56 -07:00
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
2022-11-03 12:22:17 -07:00
using SabreTools.Core;
using SabreTools.Core.Tools;
2020-09-02 21:36:14 -07:00
2021-02-02 10:23:43 -08:00
namespace SabreTools.DatItems.Formats
2020-09-02 21:36:14 -07:00
{
/// <summary>
/// Represents one machine display
/// </summary>
2020-09-08 10:12:41 -07:00
[JsonObject("display"), XmlRoot("display")]
2020-09-02 21:36:14 -07:00
public class Display : DatItem
{
#region Fields
/// <summary>
/// Display tag
/// </summary>
2022-11-03 12:22:17 -07:00
[JsonProperty("tag", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("tag")]
public string? Tag
{
2023-08-14 22:33:05 -04:00
get => _internal.ReadString(Models.Internal.Display.TagKey);
set => _internal[Models.Internal.Display.TagKey] = value;
}
2020-09-02 21:36:14 -07:00
/// <summary>
/// Display type
/// </summary>
2022-11-03 12:22:17 -07:00
[JsonProperty("type", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("type")]
[JsonConverter(typeof(StringEnumConverter))]
public DisplayType DisplayType
{
2023-08-14 22:33:05 -04:00
get => _internal.ReadString(Models.Internal.Display.DisplayTypeKey).AsDisplayType();
set => _internal[Models.Internal.Display.DisplayTypeKey] = value.FromDisplayType();
}
2020-09-02 21:36:14 -07:00
2020-09-07 22:00:02 -07:00
[JsonIgnore]
public bool DisplayTypeSpecified { get { return DisplayType != DisplayType.NULL; } }
2020-09-02 21:36:14 -07:00
/// <summary>
/// Display rotation
/// </summary>
2022-11-03 12:22:17 -07:00
[JsonProperty("rotate", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("rotate")]
public long? Rotate
{
2023-08-14 22:33:05 -04:00
get => _internal.ReadLong(Models.Internal.Display.RotateKey);
set => _internal[Models.Internal.Display.RotateKey] = value;
}
2020-09-02 21:36:14 -07:00
2020-09-07 22:00:02 -07:00
[JsonIgnore]
public bool RotateSpecified { get { return Rotate != null; } }
2020-09-02 21:36:14 -07:00
/// <summary>
/// Determines if display is flipped in the X-coordinates
/// </summary>
2022-11-03 12:22:17 -07:00
[JsonProperty("flipx", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("flipx")]
public bool? FlipX
{
2023-08-14 22:33:05 -04:00
get => _internal.ReadBool(Models.Internal.Display.FlipXKey);
set => _internal[Models.Internal.Display.FlipXKey] = value;
}
2020-09-02 21:36:14 -07:00
2020-09-07 22:00:02 -07:00
[JsonIgnore]
public bool FlipXSpecified { get { return FlipX != null; } }
2020-09-02 21:36:14 -07:00
/// <summary>
/// Display width
/// </summary>
2022-11-03 12:22:17 -07:00
[JsonProperty("width", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("width")]
public long? Width
{
2023-08-14 22:33:05 -04:00
get => _internal.ReadLong(Models.Internal.Display.WidthKey);
set => _internal[Models.Internal.Display.WidthKey] = value;
}
2020-09-02 21:36:14 -07:00
2020-09-07 22:00:02 -07:00
[JsonIgnore]
public bool WidthSpecified { get { return Width != null; } }
2020-09-02 21:36:14 -07:00
/// <summary>
/// Display height
/// </summary>
2022-11-03 12:22:17 -07:00
[JsonProperty("height", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("height")]
public long? Height
{
2023-08-14 22:33:05 -04:00
get => _internal.ReadLong(Models.Internal.Display.HeightKey);
set => _internal[Models.Internal.Display.HeightKey] = value;
}
2020-09-02 21:36:14 -07:00
2020-09-07 22:00:02 -07:00
[JsonIgnore]
public bool HeightSpecified { get { return Height != null; } }
2020-09-02 21:36:14 -07:00
/// <summary>
/// Refresh rate
/// </summary>
2022-11-03 12:22:17 -07:00
[JsonProperty("refresh", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("refresh")]
public double? Refresh
{
2023-08-14 22:33:05 -04:00
get => _internal.ReadDouble(Models.Internal.Display.RefreshKey);
set => _internal[Models.Internal.Display.RefreshKey] = value;
}
2020-09-02 21:36:14 -07:00
2020-09-07 22:00:02 -07:00
[JsonIgnore]
public bool RefreshSpecified { get { return Refresh != null; } }
2020-09-02 21:36:14 -07:00
/// <summary>
/// Pixel clock timer
/// </summary>
2022-11-03 12:22:17 -07:00
[JsonProperty("pixclock", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("pixclock")]
public long? PixClock
{
2023-08-14 22:33:05 -04:00
get => _internal.ReadLong(Models.Internal.Display.PixClockKey);
set => _internal[Models.Internal.Display.PixClockKey] = value;
}
2020-09-02 21:36:14 -07:00
2020-09-07 22:00:02 -07:00
[JsonIgnore]
public bool PixClockSpecified { get { return PixClock != null; } }
2020-09-02 21:36:14 -07:00
/// <summary>
/// Total horizontal lines
/// </summary>
2022-11-03 12:22:17 -07:00
[JsonProperty("htotal", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("htotal")]
public long? HTotal
{
2023-08-14 22:33:05 -04:00
get => _internal.ReadLong(Models.Internal.Display.HTotalKey);
set => _internal[Models.Internal.Display.HTotalKey] = value;
}
2020-09-02 21:36:14 -07:00
2020-09-07 22:00:02 -07:00
[JsonIgnore]
public bool HTotalSpecified { get { return HTotal != null; } }
2020-09-02 21:36:14 -07:00
/// <summary>
/// Horizontal blank end
/// </summary>
2022-11-03 12:22:17 -07:00
[JsonProperty("hbend", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("hbend")]
public long? HBEnd
{
2023-08-14 22:33:05 -04:00
get => _internal.ReadLong(Models.Internal.Display.HBEndKey);
set => _internal[Models.Internal.Display.HBEndKey] = value;
}
2020-09-02 21:36:14 -07:00
2020-09-07 22:00:02 -07:00
[JsonIgnore]
public bool HBEndSpecified { get { return HBEnd != null; } }
2020-09-02 21:36:14 -07:00
/// <summary>
/// Horizontal blank start
/// </summary>
2022-11-03 12:22:17 -07:00
[JsonProperty("hbstart", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("hbstart")]
public long? HBStart
{
2023-08-14 22:33:05 -04:00
get => _internal.ReadLong(Models.Internal.Display.HBStartKey);
set => _internal[Models.Internal.Display.HBStartKey] = value;
}
2020-09-02 21:36:14 -07:00
2020-09-07 22:00:02 -07:00
[JsonIgnore]
public bool HBStartSpecified { get { return HBStart != null; } }
2020-09-02 21:36:14 -07:00
/// <summary>
/// Total vertical lines
/// </summary>
2022-11-03 12:22:17 -07:00
[JsonProperty("vtotal", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("vtotal")]
public long? VTotal
{
2023-08-14 22:33:05 -04:00
get => _internal.ReadLong(Models.Internal.Display.VTotalKey);
set => _internal[Models.Internal.Display.VTotalKey] = value;
}
2020-09-02 21:36:14 -07:00
2020-09-07 22:00:02 -07:00
[JsonIgnore]
public bool VTotalSpecified { get { return VTotal != null; } }
2020-09-02 21:36:14 -07:00
/// <summary>
/// Vertical blank end
/// </summary>
2022-11-03 12:22:17 -07:00
[JsonProperty("vbend", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("vbend")]
public long? VBEnd
{
2023-08-14 22:33:05 -04:00
get => _internal.ReadLong(Models.Internal.Display.VBEndKey);
set => _internal[Models.Internal.Display.VBEndKey] = value;
}
2020-09-02 21:36:14 -07:00
2020-09-07 22:00:02 -07:00
[JsonIgnore]
public bool VBEndSpecified { get { return VBEnd != null; } }
2020-09-02 21:36:14 -07:00
/// <summary>
/// Vertical blank start
/// </summary>
2022-11-03 12:22:17 -07:00
[JsonProperty("vbstart", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("vbstart")]
public long? VBStart
{
2023-08-14 22:33:05 -04:00
get => _internal.ReadLong(Models.Internal.Display.VBStartKey);
set => _internal[Models.Internal.Display.VBStartKey] = value;
}
2020-09-02 21:36:14 -07:00
2020-09-07 22:00:02 -07:00
[JsonIgnore]
public bool VBStartSpecified { get { return VBStart != null; } }
2020-09-02 21:36:14 -07:00
#endregion
#region Constructors
/// <summary>
/// Create a default, empty Display object
/// </summary>
public Display()
{
2023-08-14 22:33:05 -04:00
_internal = new Models.Internal.Display();
2020-09-02 21:36:14 -07:00
ItemType = ItemType.Display;
}
#endregion
#region Cloning Methods
2022-11-03 12:22:17 -07:00
/// <inheritdoc/>
2020-09-02 21:36:14 -07:00
public override object Clone()
{
return new Display()
{
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Source = this.Source?.Clone() as Source,
2020-09-02 21:36:14 -07:00
Remove = this.Remove,
2023-08-14 22:33:05 -04:00
_internal = this._internal?.Clone() as Models.Internal.Display ?? new Models.Internal.Display(),
2020-09-02 21:36:14 -07:00
};
}
#endregion
}
}