コード例 #1
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public MusicManager()
 {
     this.musicPacks       = new Dictionary <string, MusicPack>();
     this.currentMusicPack = null;
     packSelector          = new Random(Game1.random.Next(1, 1000000));
     songSelector          = new Random(Game1.player.deepestMineLevel + Game1.player.facingDirection + packSelector.Next(0, 10000));
 }
コード例 #2
0
        /// <summary>
        /// Adds a valid xwb music pack to the list of music packs available.
        /// </summary>
        /// <param name="musicPack"></param>
        /// <param name="displayLogInformation">Whether or not to display the process to the console. Will include information from the pack's metadata. Default:False</param>
        /// <param name="xwbMusicPack">If displayLogInformation is also true this will display the name of all of the songs in the music pack when it is added in.</param>
        public void addMusicPack(MusicPack musicPack, bool displayLogInformation = false, bool displaySongs = false)
        {
            if (displayLogInformation == true)
            {
                StardewSymphony.ModMonitor.Log("Adding a new music pack!");


                StardewSymphony.ModMonitor.Log("    Location:" + musicPack.shortenedDirectory);
                StardewSymphony.ModMonitor.Log("    Name:" + musicPack.musicPackInformation.name);
                StardewSymphony.ModMonitor.Log("    Author:" + musicPack.musicPackInformation.author);
                StardewSymphony.ModMonitor.Log("    Description:" + musicPack.musicPackInformation.description);
                StardewSymphony.ModMonitor.Log("    Version Info:" + musicPack.musicPackInformation.versionInfo);
                StardewSymphony.ModMonitor.Log("    Song List:");

                if (displaySongs == true)
                {
                    foreach (var song in musicPack.songInformation.listOfSongsWithoutTriggers)
                    {
                        StardewSymphony.ModMonitor.Log("        " + song.name);
                    }
                }
            }

            /*
             * if(musicPack.GetType()==typeof(WavMusicPack)){
             *  foreach (var song in musicPack.songInformation.listOfSongsWithoutTriggers)
             *  {
             *      (musicPack as WavMusicPack).LoadWavFromFileToStream(song.pathToSong);
             *  }
             * }
             */

            this.musicPacks.Add(musicPack.musicPackInformation.name, musicPack);
        }
コード例 #3
0
        /// <summary>
        /// Adds a valid xwb music pack to the list of music packs available.
        /// </summary>
        /// <param name="musicPack"></param>
        /// <param name="displayLogInformation">Whether or not to display the process to the console. Will include information from the pack's metadata. Default:False</param>
        /// <param name="xwbMusicPack">If displayLogInformation is also true this will display the name of all of the songs in the music pack when it is added in.</param>
        public void addMusicPack(MusicPack musicPack, bool displayLogInformation = false, bool displaySongs = false)
        {
            if (displayLogInformation == true)
            {
                if (StardewSymphony.Config.EnableDebugLog)
                {
                    StardewSymphony.ModMonitor.Log("Adding a new music pack!");


                    //StardewSymphony.ModMonitor.Log("    Location:" + musicPack.shortenedDirectory);
                    StardewSymphony.ModMonitor.Log("    Name:" + musicPack.musicPackInformation.name);
                    StardewSymphony.ModMonitor.Log("    Author:" + musicPack.musicPackInformation.author);
                    StardewSymphony.ModMonitor.Log("    Description:" + musicPack.musicPackInformation.description);
                    StardewSymphony.ModMonitor.Log("    Version Info:" + musicPack.musicPackInformation.versionInfo);
                    StardewSymphony.ModMonitor.Log("    Song List:");
                }

                if (displaySongs == true)
                {
                    foreach (var song in musicPack.songInformation.listOfSongsWithoutTriggers)
                    {
                        if (StardewSymphony.Config.EnableDebugLog)
                        {
                            StardewSymphony.ModMonitor.Log("        " + song.name);
                        }
                    }
                }
            }

            this.musicPacks.Add(musicPack.musicPackInformation.name, musicPack);
        }
