コード例 #1
0
 public void BeginTrackFadeIn(Playlist p)
 {
     Utils.Log("Begining fade in track");
     _fadingIn = true;
     _fadeInEnd = Time.realtimeSinceStartup + p.trackFade.fadeIn;
     Speaker.volume = 0;
 }
コード例 #2
0
 public void BeginPlaylistFadeIn(Playlist p)
 {
     Utils.Log("Begining fade in playlist");
     // TODO: Shorten the fade-in if the track is too short.
     _fadingIn = true;
     _fadeInStart = Time.realtimeSinceStartup;
     _fadeInEnd = _fadeInStart + p.fade.fadeIn;
     Speaker.volume = 0;
 }
コード例 #3
0
 public void BeginTrackFadeOut(Playlist p)
 {
     Utils.Log("Begining fade out track");
     double time = (Speaker.clip.length - p.fade.fadeOut) * 1000;
     if (time > 0)
     {
         fadeOutTimer.Interval = time;
         _fadeOutEnd = p.trackFade.fadeOut;
         fadeOutTimer.Start();
     }
     else
         Debug.LogError("Invalid fadeOut clip time: Clip " + Speaker.clip.name +
             " of length " + Speaker.clip.length + " was shorter than the fade out time of " + p.fade.fadeOut);
 }
コード例 #4
0
 public Playlist(Playlist p)
 {
     name = p.name;
     enabled = p.enabled;
     playWhen = new Prerequisites(p.playWhen);
     loop = p.loop;
     shuffle = p.shuffle;
     pauseOnGamePause = p.pauseOnGamePause;
     disableAfterPlay = p.disableAfterPlay;
     playNext = p.playNext;
     playBefore = p.playBefore;
     playAfter = p.playAfter;
     tracks = new List<string>(p.tracks);
     channel = p.channel;
     fade = new Fade(p.fade);
     trackFade = new Fade(p.trackFade);
     preloadTime = p.preloadTime;
 }
コード例 #5
0
        public void UpdatePlaylist()
        {
            ActivePlaylists = GetValidPlaylists();
            if (ActivePlaylists == null || ActivePlaylists.Count == 0)
            {
                StopPlayback();
                CurrentPlaylist = null;
                return;
            }

            SortActivePlaylists();

            if (!ActivePlaylists.Equals(CurrentPlaylist))
            {
                CurrentPlaylist = ActivePlaylists[0];
                //Utils.Log("Switching to playlist " + ActivePlaylists[0].name + " of " + ActivePlaylists.Count + " matching playlists.");
                SwitchToPlaylist(ActivePlaylists[0]);
            }
        }
コード例 #6
0
        public void SwitchToPlaylist(Playlist p)
        {
            // TODO: If the new playlist contains the current track, continue playing it.
            Utils.Log("Changing playlist to " + p.name);
            CurrentPlaylist = p;
            p.trackIndex = 0;

            if (p.shuffle) p.Shuffle();

            if (p.tracks.Count > 0)
                PlayClip(p.tracks[p.trackIndex]);
            else
                Utils.Log("Playlist was empty: " + p.name);
        }
