Sound.Channels as a number

This commit is contained in:
Matt Nadareski
2020-09-03 22:35:09 -07:00
parent d204f8eb1f
commit 9c38fd82aa
4 changed files with 77 additions and 19 deletions

View File

@@ -571,16 +571,23 @@ namespace SabreTools.Library.DatFiles
break;
case "sound":
datItems.Add(new Sound
var sound = new Sound
{
Channels = reader.GetAttribute("channels"),
Source = new Source
{
Index = indexId,
Name = filename,
},
});
};
// Set the channels
if (reader.GetAttribute("channels") != null)
{
if (Int64.TryParse(reader.GetAttribute("channels"), out long channels))
sound.Channels = channels;
}
datItems.Add(sound);
reader.Read();
break;
@@ -1666,7 +1673,7 @@ namespace SabreTools.Library.DatFiles
case ItemType.Sound:
var sound = datItem as Sound;
xtw.WriteStartElement("sound");
xtw.WriteOptionalAttributeString("channels", sound.Channels);
xtw.WriteOptionalAttributeString("channels", sound.Channels?.ToString());
xtw.WriteEndElement();
break;
}

View File

@@ -1644,7 +1644,7 @@ namespace SabreTools.Library.DatFiles
var sound = datItem as Sound;
xtw.WriteStartElement("file");
xtw.WriteAttributeString("type", "sound");
xtw.WriteOptionalAttributeString("channels", sound.Channels);
xtw.WriteOptionalAttributeString("channels", sound.Channels?.ToString());
xtw.WriteEndElement();
break;
}