コード例 #4
0
 /// <summary>
 /// Play a random song from a given music pack.
 /// </summary>
 /// <param name="musicPackName"></param>
 public void playRandomSongFromPack(string musicPackName)
 {
     this.musicPacks.TryGetValue(musicPackName, out MusicPack musicPack);
     if (this.currentMusicPack != null)
     {
         this.currentMusicPack.stopSong();
     }
     musicPack.playRandomSong();
     this.currentMusicPack = musicPack;
 }
コード例 #5
0
 /// <summary>
 /// Swaps between referenced music packs and stops the last playing song.
 /// </summary>
 /// <param name="nameOfNewMusicPack"></param>
 public void swapMusicPacks(string nameOfNewMusicPack)
 {
     if (isMusicPackValid(nameOfNewMusicPack) == true)
     {
         if (this.currentMusicPack.isNull() == false)
         {
             this.currentMusicPack.stopSong();
         }
         this.currentMusicPack = getMusicPack(nameOfNewMusicPack);
     }
 }
コード例 #6
0
        /// <summary>Swap between referenced music packs and stop the current song.</summary>
        /// <param name="nameOfNewMusicPack">The name of the new music pack to select.</param>
        public void SwapMusicPacks(string nameOfNewMusicPack)
        {
            if (!this.MusicPacks.TryGetValue(nameOfNewMusicPack, out MusicPack musicPack))
            {
                if (StardewSymphony.Config.EnableDebugLog)
                {
                    StardewSymphony.ModMonitor.Log($"ERROR: Music Pack '{nameOfNewMusicPack}' isn't valid for some reason.", StardewModdingAPI.LogLevel.Alert);
                }
                return;
            }

            this.CurrentMusicPack?.StopSong();
            this.CurrentMusicPack = musicPack;
        }
コード例 #7
0
 /// <summary>
 /// Swaps between referenced music packs and stops the last playing song.
 /// </summary>
 /// <param name="nameOfNewMusicPack"></param>
 public void swapMusicPacks(string nameOfNewMusicPack)
 {
     if (isMusicPackValid(nameOfNewMusicPack) == true)
     {
         if (this.currentMusicPack.isNull() == false)
         {
             this.currentMusicPack.stopSong();
         }
         this.currentMusicPack = getMusicPack(nameOfNewMusicPack);
     }
     else
     {
         if (StardewSymphony.Config.EnableDebugLog)
         {
             StardewSymphony.ModMonitor.Log("ERROR: Music Pack " + nameOfNewMusicPack + " isn't valid for some reason.", StardewModdingAPI.LogLevel.Alert);
         }
     }
 }
コード例 #8
0
        /// <summary>Adds a valid xwb music pack to the list of music packs available.</summary>
        /// <param name="musicPack">The music pack to add.</param>
        /// <param name="displayLogInformation">Whether or not to display the process to the console. Will include information from the pack's metadata. Default:False</param>
        /// <param name="displaySongs">If displayLogInformation is also true this will display the name of all of the songs in the music pack when it is added in.</param>
        public void addMusicPack(MusicPack musicPack, bool displayLogInformation = false, bool displaySongs = false)
        {
            if (displayLogInformation)
            {
                if (StardewSymphony.Config.EnableDebugLog)
                {
                    StardewSymphony.ModMonitor.Log("Adding music pack:");
                    StardewSymphony.ModMonitor.Log($"   Name: {musicPack.Name}");
                    StardewSymphony.ModMonitor.Log($"   Author: {musicPack.Manifest.Author}");
                    StardewSymphony.ModMonitor.Log($"   Description: {musicPack.Manifest.Description}");
                    StardewSymphony.ModMonitor.Log($"   Version Info: {musicPack.Manifest.Version}");
                }
                if (displaySongs && StardewSymphony.Config.EnableDebugLog)
                {
                    StardewSymphony.ModMonitor.Log("    Song List:");
                    foreach (string song in musicPack.SongInformation.listOfSongsWithoutTriggers)
                    {
                        StardewSymphony.ModMonitor.Log($"        {song}");
                    }
                }
            }

            this.MusicPacks.Add(musicPack.Name, musicPack);
        }