コード例 #7
0
        public void PlayNextTrack(Playlist p)
        {
            if (p == null)
            {
                CurrentClip = null;
                //Debug.LogError("PlayNextTrack: Playlist was null");
                return;
            }
            if (p.tracks.Count == 0)
            {
                // Empty playlist.
                if (ActivePlaylists.Count > 1)
                {
                    int i = ActivePlaylists.IndexOf(CurrentPlaylist) + 1;
                    if (i < ActivePlaylists.Count)
                    {
                        SwitchToPlaylist(ActivePlaylists[i]);
                        return;
                    }
                    Utils.Log("PlayNextTrack: No other playlists found");
                }
                CurrentClip = null;
                Utils.Log("PlayNextTrack: No tracks found");
                return;
            }

            Utils.Log("Playing next track");
            p.trackIndex++;
            if (p.trackIndex >= p.tracks.Count)
            {
                // Check if we have any other appropriate playlists
                if (ActivePlaylists.Count > 1)
                {
                    int i = ActivePlaylists.IndexOf(CurrentPlaylist) + 1;
                    if (i < ActivePlaylists.Count)
                    {
                        SwitchToPlaylist(ActivePlaylists[i]);
                        return;
                    }
                }
                if (!p.loop) // TODO: should loop have priority over playNext?
                {
                    Utils.Log("PlayNextTrack: All tracks played (" + p.trackIndex + " >= " + p.tracks.Count + ")");
                    p.trackIndex--;

                    if (!string.IsNullOrEmpty(p.playNext))
                    {
                        Utils.Log("Playlist ended. Playing next " + p.playNext);
                        foreach (Playlist play in Playlists)
                        {
                            if (play.name.Equals(p.playNext, StringComparison.CurrentCultureIgnoreCase))
                            {
                                Utils.Log("Playlist up next:  " + p.playNext);
                                play.enabled = true;
                                SwitchToPlaylist(play);
                                break;
                            }
                        }
                    }
                    return; // No more tracks to play.
                }
                else
                    p.trackIndex = 0;
            }

            PlayClip(p.tracks[p.trackIndex]);
        }
コード例 #8
0
 public void TrackEventsForPlaylist(Playlist p)
 {
     if (p.pauseOnGamePause == true)
     {
         MonitorPause = true;
     }
     if (p.playWhen.inAtmosphere != Enums.Selector.Either)
     {
         MonitorInAtmosphere = true;
     }
     if (p.playWhen.timeOfDay != Enums.TimesOfDay.Any)
     {
         MonitorTimeOfDay = true;
     }
     if (p.playWhen.scene != Enums.Scenes.Any)
     {
         MonitorScene = true;
     }
     if (p.playWhen.situation != Enums.AnyVesselSituation)
     {
         MonitorSituation = true;
     }
     if (p.playWhen.cameraMode != Enums.CameraModes.Any)
     {
         MonitorCameraMode = true;
     }
     if (p.playWhen.bodyName.Length > 0)
     {
         MonitorBody = true;
     }
     if (p.playWhen.maxVelocitySurface != float.MaxValue)
     {
         AddMaxSurfaceVelocity(p.playWhen.maxVelocitySurface);
     }
     if (p.playWhen.minVelocitySurface != float.MinValue)
     {
         AddMinSurfaceVelocity(p.playWhen.minVelocitySurface);
     }
     if (p.playWhen.maxVelocityOrbital != float.MaxValue)
     {
         AddMaxOrbitalVelocity(p.playWhen.maxVelocityOrbital);
     }
     if (p.playWhen.minVelocityOrbital != float.MinValue)
     {
         AddMinOrbitalVelocity(p.playWhen.minVelocityOrbital);
     }
     if (p.playWhen.maxAltitude != float.MaxValue)
     {
         AddMaxAltitude(p.playWhen.maxAltitude);
     }
     if (p.playWhen.minAltitude != float.MinValue)
     {
         AddMinAltitude(p.playWhen.minAltitude);
     }
     if (p.playWhen.maxVesselDistance != float.MaxValue)
     {
         AddMaxVesselDistance(p.playWhen.maxVesselDistance);
     }
     if (p.playWhen.minVesselDistance != float.MinValue)
     {
         AddMinVesselDistance(p.playWhen.minVesselDistance);
     }
     if (p.playWhen.vesselState != Enums.VesselState.Any && p.playWhen.vesselState != 0)
     {
         MonitorVesselState = true;
     }
 }
コード例 #9
0
        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;
        }
