2020-09-03 22:35:09 -07:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
2020-09-02 12:51:21 -07:00
|
|
|
|
using System.Linq;
|
2020-09-07 22:00:02 -07:00
|
|
|
|
using System.Xml.Serialization;
|
2020-09-02 12:51:21 -07:00
|
|
|
|
|
2020-12-08 13:23:59 -08:00
|
|
|
|
using SabreTools.Core;
|
2020-12-08 16:37:08 -08:00
|
|
|
|
using SabreTools.Core.Tools;
|
2020-09-02 12:51:21 -07:00
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
|
2020-12-08 15:15:41 -08:00
|
|
|
|
namespace SabreTools.DatItems
|
2020-09-02 12:51:21 -07:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Represents the sound output for a machine
|
|
|
|
|
|
/// </summary>
|
2020-09-08 10:12:41 -07:00
|
|
|
|
[JsonObject("sound"), XmlRoot("sound")]
|
2020-09-02 12:51:21 -07:00
|
|
|
|
public class Sound : DatItem
|
|
|
|
|
|
{
|
|
|
|
|
|
#region Fields
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2020-09-06 23:00:13 -07:00
|
|
|
|
/// Number of speakers or channels
|
2020-09-02 12:51:21 -07:00
|
|
|
|
/// </summary>
|
2020-09-02 14:32:16 -07:00
|
|
|
|
[JsonProperty("channels", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
2020-09-07 22:00:02 -07:00
|
|
|
|
[XmlElement("channels")]
|
2020-09-03 22:35:09 -07:00
|
|
|
|
public long? Channels { get; set; }
|
2020-09-02 12:51:21 -07:00
|
|
|
|
|
2020-09-07 22:00:02 -07:00
|
|
|
|
[JsonIgnore]
|
|
|
|
|
|
public bool ChannelsSpecified { get { return Channels != null; } }
|
|
|
|
|
|
|
2020-09-02 12:51:21 -07:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Accessors
|
|
|
|
|
|
|
2020-12-13 13:22:06 -08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public override void SetFields(
|
|
|
|
|
|
Dictionary<DatItemField, string> datItemMappings,
|
|
|
|
|
|
Dictionary<MachineField, string> machineMappings)
|
2020-09-02 12:51:21 -07:00
|
|
|
|
{
|
|
|
|
|
|
// Set base fields
|
2020-12-13 13:22:06 -08:00
|
|
|
|
base.SetFields(datItemMappings, machineMappings);
|
2020-09-02 12:51:21 -07:00
|
|
|
|
|
2020-09-03 14:22:15 -07:00
|
|
|
|
// Handle Sound-specific fields
|
2020-12-13 13:22:06 -08:00
|
|
|
|
if (datItemMappings.Keys.Contains(DatItemField.Channels))
|
|
|
|
|
|
Channels = Utilities.CleanLong(datItemMappings[DatItemField.Channels]);
|
2020-09-02 12:51:21 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Constructors
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Create a default, empty Sound object
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public Sound()
|
|
|
|
|
|
{
|
|
|
|
|
|
ItemType = ItemType.Sound;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Cloning Methods
|
|
|
|
|
|
|
|
|
|
|
|
public override object Clone()
|
|
|
|
|
|
{
|
|
|
|
|
|
return new Sound()
|
|
|
|
|
|
{
|
|
|
|
|
|
ItemType = this.ItemType,
|
|
|
|
|
|
DupeType = this.DupeType,
|
|
|
|
|
|
|
|
|
|
|
|
Machine = this.Machine.Clone() as Machine,
|
|
|
|
|
|
Source = this.Source.Clone() as Source,
|
|
|
|
|
|
Remove = this.Remove,
|
|
|
|
|
|
|
|
|
|
|
|
Channels = this.Channels,
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Comparision Methods
|
|
|
|
|
|
|
|
|
|
|
|
public override bool Equals(DatItem other)
|
|
|
|
|
|
{
|
|
|
|
|
|
// If we don't have a Sound, return false
|
|
|
|
|
|
if (ItemType != other.ItemType)
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
// Otherwise, treat it as a Sound
|
|
|
|
|
|
Sound newOther = other as Sound;
|
|
|
|
|
|
|
|
|
|
|
|
// If the Sound information matches
|
|
|
|
|
|
return (Channels == newOther.Channels);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Sorting and Merging
|
|
|
|
|
|
|
2020-12-13 13:22:06 -08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public override void ReplaceFields(
|
|
|
|
|
|
DatItem item,
|
|
|
|
|
|
List<DatItemField> datItemFields,
|
|
|
|
|
|
List<MachineField> machineFields)
|
2020-09-02 12:51:21 -07:00
|
|
|
|
{
|
|
|
|
|
|
// Replace common fields first
|
2020-12-13 13:22:06 -08:00
|
|
|
|
base.ReplaceFields(item, datItemFields, machineFields);
|
2020-09-02 12:51:21 -07:00
|
|
|
|
|
|
|
|
|
|
// If we don't have a Sound to replace from, ignore specific fields
|
|
|
|
|
|
if (item.ItemType != ItemType.Sound)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
// Cast for easier access
|
|
|
|
|
|
Sound newItem = item as Sound;
|
|
|
|
|
|
|
|
|
|
|
|
// Replace the fields
|
2020-12-13 13:22:06 -08:00
|
|
|
|
if (datItemFields.Contains(DatItemField.Channels))
|
2020-09-02 12:51:21 -07:00
|
|
|
|
Channels = newItem.Channels;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|