/// <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 MusicPackV2 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; }
/// <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(MusicPackV2 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.songs.Keys) { StardewSymphony.ModMonitor.Log($" {song}"); } } } this.MusicPacks.Add(musicPack.Name, musicPack); }