コード例 #10
0
        //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 (p.playWhen.inAtmosphere != Enums.Selector.Either)
                                    EventManager.Instance.MonitorInAtmosphere = true;
                            }
                            if (playWhen.HasValue("timeOfDay"))
                            {
                                p.playWhen.timeOfDay = Enums.Parse<Enums.TimesOfDay>(playWhen.GetValue("timeOfDay"));
                                if (p.playWhen.timeOfDay != Enums.TimesOfDay.Any)
                                    EventManager.Instance.MonitorTimeOfDay = true;
                            }
                            if (playWhen.HasValue("scene"))
                            {
                                p.playWhen.scene = Enums.Parse<Enums.Scenes>(playWhen.GetValue("scene"));
                                if (p.playWhen.scene != Enums.Scenes.Any)
                                    EventManager.Instance.MonitorScene = true;
                            }
                            if (playWhen.HasValue("situation"))
                            {
                                p.playWhen.situation = Enums.Parse<Vessel.Situations>(playWhen.GetValue("situation"));
                                if (p.playWhen.situation != Enums.AnyVesselSituation)
                                    EventManager.Instance.MonitorSituation = true;
                            }
                            if (playWhen.HasValue("cameraMode"))
                            {
                                p.playWhen.cameraMode = Enums.Parse<Enums.CameraModes>(playWhen.GetValue("cameraMode"));
                                if (p.playWhen.cameraMode != Enums.CameraModes.Any)
                                    EventManager.Instance.MonitorCameraMode = true;
                            }
                            if (playWhen.HasValue("bodyName"))
                            {
                                p.playWhen.bodyName = playWhen.GetValue("bodyName");
                                if (p.playWhen.bodyName.Length > 0)
                                    EventManager.Instance.MonitorBody = true;
                            }
                            if (playWhen.HasValue("maxVelocitySurface"))
                            {
                                p.playWhen.maxVelocitySurface = float.Parse(playWhen.GetValue("maxVelocitySurface"));
                                if (p.playWhen.maxVelocitySurface != float.MaxValue)
                                    EventManager.Instance.AddMaxSurfaceVelocity(p.playWhen.maxVelocitySurface);
                            }
                            if (playWhen.HasValue("minVelocitySurface"))
                            {
                                p.playWhen.minVelocitySurface = float.Parse(playWhen.GetValue("minVelocitySurface"));
                                if (p.playWhen.minVelocitySurface != float.MinValue)
                                    EventManager.Instance.AddMinSurfaceVelocity(p.playWhen.minVelocitySurface);
                            }
                            if (playWhen.HasValue("maxVelocityOrbital"))
                            {
                                p.playWhen.maxVelocityOrbital = float.Parse(playWhen.GetValue("maxVelocityOrbital"));
                                if (p.playWhen.maxVelocityOrbital != float.MaxValue)
                                    EventManager.Instance.AddMaxOrbitalVelocity(p.playWhen.maxVelocityOrbital);
                            }
                            if (playWhen.HasValue("minVelocityOrbital"))
                            {
                                p.playWhen.minVelocityOrbital = float.Parse(playWhen.GetValue("minVelocityOrbital"));
                                if (p.playWhen.minVelocityOrbital != float.MinValue)
                                    EventManager.Instance.AddMinOrbitalVelocity(p.playWhen.minVelocityOrbital);
                            }
                            if (playWhen.HasValue("maxAltitude"))
                            {
                                p.playWhen.maxAltitude = float.Parse(playWhen.GetValue("maxAltitude"));
                                if (p.playWhen.maxAltitude != float.MaxValue)
                                    EventManager.Instance.AddMaxAltitude(p.playWhen.maxAltitude);
                            }
                            if (playWhen.HasValue("minAltitude"))
                            {
                                p.playWhen.minAltitude = float.Parse(playWhen.GetValue("minAltitude"));
                                if (p.playWhen.minAltitude != float.MinValue)
                                    EventManager.Instance.AddMinAltitude(p.playWhen.minAltitude);
                            }
                            if (playWhen.HasValue("maxVesselDistance"))
                            {
                                p.playWhen.maxVesselDistance = float.Parse(playWhen.GetValue("maxVesselDistance"));
                                if (p.playWhen.maxVesselDistance != float.MaxValue)
                                    EventManager.Instance.AddMaxVesselDistance(p.playWhen.maxVesselDistance);
                            }
                            if (playWhen.HasValue("minVesselDistance"))
                            {
                                p.playWhen.minVesselDistance = float.Parse(playWhen.GetValue("minAltitude"));
                                if (p.playWhen.minVesselDistance != float.MinValue)
                                    EventManager.Instance.AddMinVesselDistance(p.playWhen.minVesselDistance);
                            }
                        }

                        playlists.Add(p);
                    }
                }

                Utils.Log("Done loading playlists.");

                return playlists;
            }
            catch (Exception ex)
            {
                Debug.LogError("[STED] LoadPlaylists Error: " + ex.Message);
                return LoadStockPlaylist();
            }
        }
