public void SaveToXml(XmlDocument xmlDocument, XmlNode target) { XmlDataParser.AddAttributeToNode(xmlDocument, target, "Name", name); if (music.IsFilled) { XmlNode musicNode = xmlDocument.CreateElement("Music"); if (music.delay > 0) { XmlDataParser.AddAttributeToNode(xmlDocument, musicNode, "DelayBetweenTracks", music.delay.ToString()); } XmlDataParser.AddAttributeToNode(xmlDocument, musicNode, "MusicNotReplyLength", music.musicNotReplyCount.ToString()); foreach (var musicItem in music.tracks) { SaveTrackToXml(xmlDocument, musicNode, musicItem.Value, music.IsBackgroundMusic(musicItem.Value) ? false : true); } target.AppendChild(musicNode); } if (sound.IsFilled) { XmlNode soundNode = xmlDocument.CreateElement("Sound"); foreach (var soundItem in sound.tracks) { SaveTrackToXml(xmlDocument, soundNode, soundItem.Value); } target.AppendChild(soundNode); } }
private void SaveAudioSettings() { XmlDocument xmlDocument = new XmlDocument(); XmlNode rootNode = XmlDataParser.CreateRootNode(xmlDocument, "AudioData"); XmlNode audioNode = xmlDocument.CreateElement("AudioSettings"); XmlDataParser.AddAttributeToNode(xmlDocument, audioNode, "useMusic", isMusic.ToString()); XmlDataParser.AddAttributeToNode(xmlDocument, audioNode, "musicVolume", musicVolumme.ToString()); XmlDataParser.AddAttributeToNode(xmlDocument, audioNode, "useSound", isSound.ToString()); XmlDataParser.AddAttributeToNode(xmlDocument, audioNode, "soundVolume", soundVolumme.ToString()); rootNode.AppendChild(audioNode); XmlDataParser.SaveXmlDocument(xmlDocument, BaseEngineConstants.BaseSettingsPath, BaseEngineConstants.AudioSettingsShortFileName); }
private void SaveConfiguration(bool saveAdditionalToResources = false) { XmlDocument xmlDocument = new XmlDocument(); XmlNode root = XmlDataParser.CreateRootNode(xmlDocument, "AudioData"); XmlNode defaultNode = xmlDocument.CreateElement("AudioSettings"); XmlDataParser.AddAttributeToNode(xmlDocument, defaultNode, "useMusic", defaultSetting.useMusic.ToString()); XmlDataParser.AddAttributeToNode(xmlDocument, defaultNode, "musicVolume", defaultSetting.musicVolume.ToString()); XmlDataParser.AddAttributeToNode(xmlDocument, defaultNode, "useSound", defaultSetting.useSound.ToString()); XmlDataParser.AddAttributeToNode(xmlDocument, defaultNode, "soundVolume", defaultSetting.soundVolume.ToString()); root.AppendChild(defaultNode); defaultNode = xmlDocument.CreateElement("AudioConfiguration"); XmlDataParser.AddAttributeToNode(xmlDocument, defaultNode, "SoundSourceCount", soundSourceCount.ToString()); XmlDataParser.AddAttributeToNode(xmlDocument, defaultNode, "fade", fadeTime.ToString()); XmlDataParser.AddAttributeToNode(xmlDocument, defaultNode, "fadeOn", useFadeOn.ToString()); root.AppendChild(defaultNode); if (audioData != null) { foreach (var item in audioData) { XmlNode blockNode = xmlDocument.CreateElement("AudioBlock"); item.Value.SaveToXml(xmlDocument, blockNode); root.AppendChild(blockNode); } } else { return; } if (saveAdditionalToResources) { if (!Directory.Exists("Assets/Resources/" + BaseEngineConstants.AudioResConfigurationPath)) { Directory.CreateDirectory("Assets/Resources/" + BaseEngineConstants.AudioResConfigurationPath); } XmlDataParser.SaveXmlDocumentToResources(xmlDocument, BaseEngineConstants.AudioResConfigurationPath, BaseEngineConstants.AudioConfigurationShortFileName); } XmlDataParser.SaveXmlDocumentToProject(xmlDocument, BaseEngineConstants.AudioConfigurationPath, BaseEngineConstants.AudioConfigurationShortFileName); AssetDatabase.Refresh(); }
private void SaveTrackToXml(XmlDocument xmlDocument, XmlNode target, Track track, bool special = false) { XmlNode trackNode = xmlDocument.CreateElement("Track"); XmlDataParser.AddAttributeToNode(xmlDocument, trackNode, "Name", track.name); if (track.path != null && track.path != "") { XmlDataParser.AddAttributeToNode(xmlDocument, trackNode, "Path", track.path); } XmlDataParser.AddAttributeToNode(xmlDocument, trackNode, "Volume", track.Volume.ToString()); if (special) { XmlDataParser.AddAttributeToNode(xmlDocument, trackNode, "Special", ""); } target.AppendChild(trackNode); }
public static void Save() { if (!isInited) { Init(); } XmlDocument xmlDocument = new XmlDocument(); XmlNode rootNode = XmlDataParser.CreateRootNode(xmlDocument, "GameSettings"); foreach (KeyValuePair <string, string> item in data) { XmlNode itemNode = xmlDocument.CreateElement("Item"); XmlDataParser.AddAttributeToNode(xmlDocument, itemNode, "Key", item.Key); XmlDataParser.AddAttributeToNode(xmlDocument, itemNode, "Value", item.Value); rootNode.AppendChild(itemNode); } XmlDataParser.SaveXmlDocument(xmlDocument, "", "GameSettings"); }