private XElement MenuSoundToXElement(MenuSound sound) { XElement soundItem = new XElement("Sound"); if (sound != null) { string fileName = Path.GetFileName(sound.File); soundItem.Add(new XElement("SoundFile", fileName)); if (sound.Volume != MenuSound.DefaultVolume) { soundItem.Add(new XElement("Volume", sound.Volume)); } } return(soundItem); }
private MenuSound ReadXmlSound(XElement section) { MenuSound sound = new MenuSound(); // Backward compatibility if (section.Element("Sound") != null) { sound.File = section.Element("Sound")?.Element("SoundFile")?.Value ?? ""; sound.Volume = int.Parse(section.Element("Sound")?.Element("Volume")?.Value ?? MenuSound.DefaultVolume.ToString()); } else { sound.File = section.Element("SoundFile")?.Value ?? ""; sound.Volume = int.Parse(section.Element("Volume")?.Value ?? MenuSound.DefaultVolume.ToString()); } return(sound); }
public MenuSound(MenuSound sound) { File = sound.File; Volume = sound.Volume; }