コード例 #11
0
        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);
        }
コード例 #12
0
        //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"));
                            }
                            if (playWhen.HasValue("vesselType"))
                            {
                                p.playWhen.vesselType = Enums.Parse <Enums.CustomVesselType>(playWhen.GetValue("vesselType"));
                            }
                        }

                        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());
            }
        }
コード例 #13
0
        /// <summary>
        /// Draws a playlist viewer and editor GUI.
        /// </summary>
        /// <param name="windowID"></param>
        public void PlaylistGui(int windowID)
        {
            _playlistScrollPosition = GUILayout.BeginScrollView(_playlistScrollPosition, GUILayout.MinHeight(Screen.height / 1.25f));

            SoundtrackEditor sted = SoundtrackEditor.Instance;
            List<Playlist> playlists = sted.Playlists;

            for (int i = 0; i < playlists.Count; i++)
            {
                string playlistName = playlists[i].name;

                GUILayout.BeginHorizontal();

                if (!_expandedPlaylists.ContainsKey(playlistName))
                    _expandedPlaylists.Add(playlistName, false);
                bool isExpanded = _expandedPlaylists[playlistName];
                if (GUILayout.Button(isExpanded ? " - " : " + "))
                    _expandedPlaylists[playlistName] = !isExpanded;

                GUILayout.Label("<b>" + playlistName + (sted.CurrentPlaylist == playlists[i] ? " ►" : "") + " </b>");
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Edit"))
                {
                    _editorGuiVisible = true;
                    _editingPlaylistOriginal = playlists[i];
                    _editingPlaylist = new Playlist(playlists[i]);
                    _previousSituation = playlists[i].playWhen.situation;
                    _previousCameraMode = playlists[i].playWhen.cameraMode;
                    _previousScene = playlists[i].playWhen.scene;
                }
                GUILayout.EndHorizontal();

                if (_expandedPlaylists[playlistName])
                {
                    for (int j = 0; j < playlists[i].tracks.Count; j++)
                    {
                        string prefix =
                            sted.CurrentPlaylist != null && sted.CurrentPlaylist.name == playlists[i].name &&
                            sted.CurrentClip != null && sted.CurrentClip.name == playlists[i].tracks[j] ?
                            " ►  " : "       "; // Indent. The '►' is very wide in KSP's font.
                        GUILayout.Label(prefix + playlists[i].tracks[j]);
                    }
                }
            }

            GUILayout.EndScrollView();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button(" New "))
            {
                _editingPlaylist = new Playlist();
                _editorGuiVisible = true;
            }
            GUILayout.EndHorizontal();

            // Close button
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button(" Close "))
                _playlistGuiVisible = false;
            GUILayout.EndHorizontal();

            GUI.DragWindow();
        }
