Files
SabreTools/SabreTools.DatItems/Formats/Archive.cs

157 lines
4.6 KiB
C#
Raw Normal View History

2021-01-29 22:54:16 -08:00
using System.Xml.Serialization;
2020-09-02 12:19:12 -07:00
using Newtonsoft.Json;
2022-11-03 12:22:17 -07:00
using SabreTools.Core;
2020-08-23 22:23:55 -07:00
2021-02-02 10:23:43 -08:00
namespace SabreTools.DatItems.Formats
{
2019-01-08 17:40:12 -08:00
/// <summary>
/// Represents generic archive files to be included in a set
/// </summary>
2020-09-08 10:12:41 -07:00
[JsonObject("archive"), XmlRoot("archive")]
2019-01-08 17:40:12 -08:00
public class Archive : DatItem
{
2020-09-02 12:19:12 -07:00
#region Fields
/// <summary>
/// Name of the item
/// </summary>
2022-11-03 12:22:17 -07:00
[JsonProperty("name"), XmlElement("name")]
public string? Name
{
get => _archive.ReadString(Models.Internal.Archive.NameKey);
set => _archive[Models.Internal.Archive.NameKey] = value;
}
2020-09-02 12:19:12 -07:00
2023-04-07 14:34:49 -04:00
/// <summary>
/// Archive ID number
/// </summary>
/// <remarks>TODO: No-Intro database export only</remarks>
2023-04-07 14:34:49 -04:00
[JsonProperty("number"), XmlElement("number")]
public string? Number { get; set; }
2023-04-07 14:34:49 -04:00
/// <summary>
2023-04-07 15:47:24 -04:00
/// Clone value
2023-04-07 14:34:49 -04:00
/// </summary>
/// <remarks>TODO: No-Intro database export only</remarks>
2023-04-07 14:34:49 -04:00
[JsonProperty("clone"), XmlElement("clone")]
public string? CloneValue { get; set; }
2023-04-07 14:34:49 -04:00
/// <summary>
2023-04-07 15:47:24 -04:00
/// Regional parent value
2023-04-07 14:34:49 -04:00
/// </summary>
/// <remarks>TODO: No-Intro database export only</remarks>
2023-04-07 14:34:49 -04:00
[JsonProperty("regparent"), XmlElement("regparent")]
public string? RegParent { get; set; }
2023-04-07 14:34:49 -04:00
/// <summary>
2023-04-07 15:47:24 -04:00
/// Region value
2023-04-07 14:34:49 -04:00
/// </summary>
/// <remarks>TODO: No-Intro database export only</remarks>
2023-04-07 14:34:49 -04:00
[JsonProperty("region"), XmlElement("region")]
public string? Region { get; set; }
2023-04-07 14:34:49 -04:00
/// <summary>
2023-04-07 15:47:24 -04:00
/// Languages value
2023-04-07 14:34:49 -04:00
/// </summary>
/// <remarks>TODO: No-Intro database export only</remarks>
2023-04-07 14:34:49 -04:00
[JsonProperty("languages"), XmlElement("languages")]
public string? Languages { get; set; }
2023-04-07 14:34:49 -04:00
2023-04-07 15:47:24 -04:00
/// <summary>
/// Development status value
/// </summary>
/// <remarks>TODO: No-Intro database export only</remarks>
2023-04-07 15:47:24 -04:00
[JsonProperty("devstatus"), XmlElement("devstatus")]
public string? DevStatus { get; set; }
2023-04-07 15:47:24 -04:00
/// <summary>
/// Physical value
/// </summary>
/// <remarks>TODO: No-Intro database export only</remarks>
2023-04-07 15:47:24 -04:00
/// <remarks>TODO: Is this numeric or a flag?</remarks>
[JsonProperty("physical"), XmlElement("physical")]
public string? Physical { get; set; }
2023-04-07 15:47:24 -04:00
/// <summary>
/// Complete value
/// </summary>
/// <remarks>TODO: No-Intro database export only</remarks>
2023-04-07 15:47:24 -04:00
/// <remarks>TODO: Is this numeric or a flag?</remarks>
[JsonProperty("complete"), XmlElement("complete")]
public string? Complete { get; set; }
2023-04-07 15:47:24 -04:00
/// <summary>
/// Categories value
/// </summary>
/// <remarks>TODO: No-Intro database export only</remarks>
2023-04-07 15:47:24 -04:00
[JsonProperty("categories"), XmlElement("categories")]
public string? Categories { get; set; }
/// <summary>
/// Internal Archive model
/// </summary>
[JsonIgnore]
private Models.Internal.Archive _archive = new();
2023-04-07 15:47:24 -04:00
2020-09-02 12:19:12 -07:00
#endregion
#region Accessors
/// <inheritdoc/>
public override string? GetName() => Name;
2020-09-02 12:19:12 -07:00
/// <inheritdoc/>
public override void SetName(string? name) => Name = name;
2020-09-02 12:19:12 -07:00
#endregion
2019-01-08 17:40:12 -08:00
#region Constructors
2019-01-08 17:40:12 -08:00
/// <summary>
/// Create a default, empty Archive object
/// </summary>
public Archive()
{
2020-08-20 13:17:14 -07:00
Name = string.Empty;
ItemType = ItemType.Archive;
2019-01-08 17:40:12 -08:00
}
2019-01-08 17:40:12 -08:00
#endregion
2019-01-08 17:40:12 -08:00
#region Cloning Methods
2022-11-03 12:22:17 -07:00
/// <inheritdoc/>
2019-01-08 17:40:12 -08:00
public override object Clone()
{
return new Archive()
{
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Source = this.Source?.Clone() as Source,
2020-08-20 13:17:14 -07:00
Remove = this.Remove,
2020-09-03 13:01:33 -07:00
_archive = this._archive?.Clone() as Models.Internal.Archive ?? new Models.Internal.Archive(),
2019-01-08 17:40:12 -08:00
};
}
2019-01-08 17:40:12 -08:00
#endregion
2019-01-08 17:40:12 -08:00
#region Comparision Methods
2022-11-03 12:22:17 -07:00
/// <inheritdoc/>
public override bool Equals(DatItem? other)
2019-01-08 17:40:12 -08:00
{
// If we don't have a Archive, return false
if (ItemType != other?.ItemType || other is not Archive otherInternal)
2019-01-08 17:40:12 -08:00
return false;
// Compare the internal models
return _archive.EqualTo(otherInternal._archive);
2019-01-08 17:40:12 -08:00
}
2019-01-08 17:40:12 -08:00
#endregion
}
}