From 9526d90dbf19223ad4a1fd42e7fee1bfa8a2f287 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 5 Aug 2017 15:23:33 -0400 Subject: [PATCH] fix uses of Console.WriteLine --- GeneralMods/BuildEndurance/BuildEndurance.cs | 4 +-- .../StardewSymphony/Framework/MusicManager.cs | 36 +++++++++++-------- .../StardewSymphony/StardewSymphony.cs | 4 +-- 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/GeneralMods/BuildEndurance/BuildEndurance.cs b/GeneralMods/BuildEndurance/BuildEndurance.cs index d6ada45e..0a87f1f6 100644 --- a/GeneralMods/BuildEndurance/BuildEndurance.cs +++ b/GeneralMods/BuildEndurance/BuildEndurance.cs @@ -234,7 +234,7 @@ namespace Omegasis.BuildEndurance string path = Path.Combine(Helper.DirectoryPath, "PlayerData", $"BuildEndurance_data_{Game1.player.name}.txt"); if (!File.Exists(path)) { - Console.WriteLine("Clear Data Loaded could not find the correct file."); + this.Monitor.Log("Clear Data Loaded could not find the correct file.")); this.ClearModEffects = false; this.OriginalStamina = 0; @@ -258,7 +258,7 @@ namespace Omegasis.BuildEndurance string path = Path.Combine(Helper.DirectoryPath, "PlayerData", $"BuildEndurance_data_{Game1.player.name}.txt"); if (!File.Exists(path)) { - Console.WriteLine("Clear Data Loaded could not find the correct file."); + this.Monitor.Log("Clear Data Loaded could not find the correct file."); this.ClearModEffects = false; this.OriginalStamina = 0; diff --git a/GeneralMods/StardewSymphony/Framework/MusicManager.cs b/GeneralMods/StardewSymphony/Framework/MusicManager.cs index f23c2405..8547a51a 100644 --- a/GeneralMods/StardewSymphony/Framework/MusicManager.cs +++ b/GeneralMods/StardewSymphony/Framework/MusicManager.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using Microsoft.Xna.Framework.Audio; +using StardewModdingAPI; using StardewValley; namespace Omegasis.StardewSymphony.Framework @@ -13,6 +14,9 @@ namespace Omegasis.StardewSymphony.Framework /********* ** Properties *********/ + /// Writes messages to the console and log file. + private readonly IMonitor Monitor; + /// The valid season values. private readonly Season[] Seasons = Enum.GetValues(typeof(Season)).Cast().ToArray(); @@ -64,12 +68,14 @@ namespace Omegasis.StardewSymphony.Framework ** Public methods *********/ /// Construct an instance. + /// Writes messages to the console and log file. /// 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) + public MusicManager(IMonitor monitor, string wavebank, string soundbank, string directory) { // init data + this.Monitor = monitor; this.Directory = directory; this.WavebankName = wavebank + ".xwb"; this.SoundbankName = soundbank + ".xsb"; @@ -78,8 +84,8 @@ namespace Omegasis.StardewSymphony.Framework string wavePath = Path.Combine(this.Directory, this.WavebankName); string soundPath = Path.Combine(this.Directory, this.SoundbankName); - Console.WriteLine(wavePath); - Console.WriteLine(soundPath); + this.Monitor.Log(wavePath); + this.Monitor.Log(soundPath); if (File.Exists(wavePath)) this.Wavebank = new WaveBank(Game1.audioEngine, wavePath); @@ -98,7 +104,7 @@ namespace Omegasis.StardewSymphony.Framework 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"); + this.Monitor.Log($"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] = "========================================================================================"; @@ -107,7 +113,7 @@ namespace Omegasis.StardewSymphony.Framework } else { - Console.WriteLine($"Stardew Symphony:The music pack located at: {this.Directory} is processing the song info for the game location: {conditionalName}"); + this.Monitor.Log($"Stardew Symphony:The music pack located at: {this.Directory} is processing the song info for the game location: {conditionalName}"); string[] text = File.ReadAllLines(path); int i = 2; @@ -172,7 +178,7 @@ namespace Omegasis.StardewSymphony.Framework // 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; } - Console.WriteLine($"Stardew Symohony:The music pack located at: {this.Directory} has successfully processed the song info for the game location {conditionalName}"); + this.Monitor.Log($"Stardew Symohony:The music pack located at: {this.Directory} has successfully processed the song info for the game location {conditionalName}"); } } @@ -186,7 +192,7 @@ namespace Omegasis.StardewSymphony.Framework string path = Path.Combine(this.Directory, "Music_Files", "Locations", conditionalName + ".txt"); if (!File.Exists(path)) { - Console.WriteLine("StardewSymohony: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."); + this.Monitor.Log("StardewSymohony: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."; @@ -196,7 +202,7 @@ namespace Omegasis.StardewSymphony.Framework } else { - Console.WriteLine("Stardew Symphony:The music pack located at: " + this.Directory + " is processing the song info for the game location: " + conditionalName); + this.Monitor.Log("Stardew Symphony:The music pack located at: " + this.Directory + " is processing the song info for the game location: " + conditionalName); string[] readtext = File.ReadAllLines(path); int i = 2; var lineCount = File.ReadLines(path).Count(); @@ -224,7 +230,7 @@ namespace Omegasis.StardewSymphony.Framework if (locationSongs.Count > 0) { 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); + this.Monitor.Log("StardewSymhony:The music pack located at: " + this.Directory + " has successfully processed the song info for the game location: " + conditionalName); } } } @@ -238,7 +244,7 @@ namespace Omegasis.StardewSymphony.Framework string path = Path.Combine(this.Directory, "Music_Files", "Locations", conditionalName + ".txt"); if (!File.Exists(path)) { - 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."); + this.Monitor.Log("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] = "========================================================================================"; @@ -274,7 +280,7 @@ namespace Omegasis.StardewSymphony.Framework if (locationSongs.Count > 0) { 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); + this.Monitor.Log("StardewSymohony:The music pack located at: " + this.Directory + " has successfully processed the song info for the game location: " + conditionalName); } } } @@ -288,7 +294,7 @@ namespace Omegasis.StardewSymphony.Framework string path = Path.Combine(this.Directory, "Music_Files", "Locations", conditionalName + ".txt"); if (!File.Exists(path)) { - 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."); + this.Monitor.Log("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] = "========================================================================================"; @@ -325,7 +331,7 @@ namespace Omegasis.StardewSymphony.Framework if (locationSongs.Count > 0) { 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); + this.Monitor.Log("StardewSymphonyLThe music pack located at: " + this.Directory + " has successfully processed the song info for the game location: " + conditionalName); } } } @@ -341,7 +347,7 @@ namespace Omegasis.StardewSymphony.Framework string path = Path.Combine(musicPath, "Music_Files", "Locations", conditionalName + ".txt"); if (!File.Exists(path)) { - 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."); + this.Monitor.Log("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] = "========================================================================================"; @@ -379,7 +385,7 @@ namespace Omegasis.StardewSymphony.Framework 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); + this.Monitor.Log("StardewSymohony:The music pack located at: " + this.Directory + " has successfully processed the song info for the game location: " + conditionalName); } } } diff --git a/GeneralMods/StardewSymphony/StardewSymphony.cs b/GeneralMods/StardewSymphony/StardewSymphony.cs index c4ff5d4a..a2152ed7 100644 --- a/GeneralMods/StardewSymphony/StardewSymphony.cs +++ b/GeneralMods/StardewSymphony/StardewSymphony.cs @@ -211,7 +211,7 @@ namespace Omegasis.StardewSymphony // 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."); + this.Monitor.Log("StardewSymphony:This music pack lacks a Config.txt. Without one, I can't load in the music."); return; } @@ -221,7 +221,7 @@ namespace Omegasis.StardewSymphony 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); + MusicManager manager = new MusicManager(this.Monitor, wave, sound, rootDir); manager.LoadSeasonalSongs("spring", this.SongWaveReference); manager.LoadSeasonalSongs("summer", this.SongWaveReference); manager.LoadSeasonalSongs("fall", this.SongWaveReference);