コード例 #14
0
        public void EditorGui(int windowId)
        {
            // TODO: Save off original values.

            // Close the originating playlists window to cut down on clutter. We'll reopen it later.
            _playlistGuiVisible = false;

            //_editingPlaylist.name = GuiUtils.editString("Playlist name", _editingPlaylist.name);

            GUILayout.BeginHorizontal(); // Title
            GUILayout.Label("Playlist Name:");
            GUILayout.Space(10);
            _editingPlaylist.name = GUILayout.TextField(_editingPlaylist.name);
            GUILayout.EndHorizontal(); // Title

            GUILayout.Space(5);

            GUILayout.BeginHorizontal(); // Columns

            //
            // Settings
            //
            GUILayout.BeginVertical(); // Prereqs column
            // Header
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Label("<b>Settings</b>");
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            _playlistPrereqsScrollPosition = GUILayout.BeginScrollView(_playlistPrereqsScrollPosition, GUILayout.MinWidth(Screen.width / 3));
            _editingPlaylist.enabled = GUILayout.Toggle(_editingPlaylist.enabled, "Enabled");
            _editingPlaylist.loop = GUILayout.Toggle(_editingPlaylist.loop, "Loop");
            _editingPlaylist.shuffle = GUILayout.Toggle(_editingPlaylist.shuffle, "Shuffle");
            _editingPlaylist.pauseOnGamePause = GUILayout.Toggle(_editingPlaylist.pauseOnGamePause, "Pause On Game Pause");
            _editingPlaylist.disableAfterPlay = GUILayout.Toggle(_editingPlaylist.disableAfterPlay, "Disable Once Played");

            // Not yet implemented.
            //FadeEditor();

            // Play Next
            PlayNextPicker();
            PlayBeforePicker();
            PlayAfterPicker();
            // TODO: Channel
            _editingPlaylist.preloadTime = GuiUtils.editFloat("Preload Time (s):", _editingPlaylist.preloadTime);
            // TODO: Paused

            // TODO: Modify playlists in memory
            InAtmospherePicker();
            TimeOfDayPicker();
            ScenePicker();
            SituationPicker();
            CameraModePicker();
            _editingPlaylist.playWhen.bodyName = GuiUtils.editString("Body Name:", _editingPlaylist.playWhen.bodyName);
            GuiUtils.editFloat("Max Surface Velocity:", _editingPlaylist.playWhen.maxVelocitySurface); // TODO: "Clear" buttons.
            GuiUtils.editFloat("Min Surface Velocity:", _editingPlaylist.playWhen.minVelocitySurface);
            GuiUtils.editFloat("Max Orbital Velocity:", _editingPlaylist.playWhen.maxVelocityOrbital);
            GuiUtils.editFloat("Min Orbital Velocity:", _editingPlaylist.playWhen.minVelocityOrbital);
            GuiUtils.editFloat("Max Altitude:", _editingPlaylist.playWhen.maxAltitude);
            GuiUtils.editFloat("Min Altitude:", _editingPlaylist.playWhen.minAltitude);
            GUILayout.EndScrollView(); // _playlistPrereqsScrollPosition
            GUILayout.EndVertical(); // Prereqs column

            //
            // Tracks
            //
            GUILayout.BeginVertical(); // Tracks column
            // Header
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Label("<b>Tracks</b>");
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            _playlistTrackScrollPosition = GUILayout.BeginScrollView(_playlistTrackScrollPosition, GUILayout.MinWidth(Screen.width / 3));
            int removeTrack = -1;
            int moveUpTrack = -1;
            int moveDownTrack = -1;
            if (!_trackPickerVisible)
            {
                for (int i = 0; i < _editingPlaylist.tracks.Count; i++)
                {
                    GUILayout.BeginHorizontal(); // Track/Remove
                    GUILayout.Label(_editingPlaylist.tracks[i]);
                    GUILayout.FlexibleSpace();

                    if (i != 0 && GUILayout.Button(" ↑ "))
                        moveUpTrack = i;
                    if (i < _editingPlaylist.tracks.Count - 1)
                    {
                        if (GUILayout.Button(" ↓ "))
                            moveDownTrack = i;
                    }
                    else
                        GUILayout.Space(34);
                    if (GUILayout.Button(" Remove "))
                        removeTrack = i;
                    GUILayout.EndHorizontal(); // Track/Remove
                }
                if (removeTrack != -1)
                    _editingPlaylist.tracks.RemoveAt(removeTrack);
                if (moveUpTrack != -1)
                {
                    string t = _editingPlaylist.tracks[moveUpTrack];
                    _editingPlaylist.tracks.RemoveAt(moveUpTrack);
                    _editingPlaylist.tracks.Insert(moveUpTrack - 1, t);
                }
                if (moveDownTrack != -1)
                {
                    string t = _editingPlaylist.tracks[moveDownTrack];
                    _editingPlaylist.tracks.RemoveAt(moveDownTrack);
                    _editingPlaylist.tracks.Insert(moveDownTrack + 1, t);
                }
            }
            if (_trackPickerVisible)
                TrackPicker();
            GUILayout.EndScrollView(); // _playlistTrackScrollPosition
            if (_trackPickerVisible)
            {
                if (GUILayout.Button("Done"))
                    _trackPickerVisible = false;
            }
            else
            {
                if (GUILayout.Button(" Add Tracks "))
                    _trackPickerVisible = true;
            }
            GUILayout.EndVertical(); // Tracks column
            GUILayout.EndHorizontal(); // Columns

            // Footer
            GUILayout.BeginVertical(); // Footer
            GUILayout.Space(20); // Vertical filler space.
            GUILayout.BeginHorizontal(); // Buttons
            if (GUILayout.Button(" Delete Playlist "))
            {
                SoundtrackEditor sted = SoundtrackEditor.Instance;
                if (_editingPlaylistOriginal != null)
                    sted.Playlists.Remove(_editingPlaylistOriginal);
                _editorGuiVisible = false;
                _trackPickerVisible = false;
                _playlistGuiVisible = true;
                Persistor.SavePlaylists(sted.Playlists); // Kill it good.
            }
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("  Save  "))
            {
                _editorGuiVisible = false;
                _trackPickerVisible = false;
                _playlistGuiVisible = true;

                SoundtrackEditor sted = SoundtrackEditor.Instance;
                if (_editingPlaylistOriginal != null)
                {
                    int idx = sted.Playlists.IndexOf(_editingPlaylistOriginal);
                    sted.Playlists.RemoveAt(idx);
                    _editingPlaylistOriginal = null;
                    sted.Playlists.Insert(idx, _editingPlaylist);
                }
                else
                    sted.Playlists.Add(_editingPlaylist);
                _editingPlaylist = null;
                Persistor.SavePlaylists(sted.Playlists);
            }
            if (GUILayout.Button(" Cancel "))
            {
                _playlistGuiVisible = true;

                _editorGuiVisible = false;
                // Collapse sub-components.
                _scenesExpanded = false;
                _cameraModeExpanded = false;
                _situationExpanded = false;
                _timeOfDayExpanded = false;
                _inAtmosphereExpanded = false;
                _fadeEditorVisible = false;
                _trackPickerVisible = false;
                _playNextPickerVisible = false;
                _playBeforePickerVisible = false;
                _playAfterPickerVisible = false;
            }
            GUILayout.EndHorizontal(); // Buttons
            GUILayout.EndVertical(); // Footer

            GUI.DragWindow();
        }
