private static List<Playlist> LoadStockPlaylist() { Utils.Log("Loading stock playlists."); List<Playlist> playlists = new List<Playlist>(); playlists.Add(new Playlist { name = "Construction", loop = true, shuffle = true, preloadTime = 5, tracks = new List<string> { "KSP_Construction01", "KSP_Construction02", "KSP_Construction03", "Groove Grove", "Brittle Rille" }, playWhen = new Playlist.Prerequisites { scene = Enums.Scenes.VAB | Enums.Scenes.SPH } }); playlists.Add(new Playlist { name = "Space", loop = true, shuffle = true, preloadTime = 5, tracks = new List<string> { "KSP_SpaceAmbience01", "KSP_SpaceAmbience02", "KSP_SpaceAmbience03", "KSP_SpaceAmbience04", "Arcadia", "Bathed in the Light", "Dreamy Flashback", "Frost Waltz", "Frost Waltz (Alternate)", "Frozen Star", "Impact Lento", "Wizardtorium", "KSP_MainTheme", }, playWhen = new Playlist.Prerequisites { scene = Enums.Scenes.Flight, inAtmosphere = Enums.Selector.False } }); playlists.Add(new Playlist { name = "Astronaut Complex", loop = true, tracks = new List<string> { "KSP_AstronautComplexAmbience" }, playWhen = new Playlist.Prerequisites { //scene = Enums.Scene.AstronautComplex TODO scene = Enums.Scenes.PSystem } }); playlists.Add(new Playlist { name = "Credits", loop = true, tracks = new List<string> { "KSP_Credits" }, playWhen = new Playlist.Prerequisites { scene = Enums.Scenes.Credits } }); playlists.Add(new Playlist { name = "Menu ambience", loop = true, preloadTime = 5, enabled = false, tracks = new List<string> { "KSP_MenuAmbience" }, playWhen = new Playlist.Prerequisites { scene = Enums.Scenes.MainMenu } }); Playlist spaceCentreAmbience = new Playlist { name = "Space centre", loop = true, preloadTime = 5, tracks = new List<string> { "KSP_SpaceCenterAmbience" }, playWhen = new Playlist.Prerequisites { scene = Enums.Scenes.SpaceCentre } }; playlists.Add(spaceCentreAmbience); playlists.Add(new Playlist { name = "Menu theme", loop = false, preloadTime = 5, disableAfterPlay = true, playNext = "Menu ambience", tracks = new List<string> { "KSP_MainTheme" }, playWhen = new Playlist.Prerequisites { scene = Enums.Scenes.MainMenu } }); playlists.Add(new Playlist { name = "Mission control ambience", loop = true, tracks = new List<string> { "KSP_MissionControlAmbience" // TODO - Verify this }, playWhen = new Playlist.Prerequisites { // scene = Enums.Scene.MissionControl TODO scene = Enums.Scenes.Loading } }); playlists.Add(new Playlist { name = "Research complex ambience", loop = true, tracks = new List<string> { "KSP_ResearchAndDevelopment" // TODO - Verify this }, playWhen = new Playlist.Prerequisites { //scene = Enums.Scene.ResearchComplex TODO scene = Enums.Scenes.LoadingBuffer } }); playlists.Add(new Playlist { name = "Space center ambience", loop = true, tracks = new List<string> { "KSP_SpaceCenterAmbience" // TODO - Verify this }, playWhen = new Playlist.Prerequisites { scene = Enums.Scenes.SpaceCentre } }); playlists.Add(new Playlist { name = "SPH ambience", loop = true, tracks = new List<string> { "KSP_SPHAmbience" }, playWhen = new Playlist.Prerequisites { scene = Enums.Scenes.SPH } }); playlists.Add(new Playlist { name = "Tracking station ambience", loop = true, tracks = new List<string> { "KSP_TrackingStation" }, playWhen = new Playlist.Prerequisites { scene = Enums.Scenes.TrackingStation } }); playlists.Add(new Playlist { name = "VAB ambience", loop = true, tracks = new List<string> { "KSP_VABAmbience" }, playWhen = new Playlist.Prerequisites { scene = Enums.Scenes.VAB } }); return playlists; }
//private static string _configSavePath2 = "GameData/SoundtrackEditor/PluginData/settings2.cfg"; public static List<Playlist> LoadPlaylists() { try { List<Playlist> playlists = new List<Playlist>(); _config = ConfigNode.Load(_configSavePath); if (_config == null) { Debug.LogWarning("[STED] No config file present at " + _configSavePath + ". Loading stock tracks."); return LoadStockPlaylist(); } Utils.Log("Loading playlists: " + _configSavePath); foreach (ConfigNode node in _config.nodes) { if (node.name.Equals("playlist")) { Playlist p = new Playlist(); if (!node.HasValue("name")) continue; p.name = node.GetValue("name"); Utils.Log("Loading playlist " + p.name); if (node.HasValue("enabled")) p.enabled = bool.Parse(node.GetValue("enabled")); if (node.HasValue("loop")) p.loop = bool.Parse(node.GetValue("loop")); if (node.HasValue("shuffle")) p.shuffle = bool.Parse(node.GetValue("shuffle")); if (node.HasValue("pauseOnGamePause")) { p.pauseOnGamePause = bool.Parse(node.GetValue("pauseOnGamePause")); if (p.pauseOnGamePause) EventManager.Instance.MonitorPause = true; } if (node.HasValue("disableAfterPlay")) p.disableAfterPlay = bool.Parse(node.GetValue("disableAfterPlay")); if (node.HasValue("playNext")) p.playNext = node.GetValue("playNext"); if (node.HasValue("playBefore")) p.playBefore = node.GetValue("playBefore"); if (node.HasValue("playAfter")) p.playAfter = node.GetValue("playAfter"); if (node.HasValue("channel")) p.channel = int.Parse(node.GetValue("channel")); if (node.HasValue("preloadTime")) p.preloadTime = float.Parse(node.GetValue("preloadTime")); /* Not yet implemented. if (node.HasNode("fade")) { p.fade = new Playlist.Fade(); ConfigNode fade = node.GetNode("fade"); if (fade.HasNode("fadeIn")) { p.fade.fadeIn = float.Parse(node.GetValue("fadeIn")); } if (fade.HasNode("fadeOut")) p.fade.fadeOut = float.Parse(node.GetValue("fadeOut")); if (fade.HasNode("crossfade")) p.fade.crossfade = bool.Parse(node.GetValue("crossfade")); } if (node.HasValue("trackFade")) { p.trackFade = new Playlist.Fade(); ConfigNode trackFade = node.GetNode("trackFade"); if (trackFade.HasNode("fadeIn")) p.trackFade.fadeIn = float.Parse(node.GetValue("fadeIn")); if (trackFade.HasNode("fadeOut")) p.trackFade.fadeOut = float.Parse(node.GetValue("fadeOut")); if (trackFade.HasNode("crossfade")) p.trackFade.crossfade = bool.Parse(node.GetValue("crossfade")); }*/ if (node.HasNode("tracks")) { ConfigNode tracks = node.GetNode("tracks"); foreach (string t in tracks.GetValues("track")) { p.tracks.Add(Utils.RemoveQuotes(t)); } } if (node.HasNode("playWhen")) { p.playWhen = new Playlist.Prerequisites(); ConfigNode playWhen = node.GetNode("playWhen"); if (playWhen.HasValue("paused")) { p.playWhen.paused = Enums.Parse<Enums.Selector>(playWhen.GetValue("paused")); } if (playWhen.HasValue("inAtmosphere")) { p.playWhen.inAtmosphere = Enums.Parse<Enums.Selector>(playWhen.GetValue("inAtmosphere")); } if (playWhen.HasValue("timeOfDay")) { p.playWhen.timeOfDay = Enums.Parse<Enums.TimesOfDay>(playWhen.GetValue("timeOfDay")); } if (playWhen.HasValue("scene")) { p.playWhen.scene = Enums.Parse<Enums.Scenes>(playWhen.GetValue("scene")); } if (playWhen.HasValue("situation")) { p.playWhen.situation = Enums.Parse<Vessel.Situations>(playWhen.GetValue("situation")); } if (playWhen.HasValue("cameraMode")) { p.playWhen.cameraMode = Enums.Parse<Enums.CameraModes>(playWhen.GetValue("cameraMode")); } if (playWhen.HasValue("bodyName")) { p.playWhen.bodyName = playWhen.GetValue("bodyName"); } if (playWhen.HasValue("maxVelocitySurface")) { p.playWhen.maxVelocitySurface = float.Parse(playWhen.GetValue("maxVelocitySurface")); } if (playWhen.HasValue("minVelocitySurface")) { p.playWhen.minVelocitySurface = float.Parse(playWhen.GetValue("minVelocitySurface")); } if (playWhen.HasValue("maxVelocityOrbital")) { p.playWhen.maxVelocityOrbital = float.Parse(playWhen.GetValue("maxVelocityOrbital")); } if (playWhen.HasValue("minVelocityOrbital")) { p.playWhen.minVelocityOrbital = float.Parse(playWhen.GetValue("minVelocityOrbital")); } if (playWhen.HasValue("maxAltitude")) { p.playWhen.maxAltitude = float.Parse(playWhen.GetValue("maxAltitude")); } if (playWhen.HasValue("minAltitude")) { p.playWhen.minAltitude = float.Parse(playWhen.GetValue("minAltitude")); } if (playWhen.HasValue("maxVesselDistance")) { p.playWhen.maxVesselDistance = float.Parse(playWhen.GetValue("maxVesselDistance")); } if (playWhen.HasValue("minVesselDistance")) { p.playWhen.minVesselDistance = float.Parse(playWhen.GetValue("minAltitude")); } if (playWhen.HasValue("vesselState")) { p.playWhen.vesselState = Enums.Parse<Enums.VesselState>(playWhen.GetValue("vesselState")); } } playlists.Add(p); EventManager.Instance.TrackEventsForPlaylist(p); } } Utils.Log("Done loading playlists."); return playlists; } catch (Exception ex) { Debug.LogError("[STED] LoadPlaylists Error: " + ex.Message); return LoadStockPlaylist(); } }