From 698f5d84986e089b2fd55b27b469c52c7ad6bf0b Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 30 Jul 2017 01:44:38 -0400 Subject: [PATCH] refactor StardewSymphony This commit formats/documents/simplifies code, standardises naming conventions, removes unused code, etc. --- GeneralMods/StardewSymphony/Class1.cs | 2326 ++++++++--------- .../StardewSymphony/MusicHexProcessor.cs | 200 +- GeneralMods/StardewSymphony/MusicManager.cs | 847 +++--- GeneralMods/StardewSymphony/manifest.json | 2 +- 4 files changed, 1457 insertions(+), 1918 deletions(-) diff --git a/GeneralMods/StardewSymphony/Class1.cs b/GeneralMods/StardewSymphony/Class1.cs index 0775d1f5..cb18cbac 100644 --- a/GeneralMods/StardewSymphony/Class1.cs +++ b/GeneralMods/StardewSymphony/Class1.cs @@ -5,546 +5,430 @@ using System.Linq; using System.Timers; using Microsoft.Xna.Framework.Audio; using StardewModdingAPI; +using StardewModdingAPI.Events; using StardewValley; -/* -TODO: -0. Add in event handling so that I don;t mute a heart event or wedding music. -6. add in Stardew songs again to music selection -7. add in more tracks. -11. Tutorial for adding more music into the game? -15.add in blank templates for users to make their own wave/sound banks - -*/ namespace Omegasis.StardewSymphony { - - - - public class Class1 : Mod + /* + TODO: + 0. Add in event handling so that I don't mute a heart event or wedding music. + 6. add in Stardew songs again to music selection + 7. add in more tracks. + 11. Tutorial for adding more music into the game? + 15. add in blank templates for users to make their own wave/sound banks + */ + /// The mod entry point. + public class StardewSymphony : Mod { - public static string[] subdirectoryEntries = new string[9999999]; - public static string[] fileEntries = new string[9999999]; + /********* + ** Properties + *********/ + /// All of the music/soundbanks and their locations. + private IList MasterList = new List(); - public static List master_list; //holds all of my WAVE banks and sound banks and their locations. - public static Dictionary song_wave_reference; //holds a list of all of the cue names that I ever add in. - public static List location_list; //holds all of the locations in SDV - public static List temp_cue; //temporary list of songs from music pack + /// All of the cue names that I ever add in. + private IDictionary SongWaveReference; - public static Dictionary music_packs; + /// The game locations. + private IList GameLocations; - public static string master_path; //path to this mod + /// The number generator for randomisation. + private Random Random; - static int delay_time; - static int delay_time_min; //min time to pass before next song - static int delay_time_max; //max time to pass before next song - static bool game_loaded; //make sure the game is loaded - bool silent_rain; //auto mix in SDV rain sound with music? - int night_time; //not really used, but keeping it for now. - public static bool seasonal_music; //will I play the seasonal music or not? - public static Random random; + /// The game's original soundbank. + private SoundBank DefaultSoundbank; + + /// The game's original wavebank. + private WaveBank DefaultWavebank; + + private MusicHexProcessor HexProcessor; + + /**** + ** Context + ****/ + /// Whether the player loaded a save. + private bool IsGameLoaded; + + /// Whether no music pack was loaded for the current location. + private bool HasNoMusic; + + /// The song that's currently playing. + private Cue CurrentSong; + + /// The current sound info. + private MusicManager CurrentSoundInfo; + + /// A timer used to create random pauses between songs. + private Timer SongDelayTimer = new Timer(); + + /**** + ** Config + ****/ + /// The minimum delay (in milliseconds) to pass before playing the next song, or 0 for no delay. + private int MinSongDelay; + + /// The maximum delay (in milliseconds) to pass before playing the next song, or 0 for no delay. + private int MaxSongDelay; + + /// Whether to disable ambient rain audio when music is playing. If false, plays ambient rain audio alongside whatever songs are set in rain music. + private bool SilentRain; + + /// Whether to play seasonal music from the music packs, instead of defaulting to the Stardew Valley Soundtrack. + private bool PlaySeasonalMusic; - static bool no_music; //will trigger if a music pack can't be loaded for that location. - - public static SoundBank old_sound_bank; //game's default sound bank - public static SoundBank new_sound_bank; - public static Cue cueball; //the actual song that is playing. Why do you call songs cues microsoft? Probably something I'm oblivious to. - - public static WaveBank oldwave; - public static WaveBank newwave; - - public bool once; - - public static MusicManager current_info_class; - - - public static bool farm_player; - public static bool is_farm; - + /********* + ** Public methods + *********/ + /// The mod entry point, called after the mod is first loaded. + /// Provides simplified APIs for writing mods. public override void Entry(IModHelper helper) { - StardewModdingAPI.Events.SaveEvents.AfterLoad+= PlayerEvents_LoadedGame; - StardewModdingAPI.Events.TimeEvents.DayOfMonthChanged += TimeEvents_DayOfMonthChanged; - StardewModdingAPI.Events.GameEvents.UpdateTick += GameEvents_UpdateTick; - StardewModdingAPI.Events.LocationEvents.CurrentLocationChanged += LocationEvents_CurrentLocationChanged; - once = true; - MusicHexProcessor.allsoundBanks = new List(); - MusicHexProcessor.allHexDumps = new List(); - MusicHexProcessor.allWaveBanks = new List(); + this.HexProcessor = new MusicHexProcessor(this.MasterList, this.Reset); + + SaveEvents.AfterLoad += this.SaveEvents_AfterLoad; + TimeEvents.DayOfMonthChanged += this.TimeEvents_DayOfMonthChanged; + GameEvents.UpdateTick += this.GameEvents_UpdateTick; + LocationEvents.CurrentLocationChanged += this.LocationEvents_CurrentLocationChanged; } - public void GameEvents_UpdateTick(object sender, EventArgs e) - { - if (game_loaded == false) return; - if (master_list != null) - { - if (master_list.Count == 0) return; //basically if absolutly no music is loaded into the game for locations/festivals/seasons, don't override the game's default music player. - } - if (cueball == null) + /********* + ** Private methods + *********/ + /// The method invoked when the game updates (roughly 60 times per second). + /// The event sender. + /// The event data. + private void GameEvents_UpdateTick(object sender, EventArgs e) + { + if (!this.IsGameLoaded || !this.MasterList.Any()) + return; //basically if absolutly no music is loaded into the game for locations/festivals/seasons, don't override the game's default music player. + + if (this.CurrentSong == null) { - no_music = true; + this.HasNoMusic = true; return; //if there wasn't any music at loaded at all for the area, just play the default stardew soundtrack. } - if (no_music == true && cueball.IsPlaying == false) + if (this.HasNoMusic && !this.CurrentSong.IsPlaying) + this.CurrentSong = null; //if there was no music loaded for the area and the last song has finished playing, default to the Stardew Soundtrack. + + if (this.CurrentSong != null) { - cueball = null; //if there was no music loaded for the area and the last song has finished playing, default to the Stardew Soundtrack. - } - if (cueball != null) - { - no_music = false; - if (cueball.IsPlaying == false) //if a song isn't playing - { - //cueball = null; - if (aTimer.Enabled == false) //if my timer isn't enabled, set it. - { - SetTimer(); - } - else - { - //do nothing - } - } + this.HasNoMusic = false; + if (!this.CurrentSong.IsPlaying && !this.SongDelayTimer.Enabled) + this.StartMusicDelay(); } - if (StardewValley.Game1.isFestival() == true) - { - return; //replace with festival - } - if (StardewValley.Game1.eventUp == true) - { - return; //replace with event music - } - - if (StardewValley.Game1.isRaining == true) - { - if (silent_rain == false) return;// If silent_rain = false. AKA, play the rain ambience soundtrack. If it is true, turn off the rain ambience sound track. - } + if (Game1.isFestival()) + return; // replace with festival + if (Game1.eventUp) + return; // replace with event music + if (Game1.isRaining && !this.SilentRain) + return; // play the rain ambience soundtrack Game1.currentSong.Stop(AudioStopOptions.Immediate); //stop the normal songs from playing over the new songs Game1.nextMusicTrack = ""; //same as above line - - } - public void TimeEvents_DayOfMonthChanged(object sender, StardewModdingAPI.Events.EventArgsIntChanged e) - { - if (game_loaded == false) return; - random.Next(); - stop_sound(); //if my music player is called and I forget to clean up sound before hand, kill the old sound. - DataLoader(); - MyWritter(); - - if (game_loaded == false) return; - night_time = Game1.getModeratelyDarkTime(); //not sure I even really use this... - music_selector(); - - - } - public void PlayerEvents_LoadedGame(object sender, EventArgs e) - { - DataLoader(); - MyWritter(); - - music_packs = new Dictionary(); - random = new Random(); - master_list = new List(); - song_wave_reference = new Dictionary(); - location_list = new List(); - temp_cue = new List(); - no_music = true; - - master_creator(); //creates the directory and files necessary to run the mod. - Location_Grabber(); //grab all of the locations in the game and add them to a list; - ProcessDirectory(master_path); - //master_list.Add(new MusicManager("Wave Bank2", "Sound Bank2", PathOnDisk)); Old static way that only alowed one external wave bank. Good thing I found a way around that. - aTimer.Enabled = false; - night_time = Game1.getModeratelyDarkTime(); - process_music_packs(); - - - MusicHexProcessor.processHex(); - - - - Monitor.Log("READY TO GO"); - game_loaded = true; - music_selector(); - - } - public void LocationEvents_CurrentLocationChanged(object sender, StardewModdingAPI.Events.EventArgsCurrentLocationChanged e) - { - if (game_loaded == false) return; - // Monitor.Log("NEW LOCATION"); - if (Game1.player.currentLocation.name == "Farm") is_farm = true; - else is_farm = false; - music_selector(); - } - public static Timer aTimer = new Timer(); - public void SetTimer() + /// The method invoked when changes. + /// The event sender. + /// The event data. + private void TimeEvents_DayOfMonthChanged(object sender, EventArgsIntChanged e) { - //set up a new timer - Random random2 = new Random(); - delay_time = random2.Next(delay_time_min, delay_time_max); //random number between 0 and n. 0 not included + if (!this.IsGameLoaded) + return; + this.StopSound(); //if my music player is called and I forget to clean up sound before hand, kill the old sound. + this.LoadConfig(); + this.WriteConfig(); - // Create a timer with a two second interval. - aTimer = new System.Timers.Timer(delay_time); - // Hook up the Elapsed event for the timer. - aTimer.Elapsed += OnTimedEvent; - aTimer.Enabled = true; - } - public void OnTimedEvent(System.Object source, ElapsedEventArgs e) - { - //when my timer runs out play some music - music_selector(); - aTimer.Enabled = false; + this.SelectMusic(); } - - public void master_creator() + /// The method invoked after the player loads a save. + /// The event sender. + /// The event data. + private void SaveEvents_AfterLoad(object sender, EventArgs e) { - //loads the data to the variables upon loading the game. - var music_path = Helper.DirectoryPath; - if (!Directory.Exists(Path.Combine(music_path, "Music_Packs"))) + // init config + this.LoadConfig(); + this.WriteConfig(); + + // init context + this.Random = new Random(); + this.MasterList = new List(); + this.SongWaveReference = new Dictionary(); + this.GameLocations = Game1.locations; + this.HasNoMusic = true; + + // keep a copy of the original banks + this.DefaultSoundbank = Game1.soundBank; + this.DefaultWavebank = Game1.waveBank; + + // load music packs { - Monitor.Log("Creating Music Directory"); - Directory.CreateDirectory(Path.Combine(music_path, "Music_Packs")); //create the Music_Packs directory. Because organization is nice. + string musicPacksPath = Directory.CreateDirectory(Path.Combine(Helper.DirectoryPath, "Music_Packs")).FullName; + var musicPacks = new Dictionary(); + ProcessDirectory(musicPacksPath, musicPacks); + this.SongDelayTimer.Enabled = false; + foreach (var pack in musicPacks) + this.LoadMusicInfo(pack.Key, pack.Value); } - /* + // init sound + this.HexProcessor.ProcessHex(); + this.IsGameLoaded = true; + this.SelectMusic(); + } - Old chunk of code that was suppose to automatically populate the music packs with a blank music pack for people to use as a template. Sadly this doesn't work all the way. - - if (!Directory.Exists(Path.Combine(music_path, "Music_Packs", "Blank_Music_Pack"))) - { - Monitor.Log("Creating Music Directory"); - Directory.CreateDirectory(Path.Combine(music_path, "Music_Packs", "Blank_Music_Pack")); //create the Music_Packs directory. Because organization is nice. - Setup_Creator(Path.Combine(music_path, "Music_Packs", "Blank_Music_Pack", "Config.txt")); - Setup_Creator(Path.Combine(music_path, "Music_Packs", "Blank_Music_Pack", "master_reference_sheet.txt")); - File.Create(Path.Combine(music_path, "Music_Packs", "Blank_Music_Pack", "your_sound_bank_here.xsb")); - File.Create(Path.Combine(music_path, "Music_Packs", "Blank_Music_Pack", "your_wave_bank_here.xwb")); - } - - - if (!Directory.Exists(Path.Combine(music_path, "Music_Packs","Blank_Music_Pack","Music_Files", "Seasons"))) - { - Monitor.Log("Creating Music Directory"); - Directory.CreateDirectory(Path.Combine(music_path, "Music_Packs", "Blank_Music_Pack","Music_Files", "Seasons")); //create the Music_Packs directory. Because organization is nice. - } - if (!Directory.Exists(Path.Combine(music_path, "Music_Packs", "Blank_Music_Pack","Music_Files", "Locations"))) - { - Monitor.Log("Creating Music Directory"); - Directory.CreateDirectory(Path.Combine(music_path, "Music_Packs", "Blank_Music_Pack","Music_Files", "Locations")); //create the Music_Packs directory. Because organization is nice. - } - */ - - music_path = Path.Combine(music_path, "Music_Packs"); - master_path = music_path; - old_sound_bank = Game1.soundBank; - - oldwave = Game1.waveBank; - - } //works - - - public static void Info_Loader(string root_dir, string config_path) //reads in cue names from a text file and adds them to a specific list. Morphs with specific conditional name. + /// The method invoked after the player warps to a new area. + /// The event sender. + /// The event data. + private void LocationEvents_CurrentLocationChanged(object sender, EventArgsCurrentLocationChanged e) { + if (!this.IsGameLoaded) + return; - if (!File.Exists(config_path)) //check to make sure the file actually exists. It should. + this.SelectMusic(); + } + + /// Create a random delay and then choose the next song. + private void StartMusicDelay() + { + // reset timer + this.SongDelayTimer.Dispose(); + this.SongDelayTimer = new Timer(this.Random.Next(this.MinSongDelay, this.MaxSongDelay)); + + // start timer + this.SongDelayTimer.Elapsed += (sender, args) => + { + this.SelectMusic(); + this.SongDelayTimer.Enabled = false; + }; + this.SongDelayTimer.Start(); + } + + /// Reads cue names from a text file and adds them to a specific list. Morphs with specific conditional name. + /// The root directory for music files. + /// The full path to the config file to read. + private void LoadMusicInfo(string rootDir, string configPath) + { + // make sure file exists + if (!File.Exists(configPath)) { Console.WriteLine("StardewSymphony:This music pack lacks a Config.txt. Without one, I can't load in the music."); - //Setup_Creator(config_path); - } - - else - { - // Load in all of the text files from the Music Packs - string[] readtext = File.ReadAllLines(config_path); - string wave = Convert.ToString(readtext[3]); - string sound = Convert.ToString(readtext[5]); - MusicManager lol = new MusicManager(wave,sound, root_dir); - lol.Music_Loader_Seasons("spring", song_wave_reference); //load all of the info files here. This is some deep magic I worked at 4 AM. I almost forgot how the heck this worked when I woke up. - lol.Music_Loader_Seasons("summer", song_wave_reference); //load all of the info files here. This is some deep magic I worked at 4 AM. I almost forgot how the heck this worked when I woke up. - lol.Music_Loader_Seasons("fall", song_wave_reference); //load all of the info files here. This is some deep magic I worked at 4 AM. I almost forgot how the heck this worked when I woke up. - lol.Music_Loader_Seasons("winter", song_wave_reference); //load all of the info files here. This is some deep magic I worked at 4 AM. I almost forgot how the heck this worked when I woke up. - lol.Music_Loader_Seasons("spring_night", song_wave_reference); //load all of the info files here. This is some deep magic I worked at 4 AM. I almost forgot how the heck this worked when I woke up. - lol.Music_Loader_Seasons("summer_night", song_wave_reference); //load all of the info files here. This is some deep magic I worked at 4 AM. I almost forgot how the heck this worked when I woke up. - lol.Music_Loader_Seasons("fall_night", song_wave_reference); //load all of the info files here. This is some deep magic I worked at 4 AM. I almost forgot how the heck this worked when I woke up. - lol.Music_Loader_Seasons("winter_night", song_wave_reference); //load all of the info files here. This is some deep magic I worked at 4 AM. I almost forgot how the heck this worked when I woke up. - lol.Music_Loader_Seasons("spring_rain", song_wave_reference); //load all of the info files here. This is some deep magic I worked at 4 AM. I almost forgot how the heck this worked when I woke up. - lol.Music_Loader_Seasons("summer_rain", song_wave_reference); //load all of the info files here. This is some deep magic I worked at 4 AM. I almost forgot how the heck this worked when I woke up. - lol.Music_Loader_Seasons("fall_rain", song_wave_reference); //load all of the info files here. This is some deep magic I worked at 4 AM. I almost forgot how the heck this worked when I woke up. - lol.Music_Loader_Seasons("winter_snow", song_wave_reference); //load all of the info files here. This is some deep magic I worked at 4 AM. I almost forgot how the heck this worked when I woke up. - lol.Music_Loader_Seasons("spring_rain_night", song_wave_reference); //load all of the info files here. This is some deep magic I worked at 4 AM. I almost forgot how the heck this worked when I woke up. - lol.Music_Loader_Seasons("summer_rain_night", song_wave_reference); //load all of the info files here. This is some deep magic I worked at 4 AM. I almost forgot how the heck this worked when I woke up. - lol.Music_Loader_Seasons("fall_rain_night", song_wave_reference); //load all of the info files here. This is some deep magic I worked at 4 AM. I almost forgot how the heck this worked when I woke up. - lol.Music_Loader_Seasons("winter_snow_night", song_wave_reference); //load all of the info files here. This is some deep magic I worked at 4 AM. I almost forgot how the heck this worked when I woke up. - foreach (var loc in location_list) - { - lol.Music_Loader_Locations(loc.name, song_wave_reference); //name of location, and the song_wave_reference list - lol.Music_Loader_Locations_Night(loc.name+"_night", song_wave_reference); //name of location, and the song_wave_reference list - lol.Music_Loader_Locations_Rain(loc.name+"_rain", song_wave_reference); //name of location, and the song_wave_reference list - lol.Music_Loader_Locations_Rain_Night(loc.name+"_rain_night", song_wave_reference); //name of location, and the song_wave_reference list - } - if (lol != null) - { - master_list.Add(lol); //add everything to my master list of songs! - } - } - } - - public static void ProcessDirectory(string targetDirectory) - { - // System.Threading.Thread.Sleep(1); - // Process the list of files found in the directory. - fileEntries = Directory.GetFiles(targetDirectory); - - foreach (var v in fileEntries) - { - string extension = Path.GetExtension(v); - // Log.AsyncC(extension); - if (extension == ".xsb") - { - Log.AsyncG(v); - MusicHexProcessor.allsoundBanks.Add(v); - } - if(extension == "xwb") - { - Log.AsyncC(v); - MusicHexProcessor.allWaveBanks.Add(v); - } - } - - if (File.Exists(Path.Combine(targetDirectory, "Config.txt"))){ - string temp = Path.Combine(targetDirectory, "Config.txt"); - //Monitor.Log("YAY"); - music_packs.Add(targetDirectory, temp); - - } - - - - //do checking for spring, summer, night, etc. - - // Recurse into subdirectories of this directory. - subdirectoryEntries = Directory.GetDirectories(targetDirectory); - foreach (string subdirectory in subdirectoryEntries) - { - - ProcessDirectory(subdirectory); - } - } - - public static void process_music_packs() - { - foreach(var hello in music_packs) - { - Info_Loader(hello.Key, hello.Value); - // Monitor.Log("HORRAY"); - } - - - } - public void Location_Grabber() - { - //grab each location in SDV so that the mod will update itself accordingly incase new areas are added - foreach (var loc in StardewValley.Game1.locations) - { - Monitor.Log(loc.name); - location_list.Add(loc); - - } - } - public void music_selector() - { - if (game_loaded == false) - { return; } - // no_music = false; - //if at any time the music for an area can't be played for some unknown reason, the game should default to playing the Stardew Valley Soundtrack. - bool night_time=false; - bool rainy = Game1.isRaining; - if (is_farm == true) + // parse config file + string[] text = File.ReadAllLines(configPath); + string wave = Convert.ToString(text[3]); + string sound = Convert.ToString(text[5]); + + // load all of the info files here. This is some deep magic I worked at 4 AM. I almost forgot how the heck this worked when I woke up. + MusicManager manager = new MusicManager(wave, sound, rootDir); + manager.Music_Loader_Seasons("spring", this.SongWaveReference); + manager.Music_Loader_Seasons("summer", this.SongWaveReference); + manager.Music_Loader_Seasons("fall", this.SongWaveReference); + manager.Music_Loader_Seasons("winter", this.SongWaveReference); + manager.Music_Loader_Seasons("spring_night", this.SongWaveReference); + manager.Music_Loader_Seasons("summer_night", this.SongWaveReference); + manager.Music_Loader_Seasons("fall_night", this.SongWaveReference); + manager.Music_Loader_Seasons("winter_night", this.SongWaveReference); + manager.Music_Loader_Seasons("spring_rain", this.SongWaveReference); + manager.Music_Loader_Seasons("summer_rain", this.SongWaveReference); + manager.Music_Loader_Seasons("fall_rain", this.SongWaveReference); + manager.Music_Loader_Seasons("winter_snow", this.SongWaveReference); + manager.Music_Loader_Seasons("spring_rain_night", this.SongWaveReference); + manager.Music_Loader_Seasons("summer_rain_night", this.SongWaveReference); + manager.Music_Loader_Seasons("fall_rain_night", this.SongWaveReference); + manager.Music_Loader_Seasons("winter_snow_night", this.SongWaveReference); + + // load location music + foreach (GameLocation location in this.GameLocations) + { + manager.Music_Loader_Locations(location.name, this.SongWaveReference); + manager.Music_Loader_Locations_Night(location.name + "_night", this.SongWaveReference); + manager.Music_Loader_Locations_Rain(location.name + "_rain", this.SongWaveReference); + manager.Music_Loader_Locations_Rain_Night(location.name + "_rain_night", this.SongWaveReference); + } + + // add everything to master song list + this.MasterList.Add(manager); + } + + /// Recursively load music packs from the given directory. + /// The directory path to search for music packs. + /// The dictionary to update with music packs. + private void ProcessDirectory(string dirPath, IDictionary musicPacks) + { + // load music files + foreach (string filePath in Directory.GetFiles(dirPath)) + { + string extension = Path.GetExtension(filePath); + if (extension == ".xsb") + { + Log.AsyncG(filePath); + this.HexProcessor.AddSoundBank(filePath); + } + //if (extension == "xwb") + //{ + // Log.AsyncC(path); + // MusicHexProcessor.allWaveBanks.Add(path); + //} + } + + // read config file + if (File.Exists(Path.Combine(dirPath, "Config.txt"))) + { + string temp = Path.Combine(dirPath, "Config.txt"); + musicPacks.Add(dirPath, temp); + } + + // check subdirectories + foreach (string childDir in Directory.GetDirectories(dirPath)) + this.ProcessDirectory(childDir, musicPacks); + } + + /// Select music for the current location. + private void SelectMusic() + { + if (!this.IsGameLoaded) + return; + + // no_music = false; + //if at any time the music for an area can't be played for some unknown reason, the game should default to playing the Stardew Valley Soundtrack. + bool isRaining = Game1.isRaining; + + if (Game1.player.currentLocation is Farm) { farm_music_selector(); return; } - if (StardewValley.Game1.isFestival() == true) + if (Game1.isFestival()) { - stop_sound(); + this.StopSound(); return; //replace with festival music if I decide to support it. } - if (StardewValley.Game1.eventUp == true) + if (Game1.eventUp) { - stop_sound(); + this.StopSound(); return; //replace with event music if I decide to support it/people request it. } - if (Game1.timeOfDay < 600 || Game1.timeOfDay > Game1.getModeratelyDarkTime()) + bool isNight = (Game1.timeOfDay < 600 || Game1.timeOfDay > Game1.getModeratelyDarkTime()); + if (isRaining) { - night_time = true; - } - else - { - night_time = false; - } - - if (rainy == true && night_time == true) - { - music_player_rain_night(); //some really awful heirarchy type thing I made up to help ensure that music plays all the time - if (no_music==true) + if (isNight) { - music_player_rain(); - if (no_music==true) + music_player_rain_night(); //some really awful heirarchy type thing I made up to help ensure that music plays all the time + if (this.HasNoMusic) { - music_player_night(); - if (no_music == true) + music_player_rain(); + if (this.HasNoMusic) { - music_player_location(); - + music_player_night(); + if (this.HasNoMusic) + music_player_location(); } } } - - } - if (rainy == true && night_time == false) - { - music_player_rain(); - if (no_music == true) + else { - music_player_night(); - if (no_music == true) + music_player_rain(); + if (this.HasNoMusic) { - music_player_location(); - + music_player_night(); + if (this.HasNoMusic) + music_player_location(); } } - - } - if (rainy == false && night_time == true) - { - music_player_night(); - if (no_music == true) //if there is no music playing right now play some music. - { - music_player_location(); - - } - - } - if (rainy == false && night_time == false) - { - music_player_location(); - } - - if (no_music==false) //if there is valid music playing - { - // Monitor.Log("RETURN"); - return; } else { - if (seasonal_music == false) + if (isNight) { + music_player_night(); + if (this.HasNoMusic) //if there is no music playing right now play some music. + music_player_location(); + } + else + music_player_location(); + } + + if (this.HasNoMusic) //if there is valid music playing + { + if (!this.PlaySeasonalMusic) return; - } - if (cueball != null) - { - if (cueball.IsPlaying == true) - { - return; - } - } + if (this.CurrentSong != null && this.CurrentSong.IsPlaying) + return; - Monitor.Log("Loading Default Seasonal Music"); - - if (master_list.Count == 0) + this.Monitor.Log("Loading Default Seasonal Music"); + + if (!this.MasterList.Any()) { Monitor.Log("The Wave Bank list is empty. Something went wrong, or you don't have any music packs installed, or you didn't have any songs in the list files."); - reset(); + this.Reset(); return; - } //add in seasonal stuff here - if (Game1.IsSpring == true && no_music==true) + if (this.HasNoMusic) { - if (rainy==true) + if (Game1.IsSpring) { - spring_rain_songs(); + if (isRaining) + spring_rain_songs(); + else + spring_songs(); } - else + else if (Game1.IsSummer) { - spring_songs(); + if (isRaining) + summer_rain_songs(); + else + summer_songs(); + } + else if (Game1.IsFall) + { + if (isRaining) + fall_rain_songs(); + else + fall_songs(); + } + else if (Game1.IsWinter) + { + if (Game1.isSnowing) + winter_snow_songs(); + else + winter_songs(); } } - if (Game1.IsSummer == true && no_music == true) - { - if (rainy == true) - { - summer_rain_songs(); - } - else - { - summer_songs(); - } - } - if (Game1.IsFall == true && no_music == true) - { - if (rainy == true) - { - fall_rain_songs(); - } - else - { - fall_songs(); - } - } - if (Game1.IsWinter == true && no_music == true) - { - if (Game1.isSnowing==true) - { - winter_snow_songs(); - } - else - { - winter_songs(); - } - } - } - - - //end of function. Natural return; - return; } public void farm_music_selector() { - - if (game_loaded == false) - { + if (!this.IsGameLoaded) return; - } + // no_music = false; //if at any time the music for an area can't be played for some unknown reason, the game should default to playing the Stardew Valley Soundtrack. bool night_time = false; bool rainy = Game1.isRaining; Monitor.Log("Loading farm music."); - if (StardewValley.Game1.isFestival() == true) + if (Game1.isFestival()) { - stop_sound(); + this.StopSound(); return; //replace with festival music if I decide to support it. } - if (StardewValley.Game1.eventUp == true) + if (Game1.eventUp) { - stop_sound(); + this.StopSound(); return; //replace with event music if I decide to support it/people request it. } @@ -558,158 +442,157 @@ namespace Omegasis.StardewSymphony night_time = false; } - Monitor.Log("Loading Default Seasonal Music"); + Monitor.Log("Loading Default Seasonal Music"); - if (master_list.Count == 0) - { - Monitor.Log("The Wave Bank list is empty. Something went wrong, or you don't have any music packs installed, or you didn't have any songs in the list files."); - reset(); - return; - - } - - //add in seasonal stuff here - if (Game1.IsSpring == true) - { - if (rainy == true) - { - spring_rain_songs(); - } - else - { - spring_songs(); - } - } - if (Game1.IsSummer == true) - { - if (rainy == true) - { - summer_rain_songs(); - } - else - { - summer_songs(); - } - } - if (Game1.IsFall == true) - { - if (rainy == true) - { - fall_rain_songs(); - } - else - { - fall_songs(); - } - } - if (Game1.IsWinter == true) - { - if (Game1.isSnowing == true) - { - winter_snow_songs(); - } - else - { - winter_songs(); - } - } - //end seasonal songs - if (cueball != null) + if (!this.MasterList.Any()) { - if (cueball.IsPlaying == true) + Monitor.Log("The Wave Bank list is empty. Something went wrong, or you don't have any music packs installed, or you didn't have any songs in the list files."); + this.Reset(); + return; + + } + + //add in seasonal stuff here + if (Game1.IsSpring) + { + if (rainy) + { + spring_rain_songs(); + } + else + { + spring_songs(); + } + } + if (Game1.IsSummer) + { + if (rainy) + { + summer_rain_songs(); + } + else + { + summer_songs(); + } + } + if (Game1.IsFall) + { + if (rainy) + { + fall_rain_songs(); + } + else + { + fall_songs(); + } + } + if (Game1.IsWinter) + { + if (Game1.isSnowing) + { + winter_snow_songs(); + } + else + { + winter_songs(); + } + } + //end seasonal songs + if (this.CurrentSong != null) + { + if (this.CurrentSong.IsPlaying) { return; } } //start locational songs - if (rainy == true && night_time == true) - { - music_player_rain_night(); //some really awful heirarchy type thing I made up to help ensure that music plays all the time - if (no_music == true) - { - music_player_rain(); - if (no_music == true) - { - music_player_night(); - if (no_music == true) - { - music_player_location(); - - } - } - } - - } - if (rainy == true && night_time == false) + if (rainy && night_time) + { + music_player_rain_night(); //some really awful heirarchy type thing I made up to help ensure that music plays all the time + if (this.HasNoMusic) { music_player_rain(); - if (no_music == true) + if (this.HasNoMusic) { music_player_night(); - if (no_music == true) + if (this.HasNoMusic) { music_player_location(); } } - } - if (rainy == false && night_time == true) + + } + if (rainy && night_time == false) + { + music_player_rain(); + if (this.HasNoMusic) { music_player_night(); - if (no_music == true) + if (this.HasNoMusic) { music_player_location(); } - } - if (rainy == false && night_time == false) + + } + if (rainy == false && night_time) + { + music_player_night(); + if (this.HasNoMusic) { music_player_location(); + } + } + if (rainy == false && night_time == false) + { + music_player_location(); + } + //end of function. Natural return; return; } public void music_player_location() { - if (game_loaded == false) + if (!this.IsGameLoaded) { - SetTimer(); + this.StartMusicDelay(); return; } - random.Next(); - int randomNumber = random.Next(0, master_list.Count); //random number between 0 and n. 0 not included + this.Random.Next(); + int randomNumber = this.Random.Next(0, this.MasterList.Count); //random number between 0 and n. 0 not included - if (master_list.Count == 0) + if (!this.MasterList.Any()) { Monitor.Log("The Wave Bank list is empty. Something went wrong, or you don't have any music packs installed, or you didn't have any songs in the list files."); - reset(); + this.Reset(); return; } - current_info_class = master_list.ElementAt(randomNumber); //grab a random wave bank/song bank/music pack/ from all available music packs. + this.CurrentSoundInfo = this.MasterList.ElementAt(randomNumber); //grab a random wave bank/song bank/music pack/ from all available music packs. if (Game1.player.currentLocation != null) { int helper1 = 0; int master_helper = 0; bool found = false; - int chedar = 0; //this mess of a while loop iterates across all of my music packs looking for a valid music pack to play music from. while (true) { - if (current_info_class.locational_songs.Keys.Contains(Game1.player.currentLocation.name)) + if (this.CurrentSoundInfo.LocationSongs.Keys.Contains(Game1.player.currentLocation.name)) { - foreach (var happy in current_info_class.locational_songs) + foreach (var entry in this.CurrentSoundInfo.LocationSongs) { - if (happy.Key == Game1.player.currentLocation.name) + if (entry.Key == Game1.player.currentLocation.name) { - if (happy.Value.Count > 0) + if (entry.Value.Count > 0) { //Monitor.Log("FOUND THE RIGHT POSITIONING OF THE CLASS"); found = true; @@ -745,16 +628,15 @@ namespace Omegasis.StardewSymphony { master_helper++; - if (master_helper > master_list.Count) + if (master_helper > this.MasterList.Count) { Monitor.Log("I've gone though every music pack with no success. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); - no_music = true; + this.HasNoMusic = true; return; } - chedar = (master_helper + randomNumber) % master_list.Count; //circular arrays FTW - - current_info_class = master_list.ElementAt(chedar); //grab a random wave bank/song bank/music pack/ from all available music packs. + int randomIndex = (master_helper + randomNumber) % this.MasterList.Count; + this.CurrentSoundInfo = this.MasterList.ElementAt(randomIndex); //grab a random wave bank/song bank/music pack/ from all available music packs. continue; } else @@ -763,71 +645,66 @@ namespace Omegasis.StardewSymphony } } - temp_cue = current_info_class.locational_songs.Values.ElementAt(helper1); //set a list of songs to a "random" list of songs from a music pack + + List cues = this.CurrentSoundInfo.LocationSongs.Values.ElementAt(helper1); //set a list of songs to a "random" list of songs from a music pack int pointer = 0; - int motzy = 0; //why do I name my variables pointless names? - while (temp_cue.Count == 0) //yet another circular array + while (!cues.Any()) //yet another circular array { pointer++; - motzy = (pointer + randomNumber) % master_list.Count; - - current_info_class = master_list.ElementAt(motzy); - if (pointer > master_list.Count) + int motzy = (pointer + randomNumber) % this.MasterList.Count; //why do I name my variables pointless names? + + this.CurrentSoundInfo = this.MasterList.ElementAt(motzy); + if (pointer > this.MasterList.Count) { Monitor.Log("No music packs have any valid music for this area. AKA all music packs are empty;"); - no_music = true; + this.HasNoMusic = true; return; } } Monitor.Log("loading music for this area"); - if (temp_cue == null) - { - Monitor.Log("temp cue list is null????"); - return; - } - stop_sound(); - int random3 = random.Next(0, temp_cue.Count); - Game1.soundBank = current_info_class.new_sound_bank; //change the game's soundbank temporarily - Game1.waveBank = current_info_class.newwave;//dito but wave bank + this.StopSound(); + int random3 = this.Random.Next(0, cues.Count); + Game1.soundBank = this.CurrentSoundInfo.Soundbank; //change the game's soundbank temporarily + Game1.waveBank = this.CurrentSoundInfo.Wavebank;//dito but wave bank - cueball = temp_cue.ElementAt(random3); //grab a random song from the winter song list - cueball = Game1.soundBank.GetCue(cueball.Name); - if (cueball != null) + this.CurrentSong = cues.ElementAt(random3); //grab a random song from the winter song list + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); + if (this.CurrentSong != null) { - Monitor.Log("Now listening to: " + cueball.Name + " from the music pack located at: " + current_info_class.path_loc + "for the location " + Game1.player.currentLocation); - no_music = false; - cueball.Play(); //play some music - reset(); + Monitor.Log("Now listening to: " + this.CurrentSong.Name + " from the music pack located at: " + this.CurrentSoundInfo.Directory + "for the location " + Game1.player.currentLocation); + this.HasNoMusic = false; + this.CurrentSong.Play(); //play some music + this.Reset(); return; } } else { Monitor.Log("Location is null"); - no_music = true; + this.HasNoMusic = true; } }//end music player public void music_player_rain() { - if (game_loaded == false) + if (!this.IsGameLoaded) { - SetTimer(); + this.StartMusicDelay(); return; } - random.Next(); - int randomNumber = random.Next(0, master_list.Count); //random number between 0 and n. 0 not included + this.Random.Next(); + int randomNumber = this.Random.Next(0, this.MasterList.Count); //random number between 0 and n. 0 not included - if (master_list.Count == 0) + if (!this.MasterList.Any()) { Monitor.Log("The Wave Bank list is empty. Something went wrong, or you don't have any music packs installed, or you didn't have any songs in the list files."); - reset(); + this.Reset(); return; } - current_info_class = master_list.ElementAt(randomNumber); //grab a random wave bank/song bank/music pack/ from all available music packs. + this.CurrentSoundInfo = this.MasterList.ElementAt(randomNumber); //grab a random wave bank/song bank/music pack/ from all available music packs. if (Game1.player.currentLocation != null) { @@ -835,18 +712,16 @@ namespace Omegasis.StardewSymphony int master_helper = 0; bool found = false; - int chedar = 0; - while (true) { - if (current_info_class.locational_rain_songs.Keys.Contains(Game1.player.currentLocation.name+"_rain")) + if (this.CurrentSoundInfo.LocationRainSongs.Keys.Contains(Game1.player.currentLocation.name + "_rain")) { - foreach (var happy in current_info_class.locational_rain_songs) + foreach (var entry in this.CurrentSoundInfo.LocationRainSongs) { - if (happy.Key == Game1.player.currentLocation.name+"_rain") + if (entry.Key == Game1.player.currentLocation.name + "_rain") { - if (happy.Value.Count > 0) + if (entry.Value.Count > 0) { //Monitor.Log("FOUND THE RIGHT POSITIONING OF THE CLASS"); found = true; @@ -882,16 +757,15 @@ namespace Omegasis.StardewSymphony { master_helper++; - if (master_helper > master_list.Count) + if (master_helper > this.MasterList.Count) { Monitor.Log("I've gone though every music pack with no success. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); - no_music = true; + this.HasNoMusic = true; return; } - chedar = (master_helper + randomNumber) % master_list.Count; //circular arrays FTW - - current_info_class = master_list.ElementAt(chedar); //grab a random wave bank/song bank/music pack/ from all available music packs. + int randomIndex = (master_helper + randomNumber) % this.MasterList.Count; + this.CurrentSoundInfo = this.MasterList.ElementAt(randomIndex); //grab a random wave bank/song bank/music pack/ from all available music packs. continue; } else @@ -899,21 +773,21 @@ namespace Omegasis.StardewSymphony break; } } - temp_cue = current_info_class.locational_rain_songs.Values.ElementAt(helper1); + + List cues = this.CurrentSoundInfo.LocationRainSongs.Values.ElementAt(helper1); int pointer = 0; - int motzy = 0; - while (temp_cue.Count == 0) + while (!cues.Any()) { pointer++; - motzy = (pointer + randomNumber) % master_list.Count; + int motzy = (pointer + randomNumber) % this.MasterList.Count; - current_info_class = master_list.ElementAt(motzy); - if (pointer > master_list.Count) + this.CurrentSoundInfo = this.MasterList.ElementAt(motzy); + if (pointer > this.MasterList.Count) { Monitor.Log("No music packs have any valid music for this area. AKA all music packs are empty;"); - no_music = true; + this.HasNoMusic = true; return; } @@ -922,24 +796,19 @@ namespace Omegasis.StardewSymphony Monitor.Log("loading music for this area"); - if (temp_cue == null) - { - Monitor.Log("temp cue list is null????"); - return; - } - stop_sound(); - int random3 = random.Next(0, temp_cue.Count); - Game1.soundBank = current_info_class.new_sound_bank; - Game1.waveBank = current_info_class.newwave; + this.StopSound(); + int random3 = this.Random.Next(0, cues.Count); + Game1.soundBank = this.CurrentSoundInfo.Soundbank; + Game1.waveBank = this.CurrentSoundInfo.Wavebank; - cueball = temp_cue.ElementAt(random3); //grab a random song from the winter song list - cueball = Game1.soundBank.GetCue(cueball.Name); - if (cueball != null) + this.CurrentSong = cues.ElementAt(random3); //grab a random song from the winter song list + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); + if (this.CurrentSong != null) { - no_music = false; - Monitor.Log("Now listening to: " + cueball.Name + " from the music pack located at: " + current_info_class.path_loc + "for the location " + Game1.player.currentLocation + " while it is raining"); - cueball.Play(); - reset(); + this.HasNoMusic = false; + Monitor.Log("Now listening to: " + this.CurrentSong.Name + " from the music pack located at: " + this.CurrentSoundInfo.Directory + "for the location " + Game1.player.currentLocation + " while it is raining"); + this.CurrentSong.Play(); + this.Reset(); return; } @@ -953,23 +822,23 @@ namespace Omegasis.StardewSymphony }//end music player public void music_player_night() { - if (game_loaded == false) + if (!this.IsGameLoaded) { - SetTimer(); + this.StartMusicDelay(); return; } - random.Next(); - int randomNumber = random.Next(0, master_list.Count); //random number between 0 and n. 0 not included + this.Random.Next(); + int randomNumber = this.Random.Next(0, this.MasterList.Count); //random number between 0 and n. 0 not included - if (master_list.Count == 0) + if (!this.MasterList.Any()) { Monitor.Log("The Wave Bank list is empty. Something went wrong, or you don't have any music packs installed, or you didn't have any songs in the list files."); - reset(); + this.Reset(); return; } - current_info_class = master_list.ElementAt(randomNumber); //grab a random wave bank/song bank/music pack/ from all available music packs. + this.CurrentSoundInfo = this.MasterList.ElementAt(randomNumber); //grab a random wave bank/song bank/music pack/ from all available music packs. if (Game1.player.currentLocation != null) { @@ -977,18 +846,16 @@ namespace Omegasis.StardewSymphony int master_helper = 0; bool found = false; - int chedar = 0; - while (true) { - if (current_info_class.locational_night_songs.Keys.Contains(Game1.player.currentLocation.name+"_night")) + if (this.CurrentSoundInfo.LocationNightSongs.Keys.Contains(Game1.player.currentLocation.name + "_night")) { - foreach (var happy in current_info_class.locational_night_songs) + foreach (var entry in this.CurrentSoundInfo.LocationNightSongs) { - if (happy.Key == Game1.player.currentLocation.name+"_night") + if (entry.Key == Game1.player.currentLocation.name + "_night") { - if (happy.Value.Count > 0) + if (entry.Value.Count > 0) { //Monitor.Log("FOUND THE RIGHT POSITIONING OF THE CLASS"); found = true; @@ -1024,16 +891,15 @@ namespace Omegasis.StardewSymphony { master_helper++; - if (master_helper > master_list.Count) + if (master_helper > this.MasterList.Count) { Monitor.Log("I've gone though every music pack with no success. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); - no_music = true; + this.HasNoMusic = true; return; } - chedar = (master_helper + randomNumber) % master_list.Count; //circular arrays FTW - - current_info_class = master_list.ElementAt(chedar); //grab a random wave bank/song bank/music pack/ from all available music packs. + int randomIndex = (master_helper + randomNumber) % this.MasterList.Count; + this.CurrentSoundInfo = this.MasterList.ElementAt(randomIndex); //grab a random wave bank/song bank/music pack/ from all available music packs. continue; } else @@ -1041,19 +907,20 @@ namespace Omegasis.StardewSymphony break; } } - temp_cue = current_info_class.locational_night_songs.Values.ElementAt(helper1); + + List cues = this.CurrentSoundInfo.LocationNightSongs.Values.ElementAt(helper1); int pointer = 0; int motzy = 0; - while (temp_cue.Count == 0) + while (!cues.Any()) { pointer++; - motzy = (pointer + randomNumber) % master_list.Count; + motzy = (pointer + randomNumber) % this.MasterList.Count; - current_info_class = master_list.ElementAt(motzy); - if (pointer > master_list.Count) + this.CurrentSoundInfo = this.MasterList.ElementAt(motzy); + if (pointer > this.MasterList.Count) { Monitor.Log("No music packs have any valid music for this area. AKA all music packs are empty;"); - no_music = true; + this.HasNoMusic = true; return; } @@ -1061,24 +928,19 @@ namespace Omegasis.StardewSymphony Monitor.Log("loading music for this area"); - if (temp_cue == null) - { - Monitor.Log("temp cue list is null????"); - return; - } - stop_sound(); - int random3 = random.Next(0, temp_cue.Count); - Game1.soundBank = current_info_class.new_sound_bank; - Game1.waveBank = current_info_class.newwave; + this.StopSound(); + int random3 = this.Random.Next(0, cues.Count); + Game1.soundBank = this.CurrentSoundInfo.Soundbank; + Game1.waveBank = this.CurrentSoundInfo.Wavebank; - cueball = temp_cue.ElementAt(random3); //grab a random song from the winter song list - cueball = Game1.soundBank.GetCue(cueball.Name); - if (cueball != null) + this.CurrentSong = cues.ElementAt(random3); //grab a random song from the winter song list + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); + if (this.CurrentSong != null) { - no_music = false; - Monitor.Log("Now listening to: " + cueball.Name + " from the music pack located at: " + current_info_class.path_loc + "for the location " + Game1.player.currentLocation + " while it is night time."); - cueball.Play(); - reset(); + this.HasNoMusic = false; + Monitor.Log("Now listening to: " + this.CurrentSong.Name + " from the music pack located at: " + this.CurrentSoundInfo.Directory + "for the location " + Game1.player.currentLocation + " while it is night time."); + this.CurrentSong.Play(); + this.Reset(); return; } @@ -1092,43 +954,41 @@ namespace Omegasis.StardewSymphony }//end music player public void music_player_rain_night() { - if (game_loaded == false) + if (!this.IsGameLoaded) { - SetTimer(); + this.StartMusicDelay(); return; } - random.Next(); - int randomNumber = random.Next(0, master_list.Count); //random number between 0 and n. 0 not included + this.Random.Next(); + int randomNumber = this.Random.Next(0, this.MasterList.Count); //random number between 0 and n. 0 not included - if (master_list.Count == 0) + if (!this.MasterList.Any()) { Monitor.Log("The Wave Bank list is empty. Something went wrong, or you don't have any music packs installed, or you didn't have any songs in the list files."); - reset(); + this.Reset(); return; } - current_info_class = master_list.ElementAt(randomNumber); //grab a random wave bank/song bank/music pack/ from all available music packs. + this.CurrentSoundInfo = this.MasterList.ElementAt(randomNumber); //grab a random wave bank/song bank/music pack/ from all available music packs. if (Game1.player.currentLocation != null) { - + int helper1 = 0; int master_helper = 0; bool found = false; - int chedar = 0; //this is why I shouldn't program before a date. I name my variables after really random crap. - while (true) { - if (current_info_class.locational_rain_night_songs.Keys.Contains(Game1.player.currentLocation.name+"_rain_night")) + if (this.CurrentSoundInfo.LocationRainNightSongs.Keys.Contains(Game1.player.currentLocation.name + "_rain_night")) { - foreach (var happy in current_info_class.locational_rain_night_songs) + foreach (var entry in this.CurrentSoundInfo.LocationRainNightSongs) { - if (happy.Key == Game1.player.currentLocation.name+"_rain_night") + if (entry.Key == Game1.player.currentLocation.name + "_rain_night") { - if (happy.Value.Count > 0) + if (entry.Value.Count > 0) { //Monitor.Log("FOUND THE RIGHT POSITIONING OF THE CLASS"); found = true; @@ -1164,16 +1024,15 @@ namespace Omegasis.StardewSymphony { master_helper++; - if (master_helper > master_list.Count) + if (master_helper > this.MasterList.Count) { Monitor.Log("I've gone though every music pack with no success. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); - no_music = true; + this.HasNoMusic = true; return; } - chedar = (master_helper + randomNumber) % master_list.Count; //circular arrays FTW - - current_info_class = master_list.ElementAt(chedar); //grab a random wave bank/song bank/music pack/ from all available music packs. + int randomIndex = (master_helper + randomNumber) % this.MasterList.Count; + this.CurrentSoundInfo = this.MasterList.ElementAt(randomIndex); //grab a random wave bank/song bank/music pack/ from all available music packs. continue; } else @@ -1181,43 +1040,38 @@ namespace Omegasis.StardewSymphony break; } } - temp_cue = current_info_class.locational_rain_night_songs.Values.ElementAt(helper1); + + List cues = this.CurrentSoundInfo.LocationRainNightSongs.Values.ElementAt(helper1); int pointer = 0; - int motzy = 0; - while (temp_cue.Count == 0) + while (!cues.Any()) { pointer++; - motzy = (pointer + randomNumber) % master_list.Count; + int motzy = (pointer + randomNumber) % this.MasterList.Count; - current_info_class = master_list.ElementAt(motzy); - if (pointer > master_list.Count) + this.CurrentSoundInfo = this.MasterList.ElementAt(motzy); + if (pointer > this.MasterList.Count) { Monitor.Log("No music packs have any valid music for this area. AKA all music packs are empty;"); - no_music = true; + this.HasNoMusic = true; return; } } Monitor.Log("loading music for this area"); - if (temp_cue == null) - { - Monitor.Log("temp cue list is null????"); - return; - } - stop_sound(); - int random3 = random.Next(0, temp_cue.Count); - Game1.soundBank = current_info_class.new_sound_bank; - Game1.waveBank = current_info_class.newwave; + this.StopSound(); + int random3 = this.Random.Next(0, cues.Count); + Game1.soundBank = this.CurrentSoundInfo.Soundbank; + Game1.waveBank = this.CurrentSoundInfo.Wavebank; - cueball = temp_cue.ElementAt(random3); //grab a random song from the winter song list - cueball = Game1.soundBank.GetCue(cueball.Name); - if (cueball != null) + this.CurrentSong = cues.ElementAt(random3); //grab a random song from the winter song list + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); + if (this.CurrentSong != null) { - no_music = false; - Monitor.Log("Now listening to: " + cueball.Name + " from the music pack located at: " + current_info_class.path_loc + "for the location " + Game1.player.currentLocation + " while it is raining at night."); - cueball.Play(); - reset(); + this.HasNoMusic = false; + Monitor.Log("Now listening to: " + this.CurrentSong.Name + " from the music pack located at: " + this.CurrentSoundInfo.Directory + "for the location " + Game1.player.currentLocation + " while it is raining at night."); + this.CurrentSong.Play(); + this.Reset(); return; } @@ -1232,44 +1086,42 @@ namespace Omegasis.StardewSymphony public void spring_songs() { - - if (game_loaded == false) + if (!this.IsGameLoaded) { - SetTimer(); + this.StartMusicDelay(); return; } - random.Next(); - int randomNumber = random.Next(0, master_list.Count); //random number between 0 and n. 0 not included + this.Random.Next(); + int randomNumber = this.Random.Next(0, this.MasterList.Count); //random number between 0 and n. 0 not included - if (master_list.Count == 0) + if (!this.MasterList.Any()) { Monitor.Log("The Wave Bank list is empty. Something went wrong, or you don't have any music packs installed, or you didn't have any songs in the list files."); - reset(); + this.Reset(); return; } - current_info_class = master_list.ElementAt(randomNumber); //grab a random wave bank/song bank/music pack/ from all available music packs. + this.CurrentSoundInfo = this.MasterList.ElementAt(randomNumber); //grab a random wave bank/song bank/music pack/ from all available music packs. + - if (Game1.timeOfDay < 600 || Game1.timeOfDay >= Game1.getModeratelyDarkTime()) //expanded upon, just incase my night owl mod is installed. { - randomNumber = random.Next(0,current_info_class.num_of_spring_night_songs); //random number between 0 and n. 0 not includes + randomNumber = this.Random.Next(0, this.CurrentSoundInfo.SpringNightSongs.Count); //random number between 0 and n. 0 not includes - if (current_info_class.spring_night_song_list.Count == 0) //nightly spring songs + if (this.CurrentSoundInfo.SpringNightSongs.Count == 0) //nightly spring songs { Monitor.Log("The spring night song list is empty. Trying to look for more songs."); //or should I default where if there aren't any nightly songs to play a song from a different play list? int master_helper = 0; - int chedar = 0; - while (master_helper != master_list.Count) + while (master_helper != this.MasterList.Count) { - if (current_info_class.spring_night_song_list.Count > 0) + if (this.CurrentSoundInfo.SpringNightSongs.Count > 0) { - stop_sound(); - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = current_info_class.spring_night_song_list.ElementAt(randomNumber); //grab a random song from the spring song list - cueball = Game1.soundBank.GetCue(cueball.Name); + this.StopSound(); + Game1.soundBank = this.CurrentSoundInfo.Soundbank; //access my new sound table + Game1.waveBank = this.CurrentSoundInfo.Wavebank; + this.CurrentSong = this.CurrentSoundInfo.SpringNightSongs.ElementAt(randomNumber); //grab a random song from the spring song list + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); break; } //itterate through all of the svalid locations that were stored in this class @@ -1277,37 +1129,36 @@ namespace Omegasis.StardewSymphony { master_helper++; } - if (master_helper > master_list.Count) - { - Monitor.Log("I've gone though every music pack with no success for default music. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); - no_music = true; - - return; - - //break; - } - chedar = (master_helper + randomNumber) % master_list.Count; //circular arrays FTW + if (master_helper > this.MasterList.Count) + { + Monitor.Log("I've gone though every music pack with no success for default music. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); + this.HasNoMusic = true; - current_info_class = master_list.ElementAt(chedar); //grab a random wave bank/song bank/music pack/ from all available music packs. - continue; + return; + + //break; } + int randomIndex = (master_helper + randomNumber) % this.MasterList.Count; + this.CurrentSoundInfo = this.MasterList.ElementAt(randomIndex); //grab a random wave bank/song bank/music pack/ from all available music packs. + continue; + } } else { - stop_sound(); - cueball = current_info_class.spring_night_song_list.ElementAt(randomNumber); //grab a random song from the spring song list - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = Game1.soundBank.GetCue(cueball.Name); + this.StopSound(); + this.CurrentSong = this.CurrentSoundInfo.SpringNightSongs.ElementAt(randomNumber); //grab a random song from the spring song list + Game1.soundBank = this.CurrentSoundInfo.Soundbank; //access my new sound table + Game1.waveBank = this.CurrentSoundInfo.Wavebank; + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); } - if (cueball != null) + if (this.CurrentSong != null) { - no_music = false; - Monitor.Log("Now listening to: " + cueball.Name + " from the music pack located at: " + current_info_class.path_loc + " while it is a Spring Night. Check the seasons folder for more info"); - cueball.Play(); - Class1.reset(); + this.HasNoMusic = false; + Monitor.Log("Now listening to: " + this.CurrentSong.Name + " from the music pack located at: " + this.CurrentSoundInfo.Directory + " while it is a Spring Night. Check the seasons folder for more info"); + this.CurrentSong.Play(); + this.Reset(); return; } //if cueballs is null, aka the song list either wasn't initialized, or it is empty, default to playing the normal songs. @@ -1315,21 +1166,20 @@ namespace Omegasis.StardewSymphony } //not nightly spring songs. AKA default songs - randomNumber = random.Next(0,current_info_class.num_of_spring_songs); //random number between 0 and n. 0 not includes - if (current_info_class.spring_song_list.Count == 0) + randomNumber = this.Random.Next(0, this.CurrentSoundInfo.SpringSongs.Count); //random number between 0 and n. 0 not includes + if (this.CurrentSoundInfo.SpringSongs.Count == 0) { Monitor.Log("The spring night song list is empty. Trying to look for more songs."); //or should I default where if there aren't any nightly songs to play a song from a different play list? int master_helper = 0; - int chedar = 0; - while (master_helper != master_list.Count) + while (master_helper != this.MasterList.Count) { - if (current_info_class.spring_night_song_list.Count > 0) + if (this.CurrentSoundInfo.SpringNightSongs.Count > 0) { - stop_sound(); - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = current_info_class.spring_song_list.ElementAt(randomNumber); //grab a random song from the spring song list - cueball = Game1.soundBank.GetCue(cueball.Name); + this.StopSound(); + Game1.soundBank = this.CurrentSoundInfo.Soundbank; //access my new sound table + Game1.waveBank = this.CurrentSoundInfo.Wavebank; + this.CurrentSong = this.CurrentSoundInfo.SpringSongs.ElementAt(randomNumber); //grab a random song from the spring song list + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); break; } //itterate through all of the svalid locations that were stored in this class @@ -1337,75 +1187,72 @@ namespace Omegasis.StardewSymphony { master_helper++; } - if (master_helper > master_list.Count) + if (master_helper > this.MasterList.Count) { Monitor.Log("I've gone though every music pack with no success for default music. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); - no_music = true; + this.HasNoMusic = true; return; - // cueball = null; + // cueball = null; } - chedar = (master_helper + randomNumber) % master_list.Count; //circular arrays FTW - - current_info_class = master_list.ElementAt(chedar); //grab a random wave bank/song bank/music pack/ from all available music packs. + int randomIndex = (master_helper + randomNumber) % this.MasterList.Count; + this.CurrentSoundInfo = this.MasterList.ElementAt(randomIndex); //grab a random wave bank/song bank/music pack/ from all available music packs. continue; } } else { - stop_sound(); - cueball = current_info_class.spring_song_list.ElementAt(randomNumber); //grab a random song from the spring song list - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = Game1.soundBank.GetCue(cueball.Name); + this.StopSound(); + this.CurrentSong = this.CurrentSoundInfo.SpringSongs.ElementAt(randomNumber); //grab a random song from the spring song list + Game1.soundBank = this.CurrentSoundInfo.Soundbank; //access my new sound table + Game1.waveBank = this.CurrentSoundInfo.Wavebank; + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); } - if (cueball == null) return; - no_music = false; - Monitor.Log("Now listening to: " + cueball.Name + " from the music pack located at: " + current_info_class.path_loc + "while it is Spring Time. Check the seasons folder for more info"); - cueball.Play(); - Class1.reset(); + if (this.CurrentSong == null) return; + this.HasNoMusic = false; + Monitor.Log("Now listening to: " + this.CurrentSong.Name + " from the music pack located at: " + this.CurrentSoundInfo.Directory + "while it is Spring Time. Check the seasons folder for more info"); + this.CurrentSong.Play(); + this.Reset(); return; } //plays the songs associated with spring time public void spring_rain_songs() { - - if (game_loaded == false) + if (!this.IsGameLoaded) { - SetTimer(); + this.StartMusicDelay(); return; } - random.Next(); - int randomNumber = random.Next(0, master_list.Count); //random number between 0 and n. 0 not included + this.Random.Next(); + int randomNumber = this.Random.Next(0, this.MasterList.Count); //random number between 0 and n. 0 not included - if (master_list.Count == 0) + if (!this.MasterList.Any()) { Monitor.Log("The Wave Bank list is empty. Something went wrong, or you don't have any music packs installed, or you didn't have any songs in the list files."); - reset(); + this.Reset(); return; } - current_info_class = master_list.ElementAt(randomNumber); //grab a random wave bank/song bank/music pack/ from all available music packs. + this.CurrentSoundInfo = this.MasterList.ElementAt(randomNumber); //grab a random wave bank/song bank/music pack/ from all available music packs. if (Game1.timeOfDay < 600 || Game1.timeOfDay >= Game1.getModeratelyDarkTime()) //expanded upon, just incase my night owl mod is installed. { - randomNumber = random.Next(0, current_info_class.num_of_spring_rain_night_songs); //random number between 0 and n. 0 not includes + randomNumber = this.Random.Next(0, this.CurrentSoundInfo.SpringRainNightSongs.Count); //random number between 0 and n. 0 not includes - if (current_info_class.spring_rain_night_song_list.Count == 0) //nightly spring_rain songs + if (this.CurrentSoundInfo.SpringRainNightSongs.Count == 0) //nightly spring_rain songs { Monitor.Log("The spring_rain night song list is empty. Trying to look for more songs."); //or should I default where if there aren't any nightly songs to play a song from a different play list? int master_helper = 0; - int chedar = 0; - while (master_helper != master_list.Count) + while (master_helper != this.MasterList.Count) { - if (current_info_class.spring_rain_night_song_list.Count > 0) + if (this.CurrentSoundInfo.SpringRainNightSongs.Count > 0) { - stop_sound(); - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = current_info_class.spring_rain_night_song_list.ElementAt(randomNumber); //grab a random song from the spring_rain song list - cueball = Game1.soundBank.GetCue(cueball.Name); + this.StopSound(); + Game1.soundBank = this.CurrentSoundInfo.Soundbank; //access my new sound table + Game1.waveBank = this.CurrentSoundInfo.Wavebank; + this.CurrentSong = this.CurrentSoundInfo.SpringRainNightSongs.ElementAt(randomNumber); //grab a random song from the spring_rain song list + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); break; } //itterate through all of the svalid locations that were stored in this class @@ -1413,34 +1260,33 @@ namespace Omegasis.StardewSymphony { master_helper++; } - if (master_helper > master_list.Count) + if (master_helper > this.MasterList.Count) { Monitor.Log("I've gone though every music pack with no success for default music. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); - no_music = true; + this.HasNoMusic = true; return; } - chedar = (master_helper + randomNumber) % master_list.Count; //circular arrays FTW - - current_info_class = master_list.ElementAt(chedar); //grab a random wave bank/song bank/music pack/ from all available music packs. + int randomIndex = (master_helper + randomNumber) % this.MasterList.Count; + this.CurrentSoundInfo = this.MasterList.ElementAt(randomIndex); //grab a random wave bank/song bank/music pack/ from all available music packs. continue; } } else { - stop_sound(); - cueball = current_info_class.spring_rain_night_song_list.ElementAt(randomNumber); //grab a random song from the fall song list - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = Game1.soundBank.GetCue(cueball.Name); + this.StopSound(); + this.CurrentSong = this.CurrentSoundInfo.SpringRainNightSongs.ElementAt(randomNumber); //grab a random song from the fall song list + Game1.soundBank = this.CurrentSoundInfo.Soundbank; //access my new sound table + Game1.waveBank = this.CurrentSoundInfo.Wavebank; + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); } - if (cueball != null) + if (this.CurrentSong != null) { - no_music = false; - Monitor.Log("Now listening to: " + cueball.Name + " from the music pack located at: " + current_info_class.path_loc + "while it is a rainy Spring night. Check the Seasons folder for more info"); - cueball.Play(); - Class1.reset(); + this.HasNoMusic = false; + Monitor.Log("Now listening to: " + this.CurrentSong.Name + " from the music pack located at: " + this.CurrentSoundInfo.Directory + "while it is a rainy Spring night. Check the Seasons folder for more info"); + this.CurrentSong.Play(); + this.Reset(); return; } //if cueballs is null, aka the song list either wasn't initialized, or it is empty, default to playing the normal songs. @@ -1448,21 +1294,20 @@ namespace Omegasis.StardewSymphony } //not nightly spring_rain songs. AKA default songs - randomNumber = random.Next(0, current_info_class.num_of_spring_rain_songs); //random number between 0 and n. 0 not includes - if (current_info_class.spring_rain_song_list.Count == 0) + randomNumber = this.Random.Next(0, this.CurrentSoundInfo.SpringRainSongs.Count); //random number between 0 and n. 0 not includes + if (this.CurrentSoundInfo.SpringRainSongs.Count == 0) { Monitor.Log("The spring_rain night song list is empty. Trying to look for more songs."); //or should I default where if there aren't any nightly songs to play a song from a different play list? int master_helper = 0; - int chedar = 0; - while (master_helper != master_list.Count) + while (master_helper != this.MasterList.Count) { - if (current_info_class.spring_rain_song_list.Count > 0) + if (this.CurrentSoundInfo.SpringRainSongs.Count > 0) { - stop_sound(); - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = current_info_class.spring_rain_song_list.ElementAt(randomNumber); //grab a random song from the spring_rain song list - cueball = Game1.soundBank.GetCue(cueball.Name); + this.StopSound(); + Game1.soundBank = this.CurrentSoundInfo.Soundbank; //access my new sound table + Game1.waveBank = this.CurrentSoundInfo.Wavebank; + this.CurrentSong = this.CurrentSoundInfo.SpringRainSongs.ElementAt(randomNumber); //grab a random song from the spring_rain song list + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); break; } //itterate through all of the svalid locations that were stored in this class @@ -1470,75 +1315,71 @@ namespace Omegasis.StardewSymphony { master_helper++; } - if (master_helper > master_list.Count) + if (master_helper > this.MasterList.Count) { Monitor.Log("I've gone though every music pack with no success for default music. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); - no_music = true; + this.HasNoMusic = true; return; // cueball = null; } - chedar = (master_helper + randomNumber) % master_list.Count; //circular arrays FTW - - current_info_class = master_list.ElementAt(chedar); //grab a random wave bank/song bank/music pack/ from all available music packs. + int randomIndex = (master_helper + randomNumber) % this.MasterList.Count; + this.CurrentSoundInfo = this.MasterList.ElementAt(randomIndex); //grab a random wave bank/song bank/music pack/ from all available music packs. continue; } } else { - stop_sound(); - cueball = current_info_class.spring_rain_song_list.ElementAt(randomNumber); //grab a random song from the fall song list - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = Game1.soundBank.GetCue(cueball.Name); + this.StopSound(); + this.CurrentSong = this.CurrentSoundInfo.SpringRainSongs.ElementAt(randomNumber); //grab a random song from the fall song list + Game1.soundBank = this.CurrentSoundInfo.Soundbank; //access my new sound table + Game1.waveBank = this.CurrentSoundInfo.Wavebank; + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); } - if (cueball == null) return; - no_music = false; - Monitor.Log("Now listening to: " + cueball.Name + " from the music pack located at: " + current_info_class.path_loc + "while it is a rainy Spring Day. Check the seasons folder for more info"); - cueball.Play(); - Class1.reset(); - return; + if (this.CurrentSong == null) return; + this.HasNoMusic = false; + Monitor.Log("Now listening to: " + this.CurrentSong.Name + " from the music pack located at: " + this.CurrentSoundInfo.Directory + "while it is a rainy Spring Day. Check the seasons folder for more info"); + this.CurrentSong.Play(); + this.Reset(); + } - } //plays the songs associated with spring time public void summer_songs() { - - if (game_loaded == false) + if (!this.IsGameLoaded) { - SetTimer(); + this.StartMusicDelay(); return; } - random.Next(); - int randomNumber = random.Next(0, master_list.Count); //random number between 0 and n. 0 not included + this.Random.Next(); + int randomNumber = this.Random.Next(0, this.MasterList.Count); //random number between 0 and n. 0 not included - if (master_list.Count == 0) + if (this.MasterList.Count == 0) { Monitor.Log("The Wave Bank list is empty. Something went wrong, or you don't have any music packs installed, or you didn't have any songs in the list files."); - reset(); + this.Reset(); return; } - current_info_class = master_list.ElementAt(randomNumber); //grab a random wave bank/song bank/music pack/ from all available music packs. + this.CurrentSoundInfo = this.MasterList.ElementAt(randomNumber); //grab a random wave bank/song bank/music pack/ from all available music packs. if (Game1.timeOfDay < 600 || Game1.timeOfDay >= Game1.getModeratelyDarkTime()) //expanded upon, just incase my night owl mod is installed. { - randomNumber = random.Next(0, current_info_class.num_of_summer_night_songs); //random number between 0 and n. 0 not includes + randomNumber = this.Random.Next(0, this.CurrentSoundInfo.SummerNightSongs.Count); //random number between 0 and n. 0 not includes - if (current_info_class.summer_night_song_list.Count == 0) //nightly summer songs + if (this.CurrentSoundInfo.SummerNightSongs.Count == 0) //nightly summer songs { Monitor.Log("The summer night song list is empty. Trying to look for more songs."); //or should I default where if there aren't any nightly songs to play a song from a different play list? int master_helper = 0; - int chedar = 0; - while (master_helper != master_list.Count) + while (master_helper != this.MasterList.Count) { - if (current_info_class.summer_night_song_list.Count > 0) + if (this.CurrentSoundInfo.SummerNightSongs.Count > 0) { - stop_sound(); - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = current_info_class.summer_night_song_list.ElementAt(randomNumber); //grab a random song from the summer song list - cueball = Game1.soundBank.GetCue(cueball.Name); + this.StopSound(); + Game1.soundBank = this.CurrentSoundInfo.Soundbank; //access my new sound table + Game1.waveBank = this.CurrentSoundInfo.Wavebank; + this.CurrentSong = this.CurrentSoundInfo.SummerNightSongs.ElementAt(randomNumber); //grab a random song from the summer song list + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); break; } //itterate through all of the svalid locations that were stored in this class @@ -1546,36 +1387,35 @@ namespace Omegasis.StardewSymphony { master_helper++; } - if (master_helper > master_list.Count) + if (master_helper > this.MasterList.Count) { Monitor.Log("I've gone though every music pack with no success for default music. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); - no_music = true; + this.HasNoMusic = true; return; } - chedar = (master_helper + randomNumber) % master_list.Count; //circular arrays FTW - - current_info_class = master_list.ElementAt(chedar); //grab a random wave bank/song bank/music pack/ from all available music packs. + int randomIndex = (master_helper + randomNumber) % this.MasterList.Count; + this.CurrentSoundInfo = this.MasterList.ElementAt(randomIndex); //grab a random wave bank/song bank/music pack/ from all available music packs. continue; } } else { - stop_sound(); - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = current_info_class.summer_night_song_list.ElementAt(randomNumber); //grab a random song from the summer song list - cueball = Game1.soundBank.GetCue(cueball.Name); - + this.StopSound(); + Game1.soundBank = this.CurrentSoundInfo.Soundbank; //access my new sound table + Game1.waveBank = this.CurrentSoundInfo.Wavebank; + this.CurrentSong = this.CurrentSoundInfo.SummerNightSongs.ElementAt(randomNumber); //grab a random song from the summer song list + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); + } - if (cueball != null) + if (this.CurrentSong != null) { - Monitor.Log("Now listening to: " + cueball.Name + " from the music pack located at: " + current_info_class.path_loc + " while it is a Summer Night. Check the Seasons folder for more info."); - no_music = false; - cueball.Play(); - Class1.reset(); + Monitor.Log("Now listening to: " + this.CurrentSong.Name + " from the music pack located at: " + this.CurrentSoundInfo.Directory + " while it is a Summer Night. Check the Seasons folder for more info."); + this.HasNoMusic = false; + this.CurrentSong.Play(); + this.Reset(); return; } //if cueballs is null, aka the song list either wasn't initialized, or it is empty, default to playing the normal songs. @@ -1583,21 +1423,20 @@ namespace Omegasis.StardewSymphony } //not nightly summer songs. AKA default songs - randomNumber = random.Next(0, current_info_class.num_of_summer_songs); //random number between 0 and n. 0 not includes - if (current_info_class.summer_song_list.Count == 0) + randomNumber = this.Random.Next(0, this.CurrentSoundInfo.SummerSongs.Count); //random number between 0 and n. 0 not includes + if (this.CurrentSoundInfo.SummerSongs.Count == 0) { Monitor.Log("The summer night song list is empty. Trying to look for more songs."); //or should I default where if there aren't any nightly songs to play a song from a different play list? int master_helper = 0; - int chedar = 0; - while (master_helper != master_list.Count) + while (master_helper != this.MasterList.Count) { - if (current_info_class.summer_night_song_list.Count > 0) + if (this.CurrentSoundInfo.SummerNightSongs.Count > 0) { - stop_sound(); - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = current_info_class.summer_song_list.ElementAt(randomNumber); //grab a random song from the summer song list - cueball = Game1.soundBank.GetCue(cueball.Name); + this.StopSound(); + Game1.soundBank = this.CurrentSoundInfo.Soundbank; //access my new sound table + Game1.waveBank = this.CurrentSoundInfo.Wavebank; + this.CurrentSong = this.CurrentSoundInfo.SummerSongs.ElementAt(randomNumber); //grab a random song from the summer song list + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); break; } //itterate through all of the svalid locations that were stored in this class @@ -1605,76 +1444,73 @@ namespace Omegasis.StardewSymphony { master_helper++; } - if (master_helper > master_list.Count) + if (master_helper > this.MasterList.Count) { Monitor.Log("I've gone though every music pack with no success for default music. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); - no_music = true; + this.HasNoMusic = true; return; // cueball = null; } - chedar = (master_helper + randomNumber) % master_list.Count; //circular arrays FTW - - current_info_class = master_list.ElementAt(chedar); //grab a random wave bank/song bank/music pack/ from all available music packs. + int randomIndex = (master_helper + randomNumber) % this.MasterList.Count; + this.CurrentSoundInfo = this.MasterList.ElementAt(randomIndex); //grab a random wave bank/song bank/music pack/ from all available music packs. continue; } } - if (cueball == null) return; - stop_sound(); - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = current_info_class.summer_song_list.ElementAt(randomNumber); //grab a random song from the summer song list - cueball = Game1.soundBank.GetCue(cueball.Name); - if (cueball != null) + if (this.CurrentSong == null) return; + this.StopSound(); + Game1.soundBank = this.CurrentSoundInfo.Soundbank; //access my new sound table + Game1.waveBank = this.CurrentSoundInfo.Wavebank; + this.CurrentSong = this.CurrentSoundInfo.SummerSongs.ElementAt(randomNumber); //grab a random song from the summer song list + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); + if (this.CurrentSong != null) { - Monitor.Log("Now listening to: " + cueball.Name + " from the music pack located at: " + current_info_class.path_loc + " while it is a Fall day. Check the Seasons folder for more info."); + Monitor.Log("Now listening to: " + this.CurrentSong.Name + " from the music pack located at: " + this.CurrentSoundInfo.Directory + " while it is a Fall day. Check the Seasons folder for more info."); // System.Threading.Thread.Sleep(30000); - no_music = false; - cueball.Play(); - Class1.reset(); - } + this.HasNoMusic = false; + this.CurrentSong.Play(); + this.Reset(); + } return; } //plays the songs associated with summer time public void summer_rain_songs() { - - if (game_loaded == false) + if (!this.IsGameLoaded) { - SetTimer(); + this.StartMusicDelay(); return; } - random.Next(); - int randomNumber = random.Next(0, master_list.Count); //random number between 0 and n. 0 not included + this.Random.Next(); + int randomNumber = this.Random.Next(0, this.MasterList.Count); //random number between 0 and n. 0 not included - if (master_list.Count == 0) + if (this.MasterList.Count == 0) { Monitor.Log("The Wave Bank list is empty. Something went wrong, or you don't have any music packs installed, or you didn't have any songs in the list files."); - reset(); + this.Reset(); return; } - current_info_class = master_list.ElementAt(randomNumber); //grab a random wave bank/song bank/music pack/ from all available music packs. + this.CurrentSoundInfo = this.MasterList.ElementAt(randomNumber); //grab a random wave bank/song bank/music pack/ from all available music packs. if (Game1.timeOfDay < 600 || Game1.timeOfDay >= Game1.getModeratelyDarkTime()) //expanded upon, just incase my night owl mod is installed. { - randomNumber = random.Next(0, current_info_class.num_of_summer_rain_night_songs); //random number between 0 and n. 0 not includes + randomNumber = this.Random.Next(0, this.CurrentSoundInfo.SummerRainNightSongs.Count); //random number between 0 and n. 0 not includes - if (current_info_class.summer_rain_night_song_list.Count == 0) //nightly summer_rain songs + if (this.CurrentSoundInfo.SummerRainNightSongs.Count == 0) //nightly summer_rain songs { Monitor.Log("The summer_rain night song list is empty. Trying to look for more songs."); //or should I default where if there aren't any nightly songs to play a song from a different play list? int master_helper = 0; - int chedar = 0; - while (master_helper != master_list.Count) + while (master_helper != this.MasterList.Count) { - if (current_info_class.summer_rain_night_song_list.Count > 0) + if (this.CurrentSoundInfo.SummerRainNightSongs.Count > 0) { - stop_sound(); - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = current_info_class.summer_rain_night_song_list.ElementAt(randomNumber); //grab a random song from the summer_rain song list - cueball = Game1.soundBank.GetCue(cueball.Name); + this.StopSound(); + Game1.soundBank = this.CurrentSoundInfo.Soundbank; //access my new sound table + Game1.waveBank = this.CurrentSoundInfo.Wavebank; + this.CurrentSong = this.CurrentSoundInfo.SummerRainNightSongs.ElementAt(randomNumber); //grab a random song from the summer_rain song list + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); break; } //itterate through all of the svalid locations that were stored in this class @@ -1682,34 +1518,33 @@ namespace Omegasis.StardewSymphony { master_helper++; } - if (master_helper > master_list.Count) + if (master_helper > this.MasterList.Count) { Monitor.Log("I've gone though every music pack with no success for default music. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); - no_music = true; + this.HasNoMusic = true; return; } - chedar = (master_helper + randomNumber) % master_list.Count; //circular arrays FTW - - current_info_class = master_list.ElementAt(chedar); //grab a random wave bank/song bank/music pack/ from all available music packs. + int randomIndex = (master_helper + randomNumber) % this.MasterList.Count; + this.CurrentSoundInfo = this.MasterList.ElementAt(randomIndex); //grab a random wave bank/song bank/music pack/ from all available music packs. continue; } } else { - stop_sound(); - cueball = current_info_class.summer_rain_night_song_list.ElementAt(randomNumber); //grab a random song from the summer song list - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = Game1.soundBank.GetCue(cueball.Name); + this.StopSound(); + this.CurrentSong = this.CurrentSoundInfo.SummerRainNightSongs.ElementAt(randomNumber); //grab a random song from the summer song list + Game1.soundBank = this.CurrentSoundInfo.Soundbank; //access my new sound table + Game1.waveBank = this.CurrentSoundInfo.Wavebank; + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); } - if (cueball != null) + if (this.CurrentSong != null) { - Monitor.Log("Now listening to: " + cueball.Name + " from the music pack located at: " + current_info_class.path_loc + " while it is a rainy Summer Night. Check the Seasons folder for more info."); - no_music = false; - cueball.Play(); - Class1.reset(); + Monitor.Log("Now listening to: " + this.CurrentSong.Name + " from the music pack located at: " + this.CurrentSoundInfo.Directory + " while it is a rainy Summer Night. Check the Seasons folder for more info."); + this.HasNoMusic = false; + this.CurrentSong.Play(); + this.Reset(); return; } //if cueballs is null, aka the song list either wasn't initialized, or it is empty, default to playing the normal songs. @@ -1717,21 +1552,20 @@ namespace Omegasis.StardewSymphony } //not nightly summer_rain songs. AKA default songs - randomNumber = random.Next(0, current_info_class.num_of_summer_rain_songs); //random number between 0 and n. 0 not includes - if (current_info_class.summer_rain_song_list.Count == 0) + randomNumber = this.Random.Next(0, this.CurrentSoundInfo.SummerRainSongs.Count); //random number between 0 and n. 0 not includes + if (this.CurrentSoundInfo.SummerRainSongs.Count == 0) { Monitor.Log("The summer_rain night song list is empty. Trying to look for more songs."); //or should I default where if there aren't any nightly songs to play a song from a different play list? int master_helper = 0; - int chedar = 0; - while (master_helper != master_list.Count) + while (master_helper != this.MasterList.Count) { - if (current_info_class.summer_rain_song_list.Count > 0) + if (this.CurrentSoundInfo.SummerRainSongs.Count > 0) { - stop_sound(); - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = current_info_class.summer_rain_song_list.ElementAt(randomNumber); //grab a random song from the summer_rain song list - cueball = Game1.soundBank.GetCue(cueball.Name); + this.StopSound(); + Game1.soundBank = this.CurrentSoundInfo.Soundbank; //access my new sound table + Game1.waveBank = this.CurrentSoundInfo.Wavebank; + this.CurrentSong = this.CurrentSoundInfo.SummerRainSongs.ElementAt(randomNumber); //grab a random song from the summer_rain song list + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); break; } //itterate through all of the svalid locations that were stored in this class @@ -1739,79 +1573,75 @@ namespace Omegasis.StardewSymphony { master_helper++; } - if (master_helper > master_list.Count) + if (master_helper > this.MasterList.Count) { Monitor.Log("I've gone though every music pack with no success for default music. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); - no_music = true; + this.HasNoMusic = true; return; // cueball = null; } - chedar = (master_helper + randomNumber) % master_list.Count; //circular arrays FTW - current_info_class = master_list.ElementAt(chedar); //grab a random wave bank/song bank/music pack/ from all available music packs. + int randomIndex = (master_helper + randomNumber) % this.MasterList.Count; + this.CurrentSoundInfo = this.MasterList.ElementAt(randomIndex); //grab a random wave bank/song bank/music pack/ from all available music packs. continue; } } else { - stop_sound(); - cueball = current_info_class.summer_rain_song_list.ElementAt(randomNumber); //grab a random song from the summer song list - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = Game1.soundBank.GetCue(cueball.Name); + this.StopSound(); + this.CurrentSong = this.CurrentSoundInfo.SummerRainSongs.ElementAt(randomNumber); //grab a random song from the summer song list + Game1.soundBank = this.CurrentSoundInfo.Soundbank; //access my new sound table + Game1.waveBank = this.CurrentSoundInfo.Wavebank; + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); } - if (cueball == null) return; - Monitor.Log("Now listening to: " + cueball.Name + " from the music pack located at: " + current_info_class.path_loc + " while it is a rainy Summer day. Check the Seasons folder for more info."); - no_music = false; - cueball.Play(); - Class1.reset(); - return; + if (this.CurrentSong == null) return; + Monitor.Log("Now listening to: " + this.CurrentSong.Name + " from the music pack located at: " + this.CurrentSoundInfo.Directory + " while it is a rainy Summer day. Check the Seasons folder for more info."); + this.HasNoMusic = false; + this.CurrentSong.Play(); + this.Reset(); } //plays the songs associated with summer time public void fall_songs() { - - if (game_loaded == false) - { + if (!this.IsGameLoaded) return; - } - random.Next(); - int randomNumber = random.Next(0, master_list.Count); //random number between 0 and n. 0 not included - if (master_list.Count == 0) + this.Random.Next(); + int randomNumber = this.Random.Next(0, this.MasterList.Count); //random number between 0 and n. 0 not included + + if (this.MasterList.Count == 0) { Monitor.Log("The Wave Bank list is empty. Something went wrong, or you don't have any music packs installed, or you didn't have any songs in the list files."); - // System.Threading.Thread.Sleep(3000); - reset(); + // System.Threading.Thread.Sleep(3000); + this.Reset(); return; } - current_info_class = master_list.ElementAt(randomNumber); //grab a random wave bank/song bank/music pack/ from all available music packs. + this.CurrentSoundInfo = this.MasterList.ElementAt(randomNumber); //grab a random wave bank/song bank/music pack/ from all available music packs. if (Game1.timeOfDay < 600 || Game1.timeOfDay >= Game1.getModeratelyDarkTime()) //expanded upon, just incase my night owl mod is installed. { - randomNumber = random.Next(0, current_info_class.fall_night_song_list.Count); //random number between 0 and n. 0 not includes + randomNumber = this.Random.Next(0, this.CurrentSoundInfo.FallNightSongs.Count); //random number between 0 and n. 0 not includes - if (current_info_class.fall_night_song_list.Count == 0) //nightly fall songs + if (this.CurrentSoundInfo.FallNightSongs.Count == 0) //nightly fall songs { Monitor.Log("The fall night song list is empty. Trying to look for more songs."); //or should I default where if there aren't any nightly songs to play a song from a different play list? - // System.Threading.Thread.Sleep(3000); + // System.Threading.Thread.Sleep(3000); int master_helper = 0; - int chedar = 0; - while (master_helper != master_list.Count) + while (master_helper != this.MasterList.Count) { - if (current_info_class.fall_night_song_list.Count > 0) + if (this.CurrentSoundInfo.FallNightSongs.Count > 0) { - stop_sound(); - cueball = current_info_class.fall_night_song_list.ElementAt(randomNumber); //grab a random song from the fall song list - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; + this.StopSound(); + this.CurrentSong = this.CurrentSoundInfo.FallNightSongs.ElementAt(randomNumber); //grab a random song from the fall song list + Game1.soundBank = this.CurrentSoundInfo.Soundbank; //access my new sound table + Game1.waveBank = this.CurrentSoundInfo.Wavebank; - cueball = Game1.soundBank.GetCue(cueball.Name); + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); break; } //itterate through all of the svalid locations that were stored in this class @@ -1819,39 +1649,38 @@ namespace Omegasis.StardewSymphony { master_helper++; } - if (master_helper >= master_list.Count) + if (master_helper >= this.MasterList.Count) { Monitor.Log("I've gone though every music pack with no success for default music. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); - // System.Threading.Thread.Sleep(3000); - no_music = true; + // System.Threading.Thread.Sleep(3000); + this.HasNoMusic = true; return; - // cueball = null; + // cueball = null; } - chedar = (master_helper + randomNumber) % master_list.Count; //circular arrays FTW - - current_info_class = master_list.ElementAt(chedar); //grab a random wave bank/song bank/music pack/ from all available music packs. + int randomIndex = (master_helper + randomNumber) % this.MasterList.Count; + this.CurrentSoundInfo = this.MasterList.ElementAt(randomIndex); //grab a random wave bank/song bank/music pack/ from all available music packs. continue; } } else { - stop_sound(); + this.StopSound(); - cueball = current_info_class.fall_night_song_list.ElementAt(randomNumber); //grab a random song from the fall song list - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = Game1.soundBank.GetCue(cueball.Name); + this.CurrentSong = this.CurrentSoundInfo.FallNightSongs.ElementAt(randomNumber); //grab a random song from the fall song list + Game1.soundBank = this.CurrentSoundInfo.Soundbank; //access my new sound table + Game1.waveBank = this.CurrentSoundInfo.Wavebank; + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); } - if (cueball != null) + if (this.CurrentSong != null) { - Monitor.Log("Now listening to: " + cueball.Name + " from the music pack located at: " + current_info_class.path_loc + " while it is a Fall Night. Check the Seasons folder for more info."); + Monitor.Log("Now listening to: " + this.CurrentSong.Name + " from the music pack located at: " + this.CurrentSoundInfo.Directory + " while it is a Fall Night. Check the Seasons folder for more info."); //System.Threading.Thread.Sleep(30000); - no_music = false; - cueball.Play(); - reset(); + this.HasNoMusic = false; + this.CurrentSong.Play(); + this.Reset(); return; } //if cueballs is null, aka the song list either wasn't initialized, or it is empty, default to playing the normal songs. @@ -1859,22 +1688,21 @@ namespace Omegasis.StardewSymphony } //not nightly fall songs. AKA default songs - randomNumber = random.Next(0, current_info_class.fall_song_list.Count); //random number between 0 and n. 0 not includes - if (current_info_class.fall_song_list.Count == 0) + randomNumber = this.Random.Next(0, this.CurrentSoundInfo.FallSongs.Count); //random number between 0 and n. 0 not includes + if (this.CurrentSoundInfo.FallSongs.Count == 0) { Monitor.Log("The fall night song list is empty. Trying to look for more songs."); //or should I default where if there aren't any nightly songs to play a song from a different play list? - // System.Threading.Thread.Sleep(3000); + // System.Threading.Thread.Sleep(3000); int master_helper = 0; - int chedar = 0; - while (master_helper != master_list.Count) + while (master_helper != this.MasterList.Count) { - if (current_info_class.fall_song_list.Count > 0) + if (this.CurrentSoundInfo.FallSongs.Count > 0) { - stop_sound(); - cueball = current_info_class.fall_song_list.ElementAt(randomNumber); //grab a random song from the fall song list - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = Game1.soundBank.GetCue(cueball.Name); + this.StopSound(); + this.CurrentSong = this.CurrentSoundInfo.FallSongs.ElementAt(randomNumber); //grab a random song from the fall song list + Game1.soundBank = this.CurrentSoundInfo.Soundbank; //access my new sound table + Game1.waveBank = this.CurrentSoundInfo.Wavebank; + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); break; } //itterate through all of the svalid locations that were stored in this class @@ -1882,80 +1710,77 @@ namespace Omegasis.StardewSymphony { master_helper++; } - - if (master_helper >= master_list.Count) + + if (master_helper >= this.MasterList.Count) { Monitor.Log("I've gone though every music pack with no success for default music. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); - // System.Thr1eading.Thread.Sleep(3000); - no_music = true; + // System.Thr1eading.Thread.Sleep(3000); + this.HasNoMusic = true; return; // cueball = null; } - chedar = (master_helper + randomNumber) % master_list.Count; //circular arrays FTW - - current_info_class = master_list.ElementAt(chedar); //grab a random wave bank/song bank/music pack/ from all available music packs. + int randomIndex = (master_helper + randomNumber) % this.MasterList.Count; + this.CurrentSoundInfo = this.MasterList.ElementAt(randomIndex); //grab a random wave bank/song bank/music pack/ from all available music packs. continue; } } else { - stop_sound(); - cueball = current_info_class.fall_song_list.ElementAt(randomNumber); //grab a random song from the fall song list - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = Game1.soundBank.GetCue(cueball.Name); + this.StopSound(); + this.CurrentSong = this.CurrentSoundInfo.FallSongs.ElementAt(randomNumber); //grab a random song from the fall song list + Game1.soundBank = this.CurrentSoundInfo.Soundbank; //access my new sound table + Game1.waveBank = this.CurrentSoundInfo.Wavebank; + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); } - if (cueball != null) + if (this.CurrentSong != null) { - Monitor.Log("Now listening to: " + cueball.Name + " from the music pack located at: " + current_info_class.path_loc + " while it is a Fall day. Check the Seasons folder for more info."); - // System.Threading.Thread.Sleep(30000); - no_music = false; - cueball.Play(); - reset(); + Monitor.Log("Now listening to: " + this.CurrentSong.Name + " from the music pack located at: " + this.CurrentSoundInfo.Directory + " while it is a Fall day. Check the Seasons folder for more info."); + // System.Threading.Thread.Sleep(30000); + this.HasNoMusic = false; + this.CurrentSong.Play(); + this.Reset(); } return; } //plays the songs associated with fall time public void fall_rain_songs() { - - if (game_loaded == false) + if (!this.IsGameLoaded) { - SetTimer(); + this.StartMusicDelay(); return; } - random.Next(); - int randomNumber = random.Next(0, master_list.Count); //random number between 0 and n. 0 not included + this.Random.Next(); + int randomNumber = this.Random.Next(0, this.MasterList.Count); //random number between 0 and n. 0 not included - if (master_list.Count == 0) + if (this.MasterList.Count == 0) { Monitor.Log("The Wave Bank list is empty. Something went wrong, or you don't have any music packs installed, or you didn't have any songs in the list files."); - reset(); + this.Reset(); return; } - current_info_class = master_list.ElementAt(randomNumber); //grab a random wave bank/song bank/music pack/ from all available music packs. + this.CurrentSoundInfo = this.MasterList.ElementAt(randomNumber); //grab a random wave bank/song bank/music pack/ from all available music packs. if (Game1.timeOfDay < 600 || Game1.timeOfDay >= Game1.getModeratelyDarkTime()) //expanded upon, just incase my night owl mod is installed. { - randomNumber = random.Next(0, current_info_class.num_of_fall_rain_night_songs); //random number between 0 and n. 0 not includes + randomNumber = this.Random.Next(0, this.CurrentSoundInfo.FallRainNightSongs.Count); //random number between 0 and n. 0 not includes - if (current_info_class.fall_rain_night_song_list.Count == 0) //nightly fall_rain songs + if (this.CurrentSoundInfo.FallRainNightSongs.Count == 0) //nightly fall_rain songs { Monitor.Log("The fall_rain night song list is empty. Trying to look for more songs."); //or should I default where if there aren't any nightly songs to play a song from a different play list? int master_helper = 0; - int chedar = 0; - while (master_helper != master_list.Count) + while (master_helper != this.MasterList.Count) { - if (current_info_class.fall_rain_night_song_list.Count > 0) + if (this.CurrentSoundInfo.FallRainNightSongs.Count > 0) { - stop_sound(); - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = current_info_class.fall_rain_night_song_list.ElementAt(randomNumber); //grab a random song from the fall_rain song list - cueball = Game1.soundBank.GetCue(cueball.Name); + this.StopSound(); + Game1.soundBank = this.CurrentSoundInfo.Soundbank; //access my new sound table + Game1.waveBank = this.CurrentSoundInfo.Wavebank; + this.CurrentSong = this.CurrentSoundInfo.FallRainNightSongs.ElementAt(randomNumber); //grab a random song from the fall_rain song list + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); break; @@ -1964,34 +1789,33 @@ namespace Omegasis.StardewSymphony { master_helper++; } - if (master_helper > master_list.Count) + if (master_helper > this.MasterList.Count) { Monitor.Log("I've gone though every music pack with no success for default music. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); - no_music = true; + this.HasNoMusic = true; return; } - chedar = (master_helper + randomNumber) % master_list.Count; //circular arrays FTW - - current_info_class = master_list.ElementAt(chedar); //grab a random wave bank/song bank/music pack/ from all available music packs. + int randomIndex = (master_helper + randomNumber) % this.MasterList.Count; + this.CurrentSoundInfo = this.MasterList.ElementAt(randomIndex); //grab a random wave bank/song bank/music pack/ from all available music packs. continue; } } else { - stop_sound(); - cueball = current_info_class.fall_rain_night_song_list.ElementAt(randomNumber); //grab a random song from the fall song list - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = Game1.soundBank.GetCue(cueball.Name); + this.StopSound(); + this.CurrentSong = this.CurrentSoundInfo.FallRainNightSongs.ElementAt(randomNumber); //grab a random song from the fall song list + Game1.soundBank = this.CurrentSoundInfo.Soundbank; //access my new sound table + Game1.waveBank = this.CurrentSoundInfo.Wavebank; + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); } - if (cueball != null) + if (this.CurrentSong != null) { - no_music = false; - Monitor.Log("Now listening to: " + cueball.Name + " from the music pack located at: " + current_info_class.path_loc + " while it is a rainy Fall Night. Check the Seasons folder for more info."); - cueball.Play(); - Class1.reset(); + this.HasNoMusic = false; + Monitor.Log("Now listening to: " + this.CurrentSong.Name + " from the music pack located at: " + this.CurrentSoundInfo.Directory + " while it is a rainy Fall Night. Check the Seasons folder for more info."); + this.CurrentSong.Play(); + this.Reset(); return; } //if cueballs is null, aka the song list either wasn't initialized, or it is empty, default to playing the normal songs. @@ -1999,21 +1823,20 @@ namespace Omegasis.StardewSymphony } //not nightly fall_rain songs. AKA default songs - randomNumber = random.Next(0, current_info_class.num_of_fall_rain_songs); //random number between 0 and n. 0 not includes - if (current_info_class.fall_rain_song_list.Count == 0) + randomNumber = this.Random.Next(0, this.CurrentSoundInfo.FallRainSongs.Count); //random number between 0 and n. 0 not includes + if (this.CurrentSoundInfo.FallRainSongs.Count == 0) { Monitor.Log("The fall_rain night song list is empty. Trying to look for more songs."); //or should I default where if there aren't any nightly songs to play a song from a different play list? int master_helper = 0; - int chedar = 0; - while (master_helper != master_list.Count) + while (master_helper != this.MasterList.Count) { - if (current_info_class.fall_rain_song_list.Count > 0) + if (this.CurrentSoundInfo.FallRainSongs.Count > 0) { - stop_sound(); - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = current_info_class.fall_rain_song_list.ElementAt(randomNumber); //grab a random song from the fall_rain song list - cueball = Game1.soundBank.GetCue(cueball.Name); + this.StopSound(); + Game1.soundBank = this.CurrentSoundInfo.Soundbank; //access my new sound table + Game1.waveBank = this.CurrentSoundInfo.Wavebank; + this.CurrentSong = this.CurrentSoundInfo.FallRainSongs.ElementAt(randomNumber); //grab a random song from the fall_rain song list + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); break; } //itterate through all of the svalid locations that were stored in this class @@ -2021,77 +1844,73 @@ namespace Omegasis.StardewSymphony { master_helper++; } - if (master_helper > master_list.Count) + if (master_helper > this.MasterList.Count) { Monitor.Log("I've gone though every music pack with no success for default music. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); - no_music = true; + this.HasNoMusic = true; return; // cueball = null; } - chedar = (master_helper + randomNumber) % master_list.Count; //circular arrays FTW - - current_info_class = master_list.ElementAt(chedar); //grab a random wave bank/song bank/music pack/ from all available music packs. + int randomIndex = (master_helper + randomNumber) % this.MasterList.Count; + this.CurrentSoundInfo = this.MasterList.ElementAt(randomIndex); //grab a random wave bank/song bank/music pack/ from all available music packs. continue; } } else { - stop_sound(); - cueball = current_info_class.fall_rain_song_list.ElementAt(randomNumber); //grab a random song from the fall song list - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = Game1.soundBank.GetCue(cueball.Name); + this.StopSound(); + this.CurrentSong = this.CurrentSoundInfo.FallRainSongs.ElementAt(randomNumber); //grab a random song from the fall song list + Game1.soundBank = this.CurrentSoundInfo.Soundbank; //access my new sound table + Game1.waveBank = this.CurrentSoundInfo.Wavebank; + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); } - if (cueball == null) return; - Monitor.Log("Now listening to: " + cueball.Name + " from the music pack located at: " + current_info_class.path_loc + " while it is a rainy Fall day. Check the Seasons folder for more info."); - no_music = false; - cueball.Play(); - Class1.reset(); - return; + if (this.CurrentSong == null) return; + Monitor.Log("Now listening to: " + this.CurrentSong.Name + " from the music pack located at: " + this.CurrentSoundInfo.Directory + " while it is a rainy Fall day. Check the Seasons folder for more info."); + this.HasNoMusic = false; + this.CurrentSong.Play(); + this.Reset(); } //plays the songs associated with fall time public void winter_songs() { - - if (game_loaded == false) + if (!this.IsGameLoaded) { - SetTimer(); + this.StartMusicDelay(); return; } - random.Next(); - int randomNumber = random.Next(0, master_list.Count); //random number between 0 and n. 0 not included + this.Random.Next(); + int randomNumber = this.Random.Next(0, this.MasterList.Count); //random number between 0 and n. 0 not included - if (master_list.Count == 0) + if (this.MasterList.Count == 0) { Monitor.Log("The Wave Bank list is empty. Something went wrong, or you don't have any music packs installed, or you didn't have any songs in the list files."); - reset(); + this.Reset(); return; } - current_info_class = master_list.ElementAt(randomNumber); //grab a random wave bank/song bank/music pack/ from all available music packs. + this.CurrentSoundInfo = this.MasterList.ElementAt(randomNumber); //grab a random wave bank/song bank/music pack/ from all available music packs. if (Game1.timeOfDay < 600 || Game1.timeOfDay >= Game1.getModeratelyDarkTime()) //expanded upon, just incase my night owl mod is installed. { - randomNumber = random.Next(0, current_info_class.num_of_winter_night_songs); //random number between 0 and n. 0 not includes + randomNumber = this.Random.Next(0, this.CurrentSoundInfo.WinterNightSongs.Count); //random number between 0 and n. 0 not includes - if (current_info_class.winter_night_song_list.Count == 0) //nightly winter songs + if (this.CurrentSoundInfo.WinterNightSongs.Count == 0) //nightly winter songs { Monitor.Log("The winter night song list is empty. Trying to look for more songs."); //or should I default where if there aren't any nightly songs to play a song from a different play list? int master_helper = 0; - int chedar = 0; - while (master_helper != master_list.Count) + while (master_helper != this.MasterList.Count) { - if (current_info_class.winter_night_song_list.Count > 0) + if (this.CurrentSoundInfo.WinterNightSongs.Count > 0) { - stop_sound(); - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = current_info_class.winter_night_song_list.ElementAt(randomNumber); //grab a random song from the winter song list - cueball = Game1.soundBank.GetCue(cueball.Name); + this.StopSound(); + Game1.soundBank = this.CurrentSoundInfo.Soundbank; //access my new sound table + Game1.waveBank = this.CurrentSoundInfo.Wavebank; + this.CurrentSong = this.CurrentSoundInfo.WinterNightSongs.ElementAt(randomNumber); //grab a random song from the winter song list + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); break; } //itterate through all of the svalid locations that were stored in this class @@ -2099,34 +1918,33 @@ namespace Omegasis.StardewSymphony { master_helper++; } - if (master_helper > master_list.Count) + if (master_helper > this.MasterList.Count) { Monitor.Log("I've gone though every music pack with no success for default music. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); - no_music = true; + this.HasNoMusic = true; return; } - chedar = (master_helper + randomNumber) % master_list.Count; //circular arrays FTW - - current_info_class = master_list.ElementAt(chedar); //grab a random wave bank/song bank/music pack/ from all available music packs. + int randomIndex = (master_helper + randomNumber) % this.MasterList.Count; + this.CurrentSoundInfo = this.MasterList.ElementAt(randomIndex); //grab a random wave bank/song bank/music pack/ from all available music packs. continue; } } else { - stop_sound(); - cueball = current_info_class.winter_night_song_list.ElementAt(randomNumber); //grab a random song from the fall song list - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = Game1.soundBank.GetCue(cueball.Name); + this.StopSound(); + this.CurrentSong = this.CurrentSoundInfo.WinterNightSongs.ElementAt(randomNumber); //grab a random song from the fall song list + Game1.soundBank = this.CurrentSoundInfo.Soundbank; //access my new sound table + Game1.waveBank = this.CurrentSoundInfo.Wavebank; + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); } - if (cueball != null) + if (this.CurrentSong != null) { - no_music = false; - Monitor.Log("Now listening to: " + cueball.Name + " from the music pack located at: " + current_info_class.path_loc + " while it is a Winter Night. Check the Seasons folder for more info."); - cueball.Play(); - Class1.reset(); + this.HasNoMusic = false; + Monitor.Log("Now listening to: " + this.CurrentSong.Name + " from the music pack located at: " + this.CurrentSoundInfo.Directory + " while it is a Winter Night. Check the Seasons folder for more info."); + this.CurrentSong.Play(); + this.Reset(); return; } //if cueballs is null, aka the song list either wasn't initialized, or it is empty, default to playing the normal songs. @@ -2134,21 +1952,20 @@ namespace Omegasis.StardewSymphony } //not nightly winter songs. AKA default songs - randomNumber = random.Next(0, current_info_class.num_of_winter_songs); //random number between 0 and n. 0 not includes - if (current_info_class.winter_song_list.Count == 0) + randomNumber = this.Random.Next(0, this.CurrentSoundInfo.WinterSongs.Count); //random number between 0 and n. 0 not includes + if (this.CurrentSoundInfo.WinterSongs.Count == 0) { Monitor.Log("The winter night song list is empty. Trying to look for more songs."); //or should I default where if there aren't any nightly songs to play a song from a different play list? int master_helper = 0; - int chedar = 0; - while (master_helper != master_list.Count) + while (master_helper != this.MasterList.Count) { - if (current_info_class.winter_night_song_list.Count > 0) + if (this.CurrentSoundInfo.WinterNightSongs.Count > 0) { - stop_sound(); - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = current_info_class.winter_song_list.ElementAt(randomNumber); //grab a random song from the winter song list - cueball = Game1.soundBank.GetCue(cueball.Name); + this.StopSound(); + Game1.soundBank = this.CurrentSoundInfo.Soundbank; //access my new sound table + Game1.waveBank = this.CurrentSoundInfo.Wavebank; + this.CurrentSong = this.CurrentSoundInfo.WinterSongs.ElementAt(randomNumber); //grab a random song from the winter song list + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); break; } //itterate through all of the svalid locations that were stored in this class @@ -2156,75 +1973,72 @@ namespace Omegasis.StardewSymphony { master_helper++; } - if (master_helper > master_list.Count) + if (master_helper > this.MasterList.Count) { Monitor.Log("I've gone though every music pack with no success for default music. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); - no_music = true; + this.HasNoMusic = true; return; // cueball = null; } - chedar = (master_helper + randomNumber) % master_list.Count; //circular arrays FTW - - current_info_class = master_list.ElementAt(chedar); //grab a random wave bank/song bank/music pack/ from all available music packs. + int randomIndex = (master_helper + randomNumber) % this.MasterList.Count; + this.CurrentSoundInfo = this.MasterList.ElementAt(randomIndex); //grab a random wave bank/song bank/music pack/ from all available music packs. continue; } } else { - stop_sound(); - cueball = current_info_class.winter_song_list.ElementAt(randomNumber); //grab a random song from the fall song list - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = Game1.soundBank.GetCue(cueball.Name); + this.StopSound(); + this.CurrentSong = this.CurrentSoundInfo.WinterSongs.ElementAt(randomNumber); //grab a random song from the fall song list + Game1.soundBank = this.CurrentSoundInfo.Soundbank; //access my new sound table + Game1.waveBank = this.CurrentSoundInfo.Wavebank; + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); } - if (cueball == null) return; - Monitor.Log("Now listening to: " + cueball.Name + " from the music pack located at: " + current_info_class.path_loc + " while it is a Winter Day. Check the Seasons folder for more info."); - no_music = false; - cueball.Play(); - Class1.reset(); - return; + if (this.CurrentSong == null) return; + Monitor.Log("Now listening to: " + this.CurrentSong.Name + " from the music pack located at: " + this.CurrentSoundInfo.Directory + " while it is a Winter Day. Check the Seasons folder for more info."); + this.HasNoMusic = false; + this.CurrentSong.Play(); + this.Reset(); } //plays the songs associated with winter time + public void winter_snow_songs() { - - if (game_loaded == false) + if (!this.IsGameLoaded) { - SetTimer(); + this.StartMusicDelay(); return; } - random.Next(); - int randomNumber = random.Next(0, master_list.Count); //random number between 0 and n. 0 not included + this.Random.Next(); + int randomNumber = this.Random.Next(0, this.MasterList.Count); //random number between 0 and n. 0 not included - if (master_list.Count == 0) + if (this.MasterList.Count == 0) { Monitor.Log("The Wave Bank list is empty. Something went wrong, or you don't have any music packs installed, or you didn't have any songs in the list files."); - reset(); + this.Reset(); return; } - current_info_class = master_list.ElementAt(randomNumber); //grab a random wave bank/song bank/music pack/ from all available music packs. + this.CurrentSoundInfo = this.MasterList.ElementAt(randomNumber); //grab a random wave bank/song bank/music pack/ from all available music packs. if (Game1.timeOfDay < 600 || Game1.timeOfDay >= Game1.getModeratelyDarkTime()) //expanded upon, just incase my night owl mod is installed. { - randomNumber = random.Next(0, current_info_class.num_of_winter_snow_night_songs); //random number between 0 and n. 0 not includes + randomNumber = this.Random.Next(0, this.CurrentSoundInfo.WinterSnowNightSongs.Count); //random number between 0 and n. 0 not includes - if (current_info_class.winter_snow_night_song_list.Count == 0) //nightly winter_snow songs + if (this.CurrentSoundInfo.WinterSnowNightSongs.Count == 0) //nightly winter_snow songs { Monitor.Log("The winter_snow night song list is empty. Trying to look for more songs."); //or should I default where if there aren't any nightly songs to play a song from a different play list? int master_helper = 0; - int chedar = 0; - while (master_helper != master_list.Count) + while (master_helper != this.MasterList.Count) { - if (current_info_class.winter_snow_night_song_list.Count > 0) + if (this.CurrentSoundInfo.WinterSnowNightSongs.Count > 0) { - stop_sound(); - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = current_info_class.winter_snow_night_song_list.ElementAt(randomNumber); //grab a random song from the winter_snow song list - cueball = Game1.soundBank.GetCue(cueball.Name); + this.StopSound(); + Game1.soundBank = this.CurrentSoundInfo.Soundbank; //access my new sound table + Game1.waveBank = this.CurrentSoundInfo.Wavebank; + this.CurrentSong = this.CurrentSoundInfo.WinterSnowNightSongs.ElementAt(randomNumber); //grab a random song from the winter_snow song list + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); break; } //itterate through all of the svalid locations that were stored in this class @@ -2232,34 +2046,33 @@ namespace Omegasis.StardewSymphony { master_helper++; } - if (master_helper > master_list.Count) + if (master_helper > this.MasterList.Count) { Monitor.Log("I've gone though every music pack with no success for default music. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); - no_music = true; + this.HasNoMusic = true; return; } - chedar = (master_helper + randomNumber) % master_list.Count; //circular arrays FTW - - current_info_class = master_list.ElementAt(chedar); //grab a random wave bank/song bank/music pack/ from all available music packs. + int randomIndex = (master_helper + randomNumber) % this.MasterList.Count; + this.CurrentSoundInfo = this.MasterList.ElementAt(randomIndex); //grab a random wave bank/song bank/music pack/ from all available music packs. continue; } } else { - stop_sound(); - cueball = current_info_class.winter_snow_night_song_list.ElementAt(randomNumber); //grab a random song from the fall song list - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = Game1.soundBank.GetCue(cueball.Name); + this.StopSound(); + this.CurrentSong = this.CurrentSoundInfo.WinterSnowNightSongs.ElementAt(randomNumber); //grab a random song from the fall song list + Game1.soundBank = this.CurrentSoundInfo.Soundbank; //access my new sound table + Game1.waveBank = this.CurrentSoundInfo.Wavebank; + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); } - if (cueball != null) + if (this.CurrentSong != null) { - no_music = false; - Monitor.Log("Now listening to: " + cueball.Name + " from the music pack located at: " + current_info_class.path_loc + " while it is a snowy Winter night. Check the Seasons folder for more info."); - cueball.Play(); - Class1.reset(); + this.HasNoMusic = false; + Monitor.Log("Now listening to: " + this.CurrentSong.Name + " from the music pack located at: " + this.CurrentSoundInfo.Directory + " while it is a snowy Winter night. Check the Seasons folder for more info."); + this.CurrentSong.Play(); + this.Reset(); return; } //if cueballs is null, aka the song list either wasn't initialized, or it is empty, default to playing the normal songs. @@ -2267,21 +2080,20 @@ namespace Omegasis.StardewSymphony } //not nightly winter_snow songs. AKA default songs - randomNumber = random.Next(0, current_info_class.num_of_winter_snow_songs); //random number between 0 and n. 0 not includes - if (current_info_class.winter_snow_song_list.Count == 0) + randomNumber = this.Random.Next(0, this.CurrentSoundInfo.WinterSnowSongs.Count); //random number between 0 and n. 0 not includes + if (this.CurrentSoundInfo.WinterSnowSongs.Count == 0) { Monitor.Log("The winter_snow night song list is empty. Trying to look for more songs."); //or should I default where if there aren't any nightly songs to play a song from a different play list? int master_helper = 0; - int chedar = 0; - while (master_helper != master_list.Count) + while (master_helper != this.MasterList.Count) { - if (current_info_class.winter_snow_song_list.Count > 0) + if (this.CurrentSoundInfo.WinterSnowSongs.Count > 0) { - stop_sound(); - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = current_info_class.winter_snow_song_list.ElementAt(randomNumber); //grab a random song from the winter_snow song list - cueball = Game1.soundBank.GetCue(cueball.Name); + this.StopSound(); + Game1.soundBank = this.CurrentSoundInfo.Soundbank; //access my new sound table + Game1.waveBank = this.CurrentSoundInfo.Wavebank; + this.CurrentSong = this.CurrentSoundInfo.WinterSnowSongs.ElementAt(randomNumber); //grab a random song from the winter_snow song list + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); break; } //itterate through all of the svalid locations that were stored in this class @@ -2289,158 +2101,108 @@ namespace Omegasis.StardewSymphony { master_helper++; } - if (master_helper > master_list.Count) + if (master_helper > this.MasterList.Count) { Monitor.Log("I've gone though every music pack with no success for default music. There is no music to load for this area so it will be silent once this song finishes playing. Sorry!"); - no_music = true; + this.HasNoMusic = true; return; // cueball = null; } - chedar = (master_helper + randomNumber) % master_list.Count; //circular arrays FTW - - current_info_class = master_list.ElementAt(chedar); //grab a random wave bank/song bank/music pack/ from all available music packs. + int randomIndex = (master_helper + randomNumber) % this.MasterList.Count; + this.CurrentSoundInfo = this.MasterList.ElementAt(randomIndex); //grab a random wave bank/song bank/music pack/ from all available music packs. continue; } } else { - stop_sound(); - cueball = current_info_class.winter_snow_song_list.ElementAt(randomNumber); //grab a random song from the fall song list - Game1.soundBank = current_info_class.new_sound_bank; //access my new sound table - Game1.waveBank = current_info_class.newwave; - cueball = Game1.soundBank.GetCue(cueball.Name); + this.StopSound(); + this.CurrentSong = this.CurrentSoundInfo.WinterSnowSongs.ElementAt(randomNumber); //grab a random song from the fall song list + Game1.soundBank = this.CurrentSoundInfo.Soundbank; //access my new sound table + Game1.waveBank = this.CurrentSoundInfo.Wavebank; + this.CurrentSong = Game1.soundBank.GetCue(this.CurrentSong.Name); } - if (cueball == null) return; - no_music = false; - Monitor.Log("Now listening to: " + cueball.Name + " from the music pack located at: " + current_info_class.path_loc + " while it is a snowy winter day. Check the Seasons folder for more info."); - cueball.Play(); - Class1.reset(); + if (this.CurrentSong == null) return; + this.HasNoMusic = false; + Monitor.Log("Now listening to: " + this.CurrentSong.Name + " from the music pack located at: " + this.CurrentSoundInfo.Directory + " while it is a snowy winter day. Check the Seasons folder for more info."); + this.CurrentSong.Play(); + this.Reset(); return; } //plays the songs associated with spring time - - public static void stop_sound() //Stops any song that is playing at the time. + + /// Stop the currently playing sound, if any. + public void StopSound() { - - if (cueball == null) + if (this.CurrentSong == null) { //trying to stop a song that doesn't "exist" crashes the game. This prevents that. return; } - if (current_info_class == null) + if (this.CurrentSoundInfo == null) { - //if my info class is null, return. Should only be null if the game starts. Pretty sure my code should prevent this. + //if my info class is null, return. Should only be null if the game starts. Pretty sure my code should prevent this. return; } - Game1.soundBank = current_info_class.new_sound_bank; //reset the wave/sound banks back to the music pack's - Game1.waveBank = current_info_class.newwave; - cueball.Stop(AudioStopOptions.Immediate); //redundant stopping code - cueball.Stop(AudioStopOptions.AsAuthored); - Game1.soundBank = old_sound_bank; //reset the wave/sound to the game's original - Game1.waveBank = oldwave; - cueball = null; - } //stop whatever song is playing. - public static void reset() - { - Game1.waveBank = oldwave; - Game1.soundBank = old_sound_bank; + Game1.soundBank = this.CurrentSoundInfo.Soundbank; //reset the wave/sound banks back to the music pack's + Game1.waveBank = this.CurrentSoundInfo.Wavebank; + this.CurrentSong.Stop(AudioStopOptions.Immediate); //redundant stopping code + this.CurrentSong.Stop(AudioStopOptions.AsAuthored); + Game1.soundBank = this.DefaultSoundbank; //reset the wave/sound to the game's original + Game1.waveBank = this.DefaultWavebank; + this.CurrentSong = null; } -//config/loading stuff below - void MyWritter() + /// Reset the game audio to the original settings. + private void Reset() { - //saves the BuildEndurance_data at the end of a new day; - string mylocation = Path.Combine(Helper.DirectoryPath, "Music_Expansion_Config"); - //string mylocation2 = mylocation + myname; - string mylocation3 = mylocation + ".txt"; - string[] mystring3 = new string[20]; - if (!File.Exists(mylocation3)) + Game1.waveBank = this.DefaultWavebank; + Game1.soundBank = this.DefaultSoundbank; + } + + /// Save the configuration settings. + private void WriteConfig() + { + string path = Path.Combine(Helper.DirectoryPath, "Music_Expansion_Config.txt"); + string[] text = new string[20]; + text[0] = "Player: Stardew Valley Music Expansion Config. Feel free to edit."; + text[1] = "===================================================================================="; + + text[2] = "Minimum delay time: This is the minimal amout of time(in miliseconds!!!) that will pass before another song will play. 0 means a song will play immediately, 1000 means a second will pass, etc. Used in RNG to determine a random delay between songs."; + text[3] = this.MinSongDelay.ToString(); + + text[4] = "Maximum delay time: This is the maximum amout of time(in miliseconds!!!) that will pass before another song will play. 0 means a song will play immediately, 1000 means a second will pass, etc. Used in RNG to determine a random delay between songs."; + text[5] = this.MaxSongDelay.ToString(); + + text[6] = "Silent rain? Setting this value to false plays the default ambient rain music along side whatever songs are set in rain music. Setting this to true will disable the ambient rain music. It's up to the soundpack creators wither or not they want to mix their music with rain prior to loading it in here."; + text[7] = this.SilentRain.ToString(); + + text[8] = "Seasonal_Music? Setting this value to true will play the seasonal music from the music packs instead of defaulting to the Stardew Valley Soundtrack."; + text[9] = this.PlaySeasonalMusic.ToString(); + + File.WriteAllLines(path, text); + } + + /// Load the configuration settings. + void LoadConfig() + { + string path = Path.Combine(Helper.DirectoryPath, "Music_Expansion_Config.txt"); + if (!File.Exists(path)) { - Console.WriteLine("The config file for SDV_Music_Expansion wasn't found. Time to create it!"); - - //write out the info to a text file at the end of a day. This will run if it doesnt exist. - - mystring3[0] = "Player: Stardew Valley Music Expansion Config. Feel free to edit."; - mystring3[1] = "===================================================================================="; - - mystring3[2] = "Minimum delay time: This is the minimal amout of time(in miliseconds!!!) that will pass before another song will play. 0 means a song will play immediately, 1000 means a second will pass, etc. Used in RNG to determine a random delay between songs."; - mystring3[3] = delay_time_min.ToString(); - - mystring3[4] = "Maximum delay time: This is the maximum amout of time(in miliseconds!!!) that will pass before another song will play. 0 means a song will play immediately, 1000 means a second will pass, etc. Used in RNG to determine a random delay between songs."; - mystring3[5] = delay_time_max.ToString(); - - mystring3[6] = "Silent rain? Setting this value to false plays the default ambient rain music along side whatever songs are set in rain music. Setting this to true will disable the ambient rain music. It's up to the soundpack creators wither or not they want to mix their music with rain prior to loading it in here."; - mystring3[7] = silent_rain.ToString(); - - mystring3[8] = "Seasonal_Music? Setting this value to true will play the seasonal music from the music packs instead of defaulting to the Stardew Valley Soundtrack."; - mystring3[9] = seasonal_music.ToString(); - - mystring3[10] = "Prioritize seasonal music on the Farm? If true the game will check for seasonal music before checking for locational music."; - mystring3[11] = farm_player.ToString(); - - File.WriteAllLines(mylocation3, mystring3); + this.MinSongDelay = 10000; + this.MaxSongDelay = 30000; + this.SilentRain = false; + this.PlaySeasonalMusic = true; } - else { - - //write out the info to a text file at the end of a day. This will run if it doesnt exist. - - mystring3[0] = "Player: Stardew Valley Music Expansion Config. Feel free to edit."; - mystring3[1] = "===================================================================================="; - - mystring3[2] = "Minimum delay time: This is the minimal amout of time(in miliseconds!!!) that will pass before another song will play. 0 means a song will play immediately, 1000 means a second will pass, etc. Used in RNG to determine a random delay between songs."; - mystring3[3] = delay_time_min.ToString(); - - mystring3[4] = "Maximum delay time: This is the maximum amout of time(in miliseconds!!!) that will pass before another song will play. 0 means a song will play immediately, 1000 means a second will pass, etc. Used in RNG to determine a random delay between songs."; - mystring3[5] = delay_time_max.ToString(); - - mystring3[6] = "Silent rain? Setting this value to false plays the default ambient rain music along side whatever songs are set in rain music. Setting this to true will disable the ambient rain music. It's up to the soundpack creators wither or not they want to mix their music with rain prior to loading it in here."; - mystring3[7] = silent_rain.ToString(); - mystring3[8] = "Seasonal_Music? Setting this value to true will play the seasonal music from the music packs instead of defaulting to the Stardew Valley Soundtrack."; - mystring3[9] = seasonal_music.ToString(); - - mystring3[10] = "Prioritize seasonal music on the Farm? If true the game will check for seasonal music before checking for locational music."; - mystring3[11] = farm_player.ToString(); - - File.WriteAllLines(mylocation3, mystring3); + string[] text = File.ReadAllLines(path); + this.MinSongDelay = Convert.ToInt32(text[3]); + this.MaxSongDelay = Convert.ToInt32(text[5]); + this.SilentRain = Convert.ToBoolean(text[7]); + this.PlaySeasonalMusic = Convert.ToBoolean(text[9]); } } - void DataLoader() - { - //loads the data to the variables upon loading the game. - string mylocation = Path.Combine(Helper.DirectoryPath, "Music_Expansion_Config"); - //string mylocation2 = mylocation + myname; - string mylocation3 = mylocation + ".txt"; - if (!File.Exists(mylocation3)) //if not data.json exists, initialize the data variables to the ModConfig data. I.E. starting out. - { - delay_time_min = 10000; - delay_time_max = 30000; - silent_rain = false; - seasonal_music = true; - farm_player = true; - } - - else - { - Monitor.Log("Music Expansion Config Loaded"); - // Console.WriteLine("HEY THERE IM LOADING DATA"); - - //loads the BuildEndurance_data upon loading the mod - string[] readtext = File.ReadAllLines(mylocation3); - delay_time_min = Convert.ToInt32(readtext[3]); - delay_time_max = Convert.ToInt32(readtext[5]); //these array locations refer to the lines in BuildEndurance_data.json - silent_rain = Convert.ToBoolean(readtext[7]); - seasonal_music = Convert.ToBoolean(readtext[9]); - if (readtext[11] == "") farm_player = true; - else farm_player = Convert.ToBoolean(readtext[11]); - - } - } - - - - }//ends class1 -}//ends namespace \ No newline at end of file + } +} diff --git a/GeneralMods/StardewSymphony/MusicHexProcessor.cs b/GeneralMods/StardewSymphony/MusicHexProcessor.cs index 1946ea1a..f1109494 100644 --- a/GeneralMods/StardewSymphony/MusicHexProcessor.cs +++ b/GeneralMods/StardewSymphony/MusicHexProcessor.cs @@ -6,123 +6,114 @@ using StardewValley; namespace Omegasis.StardewSymphony { - class MusicHexProcessor + internal class MusicHexProcessor { - public static List allsoundBanks; - public static List allHexDumps; - public static List allWaveBanks; + /********* + ** Properties + *********/ + /// All of the music/soundbanks and their locations. + private readonly IList MasterList; - public static void processHex() + /// The registered soundbanks. + private readonly List SoundBanks = new List(); + + /// The callback to reset the game audio. + private readonly Action Reset; + + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// All of the music/soundbanks and their locations. + /// The callback to reset the game audio. + public MusicHexProcessor(IList masterList, Action reset) + { + this.MasterList = masterList; + this.Reset = reset; + } + + /// Add a file path to the list of soundbanks. + /// The soundbank file path. + public void AddSoundBank(string path) + { + this.SoundBanks.Add(path); + } + + public void ProcessHex() { int counter = 0; - string HexDumpContents = ""; - string rawName = ""; - string rawHexName = ""; - string cueName = ""; - List cleanCueNames = new List(); - foreach (var v in allsoundBanks) + foreach (string entry in SoundBanks) { - cleanCueNames = new List(); - byte[] array = System.IO.File.ReadAllBytes(v); - // Log.AsyncC(HexDump(array)); - rawName=v.Substring(0,v.Length-4); - cueName = (rawName + "CueList.txt"); + List cleanCueNames = new List(); + byte[] array = File.ReadAllBytes(entry); + string rawName = entry.Substring(0, entry.Length - 4); + string cueName = rawName + "CueList.txt"; if (File.Exists(cueName)) continue; - HexDumpContents = HexDump(array); + string hexDumpContents = this.HexDump(array); + + string rawHexName = rawName + "HexDump.txt"; + File.WriteAllText(rawHexName, hexDumpContents); - rawHexName = rawName + "HexDump.txt"; - File.WriteAllText(rawHexName, HexDumpContents); - // string fileName = (v.Remove(v.Length - 5, v.Length-1)); - //Log.AsyncM(fileName); - allHexDumps.Add(rawHexName); - string[] readText = File.ReadAllLines(rawHexName); - string largeString=""; + string largeString = ""; foreach (var line in readText) { - // Log.AsyncY(line); try { string newString = ""; for (int i = 62; i <= 77; i++) - { newString += line[i]; - } - // Log.AsyncG(newString); largeString += newString; - // Log.AsyncC(largeString); - //Log.AsyncG(line.Substring(63, 78)); - } - catch (Exception e) - { - // Log.AsyncY("WTF"); - // Log.AsyncO(line.Length); } + catch { } } - string[] splits = largeString.Split('ÿ'); - string fix = ""; - foreach (string s in splits) + string[] splits = largeString.Split('ÿ'); + string fix = ""; + foreach (string s in splits) + { + if (s == "") continue; + fix += s; + } + splits = fix.Split('.'); + + foreach (var split in splits) + { + if (split == "") continue; + + try { - if (s == "") continue; - fix += s; - } - splits = fix.Split('.'); + Game1.waveBank = this.MasterList[counter].Wavebank; + Game1.soundBank = this.MasterList[counter].Soundbank; - foreach (var split in splits) - { - if (split == "") continue; - // Log.AsyncM(split); - - try - { - - - - // Game1.playSound(split); - Game1.waveBank = Class1.master_list[counter].newwave; - Game1.soundBank = Class1.master_list[counter].new_sound_bank; - - if (Game1.soundBank.GetCue(split) != null) - { - //Game1.playSound(split); cleanCueNames.Add(split); - // Log.AsyncG("Sucessfully added " + split + " to the list of successful songs to play."); - } - - Class1.reset(); - - } - catch(Exception e) - { - // Log.AsyncR(e); - } + this.Reset(); } + catch { } + } - cueName = (rawName + "CueList.txt"); - // Log.AsyncM(cueName); + cueName = rawName + "CueList.txt"; cleanCueNames.Sort(); File.WriteAllLines(cueName, cleanCueNames); counter++; } - - } - - + } - - - - - public static string HexDump(byte[] bytes, int bytesPerLine = 16) + /********* + ** Private methods + *********/ + private string HexDump(byte[] bytes, int bytesPerLine = 16) { - if (bytes == null) return ""; + if (bytes == null) + return ""; + int bytesLength = bytes.Length; - char[] HexChars = "0123456789ABCDEF".ToCharArray(); + char[] hexChars = "0123456789ABCDEF".ToCharArray(); int firstHexColumn = 8 // 8 characters for the address @@ -143,14 +134,14 @@ namespace Omegasis.StardewSymphony for (int i = 0; i < bytesLength; i += bytesPerLine) { - line[0] = HexChars[(i >> 28) & 0xF]; - line[1] = HexChars[(i >> 24) & 0xF]; - line[2] = HexChars[(i >> 20) & 0xF]; - line[3] = HexChars[(i >> 16) & 0xF]; - line[4] = HexChars[(i >> 12) & 0xF]; - line[5] = HexChars[(i >> 8) & 0xF]; - line[6] = HexChars[(i >> 4) & 0xF]; - line[7] = HexChars[(i >> 0) & 0xF]; + line[0] = hexChars[(i >> 28) & 0xF]; + line[1] = hexChars[(i >> 24) & 0xF]; + line[2] = hexChars[(i >> 20) & 0xF]; + line[3] = hexChars[(i >> 16) & 0xF]; + line[4] = hexChars[(i >> 12) & 0xF]; + line[5] = hexChars[(i >> 8) & 0xF]; + line[6] = hexChars[(i >> 4) & 0xF]; + line[7] = hexChars[(i >> 0) & 0xF]; int hexColumn = firstHexColumn; int charColumn = firstCharColumn; @@ -167,9 +158,9 @@ namespace Omegasis.StardewSymphony else { byte b = bytes[i + j]; - line[hexColumn] = HexChars[(b >> 4) & 0xF]; - line[hexColumn + 1] = HexChars[b & 0xF]; - line[charColumn] = asciiSymbol(b); + line[hexColumn] = hexChars[(b >> 4) & 0xF]; + line[hexColumn + 1] = hexChars[b & 0xF]; + line[charColumn] = this.GetAsciiSymbol(b); } hexColumn += 3; charColumn++; @@ -178,20 +169,17 @@ namespace Omegasis.StardewSymphony } return result.ToString(); } - static char asciiSymbol(byte val) + + private char GetAsciiSymbol(byte ch) { - if (val < 32) return '.'; // Non-printable ASCII - if (val < 127) return (char)val; // Normal ASCII + if (ch < 32) return '.'; // Non-printable ASCII + if (ch < 127) return (char)ch; // Normal ASCII // Handle the hole in Latin-1 - if (val == 127) return '.'; - if (val < 0x90) return "€.‚ƒ„…†‡ˆ‰Š‹Œ.Ž."[val & 0xF]; - if (val < 0xA0) return ".‘’“”•–—˜™š›œ.žŸ"[val & 0xF]; - if (val == 0xAD) return '.'; // Soft hyphen: this symbol is zero-width even in monospace fonts - return (char)val; // Normal Latin-1 + if (ch == 127) return '.'; + if (ch < 0x90) return "€.‚ƒ„…†‡ˆ‰Š‹Œ.Ž."[ch & 0xF]; + if (ch < 0xA0) return ".‘’“”•–—˜™š›œ.žŸ"[ch & 0xF]; + if (ch == 0xAD) return '.'; // Soft hyphen: this symbol is zero-width even in monospace fonts + return (char)ch; // Normal Latin-1 } - - - - -} + } } diff --git a/GeneralMods/StardewSymphony/MusicManager.cs b/GeneralMods/StardewSymphony/MusicManager.cs index 5cbf4b09..4c894e7c 100644 --- a/GeneralMods/StardewSymphony/MusicManager.cs +++ b/GeneralMods/StardewSymphony/MusicManager.cs @@ -8,512 +8,365 @@ using StardewValley; namespace Omegasis.StardewSymphony { //also known as the music_pack - public class MusicManager + internal class MusicManager { - public string wave_bank_name; - public string sound_bank_name; + /********* + ** Properties + *********/ + /// The directory path containing the music. + public string Directory { get; } - public List spring_song_list; - public int num_of_spring_songs; - public List summer_song_list; - public int num_of_summer_songs; - public List fall_song_list; - public int num_of_fall_songs; - public List winter_song_list; - public int num_of_winter_songs; + /// The name of the wavebank file. + public string WavebankName { get; } + + /// The name of the soundbank file. + public string SoundbankName { get; } + + /// The loaded wavebank (if any). + public WaveBank Wavebank { get; } + + /// The loaded soundbank (if any). + public SoundBank Soundbank { get; } + + /// Songs that play in spring. + public List SpringSongs { get; } = new List(); + + /// Songs that play in summer. + public List SummerSongs { get; } = new List(); + + /// Songs that play in fall. + public List FallSongs { get; } = new List(); + + /// Songs that play in winter. + public List WinterSongs { get; } = new List(); + + /// Songs that play on spring nights. + public List SpringNightSongs { get; } = new List(); + + /// Songs that play on summer nights. + public List SummerNightSongs { get; } = new List(); + + /// Songs that play on fall nights. + public List FallNightSongs { get; } = new List(); + + /// Songs that play on winter nights. + public List WinterNightSongs { get; } = new List(); + + /// Songs that play on rainy spring days. + public List SpringRainSongs { get; } = new List(); + + /// Songs that play on rainy summer days. + public List SummerRainSongs { get; } = new List(); + + /// Songs that play on rainy fall days. + public List FallRainSongs { get; } = new List(); + + /// Songs that play on rainy winter days. + public List WinterSnowSongs { get; } = new List(); + + /// Songs that play on rainy spring nights. + public List SpringRainNightSongs { get; } = new List(); + + /// Songs that play on rainy summer nights. + public List SummerRainNightSongs { get; } = new List(); + + /// Songs that play on rainy fall nights. + public List FallRainNightSongs { get; } = new List(); + + /// Songs that play on rainy winter nights. + public List WinterSnowNightSongs { get; } = new List(); + + /// Songs that play in specific locations. + public Dictionary> LocationSongs { get; } = new Dictionary>(); + + /// Songs that play in specific locations on rainy days. + public Dictionary> LocationRainSongs { get; } = new Dictionary>(); + + /// Songs that play in specific locations at night. + public Dictionary> LocationNightSongs { get; } = new Dictionary>(); + + /// Songs that play in specific locations on rainy nights. + public Dictionary> LocationRainNightSongs { get; } = new Dictionary>(); - public List spring_night_song_list; - public int num_of_spring_night_songs; - public List summer_night_song_list; - public int num_of_summer_night_songs; - public List fall_night_song_list; - public int num_of_fall_night_songs; - public List winter_night_song_list; - public int num_of_winter_night_songs; - - - public List spring_rain_song_list; - public int num_of_spring_rain_songs; - public List summer_rain_song_list; - public int num_of_summer_rain_songs; - public List fall_rain_song_list; - public int num_of_fall_rain_songs; - public List winter_snow_song_list; - public int num_of_winter_snow_songs; - - - public List spring_rain_night_song_list; - public int num_of_spring_rain_night_songs; - public List summer_rain_night_song_list; - public int num_of_summer_rain_night_songs; - public List fall_rain_night_song_list; - public int num_of_fall_rain_night_songs; - public List winter_snow_night_song_list; - public int num_of_winter_snow_night_songs; - - public List locational_cues; - public Dictionary> locational_songs; - - - public Dictionary> locational_rain_songs; - public Dictionary> locational_night_songs; - public Dictionary> locational_rain_night_songs; - - - public WaveBank newwave; - public SoundBank new_sound_bank; - public string path_loc; - - public MusicManager(string wb, string sb, string directory) + /********* + ** Public methods + *********/ + /// Construct an instance. + /// The name of the wavebank file. + /// The name of the soundbank file. + /// The directory path containing the music. + public MusicManager(string wavebank, string soundbank, string directory) { - wave_bank_name = wb; - sound_bank_name = sb; - wave_bank_name += ".xwb"; - sound_bank_name += ".xsb"; - path_loc = directory; + // init data + this.Directory = directory; + this.WavebankName = wavebank + ".xwb"; + this.SoundbankName = soundbank + ".xsb"; - Console.WriteLine(Path.Combine(path_loc, wave_bank_name)); - Console.WriteLine(Path.Combine(path_loc, sound_bank_name)); + // init banks + string wavePath = Path.Combine(this.Directory, this.WavebankName); + string soundPath = Path.Combine(this.Directory, this.SoundbankName); + Console.WriteLine(wavePath); + Console.WriteLine(soundPath); - if (File.Exists(Path.Combine(path_loc, wave_bank_name))) - { - newwave = new WaveBank(Game1.audioEngine, Path.Combine(path_loc, wave_bank_name)); //look for wave bank in sound_pack root directory. - } - if (File.Exists(Path.Combine(path_loc, sound_bank_name))) - { - new_sound_bank = new SoundBank(Game1.audioEngine, Path.Combine(path_loc, sound_bank_name)); //look for sound bank in sound_pack root directory. - } + if (File.Exists(wavePath)) + this.Wavebank = new WaveBank(Game1.audioEngine, wavePath); + if (File.Exists(Path.Combine(this.Directory, this.SoundbankName))) + this.Soundbank = new SoundBank(Game1.audioEngine, soundPath); + // update audio Game1.audioEngine.Update(); - - spring_song_list = new List(); - num_of_spring_songs = 0; - summer_song_list = new List(); - num_of_summer_songs = 0; - fall_song_list = new List(); - num_of_fall_songs = 0; - winter_song_list = new List(); - num_of_winter_songs = 0; - - spring_night_song_list = new List(); - num_of_spring_night_songs = 0; - summer_night_song_list = new List(); - num_of_summer_night_songs = 0; - fall_night_song_list = new List(); - num_of_fall_night_songs = 0; - winter_night_song_list = new List(); - num_of_winter_night_songs = 0; - - - //rainy initialization - spring_rain_song_list = new List(); - num_of_spring_rain_songs = 0; - summer_rain_song_list = new List(); - num_of_summer_rain_songs = 0; - fall_rain_song_list = new List(); - num_of_fall_rain_songs = 0; - winter_snow_song_list = new List(); - num_of_winter_snow_songs = 0; - - spring_rain_night_song_list = new List(); - num_of_spring_rain_night_songs = 0; - summer_rain_night_song_list = new List(); - num_of_summer_rain_night_songs = 0; - fall_rain_night_song_list = new List(); - num_of_fall_rain_night_songs = 0; - winter_snow_night_song_list = new List(); - num_of_winter_snow_night_songs = 0; - - locational_songs = new Dictionary>(); - locational_rain_songs = new Dictionary>(); - locational_night_songs = new Dictionary>(); - locational_rain_night_songs = new Dictionary>(); } - public void Music_Loader_Seasons(string conditional_name, Dictionary reference_dic) //reads in cue names from a text file and adds them to a specific list. Morphs with specific conditional name. Conditionals are hardcoded. + /// Read cue names from a text file and adds them to a specific list. Morphs with specific conditional name. Conditionals are hardcoded. + /// The conditional file name to read. + /// The music list to update. + public void Music_Loader_Seasons(string conditionalName, IDictionary cues) { - //loads the data to the variables upon loading the game. - var music_path = path_loc; - string mylocation = Path.Combine(music_path, "Music_Files", "Seasons", conditional_name); - string mylocation2 = mylocation; - string mylocation3 = mylocation2 + ".txt"; - - - if (!File.Exists(mylocation3)) //check to make sure the file actually exists + string path = Path.Combine(this.Directory, "Music_Files", "Seasons", conditionalName + ".txt"); + if (!File.Exists(path)) { + Console.WriteLine($"Stardew Symohony:The specified music file could not be found. That music file is {conditionalName} which should be located at {path} but don't worry I'll create it for you right now. It's going to be blank though"); + string[] text = new string[3]; + text[0] = conditionalName + " music file. This file holds all of the music that will play when there is no music for this game location, or simply put this is default music. Simply type the name of the song below the wall of equal signs."; + text[1] = "========================================================================================"; - string error_message = "Stardew Symohony:The specified music file could not be found. That music file is " + conditional_name + " which should be located at " + mylocation3 + " but don't worry I'll create it for you right now. It's going to be blank though"; - Console.WriteLine(error_message); - - string[] mystring3 = new string[3];//seems legit. - mystring3[0] = conditional_name + " music file. This file holds all of the music that will play when there is no music for this game location, or simply put this is default music. Simply type the name of the song below the wall of equal signs."; - mystring3[1] = "========================================================================================"; - - File.WriteAllLines(mylocation3, mystring3); + File.WriteAllLines(path, text); } - else { - Console.WriteLine("Stardew Symphony:The music pack located at: " + path_loc + " is processing the song info for the game location: " + conditional_name); - //System.Threading.Thread.Sleep(1000); - // add in data here + Console.WriteLine($"Stardew Symphony:The music pack located at: {this.Directory} is processing the song info for the game location: {conditionalName}"); - string[] readtext = File.ReadAllLines(mylocation3); - string cue_name; + string[] text = File.ReadAllLines(path); int i = 2; - var lineCount = File.ReadLines(mylocation3).Count(); + var lineCount = File.ReadLines(path).Count(); while (i < lineCount) //the ordering seems bad, but it works. { - if (Convert.ToString(readtext[i]) == "") - { - // Monitor.Log("Blank space detected."); + if (Convert.ToString(text[i]) == "") + break; + if (Convert.ToString(text[i]) == "\n") break; - } - if (Convert.ToString(readtext[i]) == "\n") + string cueName; + if (conditionalName == "spring") { - break; - - } - - - if (conditional_name == "spring") - { - cue_name = Convert.ToString(readtext[i]); + cueName = Convert.ToString(text[i]); i++; - - if (!reference_dic.Keys.Contains(cue_name)) + if (!cues.Keys.Contains(cueName)) { - spring_song_list.Add(new_sound_bank.GetCue(cue_name)); + this.SpringSongs.Add(this.Soundbank.GetCue(cueName)); + cues.Add(cueName, this); + } + else + this.SpringSongs.Add(this.Soundbank.GetCue(cueName)); + } + if (conditionalName == "summer") + { + cueName = Convert.ToString(text[i]); + i++; - num_of_spring_songs++; - reference_dic.Add(cue_name, this); + if (!cues.Keys.Contains(cueName)) + { + this.SummerSongs.Add(this.Soundbank.GetCue(cueName)); + cues.Add(cueName, this); + } + else + this.SummerSongs.Add(this.Soundbank.GetCue(cueName)); + } + if (conditionalName == "fall") + { + cueName = Convert.ToString(text[i]); + i++; + + if (!cues.Keys.Contains(cueName)) + { + this.FallSongs.Add(this.Soundbank.GetCue(cueName)); + cues.Add(cueName, this); + } + else + this.FallSongs.Add(this.Soundbank.GetCue(cueName)); + } + if (conditionalName == "winter") + { + cueName = Convert.ToString(text[i]); + i++; + + if (!cues.Keys.Contains(cueName)) + { + this.WinterSongs.Add(this.Soundbank.GetCue(cueName)); + cues.Add(cueName, this); } else - { - spring_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_spring_songs++; - } - // Monitor.Log(cue_name); - } - if (conditional_name == "summer") - { - cue_name = Convert.ToString(readtext[i]); - i++; - - if (!reference_dic.Keys.Contains(cue_name)) - { - summer_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_summer_songs++; - reference_dic.Add(cue_name, this); - - } - else - { - summer_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_summer_songs++; - } - } - if (conditional_name == "fall") - { - cue_name = Convert.ToString(readtext[i]); - i++; - - if (!reference_dic.Keys.Contains(cue_name)) - { - fall_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_fall_songs++; - reference_dic.Add(cue_name, this); - - } - else - { - fall_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_fall_songs++; - } - } - if (conditional_name == "winter") - { - cue_name = Convert.ToString(readtext[i]); - i++; - - if (!reference_dic.Keys.Contains(cue_name)) - { - winter_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_winter_songs++; - reference_dic.Add(cue_name, this); - - } - else - { - winter_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_winter_songs++; - } + this.WinterSongs.Add(this.Soundbank.GetCue(cueName)); } //add in other stuff here //======================================================================================================================================================================================== //NIGHTLY SEASONAL LOADERS - if (conditional_name == "spring_night") + if (conditionalName == "spring_night") { - cue_name = Convert.ToString(readtext[i]); + cueName = Convert.ToString(text[i]); i++; - - if (!reference_dic.Keys.Contains(cue_name)) + if (!cues.Keys.Contains(cueName)) { - spring_night_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_spring_night_songs++; - reference_dic.Add(cue_name, this); - + this.SpringNightSongs.Add(this.Soundbank.GetCue(cueName)); + cues.Add(cueName, this); } else - { - spring_night_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_spring_night_songs++; - } - // Monitor.Log(cue_name); + this.SpringNightSongs.Add(this.Soundbank.GetCue(cueName)); } - if (conditional_name == "summer_night") + if (conditionalName == "summer_night") { - cue_name = Convert.ToString(readtext[i]); + cueName = Convert.ToString(text[i]); i++; - if (!reference_dic.Keys.Contains(cue_name)) + if (!cues.Keys.Contains(cueName)) { - summer_night_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_summer_night_songs++; - reference_dic.Add(cue_name, this); - + this.SummerNightSongs.Add(this.Soundbank.GetCue(cueName)); + cues.Add(cueName, this); } else - { - summer_night_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_summer_night_songs++; - } + this.SummerNightSongs.Add(this.Soundbank.GetCue(cueName)); } - if (conditional_name == "fall_night") + if (conditionalName == "fall_night") { - cue_name = Convert.ToString(readtext[i]); + cueName = Convert.ToString(text[i]); i++; - if (!reference_dic.Keys.Contains(cue_name)) + if (!cues.Keys.Contains(cueName)) { - fall_night_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_fall_night_songs++; - reference_dic.Add(cue_name, this); - + this.FallNightSongs.Add(this.Soundbank.GetCue(cueName)); + cues.Add(cueName, this); } else - { - fall_night_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_fall_night_songs++; - } + this.FallNightSongs.Add(this.Soundbank.GetCue(cueName)); } - if (conditional_name == "winter_night") + if (conditionalName == "winter_night") { - cue_name = Convert.ToString(readtext[i]); + cueName = Convert.ToString(text[i]); i++; - if (!reference_dic.Keys.Contains(cue_name)) + if (!cues.Keys.Contains(cueName)) { - winter_night_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_winter_night_songs++; - reference_dic.Add(cue_name, this); - + this.WinterNightSongs.Add(this.Soundbank.GetCue(cueName)); + cues.Add(cueName, this); } else - { - winter_night_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_winter_night_songs++; - } + this.WinterNightSongs.Add(this.Soundbank.GetCue(cueName)); } ////////NOW I"M ADDING THE PART THAT WILL READ IN RAINY SEASONAL SONGS FOR DAY AND NIGHT - if (conditional_name == "spring_rain") + if (conditionalName == "spring_rain") { - cue_name = Convert.ToString(readtext[i]); + cueName = Convert.ToString(text[i]); i++; - - if (!reference_dic.Keys.Contains(cue_name)) + if (!cues.Keys.Contains(cueName)) { - spring_rain_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_spring_rain_songs++; - reference_dic.Add(cue_name, this); - + this.SpringRainSongs.Add(this.Soundbank.GetCue(cueName)); + cues.Add(cueName, this); } else - { - spring_rain_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_spring_rain_songs++; - } - // Monitor.Log(cue_name); + this.SpringRainSongs.Add(this.Soundbank.GetCue(cueName)); } - if (conditional_name == "summer_rain") + if (conditionalName == "summer_rain") { - cue_name = Convert.ToString(readtext[i]); + cueName = Convert.ToString(text[i]); i++; - if (!reference_dic.Keys.Contains(cue_name)) + if (!cues.Keys.Contains(cueName)) { - summer_rain_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_summer_rain_songs++; - reference_dic.Add(cue_name, this); - + this.SummerRainSongs.Add(this.Soundbank.GetCue(cueName)); + cues.Add(cueName, this); } else - { - summer_rain_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_summer_rain_songs++; - } + this.SummerRainSongs.Add(this.Soundbank.GetCue(cueName)); } - if (conditional_name == "fall_rain") + if (conditionalName == "fall_rain") { - cue_name = Convert.ToString(readtext[i]); + cueName = Convert.ToString(text[i]); i++; - if (!reference_dic.Keys.Contains(cue_name)) + if (!cues.Keys.Contains(cueName)) { - fall_rain_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_fall_rain_songs++; - reference_dic.Add(cue_name, this); - + this.FallRainSongs.Add(this.Soundbank.GetCue(cueName)); + cues.Add(cueName, this); } else - { - fall_rain_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_fall_rain_songs++; - } + this.FallRainSongs.Add(this.Soundbank.GetCue(cueName)); } - if (conditional_name == "winter_snow") + if (conditionalName == "winter_snow") { - cue_name = Convert.ToString(readtext[i]); + cueName = Convert.ToString(text[i]); i++; - if (!reference_dic.Keys.Contains(cue_name)) + if (!cues.Keys.Contains(cueName)) { - winter_snow_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_winter_snow_songs++; - reference_dic.Add(cue_name, this); - + this.WinterSnowSongs.Add(this.Soundbank.GetCue(cueName)); + cues.Add(cueName, this); } else - { - winter_snow_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_winter_snow_songs++; - } + this.WinterSnowSongs.Add(this.Soundbank.GetCue(cueName)); } + //add in other stuff here //======================================================================================================================================================================================== //NIGHTLY SEASONAL RAIN LOADERS - if (conditional_name == "spring_rain_night") + if (conditionalName == "spring_rain_night") { - cue_name = Convert.ToString(readtext[i]); + cueName = Convert.ToString(text[i]); i++; - - if (!reference_dic.Keys.Contains(cue_name)) + if (!cues.Keys.Contains(cueName)) { - spring_rain_night_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_spring_rain_night_songs++; - reference_dic.Add(cue_name, this); + this.SpringRainNightSongs.Add(this.Soundbank.GetCue(cueName)); + cues.Add(cueName, this); } else - { - spring_rain_night_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_spring_rain_night_songs++; - } - // Monitor.Log(cue_name); + this.SpringRainNightSongs.Add(this.Soundbank.GetCue(cueName)); } - if (conditional_name == "summer_rain_night") + if (conditionalName == "summer_rain_night") { - cue_name = Convert.ToString(readtext[i]); + cueName = Convert.ToString(text[i]); i++; - if (!reference_dic.Keys.Contains(cue_name)) + if (!cues.Keys.Contains(cueName)) { - summer_rain_night_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_summer_rain_night_songs++; - reference_dic.Add(cue_name, this); - + this.SummerRainNightSongs.Add(this.Soundbank.GetCue(cueName)); + cues.Add(cueName, this); } else - { - summer_rain_night_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_summer_rain_night_songs++; - } + this.SummerRainNightSongs.Add(this.Soundbank.GetCue(cueName)); } - if (conditional_name == "fall_rain_night") + if (conditionalName == "fall_rain_night") { - cue_name = Convert.ToString(readtext[i]); + cueName = Convert.ToString(text[i]); i++; - if (!reference_dic.Keys.Contains(cue_name)) + if (!cues.Keys.Contains(cueName)) { - fall_rain_night_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_fall_rain_night_songs++; - reference_dic.Add(cue_name, this); - + this.FallRainNightSongs.Add(this.Soundbank.GetCue(cueName)); + cues.Add(cueName, this); } else - { - fall_rain_night_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_fall_rain_night_songs++; - } + this.FallRainNightSongs.Add(this.Soundbank.GetCue(cueName)); } - if (conditional_name == "winter_snow_night") + if (conditionalName == "winter_snow_night") { - cue_name = Convert.ToString(readtext[i]); + cueName = Convert.ToString(text[i]); i++; - if (!reference_dic.Keys.Contains(cue_name)) + if (!cues.Keys.Contains(cueName)) { - winter_snow_night_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_winter_snow_night_songs++; - reference_dic.Add(cue_name, this); - + this.WinterSnowNightSongs.Add(this.Soundbank.GetCue(cueName)); + cues.Add(cueName, this); } else - { - winter_snow_night_song_list.Add(new_sound_bank.GetCue(cue_name)); - - num_of_winter_snow_night_songs++; - } + this.WinterSnowNightSongs.Add(this.Soundbank.GetCue(cueName)); } } if (i == 2) @@ -522,291 +375,227 @@ namespace Omegasis.StardewSymphony // System.Threading.Thread.Sleep(10); return; } - Console.WriteLine("StardewSymohony:The music pack located at: " + path_loc + " has successfully processed the song info for the game location: " + conditional_name); + Console.WriteLine("StardewSymohony:The music pack located at: " + this.Directory + " has successfully processed the song info for the game location: " + conditionalName); } } - public void Music_Loader_Locations(string conditional_name, Dictionary reference_dic) //reads in cue names from a text file and adds them to a specific list. Morphs with specific conditional name. Conditionals are hardcoded. + + /// Read cue names from a text file and adds them to a specific list. Morphs with specific conditional name. Conditionals are hardcoded. + /// The conditional file name to read. + /// The music list to update. + public void Music_Loader_Locations(string conditionalName, IDictionary cues) { - locational_cues = new List(); + List locationSongs = new List(); //loads the data to the variables upon loading the game. - var music_path = path_loc; - string mylocation = Path.Combine(music_path, "Music_Files", "Locations", conditional_name); + var musicPath = this.Directory; + string mylocation = Path.Combine(musicPath, "Music_Files", "Locations", conditionalName); string mylocation2 = mylocation; string mylocation3 = mylocation2 + ".txt"; if (!File.Exists(mylocation3)) //check to make sure the file actually exists { - Console.WriteLine("StardewSymohony:A music list for the location " + conditional_name + " does not exist for the music pack located at " + mylocation3 + " which isn't a problem, I just thought I'd let you know since this may have been intentional. Also I'm creating it for you just incase. Cheers."); + Console.WriteLine("StardewSymohony:A music list for the location " + conditionalName + " does not exist for the music pack located at " + mylocation3 + " which isn't a problem, I just thought I'd let you know since this may have been intentional. Also I'm creating it for you just incase. Cheers."); //Console.WriteLine("Creating the Config file"); string[] mystring3 = new string[3];//seems legit. - mystring3[0] = conditional_name + " music file. This file holds all of the music that will play when at this game location. Simply type the name of the song below the wall of equal signs."; + mystring3[0] = conditionalName + " music file. This file holds all of the music that will play when at this game location. Simply type the name of the song below the wall of equal signs."; mystring3[1] = "========================================================================================"; File.WriteAllLines(mylocation3, mystring3); - return; } - else { - Console.WriteLine("Stardew Symphony:The music pack located at: " + path_loc + " is processing the song info for the game location: " + conditional_name); - //System.Threading.Thread.Sleep(1000); + Console.WriteLine("Stardew Symphony:The music pack located at: " + this.Directory + " is processing the song info for the game location: " + conditionalName); string[] readtext = File.ReadAllLines(mylocation3); - string cue_name; int i = 2; var lineCount = File.ReadLines(mylocation3).Count(); while (i < lineCount) //the ordering seems bad, but it works. { if (Convert.ToString(readtext[i]) == "") - { break; - } if (Convert.ToString(readtext[i]) == "\n") - { break; - } - cue_name = Convert.ToString(readtext[i]); + string cueName = Convert.ToString(readtext[i]); i++; - if (!reference_dic.Keys.Contains(cue_name)) + if (!cues.Keys.Contains(cueName)) { - locational_cues.Add(new_sound_bank.GetCue(cue_name)); - reference_dic.Add(cue_name, this); + locationSongs.Add(this.Soundbank.GetCue(cueName)); + cues.Add(cueName, this); } else - { - locational_cues.Add(new_sound_bank.GetCue(cue_name)); - } + locationSongs.Add(this.Soundbank.GetCue(cueName)); } if (i == 2) { // Monitor.Log("Just thought that I'd let you know that there are no songs associated with the music file located at " + mylocation3 + " this may be intentional, but just incase you were wanted music, now you knew which ones were blank."); return; } - if (locational_cues.Count > 0) + if (locationSongs.Count > 0) { - locational_songs.Add(conditional_name, locational_cues); - Console.WriteLine("StardewSymhony:The music pack located at: " + path_loc + " has successfully processed the song info for the game location: " + conditional_name); - - return; - } - else - { - // Monitor.Log("Just thought that I'd let you know that there are no songs associated with the music file located at " + mylocation3 + " this may be intentional, but just incase you were wanted music, now you knew which ones were blank."); - return; + this.LocationSongs.Add(conditionalName, locationSongs); + Console.WriteLine("StardewSymhony:The music pack located at: " + this.Directory + " has successfully processed the song info for the game location: " + conditionalName); } } } - public void Music_Loader_Locations_Rain(string conditional_name, Dictionary reference_dic) //reads in cue names from a text file and adds them to a specific list. Morphs with specific conditional name. Conditionals are hardcoded. + /// Read cue names from a text file and adds them to a specific list. Morphs with specific conditional name. Conditionals are hardcoded. + /// The conditional file name to read. + /// The music list to update. + public void Music_Loader_Locations_Rain(string conditionalName, IDictionary cues) { - locational_cues = new List(); - var music_path = path_loc; - string mylocation = Path.Combine(music_path, "Music_Files", "Locations", conditional_name); + List locationSongs = new List(); + var musicPath = this.Directory; + string mylocation = Path.Combine(musicPath, "Music_Files", "Locations", conditionalName); string mylocation2 = mylocation; string mylocation3 = mylocation2 + ".txt"; if (!File.Exists(mylocation3)) //check to make sure the file actually exists { - Console.WriteLine("StardewSymphony:A music list for the location " + conditional_name + " does not exist for the music pack located at " + mylocation3 + " which isn't a problem, I just thought I'd let you know since this may have been intentional. Also I'm creating it for you just incase. Cheers."); + Console.WriteLine("StardewSymphony:A music list for the location " + conditionalName + " does not exist for the music pack located at " + mylocation3 + " which isn't a problem, I just thought I'd let you know since this may have been intentional. Also I'm creating it for you just incase. Cheers."); string[] mystring3 = new string[3];//seems legit. - mystring3[0] = conditional_name + " music file. This file holds all of the music that will play when at this game location. Simply type the name of the song below the wall of equal signs."; + mystring3[0] = conditionalName + " music file. This file holds all of the music that will play when at this game location. Simply type the name of the song below the wall of equal signs."; mystring3[1] = "========================================================================================"; File.WriteAllLines(mylocation3, mystring3); - return; } - else { // add in data here string[] readtext = File.ReadAllLines(mylocation3); - string cue_name; int i = 2; var lineCount = File.ReadLines(mylocation3).Count(); while (i < lineCount) //the ordering seems bad, but it works. { if (Convert.ToString(readtext[i]) == "") - { - // Monitor.Log("Blank space detected."); break; - } if (Convert.ToString(readtext[i]) == "\n") - { - // Monitor.Log("end line reached"); break; - } - cue_name = Convert.ToString(readtext[i]); + string cueName = Convert.ToString(readtext[i]); i++; - if (!reference_dic.Keys.Contains(cue_name)) + if (!cues.Keys.Contains(cueName)) { - locational_cues.Add(new_sound_bank.GetCue(cue_name)); - reference_dic.Add(cue_name, this); + locationSongs.Add(this.Soundbank.GetCue(cueName)); + cues.Add(cueName, this); } else - { - locational_cues.Add(new_sound_bank.GetCue(cue_name)); - } + locationSongs.Add(this.Soundbank.GetCue(cueName)); } if (i == 2) { // Monitor.Log("Just thought that I'd let you know that there are no songs associated with the music file located at " + mylocation3 + " this may be intentional, but just incase you were wanted music, now you knew which ones were blank."); return; } - if (locational_cues.Count > 0) + if (locationSongs.Count > 0) { - locational_rain_songs.Add(conditional_name, locational_cues); - Console.WriteLine("StardewSymohony:The music pack located at: " + path_loc + " has successfully processed the song info for the game location: " + conditional_name); - return; - } - else - { - // Monitor.Log("Just thought that I'd let you know that there are no songs associated with the music file located at " + mylocation3 + " this may be intentional, but just incase you were wanted music, now you knew which ones were blank."); - return; + this.LocationRainSongs.Add(conditionalName, locationSongs); + Console.WriteLine("StardewSymohony:The music pack located at: " + this.Directory + " has successfully processed the song info for the game location: " + conditionalName); } } } - public void Music_Loader_Locations_Night(string conditional_name, Dictionary reference_dic) //reads in cue names from a text file and adds them to a specific list. Morphs with specific conditional name. Conditionals are hardcoded. + + /// Read cue names from a text file and adds them to a specific list. Morphs with specific conditional name. Conditionals are hardcoded. + /// The conditional file name to read. + /// The music list to update. + public void Music_Loader_Locations_Night(string conditionalName, IDictionary cues) { - locational_cues = new List(); + List locationSongs = new List(); //loads the data to the variables upon loading the game. - var music_path = path_loc; - string mylocation = Path.Combine(music_path, "Music_Files", "Locations", conditional_name); + var musicPath = this.Directory; + string mylocation = Path.Combine(musicPath, "Music_Files", "Locations", conditionalName); string mylocation2 = mylocation; string mylocation3 = mylocation2 + ".txt"; if (!File.Exists(mylocation3)) //check to make sure the file actually exists { - Console.WriteLine("StardewSymphony:A music list for the location " + conditional_name + " does not exist for the music pack located at " + mylocation3 + " which isn't a problem, I just thought I'd let you know since this may have been intentional. Also I'm creating it for you just incase. Cheers."); - //Console.WriteLine("Creating the Config file"); + Console.WriteLine("StardewSymphony:A music list for the location " + conditionalName + " does not exist for the music pack located at " + mylocation3 + " which isn't a problem, I just thought I'd let you know since this may have been intentional. Also I'm creating it for you just incase. Cheers."); string[] mystring3 = new string[3];//seems legit. - mystring3[0] = conditional_name + " music file. This file holds all of the music that will play when at this game location. Simply type the name of the song below the wall of equal signs."; + mystring3[0] = conditionalName + " music file. This file holds all of the music that will play when at this game location. Simply type the name of the song below the wall of equal signs."; mystring3[1] = "========================================================================================"; File.WriteAllLines(mylocation3, mystring3); - return; } - else { // add in data here string[] readtext = File.ReadAllLines(mylocation3); - string cue_name; int i = 2; var lineCount = File.ReadLines(mylocation3).Count(); while (i < lineCount) //the ordering seems bad, but it works. { if (Convert.ToString(readtext[i]) == "") - { - // Monitor.Log("Blank space detected."); break; - - } if (Convert.ToString(readtext[i]) == "\n") - { - //Monitor.Log("end line reached"); break; - - } - cue_name = Convert.ToString(readtext[i]); + string cueName = Convert.ToString(readtext[i]); i++; - if (!reference_dic.Keys.Contains(cue_name)) + if (!cues.Keys.Contains(cueName)) { - locational_cues.Add(new_sound_bank.GetCue(cue_name)); - reference_dic.Add(cue_name, this); + locationSongs.Add(this.Soundbank.GetCue(cueName)); + cues.Add(cueName, this); } else - { - locational_cues.Add(new_sound_bank.GetCue(cue_name)); - } - + locationSongs.Add(this.Soundbank.GetCue(cueName)); } if (i == 2) { // Monitor.Log("Just thought that I'd let you know that there are no songs associated with the music file located at " + mylocation3 + " this may be intentional, but just incase you were wanted music, now you knew which ones were blank."); return; } - if (locational_cues.Count > 0) + if (locationSongs.Count > 0) { - locational_night_songs.Add(conditional_name, locational_cues); - Console.WriteLine("StardewSymphonyLThe music pack located at: " + path_loc + " has successfully processed the song info for the game location: " + conditional_name); - return; - } - else - { - // Monitor.Log("Just thought that I'd let you know that there are no songs associated with the music file located at " + mylocation3 + " this may be intentional, but just incase you were wanted music, now you knew which ones were blank."); - return; + this.LocationNightSongs.Add(conditionalName, locationSongs); + Console.WriteLine("StardewSymphonyLThe music pack located at: " + this.Directory + " has successfully processed the song info for the game location: " + conditionalName); } } } - public void Music_Loader_Locations_Rain_Night(string conditional_name, Dictionary reference_dic) //reads in cue names from a text file and adds them to a specific list. Morphs with specific conditional name. Conditionals are hardcoded. + + /// Read cue names from a text file and adds them to a specific list. Morphs with specific conditional name. Conditionals are hardcoded. + /// The conditional file name to read. + /// The music list to update. + public void Music_Loader_Locations_Rain_Night(string conditionalName, IDictionary cues) { - locational_cues = new List(); - var music_path = path_loc; + List locationSongs = new List(); + var musicPath = this.Directory; - string mylocation = Path.Combine(music_path, "Music_Files", "Locations", conditional_name); - string mylocation2 = mylocation; - string mylocation3 = mylocation2 + ".txt"; - if (!File.Exists(mylocation3)) //check to make sure the file actually exists + string path = Path.Combine(musicPath, "Music_Files", "Locations", conditionalName + ".txt"); + if (!File.Exists(path)) //check to make sure the file actually exists { - Console.WriteLine("StardewSymphony:A music list for the location " + conditional_name + " does not exist for the music pack located at " + mylocation3 + " which isn't a problem, I just thought I'd let you know since this may have been intentional. Also I'm creating it for you just incase. Cheers."); - string[] mystring3 = new string[3];//seems legit. - mystring3[0] = conditional_name + " music file. This file holds all of the music that will play when at this game location. Simply type the name of the song below the wall of equal signs."; - mystring3[1] = "========================================================================================"; - - File.WriteAllLines(mylocation3, mystring3); - - - return; + Console.WriteLine("StardewSymphony:A music list for the location " + conditionalName + " does not exist for the music pack located at " + path + " which isn't a problem, I just thought I'd let you know since this may have been intentional. Also I'm creating it for you just incase. Cheers."); + string[] text = new string[3];//seems legit. + text[0] = conditionalName + " music file. This file holds all of the music that will play when at this game location. Simply type the name of the song below the wall of equal signs."; + text[1] = "========================================================================================"; + File.WriteAllLines(path, text); } - else { //load in music stuff from the text files using the code below. - string[] readtext = File.ReadAllLines(mylocation3); - string cue_name; + string[] text = File.ReadAllLines(path); int i = 2; - var lineCount = File.ReadLines(mylocation3).Count(); + var lineCount = File.ReadLines(path).Count(); while (i < lineCount) //the ordering seems bad, but it works. { - if (Convert.ToString(readtext[i]) == "") //if there is ever an empty line, stop processing the music file - { + if (Convert.ToString(text[i]) == "") //if there is ever an empty line, stop processing the music file break; - } - if (Convert.ToString(readtext[i]) == "\n") - { + if (Convert.ToString(text[i]) == "\n") break; - } - cue_name = Convert.ToString(readtext[i]); + string cueName = Convert.ToString(text[i]); i++; - if (!reference_dic.Keys.Contains(cue_name)) + if (!cues.Keys.Contains(cueName)) { - locational_cues.Add(new_sound_bank.GetCue(cue_name)); - reference_dic.Add(cue_name, this); + locationSongs.Add(this.Soundbank.GetCue(cueName)); + cues.Add(cueName, this); } else - { - locational_cues.Add(new_sound_bank.GetCue(cue_name)); - } + locationSongs.Add(this.Soundbank.GetCue(cueName)); } if (i == 2) - { - // Monitor.Log("Just thought that I'd let you know that there are no songs associated with the music file located at " + mylocation3 + " this may be intentional, but just incase you were wanted music, now you knew which ones were blank."); - - return; - } - - if (locational_cues.Count > 0) - { - locational_rain_night_songs.Add(conditional_name, locational_cues); - - Console.WriteLine("StardewSymohony:The music pack located at: " + path_loc + " has successfully processed the song info for the game location: " + conditional_name); - return; - } - else { // Monitor.Log("Just thought that I'd let you know that there are no songs associated with the music file located at " + mylocation3 + " this may be intentional, but just incase you were wanted music, now you knew which ones were blank."); return; } + if (locationSongs.Count > 0) + { + this.LocationRainNightSongs.Add(conditionalName, locationSongs); + Console.WriteLine("StardewSymohony:The music pack located at: " + this.Directory + " has successfully processed the song info for the game location: " + conditionalName); + } } } - - }; + } } diff --git a/GeneralMods/StardewSymphony/manifest.json b/GeneralMods/StardewSymphony/manifest.json index deb898c9..ca2e1844 100644 --- a/GeneralMods/StardewSymphony/manifest.json +++ b/GeneralMods/StardewSymphony/manifest.json @@ -11,4 +11,4 @@ "UniqueID": "StardewSymphony", "PerSaveConfigs": false, "EntryDll": "StardewSymphony.dll" -} \ No newline at end of file +}