コード例 #15
0
 private bool PlaylistPicker()
 {
     bool isVisible = true;
     SoundtrackEditor sted = SoundtrackEditor.Instance;
     for (int i = 0; i < sted.Playlists.Count; i++)
     {
         GUILayout.BeginHorizontal();
         Playlist currentPlaylist = sted.Playlists[i];
         GUILayout.Label("   " + currentPlaylist.name);
         GUILayout.FlexibleSpace();
         if (GUILayout.Button("  Select  "))
         {
             _chosenPlaylist = currentPlaylist;
             isVisible = false;
         }
         GUILayout.EndHorizontal();
     }
     GUILayout.BeginHorizontal();
     GUILayout.FlexibleSpace();
     if (GUILayout.Button("   Cancel  "))
         isVisible = false;
     if (GUILayout.Button("   None  "))
     {
         _chosenPlaylist = null;
         isVisible = false;
     }
     GUILayout.EndHorizontal();
     return isVisible;
 }
コード例 #16
0
        public bool Equals(Playlist p)
        {
            if ((object)p == null)
            {
                return false;
            }

            return (this.enabled == p.enabled) &&
                    (this.loop == p.loop) &&
                    (this.shuffle == p.shuffle) &&
                    (this.pauseOnGamePause == p.pauseOnGamePause) &&
                    (this.disableAfterPlay == p.disableAfterPlay) &&
                    (this.channel == p.channel) &&
                    (this.playNext == p.playNext) &&
                    (this.playBefore == p.playBefore) &&
                    (this.playAfter == p.playAfter) &&
                    (this.tracks.SequenceEqual(p.tracks)) &&
                    (this.playWhen.Equals(p.playWhen)) &&
                    (this.fade == p.fade) &&
                    (this.trackFade == p.trackFade) &&
                    (this.preloadTime == p.preloadTime);
        }