Promote Sound

This commit is contained in:
Matt Nadareski
2020-09-02 12:51:21 -07:00
parent 7aa042f76d
commit 07cf2135ff
11 changed files with 251 additions and 105 deletions

View File

@@ -167,6 +167,12 @@ namespace SabreTools.Library.DatFiles
[JsonIgnore]
public long SoftwareListCount { get; private set; } = 0;
/// <summary>
/// Number of Sound items
/// </summary>
[JsonIgnore]
public long SoundCount { get; private set; } = 0;
/// <summary>
/// Number of machines
/// </summary>
@@ -569,6 +575,9 @@ namespace SabreTools.Library.DatFiles
case ItemType.SoftwareList:
SoftwareListCount++;
break;
case ItemType.Sound:
SoundCount++;
break;
}
}
@@ -719,6 +728,9 @@ namespace SabreTools.Library.DatFiles
case ItemType.SoftwareList:
SoftwareListCount--;
break;
case ItemType.Sound:
SoundCount--;
break;
}
}

View File

@@ -256,6 +256,9 @@ namespace SabreTools.Library.DatFiles
case ItemType.SoftwareList:
datItem = datItemObj.ToObject<DatItems.SoftwareList>();
break;
case ItemType.Sound:
datItem = datItemObj.ToObject<DatItems.Sound>();
break;
}
}

View File

@@ -369,7 +369,21 @@ namespace SabreTools.Library.DatFiles
});
reader.Read();
break;
case "sound":
datItems.Add(new Sound
{
Channels = reader.GetAttribute("channels"),
Source = new Source
{
Index = indexId,
Name = filename,
},
});
reader.Read();
break;
case "display":
@@ -398,19 +412,6 @@ namespace SabreTools.Library.DatFiles
reader.Read();
break;
case "sound":
var sound = new Sound();
sound.Channels = reader.GetAttribute("channels");
// Ensure the list exists
if (machine.Sounds == null)
machine.Sounds = new List<Sound>();
machine.Sounds.Add(sound);
reader.Read();
break;
case "condition":
var condition = new Condition();
condition.Tag = reader.GetAttribute("tag");
@@ -1223,18 +1224,6 @@ namespace SabreTools.Library.DatFiles
xtw.WriteEndElement();
}
}
if (datItem.Machine.Sounds != null)
{
foreach (var sound in datItem.Machine.Sounds)
{
xtw.WriteStartElement("sound");
xtw.WriteOptionalAttributeString("channels", sound.Channels);
// End sound
xtw.WriteEndElement();
}
}
if (datItem.Machine.Conditions != null)
{
foreach (var condition in datItem.Machine.Conditions)
@@ -1653,6 +1642,13 @@ namespace SabreTools.Library.DatFiles
xtw.WriteOptionalAttributeString("filter", softwareList.Filter);
xtw.WriteEndElement();
break;
case ItemType.Sound:
var sound = datItem as Sound;
xtw.WriteStartElement("sound");
xtw.WriteOptionalAttributeString("channels", sound.Channels);
xtw.WriteEndElement();
break;
}
xtw.Flush();

View File

@@ -1489,6 +1489,14 @@ namespace SabreTools.Library.DatFiles
xtw.WriteOptionalAttributeString("sha512", softwareList.Filter);
xtw.WriteEndElement();
break;
case ItemType.Sound:
var sound = datItem as Sound;
xtw.WriteStartElement("file");
xtw.WriteAttributeString("type", "sound");
xtw.WriteOptionalAttributeString("channels", sound.Channels);
xtw.WriteEndElement();
break;
}
xtw.Flush();