From 917e169ceadb9ea90f715f3a498bbd15bce3b91a Mon Sep 17 00:00:00 2001 From: Date: Sat, 25 Aug 2018 22:42:57 -0700 Subject: [PATCH] Fixed vocalization translation issues for some dialogue being scraped from StringsFromCS --- .../Vocalization/Framework/AudioCues.cs | 70 + .../Vocalization/Framework/Vocabulary.cs | 2 +- .../Framework/VoiceAudioOptions.cs | 8 + .../Vocalization/Vocalization/Vocalization.cs | 1558 +++++++++++++---- .../Vocalization/Vocalization.csproj | 1 + 5 files changed, 1338 insertions(+), 301 deletions(-) create mode 100644 GeneralMods/Vocalization/Vocalization/Framework/AudioCues.cs diff --git a/GeneralMods/Vocalization/Vocalization/Framework/AudioCues.cs b/GeneralMods/Vocalization/Vocalization/Framework/AudioCues.cs new file mode 100644 index 00000000..1d9049ea --- /dev/null +++ b/GeneralMods/Vocalization/Vocalization/Framework/AudioCues.cs @@ -0,0 +1,70 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Vocalization.Framework +{ + public class AudioCues + { + //Translation_speaker_file_key + public static char Seperator = '_'; + + public static Dictionary> DictionaryReferences = new Dictionary>(); + + public static string generateKey(string translationPath, string SpeakerName, string fileName, string dialogueKey) + { + return Vocalization.config.translationInfo.getTranslationNameFromPath(translationPath) + Seperator + SpeakerName + Seperator + fileName + Seperator + dialogueKey; + } + + public static SortedDictionary getWavFileReferences(string translation) + { + return DictionaryReferences[Vocalization.config.translationInfo.getTranslationNameFromPath(translation)]; + } + + public static void initialize() + { + if (!Directory.Exists(Path.Combine(Vocalization.ModHelper.DirectoryPath, "AudioCues"))){ + Directory.CreateDirectory(Path.Combine(Vocalization.ModHelper.DirectoryPath, "AudioCues")); + } + loadAudioCues(); + + } + + public static void addWavReference(string key, VoiceAudioOptions cue) + { + try + { + string translation = key.Split(Seperator).ElementAt(0); + DictionaryReferences.TryGetValue(translation,out SortedDictionary value); + + value.Add(key, cue); + } + catch(Exception err) + { + + } + } + + public static void loadAudioCues() + { + foreach (var v in Vocalization.config.translationInfo.translations) + { + var loaded = Vocalization.ModHelper.ReadJsonFile>(Path.Combine(Vocalization.ModHelper.DirectoryPath, "AudioCues","AudioCues" + Seperator + v + ".json")); + if (loaded == null) loaded = new SortedDictionary(); + DictionaryReferences.Add(v,loaded); + } + } + + public static void saveAudioCues() + { + foreach (var v in DictionaryReferences) + { + Vocalization.ModHelper.WriteJsonFile>(Path.Combine(Vocalization.ModHelper.DirectoryPath, "AudioCues", "AudioCues" + Seperator + v.Key + ".json"),v.Value); + } + } + + } +} diff --git a/GeneralMods/Vocalization/Vocalization/Framework/Vocabulary.cs b/GeneralMods/Vocalization/Vocalization/Framework/Vocabulary.cs index 609640b8..9b522b06 100644 --- a/GeneralMods/Vocalization/Vocalization/Framework/Vocabulary.cs +++ b/GeneralMods/Vocalization/Vocalization/Framework/Vocabulary.cs @@ -146,7 +146,7 @@ namespace Vocalization.Framework { List stock = new List(); Dictionary objDict = Game1.content.Load>(Path.Combine("Data", Vocalization.config.translationInfo.getXNBForTranslation("ObjectInformation", translation))); - Vocalization.ModMonitor.Log("LOAD THE OBJECT INFO: ", LogLevel.Alert); + //Vocalization.ModMonitor.Log("LOAD THE OBJECT INFO: ", LogLevel.Alert); foreach (KeyValuePair pair in objDict) { for (int i = 0; i <= 3; i++) diff --git a/GeneralMods/Vocalization/Vocalization/Framework/VoiceAudioOptions.cs b/GeneralMods/Vocalization/Vocalization/Framework/VoiceAudioOptions.cs index cf2472f0..c8af8fb0 100644 --- a/GeneralMods/Vocalization/Vocalization/Framework/VoiceAudioOptions.cs +++ b/GeneralMods/Vocalization/Vocalization/Framework/VoiceAudioOptions.cs @@ -39,6 +39,14 @@ namespace Vocalization.Framework simpleAndHeartEvents = ""; } + public VoiceAudioOptions(string simple, string full, string heartEvent, string simpleAndHeartEvent) + { + this.simple = simple; + this.full = full; + this.heartEvents = heartEvent; + this.simpleAndHeartEvents = simpleAndHeartEvent; + } + public string getAudioClip() { if (Vocalization.config.currentMode == "Simple") return simple; diff --git a/GeneralMods/Vocalization/Vocalization/Vocalization.cs b/GeneralMods/Vocalization/Vocalization/Vocalization.cs index 17079aed..877886c3 100644 --- a/GeneralMods/Vocalization/Vocalization/Vocalization.cs +++ b/GeneralMods/Vocalization/Vocalization/Vocalization.cs @@ -171,9 +171,9 @@ namespace Vocalization /// public static SimpleSoundManager.Framework.SoundManager soundManager; - - + + /// /// The path to the folder where all of the NPC folders for dialogue .wav files are kept. /// @@ -211,9 +211,11 @@ namespace Vocalization config = ModHelper.ReadConfig(); + AudioCues.initialize(); + config.verifyValidMode(); //Make sure the current mode is valid. soundManager.volume = (float)config.voiceVolume; //Set the volume for voices. - + } private void MenuEvents_MenuChanged(object sender, StardewModdingAPI.Events.EventArgsClickableMenuChanged e) @@ -237,7 +239,7 @@ namespace Vocalization soundManager.stopAllSounds(); previousDialogue = ""; } - catch(Exception err) + catch (Exception err) { previousDialogue = ""; } @@ -255,6 +257,8 @@ namespace Vocalization initialzeModualGameMenuHack(); initialzeDirectories(); loadAllVoiceFiles(); + + AudioCues.saveAudioCues(); } /// @@ -277,18 +281,18 @@ namespace Vocalization Texture2D myText = textures.ElementAt(randNum); ClickableTextureComponent c = new ClickableTextureComponent(new Rectangle(0, 16, 16, 24), myText, new Rectangle(0, 0, 16, 24), 2f, false); - ClickableTextureComponent speech = new ClickableTextureComponent(new Rectangle(0, 0, 32, 32), ModHelper.Content.Load (Path.Combine("Content", "Graphics", "SpeechBubble.png")), new Rectangle(0, 0, 32, 32), 2f, false); + ClickableTextureComponent speech = new ClickableTextureComponent(new Rectangle(0, 0, 32, 32), ModHelper.Content.Load(Path.Combine("Content", "Graphics", "SpeechBubble.png")), new Rectangle(0, 0, 32, 32), 2f, false); List> components = new List>(); - components.Add(new KeyValuePair(c,ExtraTextureDrawOrder.after)); + components.Add(new KeyValuePair(c, ExtraTextureDrawOrder.after)); components.Add(new KeyValuePair(speech, ExtraTextureDrawOrder.after)); - Button menuTab = new Button("", new Rectangle(0, 0, 32, 32), new Texture2DExtended(ModHelper, ModManifest, Path.Combine("Content", "Graphics", "MenuTab.png")), "", new Rectangle(0, 0, 32, 32), 2f, new StardustCore.Animations.Animation(new Rectangle(0, 0, 32, 32)), Color.White, Color.White, new StardustCore.UIUtilities.MenuComponents.Delegates.Functionality.ButtonFunctionality(new StardustCore.UIUtilities.MenuComponents.Delegates.DelegatePairing(null,null), new StardustCore.UIUtilities.MenuComponents.Delegates.DelegatePairing(null,null), new StardustCore.UIUtilities.MenuComponents.Delegates.DelegatePairing(null,null)), false, components); + Button menuTab = new Button("", new Rectangle(0, 0, 32, 32), new Texture2DExtended(ModHelper, ModManifest, Path.Combine("Content", "Graphics", "MenuTab.png")), "", new Rectangle(0, 0, 32, 32), 2f, new StardustCore.Animations.Animation(new Rectangle(0, 0, 32, 32)), Color.White, Color.White, new StardustCore.UIUtilities.MenuComponents.Delegates.Functionality.ButtonFunctionality(new StardustCore.UIUtilities.MenuComponents.Delegates.DelegatePairing(null, null), new StardustCore.UIUtilities.MenuComponents.Delegates.DelegatePairing(null, null), new StardustCore.UIUtilities.MenuComponents.Delegates.DelegatePairing(null, null)), false, components); //Change this to take the vocalization menu instead List> modTabs = new List>(); - modTabs.Add(new KeyValuePair(menuTab, new VocalizationMenu(100,64,600,300,true))); - StardustCore.Menus.ModularGameMenu.AddTabsForMod(ModManifest,modTabs); + modTabs.Add(new KeyValuePair(menuTab, new VocalizationMenu(100, 64, 600, 300, true))); + StardustCore.Menus.ModularGameMenu.AddTabsForMod(ModManifest, modTabs); ModMonitor.Log("VOCALIZATION MENU HACK COMPLETE!", LogLevel.Alert); } @@ -321,11 +325,11 @@ namespace Vocalization components.Add(new KeyValuePair(c, ExtraTextureDrawOrder.after)); components.Add(new KeyValuePair(speech, ExtraTextureDrawOrder.after)); - Button menuTab = new Button("", new Rectangle(0,0, 32, 32), new Texture2DExtended(ModHelper, ModManifest, Path.Combine("Content", "Graphics", "MenuTab.png")), "", new Rectangle(0, 0, 32, 32), 2f, new StardustCore.Animations.Animation(new Rectangle(0, 0, 32, 32)), Color.White, Color.White, new StardustCore.UIUtilities.MenuComponents.Delegates.Functionality.ButtonFunctionality(null, null, null), false, components); + Button menuTab = new Button("", new Rectangle(0, 0, 32, 32), new Texture2DExtended(ModHelper, ModManifest, Path.Combine("Content", "Graphics", "MenuTab.png")), "", new Rectangle(0, 0, 32, 32), 2f, new StardustCore.Animations.Animation(new Rectangle(0, 0, 32, 32)), Color.White, Color.White, new StardustCore.UIUtilities.MenuComponents.Delegates.Functionality.ButtonFunctionality(null, null, null), false, components); //Change this to take the vocalization menu instead List> modTabs = new List>(); - modTabs.Add(new KeyValuePair(menuTab, new VocalizationMenu(100, 64, 600, 300,true))); + modTabs.Add(new KeyValuePair(menuTab, new VocalizationMenu(100, 64, 600, 300, true))); StardustCore.Menus.ModularGameMenu.StaticMenuTabsAndPages[ModManifest.UniqueID] = modTabs; } @@ -355,8 +359,10 @@ namespace Vocalization private void GameEvents_UpdateTick(object sender, EventArgs e) { soundManager.update(); - if (Game1.player != null) { - if (Game1.player.currentLocation != null) { + if (Game1.player != null) + { + if (Game1.player.currentLocation != null) + { foreach (NPC v in Game1.currentLocation.characters) { string text = (string)GetInstanceField(typeof(NPC), v, "textAboveHead"); @@ -366,7 +372,7 @@ namespace Vocalization if (onScreenSpeechBubbleDialogues.Contains(currentDialogue) && timer > 0) continue; //If I have already added this dialogue and the timer has not run out, do nothing. - if (!onScreenSpeechBubbleDialogues.Contains(currentDialogue) && timer>0) //If I have not added this dialogue and the timer has not run out, add it. + if (!onScreenSpeechBubbleDialogues.Contains(currentDialogue) && timer > 0) //If I have not added this dialogue and the timer has not run out, add it. { List tries = new List(); tries.Add("SpeechBubbles"); @@ -397,7 +403,7 @@ namespace Vocalization { onScreenSpeechBubbleDialogues.Remove(currentDialogue); } - if(timer<=0 && !onScreenSpeechBubbleDialogues.Contains(currentDialogue)) //If the timer has run out and I no longer contain the dialogue, continue on. + if (timer <= 0 && !onScreenSpeechBubbleDialogues.Contains(currentDialogue)) //If the timer has run out and I no longer contain the dialogue, continue on. { continue; } @@ -411,7 +417,7 @@ namespace Vocalization string speakerName = Game1.currentSpeaker.Name; if (Game1.activeClickableMenu.GetType() == typeof(StardewValley.Menus.DialogueBox)) { - StardewValley.Menus.DialogueBox dialogueBox =(DialogueBox)Game1.activeClickableMenu; + StardewValley.Menus.DialogueBox dialogueBox = (DialogueBox)Game1.activeClickableMenu; string currentDialogue = dialogueBox.getCurrentString(); if (previousDialogue != currentDialogue) { @@ -449,7 +455,7 @@ namespace Vocalization { ModMonitor.Log("New unregistered dialogue detected for NPC: " + v + " saying: " + currentDialogue, LogLevel.Alert); ModMonitor.Log("Make sure to add this to their respective VoiceCue.json file if you wish for this dialogue to have voice acting associated with it!", LogLevel.Alert); - + } } } @@ -458,15 +464,15 @@ namespace Vocalization else { if (Game1.activeClickableMenu == null) return; - //Support for TV - if (Game1.activeClickableMenu.GetType() == typeof(StardewValley.Menus.DialogueBox)) + //Support for TV + if (Game1.activeClickableMenu.GetType() == typeof(StardewValley.Menus.DialogueBox)) + { + StardewValley.Menus.DialogueBox dialogueBox = (DialogueBox)Game1.activeClickableMenu; + string currentDialogue = dialogueBox.getCurrentString(); + if (previousDialogue != currentDialogue) { - StardewValley.Menus.DialogueBox dialogueBox = (DialogueBox)Game1.activeClickableMenu; - string currentDialogue = dialogueBox.getCurrentString(); - if (previousDialogue != currentDialogue) - { - previousDialogue = currentDialogue; //Update my previously read dialogue so that I only read the new string once when it appears. - ModMonitor.Log(currentDialogue); //Print out my dialogue. + previousDialogue = currentDialogue; //Update my previously read dialogue so that I only read the new string once when it appears. + ModMonitor.Log(currentDialogue); //Print out my dialogue. List tries = new List(); tries.Add("TV"); @@ -481,7 +487,7 @@ namespace Vocalization { //Add in support for TV Shows CharacterVoiceCue voice; - bool f=DialogueCues.TryGetValue(v, out voice); + bool f = DialogueCues.TryGetValue(v, out voice); currentDialogue = sanitizeDialogueInGame(currentDialogue); //If contains the stuff in the else statement, change things up. if (voice.dialogueCues.ContainsKey(currentDialogue)) { @@ -495,11 +501,11 @@ namespace Vocalization { ModMonitor.Log("New unregistered dialogue detected saying: " + currentDialogue, LogLevel.Alert); ModMonitor.Log("Make sure to add this to their respective VoiceCue.json file if you wish for this dialogue to have voice acting associated with it!", LogLevel.Alert); - + } } - } } + } //Support for Letters if (Game1.activeClickableMenu.GetType() == typeof(StardewValley.Menus.LetterViewerMenu)) @@ -507,9 +513,9 @@ namespace Vocalization //Use reflection to get original text back. var menu = (StardewValley.Menus.LetterViewerMenu)Game1.activeClickableMenu; //mail dialogue text will probably need to be sanitized as well.... - List mailText=(List)ModHelper.Reflection.GetField>(menu, "mailMessage", true); + List mailText = (List)ModHelper.Reflection.GetField>(menu, "mailMessage", true); string currentDialogue = ""; - foreach(var v in mailText) + foreach (var v in mailText) { currentDialogue += mailText; } @@ -531,7 +537,7 @@ namespace Vocalization ModMonitor.Log("New unregistered Mail dialogue detected saying: " + currentDialogue, LogLevel.Alert); ModMonitor.Log("Make sure to add this to their respective VoiceCue.json file if you wish for this dialogue to have voice acting associated with it!", LogLevel.Alert); } - + } //Support for shops @@ -552,10 +558,10 @@ namespace Vocalization //Add in support for Shops CharacterVoiceCue voice; //character shops - bool f=DialogueCues.TryGetValue("Shops", out voice); + bool f = DialogueCues.TryGetValue("Shops", out voice); if (f == false) { - ModMonitor.Log("Can't find the dialogue for the shop: " + npc.Name); + ModMonitor.Log("Can't find the dialogue for the shop: " + npc.Name); } shopDialogue = sanitizeDialogueInGame(shopDialogue); //If contains the stuff in the else statement, change things up. @@ -579,7 +585,7 @@ namespace Vocalization ModMonitor.Log("New unregistered dialogue detected saying: " + shopDialogue, LogLevel.Alert); ModMonitor.Log("Make sure to add this to their respective VoiceCue.json file if you wish for this dialogue to have voice acting associated with it!", LogLevel.Alert); } - + } } @@ -600,12 +606,12 @@ namespace Vocalization VoicePath = voicePath; //Set a static reference to my voice files directory. - + //Get a list of all characters in the game and make voice directories for them in each supported translation of the mod. foreach (var loc in Game1.locations) { - foreach(var NPC in loc.characters) + foreach (var NPC in loc.characters) { foreach (var translation in config.translationInfo.translations) { @@ -618,7 +624,7 @@ namespace Vocalization //Create all of the necessary folders for different translations. foreach (var dir in config.translationInfo.translations) { - if (!Directory.Exists(Path.Combine(voicePath,dir))) Directory.CreateDirectory(Path.Combine(voicePath, dir)); + if (!Directory.Exists(Path.Combine(voicePath, dir))) Directory.CreateDirectory(Path.Combine(voicePath, dir)); } //Add in folder for TV Shows @@ -758,7 +764,7 @@ namespace Vocalization { ModMonitor.Log(dir); - string[] clips = Directory.GetFiles(dir,"*.wav"); + string[] clips = Directory.GetFiles(dir, "*.wav"); //For every .wav file in every character voice clip directory load in the voice clip. foreach (var file in clips) @@ -776,10 +782,11 @@ namespace Vocalization //I have to scrape all files if they don't exist so that way all options are available for release. if (!File.Exists(voiceCueFile)) { + CharacterVoiceCue cue = new CharacterVoiceCue(characterName); cue.initializeEnglishScrape(); cue.initializeForTranslation(translation); - scrapeDictionaries(voiceCueFile,cue,translation); + scrapeDictionaries(voiceCueFile, cue, translation); try { if (Path.GetFileName(translation) == config.translationInfo.currentTranslation) @@ -787,7 +794,7 @@ namespace Vocalization DialogueCues.Add(characterName, cue); } } - catch(Exception err) + catch (Exception err) { } @@ -817,7 +824,7 @@ namespace Vocalization /// Used to obtain all strings for almost all possible dialogue in the game. /// /// - public static void scrapeDictionaries(string path,CharacterVoiceCue cue,string translation) + public static void scrapeDictionaries(string path, CharacterVoiceCue cue, string translation) { var dialoguePath = Path.Combine("Characters", "Dialogue"); @@ -826,18 +833,18 @@ namespace Vocalization var festivalPath = Path.Combine(dataPath, "Festivals"); var eventPath = Path.Combine(dataPath, "Events"); - ModMonitor.Log("Scraping dialogue for character: " + cue.name,LogLevel.Info); + ModMonitor.Log("Scraping dialogue for character: " + cue.name, LogLevel.Info); //If the "character"'s name is TV which means I'm watching tv, scrape the data from the TV shows. if (cue.name == "TV") { - + foreach (var fileName in cue.dataFileNames) { - ModMonitor.Log(" Scraping dialogue file: " + fileName,LogLevel.Info); + ModMonitor.Log(" Scraping dialogue file: " + fileName, LogLevel.Info); //basically this will never run but can be used below to also add in dialogue. if (!String.IsNullOrEmpty(fileName)) { - string dialoguePath2 = Path.Combine(dataPath,"TV",fileName); + string dialoguePath2 = Path.Combine(dataPath, "TV", fileName); var DialogueDict = ModHelper.Content.Load>(dialoguePath2, ContentSource.GameContent); //Scraping the CookingChannel dialogue @@ -854,13 +861,23 @@ namespace Vocalization string cookingDialogue = splitDialogues.ElementAt(1); //If the key contains the character's name. - List cleanDialogues = new List(); - cleanDialogues = sanitizeDialogueFromDictionaries(cookingDialogue,cue); - foreach (var str in cleanDialogues) + List cleanDialogues = new List(); + cleanDialogues = sanitizeDialogueFromDictionaries(cookingDialogue, cue); + foreach (var str in cleanDialogues) + { + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName, key))) { - cue.addDialogue(str,new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty. + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName, key), out VoiceAudioOptions value); + + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); } - + else + { + cue.addDialogue(str, new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty. + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName, key), new VoiceAudioOptions()); + } + } + } continue; } @@ -876,13 +893,24 @@ namespace Vocalization string rawDialogue = pair.Value; if (key != "intro") continue; //If the key contains the character's name. - List cleanDialogues = new List(); - cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue,cue); - foreach (var str in cleanDialogues) + List cleanDialogues = new List(); + cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue, cue); + foreach (var str in cleanDialogues) + { + + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName, key))) { - cue.addDialogue(str,new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty. + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName, key), out VoiceAudioOptions value); + + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); } - + else + { + cue.addDialogue(str, new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty. + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName, key), new VoiceAudioOptions()); + } + } + } continue; } @@ -897,13 +925,23 @@ namespace Vocalization string key = pair.Key; string rawDialogue = pair.Value; - List cleanDialogues = new List(); - cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue,cue); - foreach (var str in cleanDialogues) + List cleanDialogues = new List(); + cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue, cue); + foreach (var str in cleanDialogues) + { + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName, key))) { - cue.addDialogue(str,new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty. + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName, key), out VoiceAudioOptions value); + + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); } - + else + { + cue.addDialogue(str, new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty. + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName, key), new VoiceAudioOptions()); + } + } + } continue; } @@ -931,16 +969,26 @@ namespace Vocalization List cleanDialogues = new List(); - if(key== "TV.cs.13151") + if (key == "TV.cs.13151") { - foreach(string recipe in Vocabulary.getAllCookingRecipes(translation)) + foreach (string recipe in Vocabulary.getAllCookingRecipes(translation)) { rawDialogue = config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:TV.cs.13151"), translation, (object)recipe); List cleanDialogues2 = new List(); cleanDialogues2 = sanitizeDialogueFromDictionaries(rawDialogue, cue); foreach (var str in cleanDialogues2) { - cue.addDialogue(str, new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty. + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName, key))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName, key), out VoiceAudioOptions value); + + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + } + else + { + cue.addDialogue(str, new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty. + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName, key), new VoiceAudioOptions()); + } } } continue; @@ -956,7 +1004,17 @@ namespace Vocalization cleanDialogues2 = sanitizeDialogueFromDictionaries(rawDialogue, cue); foreach (var str in cleanDialogues2) { - cue.addDialogue(str, new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty. + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName, key))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName, key), out VoiceAudioOptions value); + + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + } + else + { + cue.addDialogue(str, new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty. + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName, key), new VoiceAudioOptions()); + } } } continue; @@ -980,7 +1038,7 @@ namespace Vocalization string startTime = times.Split(' ').ElementAt(0); string finishTime = times.Split(' ').ElementAt(1); config.translationInfo.changeLocalizedContentManagerFromTranslation(translation); - string dialogueString=config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:TV.cs.13175"), translation, (object)name, (object)location, (object)Game1.getTimeOfDayString(Convert.ToInt32(startTime)), (object)Game1.getTimeOfDayString(Convert.ToInt32(finishTime))); + string dialogueString = config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:TV.cs.13175"), translation, (object)name, (object)location, (object)Game1.getTimeOfDayString(Convert.ToInt32(startTime)), (object)Game1.getTimeOfDayString(Convert.ToInt32(finishTime))); config.translationInfo.resetLocalizationCode(); cleanDialogues = sanitizeDialogueFromDictionaries(dialogueString, cue); @@ -988,12 +1046,22 @@ namespace Vocalization foreach (var str in cleanDialogues) { string ahh = sanitizeDialogueFromMailDictionary(str); - cue.addDialogue(ahh, new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty. + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName, key))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName, key), out VoiceAudioOptions value); + + cue.addDialogue(ahh, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + } + else + { + cue.addDialogue(ahh, new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty. + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName, key), new VoiceAudioOptions()); + } } } - catch(Exception err) + catch (Exception err) { //ModMonitor.Log(err.ToString()); } @@ -1002,12 +1070,22 @@ namespace Vocalization continue; } - cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue,cue); - + cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue, cue); + foreach (var str in cleanDialogues) { string ahh = sanitizeDialogueFromMailDictionary(str); - cue.addDialogue(ahh, new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty. + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName, key))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName, key), out VoiceAudioOptions value); + + cue.addDialogue(ahh, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + } + else + { + cue.addDialogue(ahh, new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty. + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName, key), new VoiceAudioOptions()); + } } } @@ -1043,37 +1121,58 @@ namespace Vocalization string rawDialogue = pair.Value; if (!key.Contains("ShopMenu")) continue; //If the key contains the character's name. - - if(key== "ShopMenu.cs.11464") + + if (key == "ShopMenu.cs.11464") { - foreach (var obj in Vocabulary.getCarpenterStock(translation)) { + foreach (var obj in Vocabulary.getCarpenterStock(translation)) + { foreach (string word1 in Vocabulary.getRandomPositiveAdjectivesForEventOrPerson(translation, null)) { - rawDialogue=config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:ShopMenu.cs.11464"), translation, (object)obj, (object)word1, (object)Vocabulary.getProperArticleForWord(obj,translation)); + rawDialogue = config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:ShopMenu.cs.11464"), translation, (object)obj, (object)word1, (object)Vocabulary.getProperArticleForWord(obj, translation)); List cleanDialogues2 = new List(); cleanDialogues2 = sanitizeDialogueFromDictionaries(rawDialogue, cue); foreach (var str in cleanDialogues2) { - cue.addDialogue(str, new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty. + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName, key))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName, key), out VoiceAudioOptions value); + + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + } + else + { + cue.addDialogue(str, new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty. + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName, key), new VoiceAudioOptions()); + } } } } continue; } - if(key== "ShopMenu.cs.11502") + if (key == "ShopMenu.cs.11502") { foreach (var obj in Vocabulary.getMerchantStock(translation)) { - rawDialogue = config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:ShopMenu.cs.11502"), translation, (object)obj); - List cleanDialogues2 = new List(); - cleanDialogues2 = sanitizeDialogueFromDictionaries(rawDialogue, cue); - foreach (var str in cleanDialogues2) + rawDialogue = config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:ShopMenu.cs.11502"), translation, (object)obj); + List cleanDialogues2 = new List(); + cleanDialogues2 = sanitizeDialogueFromDictionaries(rawDialogue, cue); + foreach (var str in cleanDialogues2) + { + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName, key))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName, key), out VoiceAudioOptions value); + + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + } + else { cue.addDialogue(str, new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty. + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName, key), new VoiceAudioOptions()); } - + } + } continue; } @@ -1087,7 +1186,17 @@ namespace Vocalization cleanDialogues2 = sanitizeDialogueFromDictionaries(rawDialogue, cue); foreach (var str in cleanDialogues2) { - cue.addDialogue(str, new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty. + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName, key))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName, key), out VoiceAudioOptions value); + + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + } + else + { + cue.addDialogue(str, new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty. + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName, key), new VoiceAudioOptions()); + } } } @@ -1095,14 +1204,24 @@ namespace Vocalization } List cleanDialogues = new List(); - cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue,cue); - foreach (var str in cleanDialogues) + cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue, cue); + foreach (var str in cleanDialogues) + { + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName, key))) { - cue.addDialogue(str,new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty. + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName, key), out VoiceAudioOptions value); + + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); } - + else + { + cue.addDialogue(str, new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty. + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName, key), new VoiceAudioOptions()); + } + } + } - + continue; } //For moddablity add a generic scrape here! @@ -1123,43 +1242,76 @@ namespace Vocalization string dialoguePath2 = Path.Combine(dataPath, fileName); var DialogueDict = ModHelper.Content.Load>(dialoguePath2, ContentSource.GameContent); foreach (KeyValuePair pair in DialogueDict) - { + { //Get the key in the dictionary string key = pair.Key; string rawDialogue = pair.Value; List cleanDialogues = new List(); - cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue,cue); + cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue, cue); foreach (var str in cleanDialogues) { - if(key== "NewChild_Adoption") { - cue.addDialogue(config.translationInfo.LoadString(Path.Combine("Data","ExtraDialogue:"+key),translation,replacementStrings.kid1Name), new VoiceAudioOptions()); - cue.addDialogue(config.translationInfo.LoadString(Path.Combine("Data","ExtraDialogue:"+key), translation, replacementStrings.kid2Name), new VoiceAudioOptions()); + if (key == "NewChild_Adoption") + { + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName, key))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName, key), out VoiceAudioOptions value); + + cue.addDialogue(config.translationInfo.LoadString(Path.Combine("Data", "ExtraDialogue:" + key), translation, replacementStrings.kid1Name), new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + cue.addDialogue(config.translationInfo.LoadString(Path.Combine("Data", "ExtraDialogue:" + key), translation, replacementStrings.kid2Name), new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + } + else + { + cue.addDialogue(config.translationInfo.LoadString(Path.Combine("Data", "ExtraDialogue:" + key), translation, replacementStrings.kid1Name), new VoiceAudioOptions()); + cue.addDialogue(config.translationInfo.LoadString(Path.Combine("Data", "ExtraDialogue:" + key), translation, replacementStrings.kid2Name), new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName, key), new VoiceAudioOptions()); + } continue; } - if(key== "NewChild_FirstChild") + if (key == "NewChild_FirstChild") { - cue.addDialogue(config.translationInfo.LoadString(Path.Combine("Data", "ExtraDialogue:"+key), translation, replacementStrings.kid1Name), new VoiceAudioOptions()); + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName, key))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName, key), out VoiceAudioOptions value); + cue.addDialogue(config.translationInfo.LoadString(Path.Combine("Data", "ExtraDialogue:" + key), translation, replacementStrings.kid1Name), new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(config.translationInfo.LoadString(Path.Combine("Data", "ExtraDialogue:" + key), translation, replacementStrings.kid1Name), new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName, key), new VoiceAudioOptions()); + } continue; } - if(key== "Farm_RobinWorking_ReadyTomorrow" || key== "Robin_NewConstruction_Festival"||key== "Robin_NewConstruction" || key== "Robin_Instant") + if (key == "Farm_RobinWorking_ReadyTomorrow" || key == "Robin_NewConstruction_Festival" || key == "Robin_NewConstruction" || key == "Robin_Instant") { string buildingsPath = Path.Combine(dataPath, config.translationInfo.getBuildingXNBForTranslation(translation)); var BuildingDict = ModHelper.Content.Load>(buildingsPath, ContentSource.GameContent); - foreach(KeyValuePair pair2 in BuildingDict) + foreach (KeyValuePair pair2 in BuildingDict) { - List cleanedDialogues = sanitizeDialogueFromDictionaries(config.translationInfo.LoadString(Path.Combine("Data", "ExtraDialogue:"+key),translation,pair2.Key),cue); - foreach (var clean_str in cleanedDialogues) { - cue.addDialogue(clean_str, new VoiceAudioOptions()); + List cleanedDialogues = sanitizeDialogueFromDictionaries(config.translationInfo.LoadString(Path.Combine("Data", "ExtraDialogue:" + key), translation, pair2.Key), cue); + foreach (var clean_str in cleanedDialogues) + { + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName, key))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName, key), out VoiceAudioOptions value); + cue.addDialogue(clean_str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(clean_str, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName, key), new VoiceAudioOptions()); + } } } continue; } - if (key == "Farm_RobinWorking1" || key== "Farm_RobinWorking2") + if (key == "Farm_RobinWorking1" || key == "Farm_RobinWorking2") { string buildingsPath = Path.Combine(dataPath, config.translationInfo.getBuildingXNBForTranslation(translation)); var BuildingDict = ModHelper.Content.Load>(buildingsPath, ContentSource.GameContent); @@ -1168,14 +1320,27 @@ namespace Vocalization { for (int i = 1; i <= 3; i++) { - cue.addDialogue(config.translationInfo.LoadString(Path.Combine("Data", "ExtraDialogue:" + key),translation, pair2.Key,i.ToString()), new VoiceAudioOptions()); + + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName, key))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName, key), out VoiceAudioOptions value); + cue.addDialogue(config.translationInfo.LoadString(Path.Combine("Data", "ExtraDialogue:" + key), translation, pair2.Key, i.ToString()), new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(config.translationInfo.LoadString(Path.Combine("Data", "ExtraDialogue:" + key), translation, pair2.Key, i.ToString()), new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName, key), new VoiceAudioOptions()); + } + + } } continue; } //Generate all possible tool combinations for clint. - if(key== "Clint_StillWorking") + if (key == "Clint_StillWorking") { List tools = new List(); tools.Add("Hoe"); @@ -1189,39 +1354,83 @@ namespace Vocalization levels.Add("Gold "); levels.Add("Iridium "); - foreach(var tool in tools) + foreach (var tool in tools) { - foreach(var lvl in levels) + foreach (var lvl in levels) { - cue.addDialogue(config.translationInfo.LoadString(Path.Combine("Data","ExtraDialogue:"+key),translation ,lvl+tool), new VoiceAudioOptions()); + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName, key))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName, key), out VoiceAudioOptions value); + cue.addDialogue(config.translationInfo.LoadString(Path.Combine("Data", "ExtraDialogue:" + key), translation, lvl + tool), new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(config.translationInfo.LoadString(Path.Combine("Data", "ExtraDialogue:" + key), translation, lvl + tool), new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName, key), new VoiceAudioOptions()); + } + } } continue; } - if(key== "Morris_WeekendGreeting_MembershipAvailable" || key=="Morris_FirstGreeting_MembershipAvailable") + if (key == "Morris_WeekendGreeting_MembershipAvailable" || key == "Morris_FirstGreeting_MembershipAvailable") { List cleanedDialogues = sanitizeDialogueFromDictionaries(rawDialogue, cue); - foreach(var dia in cleanedDialogues) + foreach (var dia in cleanedDialogues) { if (dia.Contains("{0}")) { string actual = dia.Replace("{0}", "5000"); - cue.addDialogue(actual, new VoiceAudioOptions()); + + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName, key))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName, key), out VoiceAudioOptions value); + cue.addDialogue(actual, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(actual, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName, key), new VoiceAudioOptions()); + } + } else { - cue.addDialogue(dia, new VoiceAudioOptions()); + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName, key))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName, key), out VoiceAudioOptions value); + cue.addDialogue(dia, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(dia, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName, key), new VoiceAudioOptions()); + } } continue; } continue; } + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName, key))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName, key), out VoiceAudioOptions value); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); - cue.addDialogue(str,new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty. } + else + { + cue.addDialogue(str, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName, key), new VoiceAudioOptions()); + } + + } + } } } @@ -1250,10 +1459,20 @@ namespace Vocalization //If the key contains the character's name. List cleanDialogues = new List(); - cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue,cue); + cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue, cue); foreach (var str in cleanDialogues) { - cue.addDialogue(str,new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty. + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName, key))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName, key), out VoiceAudioOptions value); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName, key), new VoiceAudioOptions()); + } } } @@ -1285,10 +1504,20 @@ namespace Vocalization //If the key contains the character's name. if (!key.Contains("Event")) continue; List cleanDialogues = new List(); - cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue,cue); + cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue, cue); foreach (var str in cleanDialogues) { - cue.addDialogue(str,new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty. + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName, key))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName, key), out VoiceAudioOptions value); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName, key), new VoiceAudioOptions()); + } } } } @@ -1302,10 +1531,20 @@ namespace Vocalization string rawDialogue = pair.Value; //If the key contains the character's name. List cleanDialogues = new List(); - cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue,cue); + cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue, cue); foreach (var str in cleanDialogues) { - cue.addDialogue(str,new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty. + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName, key))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName, key), out VoiceAudioOptions value); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName, key), new VoiceAudioOptions()); + } } } } @@ -1333,9 +1572,19 @@ namespace Vocalization string rawDialogue = pair.Value; //If the key contains the character's name. - string cleanDialogue = ""; - cleanDialogue = sanitizeDialogueFromMailDictionary(rawDialogue); - cue.addDialogue(cleanDialogue, new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty + string str = ""; + str = sanitizeDialogueFromMailDictionary(rawDialogue); + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName, key))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName, key), out VoiceAudioOptions value); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName, key), new VoiceAudioOptions()); + } } } } @@ -1344,7 +1593,7 @@ namespace Vocalization //Used to scrape Content/strings/Characters.yaml. else if (cue.name == "Characters") - { + { foreach (var fileName in cue.stringsFileNames) { ModMonitor.Log(" Scraping dialogue file: " + fileName, LogLevel.Info); @@ -1364,10 +1613,20 @@ namespace Vocalization //If the key contains the character's name. List cleanDialogues = new List(); - cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue,cue); + cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue, cue); foreach (var str in cleanDialogues) { - cue.addDialogue(str,new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty. + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName, key))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName, key), out VoiceAudioOptions value); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName, key), new VoiceAudioOptions()); + } } } @@ -1379,9 +1638,6 @@ namespace Vocalization //do nothing.....for now..... //FORTUNE TELLER DIALOGUE SCRAPE GOES HERE!!!! } - - - //!!!!!!!!!!!!If I ever want to make this moddable add a generic scrape here. } } @@ -1399,23 +1655,33 @@ namespace Vocalization string dialoguePath2 = Path.Combine(stringsPath, fileName); var DialogueDict = ModHelper.Content.Load>(dialoguePath2, ContentSource.GameContent); - //Scrape the whole dictionary looking for the character's name. - foreach (KeyValuePair pair in DialogueDict) + //Scrape the whole dictionary looking for the character's name. + foreach (KeyValuePair pair in DialogueDict) + { + //Get the key in the dictionary + string key = pair.Key; + string rawDialogue = pair.Value; + //If the key contains the character's name. + + List cleanDialogues = new List(); + cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue, cue); + foreach (var str in cleanDialogues) { - //Get the key in the dictionary - string key = pair.Key; - string rawDialogue = pair.Value; - //If the key contains the character's name. - - List cleanDialogues = new List(); - cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue,cue); - foreach (var str in cleanDialogues) + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName, key))) { - cue.addDialogue(str,new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty. - } + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName, key), out VoiceAudioOptions value); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + } + else + { + cue.addDialogue(str, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName, key), new VoiceAudioOptions()); + } } - continue; + + } + continue; } } @@ -1429,24 +1695,34 @@ namespace Vocalization string dialoguePath2 = Path.Combine(dataPath, fileName); var DialogueDict = ModHelper.Content.Load>(dialoguePath2, ContentSource.GameContent); - //Scrape the whole dictionary looking for the character's name. - foreach (KeyValuePair pair in DialogueDict) + //Scrape the whole dictionary looking for the character's name. + foreach (KeyValuePair pair in DialogueDict) + { + //Get the key in the dictionary + int key = pair.Key; + string rawDialogue = pair.Value; + //If the key contains the character's name. + + List cleanDialogues = new List(); + cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue, cue); + foreach (var str in cleanDialogues) { - //Get the key in the dictionary - int key = pair.Key; - string rawDialogue = pair.Value; - //If the key contains the character's name. - - List cleanDialogues = new List(); - cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue,cue); - foreach (var str in cleanDialogues) + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName, key.ToString()))) { - cue.addDialogue(str,new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty. - } + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName, key.ToString()), out VoiceAudioOptions value); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + } + else + { + cue.addDialogue(str, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName, key.ToString()), new VoiceAudioOptions()); + } } - continue; - + + } + continue; + } } @@ -1473,11 +1749,21 @@ namespace Vocalization //If the key contains the character's name. List cleanDialogue = new List(); - cleanDialogue = sanitizeDialogueFromDictionaries(rawDialogue,cue); + cleanDialogue = sanitizeDialogueFromDictionaries(rawDialogue, cue); - foreach (var v in cleanDialogue) + foreach (var str in cleanDialogue) { - cue.addDialogue(v, new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName, key))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName, key), out VoiceAudioOptions value); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName, key), new VoiceAudioOptions()); + } } } } @@ -1498,15 +1784,15 @@ namespace Vocalization continue; //If the file is not found for some reason... } var DialogueDict = ModHelper.Content.Load>(dialoguePath2, ContentSource.GameContent); - //Scrape the whole dictionary looking for the character's name. - foreach (KeyValuePair pair in DialogueDict) - { - //Get the key in the dictionary - string key = pair.Key.ToString(); - string rawDialogue = pair.Value; + //Scrape the whole dictionary looking for the character's name. + foreach (KeyValuePair pair in DialogueDict) + { + //Get the key in the dictionary + string key = pair.Key.ToString(); + string rawDialogue = pair.Value; //If the key contains the character's name. - int count = rawDialogue.Split('/').Length-1; + int count = rawDialogue.Split('/').Length - 1; string[] strippedRawQuestDialogue = new string[count]; List strippedFreshQuestDialogue = new List(); strippedRawQuestDialogue = rawDialogue.Split('/'); @@ -1518,22 +1804,32 @@ namespace Vocalization { strippedFreshQuestDialogue.Add(response); } - + List cleanDialogues = new List(); foreach (var dia in strippedFreshQuestDialogue) { - cleanDialogues = sanitizeDialogueFromDictionaries(dia,cue); + cleanDialogues = sanitizeDialogueFromDictionaries(dia, cue); foreach (var str in cleanDialogues) { - cue.addDialogue(str,new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty. + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName, key))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName, key), out VoiceAudioOptions value); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName, key), new VoiceAudioOptions()); + } } } - } - continue; - + } + continue; + } - } + } //ADD THIS TO THE ACTUAL NPC???? else if (cue.name == "NPCGiftTastes") @@ -1564,9 +1860,9 @@ namespace Vocalization string key = pair.Key; string rawDialogue = pair.Value; - //Check to see if I need to ignore this key in my dictionary I am scaping. + //Check to see if I need to ignore this key in my dictionary I am scaping. bool ignore = false; - foreach(var value in ignoreKeys) + foreach (var value in ignoreKeys) { if (key == value) { @@ -1577,9 +1873,9 @@ namespace Vocalization if (ignore) continue; - string[]strippedRawQuestDialogue = new string[20]; - ListstrippedFreshQuestDialogue = new List(); - strippedRawQuestDialogue = rawDialogue.Split(new string[] {"/" },StringSplitOptions.None); + string[] strippedRawQuestDialogue = new string[20]; + List strippedFreshQuestDialogue = new List(); + strippedRawQuestDialogue = rawDialogue.Split(new string[] { "/" }, StringSplitOptions.None); string prompt1 = strippedRawQuestDialogue.ElementAt(0); @@ -1597,10 +1893,20 @@ namespace Vocalization List cleanDialogues = new List(); foreach (var dia in strippedFreshQuestDialogue) { - cleanDialogues = sanitizeDialogueFromDictionaries(dia,cue); + cleanDialogues = sanitizeDialogueFromDictionaries(dia, cue); foreach (var str in cleanDialogues) { - cue.addDialogue(str,new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty. + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName, key))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName, key), out VoiceAudioOptions value); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName, key), new VoiceAudioOptions()); + } } } } @@ -1628,8 +1934,18 @@ namespace Vocalization //Get the key in the dictionary string key = pair.Key; string rawDialogue = pair.Value; - string cleanString = sanitizeDialogueFromSpeechBubblesDictionary(rawDialogue); - cue.addDialogue(cleanString, new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty. + string str = sanitizeDialogueFromSpeechBubblesDictionary(rawDialogue); + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName, key))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName, key), out VoiceAudioOptions value); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName, key), new VoiceAudioOptions()); + } } continue; } @@ -1640,30 +1956,200 @@ namespace Vocalization string voicePath = Path.Combine(audioPath, "VoiceFiles"); - string[] dirs = Directory.GetDirectories(Path.Combine(voicePath, translation)); - //Some additional scraping to put together better options for speech bubbles. - foreach (var v in dirs) + string[] dirs = Directory.GetDirectories(translation); + //Some additional scraping to put together better options for speech bubbles. + foreach (var v in dirs) + { + string name = Path.GetFileName(v); + + string fileName = "StringsFromCSFiles"; + string key = "NPC.cs.4068"; + string str = config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:NPC.cs.4068"), translation, (object)name); + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName, key))) { - string name = Path.GetFileName(v); - cue.addDialogue(config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:NPC.cs.4068"), translation, (object)name), new VoiceAudioOptions()); - cue.addDialogue(config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:NPC.cs.4065"),translation) + ", " + config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:NPC.cs.4066"), translation, (object)name), new VoiceAudioOptions()); - cue.addDialogue(config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:NPC.cs.4071"), translation, (object)name), new VoiceAudioOptions()); + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName, key), out VoiceAudioOptions value); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName, key), new VoiceAudioOptions()); } - - cue.addDialogue(config.translationInfo.LoadString(Path.Combine("Strings","StringsFromCSFiles:NPC.cs.4060"),translation), new VoiceAudioOptions()); - cue.addDialogue(config.translationInfo.LoadString(Path.Combine("Strings","StringsFromCSFiles:NPC.cs.4072"),translation), new VoiceAudioOptions()); + key = "NPC.cs.4065"; + str = config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:NPC.cs.4065"), translation) + ", " + config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:NPC.cs.4066"), translation, (object)name); + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName, key))) - cue.addDialogue(config.translationInfo.LoadString(Path.Combine("Strings","StringsFromCSFiles:NPC.cs.4063"),translation), new VoiceAudioOptions()); - cue.addDialogue(config.translationInfo.LoadString(Path.Combine("Strings","StringsFromCSFiles:NPC.cs.4064"),translation), new VoiceAudioOptions()); + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName, key), out VoiceAudioOptions value); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName, key), new VoiceAudioOptions()); + } + + key = "NPC.cs.4071"; + str = config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:NPC.cs.4071"), translation, (object)name); + + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName, key))) + + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName, key), out VoiceAudioOptions value); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName, key), new VoiceAudioOptions()); + } + } + + string fileName1 = "StringsFromCSFiles"; + string str1 = config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:NPC.cs.4060"), translation); + string key1 = "NPC.cs.4060"; + + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName1, key1))) + + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName1, key1), out VoiceAudioOptions value); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str1, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName1, key1), new VoiceAudioOptions()); + } + + str1 = config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:NPC.cs.4072"), translation); + key1 = "NPC.cs.4072"; + + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName1, key1))) + + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName1, key1), out VoiceAudioOptions value); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str1, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName1, key1), new VoiceAudioOptions()); + } + + key1 = "NPC.cs.4063"; + str1 = config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:NPC.cs.4063"), translation); + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName1, key1))) + + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName1, key1), out VoiceAudioOptions value); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str1, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName1, key1), new VoiceAudioOptions()); + } + + key1 = "NPC.cs.4064"; + str1 = config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:NPC.cs.4064"), translation); + + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName1, key1))) + + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName1, key1), out VoiceAudioOptions value); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str1, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName1, key1), new VoiceAudioOptions()); + } //cue.addDialogue("Hey, it's farmer, " + replacementStrings.farmerName,new VoiceAudioOptions()); - cue.addDialogue(config.translationInfo.LoadString(Path.Combine("Strings","StringsFromCSFiles:NPC.cs.4062"),translation), new VoiceAudioOptions()); - cue.addDialogue(config.translationInfo.LoadString(Path.Combine("Strings","StringsFromCSFiles:NPC.cs.4061"),translation), new VoiceAudioOptions()); - cue.addDialogue(config.translationInfo.LoadString(Path.Combine("Strings","StringsFromCSFiles:NPC.cs.4060"),translation), new VoiceAudioOptions()); - cue.addDialogue(config.translationInfo.LoadString(Path.Combine("Strings","StringsFromCSFiles:NPC.cs.4059"),translation), new VoiceAudioOptions()); - cue.addDialogue(config.translationInfo.LoadString(Path.Combine("Strings","StringsFromCSFiles:NPC.cs.4058"),translation), new VoiceAudioOptions()); + key1 = "NPC.cs.4062"; + str1 = config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:NPC.cs.4062"), translation); + + + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName1, key1))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName1, key1), out VoiceAudioOptions value); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str1, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName1, key1), new VoiceAudioOptions()); + } + + key1 = "NPC.cs.4061"; + str1 = config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:NPC.cs.4061"), translation); + + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName1, key1))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName1, key1), out VoiceAudioOptions value); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str1, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName1, key1), new VoiceAudioOptions()); + } + + key1 = "NPC.cs.4060"; + str1 = config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:NPC.cs.4060"), translation); + + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName1, key1))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName1, key1), out VoiceAudioOptions value); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str1, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName1, key1), new VoiceAudioOptions()); + } + + key1 = "NPC.cs.4059"; + str1 = config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:NPC.cs.4059"), translation); + + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName1, key1))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName1, key1), out VoiceAudioOptions value); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str1, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName1, key1), new VoiceAudioOptions()); + } + + key1 = "NPC.cs.4058"; + str1 = config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:NPC.cs.4058"), translation); + + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName1, key1))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName1, key1), out VoiceAudioOptions value); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str1, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName1, key1), new VoiceAudioOptions()); + } } @@ -1701,7 +2187,17 @@ namespace Vocalization { try { - cue.dialogueCues.Add(cleanSentence, new VoiceAudioOptions()); + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, config.translationInfo.getXNBForTranslation("Temp", translation), pair.Key))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, config.translationInfo.getXNBForTranslation("Temp", translation), pair.Key), out VoiceAudioOptions value); + cue.addDialogue(cleanSentence, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(cleanSentence, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, config.translationInfo.getXNBForTranslation("Temp", translation), pair.Key), new VoiceAudioOptions()); + } } catch (Exception err) { @@ -1728,7 +2224,17 @@ namespace Vocalization { try { - cue.dialogueCues.Add(cleanSentence, new VoiceAudioOptions()); + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, config.translationInfo.getXNBForTranslation("Temp", translation), pair.Key))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, config.translationInfo.getXNBForTranslation("Temp", translation), pair.Key), out VoiceAudioOptions value); + cue.addDialogue(cleanSentence, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(cleanSentence, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, config.translationInfo.getXNBForTranslation("Temp", translation), pair.Key), new VoiceAudioOptions()); + } } catch (Exception err) { @@ -1754,7 +2260,17 @@ namespace Vocalization { try { - cue.dialogueCues.Add(cleanSentence, new VoiceAudioOptions()); + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, config.translationInfo.getXNBForTranslation("Temp", translation), pair.Key))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, config.translationInfo.getXNBForTranslation("Temp", translation), pair.Key), out VoiceAudioOptions value); + cue.addDialogue(cleanSentence, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(cleanSentence, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, config.translationInfo.getXNBForTranslation("Temp", translation), pair.Key), new VoiceAudioOptions()); + } } catch (Exception err) { @@ -1787,7 +2303,17 @@ namespace Vocalization { try { - cue.dialogueCues.Add(cleanSentence, new VoiceAudioOptions()); + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, config.translationInfo.getXNBForTranslation("Temp", translation), pair.Key))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, config.translationInfo.getXNBForTranslation("Temp", translation), pair.Key), out VoiceAudioOptions value); + cue.addDialogue(cleanSentence, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(cleanSentence, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, config.translationInfo.getXNBForTranslation("Temp", translation), pair.Key), new VoiceAudioOptions()); + } } catch (Exception err) { @@ -1811,10 +2337,10 @@ namespace Vocalization if (!String.IsNullOrEmpty(fileName)) { string dialoguePath2 = Path.Combine(dialoguePath, fileName); - string root=Game1.content.RootDirectory;///////USE THIS TO CHECK FOR EXISTENCE!!!!! - if (!File.Exists(Path.Combine(root,dialoguePath2))) + string root = Game1.content.RootDirectory;///////USE THIS TO CHECK FOR EXISTENCE!!!!! + if (!File.Exists(Path.Combine(root, dialoguePath2))) { - ModMonitor.Log("Dialogue file not found for:" + fileName+". This might not necessarily be a mistake just a safety check."); + ModMonitor.Log("Dialogue file not found for:" + fileName + ". This might not necessarily be a mistake just a safety check."); continue; //If the file is not found for some reason... } var DialogueDict = ModHelper.Content.Load>(dialoguePath2, ContentSource.GameContent); @@ -1832,10 +2358,20 @@ namespace Vocalization if (key.Contains(cue.name)) { List cleanDialogues = new List(); - cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue,cue); + cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue, cue); foreach (var str in cleanDialogues) { - cue.addDialogue(str,new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty. + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName, key))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName, key), out VoiceAudioOptions value); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName, key), new VoiceAudioOptions()); + } } } } @@ -1843,7 +2379,7 @@ namespace Vocalization } //Check for just my generic file - if (fileName.Contains("MarriageDialogue") && !fileName.Contains("MarriageDialogue"+cue.name)) + if (fileName.Contains("MarriageDialogue") && !fileName.Contains("MarriageDialogue" + cue.name)) { //Scrape the whole dictionary looking for other character's names to ignore. if (!replacementStrings.spouseNames.Contains(cue.name)) continue; @@ -1868,10 +2404,20 @@ namespace Vocalization if (key.Contains(cue.name)) { List cleanDialogues = new List(); - cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue,cue); + cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue, cue); foreach (var str in cleanDialogues) { - cue.addDialogue(str,new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty. + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName, key))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName, key), out VoiceAudioOptions value); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName, key), new VoiceAudioOptions()); + } } } } @@ -1880,7 +2426,7 @@ namespace Vocalization } //Check for character specific marriage dialogue - if (fileName.Contains("MarriageDialogue"+cue.name)) + if (fileName.Contains("MarriageDialogue" + cue.name)) { //Scrape the whole dictionary looking for other character's names to ignore. if (!replacementStrings.spouseNames.Contains(cue.name)) continue; @@ -1893,22 +2439,43 @@ namespace Vocalization if (key.Contains(cue.name)) { List cleanDialogues = new List(); - cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue,cue); + cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue, cue); foreach (var str in cleanDialogues) { - cue.addDialogue(str,new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty. + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName, key))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName, key), out VoiceAudioOptions value); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName, key), new VoiceAudioOptions()); + } } } } } foreach (KeyValuePair pair in DialogueDict) { + string key = pair.Key; string rawDialogue = pair.Value; List cleanDialogues = new List(); - cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue,cue); + cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue, cue); foreach (var str in cleanDialogues) { - cue.addDialogue(str,new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty. + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName, key))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName, key), out VoiceAudioOptions value); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName, key), new VoiceAudioOptions()); + } } } } @@ -1931,13 +2498,23 @@ namespace Vocalization foreach (KeyValuePair pair in DialogueDict) { string key = pair.Key; - if (key != cue.name && key!=cue.name+"_spouse") continue; + if (key != cue.name && key != cue.name + "_spouse") continue; string rawDialogue = pair.Value; List cleanDialogues = new List(); cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue, cue); foreach (var str in cleanDialogues) { - cue.addDialogue(str, new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty. + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName, key))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName, key), out VoiceAudioOptions value); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName, key), new VoiceAudioOptions()); + } } } } @@ -1973,7 +2550,17 @@ namespace Vocalization cleanDialogues = sanitizeDialogueFromDictionaries(line, cue); foreach (var str in cleanDialogues) { - cue.addDialogue(str, new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty. + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName, key))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName, key), out VoiceAudioOptions value); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName, key), new VoiceAudioOptions()); + } } } } @@ -2009,10 +2596,20 @@ namespace Vocalization if (key.Contains(cue.name)) { List cleanDialogues = new List(); - cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue,cue); + cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue, cue); foreach (var str in cleanDialogues) { - cue.addDialogue(str,new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty. + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName, key))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName, key), out VoiceAudioOptions value); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName, key), new VoiceAudioOptions()); + } } } } @@ -2063,7 +2660,7 @@ namespace Vocalization string rawDialogue = pair.Value; //This helps eliminate the fortune teller dialogue from more specific npcs. - if(rawDialogue.Contains("{0}") && !ignoreKeys.Contains(key)) + if (rawDialogue.Contains("{0}") && !ignoreKeys.Contains(key)) { continue; } @@ -2072,39 +2669,348 @@ namespace Vocalization if (key.Contains("NPC")) { List cleanDialogues = new List(); - cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue,cue); - foreach (var str in cleanDialogues) + cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue, cue); + + foreach(var clean in cleanDialogues) { - cue.addDialogue(str,new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty. + string[] bday = clean.Split('/'); + + foreach (var str in bday) + { + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName, key))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName, key), out VoiceAudioOptions value); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName, key), new VoiceAudioOptions()); + } + } } } } //Scrape dialogue more specifically and replace some generic {0}'s and {1}'s - cue.addDialogue(config.translationInfo.LoadString(Path.Combine("Strings","StringsFromCSFiles:NPC.cs.3955"), translation, (object)cue.name), new VoiceAudioOptions()); - cue.addDialogue(config.translationInfo.LoadString(Path.Combine("Strings","StringsFromCSFiles:NPC.cs.3969"), translation, (object)cue.name), new VoiceAudioOptions()); - cue.addDialogue(config.translationInfo.LoadString(Path.Combine("Strings","StringsFromCSFiles:NPC.cs.3981"), translation, (object)cue.name), new VoiceAudioOptions()); - cue.addDialogue(config.translationInfo.LoadString(Path.Combine("Strings","StringsFromCSFiles:NPC.cs.3987"), translation, (object)cue.name,"2"),new VoiceAudioOptions()); - cue.addDialogue(config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:NPC.cs.4066"), translation, (object)replacementStrings.farmerName), new VoiceAudioOptions()); - cue.addDialogue(config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:NPC.cs.4068"), translation, (object)replacementStrings.farmerName), new VoiceAudioOptions()); - cue.addDialogue(config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:NPC.cs.4071"), translation, (object)replacementStrings.farmerName), new VoiceAudioOptions()); - cue.addDialogue(sanitizeDialogueFromDictionaries(config.translationInfo.LoadString(Path.Combine("Strings","StringsFromCSFiles:NPC.cs.4440"), translation, (object)replacementStrings.farmerName),cue).ElementAt(0), new VoiceAudioOptions()); - cue.addDialogue(sanitizeDialogueFromDictionaries(config.translationInfo.LoadString(Path.Combine("Strings","StringsFromCSFiles:NPC.cs.4441"), translation, (object)replacementStrings.farmerName), cue).ElementAt(0), new VoiceAudioOptions()); - cue.addDialogue(sanitizeDialogueFromDictionaries(config.translationInfo.LoadString(Path.Combine("Strings","StringsFromCSFiles:NPC.cs.4444"), translation, (object)replacementStrings.farmerName), cue).ElementAt(0), new VoiceAudioOptions()); - cue.addDialogue(sanitizeDialogueFromDictionaries(config.translationInfo.LoadString(Path.Combine("Strings","StringsFromCSFiles:NPC.cs.4445"), translation, (object)replacementStrings.farmerName), cue).ElementAt(0), new VoiceAudioOptions()); - cue.addDialogue(sanitizeDialogueFromDictionaries(config.translationInfo.LoadString(Path.Combine("Strings","StringsFromCSFiles:NPC.cs.4447"), translation, (object)replacementStrings.farmerName), cue).ElementAt(0), new VoiceAudioOptions()); - cue.addDialogue(sanitizeDialogueFromDictionaries(config.translationInfo.LoadString(Path.Combine("Strings","StringsFromCSFiles:NPC.cs.4448"), translation, (object)replacementStrings.farmerName), cue).ElementAt(0), new VoiceAudioOptions()); - cue.addDialogue(sanitizeDialogueFromDictionaries(config.translationInfo.LoadString(Path.Combine("Strings","StringsFromCSFiles:NPC.cs.4463"), translation, (object)replacementStrings.petName), cue).ElementAt(0), new VoiceAudioOptions()); - cue.addDialogue(sanitizeDialogueFromDictionaries(config.translationInfo.LoadString(Path.Combine("Strings","StringsFromCSFiles:NPC.cs.4465"), translation, (object)replacementStrings.farmerName), cue).ElementAt(0), new VoiceAudioOptions()); - cue.addDialogue(sanitizeDialogueFromDictionaries(config.translationInfo.LoadString(Path.Combine("Strings","StringsFromCSFiles:NPC.cs.4466"), translation, (object)replacementStrings.farmerName), cue).ElementAt(0), new VoiceAudioOptions()); - cue.addDialogue(sanitizeDialogueFromDictionaries(config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:NPC.cs.4486"), translation, (object)replacementStrings.farmerName), cue).ElementAt(0), new VoiceAudioOptions()); + + + string fileName1 = "StringsFromCSFiles"; + + string key1 = "NPC.cs.3955"; + string str1 = config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:NPC.cs.3955"), translation, (object)cue.name); + + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName1, key1))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName, key1), out VoiceAudioOptions value); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str1, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName1, key1), new VoiceAudioOptions()); + } + + key1 = "NPC.cs.3955"; + str1 = config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:NPC.cs.3969"), translation, (object)cue.name); + + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName1, key1))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName1, key1), out VoiceAudioOptions value); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str1, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName1, key1), new VoiceAudioOptions()); + } + + key1 = "NPC.cs.3981"; + str1 = config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:NPC.cs.3981"), translation, (object)cue.name); + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName1, key1))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName1, key1), out VoiceAudioOptions value); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str1, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName1, key1), new VoiceAudioOptions()); + } + + key1 = "NPC.cs.3987"; + str1 = config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:NPC.cs.3987"), translation, (object)cue.name, "2"); + + + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName1, key1))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName1, key1), out VoiceAudioOptions value); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str1, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName1, key1), new VoiceAudioOptions()); + } + + key1 = "NPC.cs.4066"; + str1 = config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:NPC.cs.4066"), translation, (object)replacementStrings.farmerName); + + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName1, key1))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName1, key1), out VoiceAudioOptions value); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str1, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName1, key1), new VoiceAudioOptions()); + } + + + key1 = "NPC.cs.4068"; + str1 = config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:NPC.cs.4068"), translation, (object)replacementStrings.farmerName); + + + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName1, key1))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName1, key1), out VoiceAudioOptions value); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str1, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName1, key1), new VoiceAudioOptions()); + } + + + key1 = "NPC.cs.4071"; + str1 = config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:NPC.cs.4071"), translation, (object)replacementStrings.farmerName); + + + + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName1, key1))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName1, key1), out VoiceAudioOptions value); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str1, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName1, key1), new VoiceAudioOptions()); + } + + key1 = "NPC.cs.4440"; + str1 = sanitizeDialogueFromDictionaries(config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:NPC.cs.4440"), translation, (object)replacementStrings.farmerName), cue).ElementAt(0); + + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName1, key1))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName1, key1), out VoiceAudioOptions value); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str1, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName1, key1), new VoiceAudioOptions()); + } + + key1 = "NPC.cs.4441"; + str1 = sanitizeDialogueFromDictionaries(config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:NPC.cs.4441"), translation, (object)replacementStrings.farmerName), cue).ElementAt(0); + + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName1, key1))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName1, key1), out VoiceAudioOptions value); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str1, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName1, key1), new VoiceAudioOptions()); + } + + key1 = "NPC.cs.4444"; + str1 = sanitizeDialogueFromDictionaries(config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:NPC.cs.4444"), translation, (object)replacementStrings.farmerName), cue).ElementAt(0); + + + //cue.addDialogue(sanitizeDialogueFromDictionaries(config.translationInfo.LoadString(Path.Combine("Strings","StringsFromCSFiles:NPC.cs.4444"), translation, (object)replacementStrings.farmerName), cue).ElementAt(0), new VoiceAudioOptions()); + + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName1, key1))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName1, key1), out VoiceAudioOptions value); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str1, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName1, key1), new VoiceAudioOptions()); + } + key1 = "NPC.cs.4445"; + str1 = sanitizeDialogueFromDictionaries(config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:NPC.cs.4445"), translation, (object)replacementStrings.farmerName), cue).ElementAt(0); + + + // cue.addDialogue(sanitizeDialogueFromDictionaries(config.translationInfo.LoadString(Path.Combine("Strings","StringsFromCSFiles:NPC.cs.4445"), translation, (object)replacementStrings.farmerName), cue).ElementAt(0), new VoiceAudioOptions()); + + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName1, key1))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName1, key1), out VoiceAudioOptions value); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str1, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName1, key1), new VoiceAudioOptions()); + } + + key1 = "NPC.cs.4447"; + str1 = sanitizeDialogueFromDictionaries(config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:NPC.cs.4447"), translation, (object)replacementStrings.farmerName), cue).ElementAt(0); + + + //cue.addDialogue(sanitizeDialogueFromDictionaries(config.translationInfo.LoadString(Path.Combine("Strings","StringsFromCSFiles:NPC.cs.4447"), translation, (object)replacementStrings.farmerName), cue).ElementAt(0), new VoiceAudioOptions()); + + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName1, key1))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName1, key1), out VoiceAudioOptions value); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str1, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName1, key1), new VoiceAudioOptions()); + } + + key1 = "NPC.cs.4448"; + str1 = sanitizeDialogueFromDictionaries(config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:NPC.cs.4448"), translation, (object)replacementStrings.farmerName), cue).ElementAt(0); + + + //cue.addDialogue(sanitizeDialogueFromDictionaries(config.translationInfo.LoadString(Path.Combine("Strings","StringsFromCSFiles:NPC.cs.4448"), translation, (object)replacementStrings.farmerName), cue).ElementAt(0), new VoiceAudioOptions()); + + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName1, key1))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName1, key1), out VoiceAudioOptions value); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str1, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName1, key1), new VoiceAudioOptions()); + } + + key1 = "NPC.cs.4463"; + str1 = sanitizeDialogueFromDictionaries(config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:NPC.cs.4463"), translation, (object)replacementStrings.petName), cue).ElementAt(0); + + + //cue.addDialogue(sanitizeDialogueFromDictionaries(config.translationInfo.LoadString(Path.Combine("Strings","StringsFromCSFiles:NPC.cs.4463"), translation, (object)replacementStrings.petName), cue).ElementAt(0), new VoiceAudioOptions()); + + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName1, key1))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName1, key1), out VoiceAudioOptions value); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str1, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName1, key1), new VoiceAudioOptions()); + } + + key1 = "NPC.cs.4465"; + str1 = sanitizeDialogueFromDictionaries(config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:NPC.cs.4465"), translation, (object)replacementStrings.farmerName), cue).ElementAt(0); + + //cue.addDialogue(sanitizeDialogueFromDictionaries(config.translationInfo.LoadString(Path.Combine("Strings","StringsFromCSFiles:NPC.cs.4465"), translation, (object)replacementStrings.farmerName), cue).ElementAt(0), new VoiceAudioOptions()); + + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName1, key1))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName1, key1), out VoiceAudioOptions value); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str1, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName1, key1), new VoiceAudioOptions()); + } + + key1 = "NPC.cs.4466"; + str1 = sanitizeDialogueFromDictionaries(config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:NPC.cs.4466"), translation, (object)replacementStrings.farmerName), cue).ElementAt(0); + + //cue.addDialogue(sanitizeDialogueFromDictionaries(config.translationInfo.LoadString(Path.Combine("Strings","StringsFromCSFiles:NPC.cs.4466"), translation, (object)replacementStrings.farmerName), cue).ElementAt(0), new VoiceAudioOptions()); + + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName1, key1))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName1, key1), out VoiceAudioOptions value); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str1, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName1, key1), new VoiceAudioOptions()); + } + + key1 = "NPC.cs.4486"; + str1 = sanitizeDialogueFromDictionaries(config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:NPC.cs.4486"), translation, (object)replacementStrings.farmerName), cue).ElementAt(0); + + //cue.addDialogue(sanitizeDialogueFromDictionaries(config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:NPC.cs.4486"), translation, (object)replacementStrings.farmerName), cue).ElementAt(0), new VoiceAudioOptions()); + + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName1, key1))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName1, key1), out VoiceAudioOptions value); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str1, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName1, key1), new VoiceAudioOptions()); + } for (int i = 4507; i <= 4523; i++) { - if(i==20 || i == 21) + if (i == 20 || i == 21) { continue; } - cue.addDialogue(sanitizeDialogueFromDictionaries(config.translationInfo.LoadString(Path.Combine("Strings","StringsFromCSFiles:NPC.cs.4465"), translation,(object)config.translationInfo.LoadString(Path.Combine("Strings","StringsFromCSFiles:NPC.cs.")+i.ToString(),translation)), cue).ElementAt(0), new VoiceAudioOptions()); - cue.addDialogue(sanitizeDialogueFromDictionaries(config.translationInfo.LoadString(Path.Combine("Strings","StringsFromCSFiles:NPC.cs.4466"), translation, (object)config.translationInfo.LoadString(Path.Combine("Strings","StringsFromCSFiles:NPC.cs.") + i.ToString(),translation)), cue).ElementAt(0), new VoiceAudioOptions()); + + key1 = "NPC.cs.4465"; + str1 = sanitizeDialogueFromDictionaries(config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:NPC.cs.4465"), translation, (object)config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:NPC.cs.") + i.ToString(), translation)), cue).ElementAt(0); + + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName1, key1))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName1, key1), out VoiceAudioOptions value); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str1, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName1, key1), new VoiceAudioOptions()); + } + key1 = "NPC.cs.4466"; + str1 = sanitizeDialogueFromDictionaries(config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:NPC.cs.4466"), translation, (object)config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:NPC.cs.") + i.ToString(), translation)), cue).ElementAt(0); + + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName1, key1))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName1, key1), out VoiceAudioOptions value); + cue.addDialogue(str1, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str1, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName1, key1), new VoiceAudioOptions()); + } } @@ -2116,21 +3022,37 @@ namespace Vocalization string audioPath = Path.Combine(contentPath, "Audio"); string voicePath = Path.Combine(audioPath, "VoiceFiles"); - string[] dirs = Directory.GetDirectories(Path.Combine(voicePath, translation)); - //Some additional scraping to put together better options for speech bubbles. - foreach (var v in dirs) + string[] dirs = Directory.GetDirectories(translation); + //Some additional scraping to put together better options for speech bubbles. + foreach (var v in dirs) + { + + string name = Path.GetFileName(v); + string key = "NPC.cs.3985"; + + string str2 = sanitizeDialogueFromDictionaries(config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:NPC.cs.3985"), translation, (object)name), cue).ElementAt(0); + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName, key))) { - string name = Path.GetFileName(v); - cue.addDialogue(sanitizeDialogueFromDictionaries(config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:NPC.cs.3985"), translation, (object)name), cue).ElementAt(0), new VoiceAudioOptions()); + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName, key), out VoiceAudioOptions value); + cue.addDialogue(str2, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + } + else + { + cue.addDialogue(str2, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName, key), new VoiceAudioOptions()); + } + } + + continue; } if (fileName.Contains(cue.name)) { - dialoguePath2 = Path.Combine(stringsPath,"schedules", fileName); + dialoguePath2 = Path.Combine(stringsPath, "schedules", fileName); root = Game1.content.RootDirectory;///////USE THIS TO CHECK FOR EXISTENCE!!!!! if (!File.Exists(Path.Combine(root, dialoguePath2))) { @@ -2145,13 +3067,23 @@ namespace Vocalization string key = pair.Key; string rawDialogue = pair.Value; //If the key contains the character's name. - List cleanDialogues = new List(); - cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue,cue); - foreach (var str in cleanDialogues) + List cleanDialogues = new List(); + cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue, cue); + foreach (var str in cleanDialogues) + { + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName, key))) { - cue.addDialogue(str,new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty. + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName, key), out VoiceAudioOptions value); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + } - + else + { + cue.addDialogue(str, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName, key), new VoiceAudioOptions()); + } + } + } continue; } @@ -2159,53 +3091,75 @@ namespace Vocalization //LOad item dictionary, pass in item and npc, sanitize the output string using the sanitizationDictionary function, and add in the cue! - Dictionary objDict = Game1.content.Load>(Path.Combine("Data", config.translationInfo.getXNBForTranslation("ObjectInformation",translation))); - ModMonitor.Log("LOAD THE OBJECT INFO: ", LogLevel.Alert); - foreach(KeyValuePair pair in objDict) + Dictionary objDict = Game1.content.Load>(Path.Combine("Data", config.translationInfo.getXNBForTranslation("ObjectInformation", translation))); + //ModMonitor.Log("LOAD THE OBJECT INFO: ", LogLevel.Alert); + foreach (KeyValuePair pair in objDict) { - for(int i=0; i<=3; i++) { - StardewValley.Object obj = new StardewValley.Object(pair.Key,1,false,-1,i); + for (int i = 0; i <= 3; i++) + { + StardewValley.Object obj = new StardewValley.Object(pair.Key, 1, false, -1, i); - string[] strArray = config.translationInfo.LoadString(Path.Combine("Strings","Lexicon:GenericPlayerTerm"),translation).Split('^'); + string[] strArray = config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:GenericPlayerTerm"), translation).Split('^'); string str2 = strArray[0]; if (strArray.Length > 1 && !(bool)((NetFieldBase)Game1.player.isMale)) str2 = strArray[1]; string str3 = Game1.player.Name; - List rawScrape = getPurchasedItemDialogueForNPC(obj, cue.name,str3,translation); + List rawScrape = getPurchasedItemDialogueForNPC(obj, cue.name, str3, translation); foreach (string raw in rawScrape) { List cleanDialogues = sanitizeDialogueFromDictionaries(raw, cue); - foreach (var dia in cleanDialogues) + foreach (var str in cleanDialogues) { - cue.addDialogue(dia, new VoiceAudioOptions()); + string fileName = config.translationInfo.getXNBForTranslation("ObjectInformation", translation); + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, fileName, pair.Key.ToString()))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, fileName, pair.Key.ToString()), out VoiceAudioOptions value); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, fileName, pair.Key.ToString()), new VoiceAudioOptions()); + } } } str3 = str2; - List rawScrape2 = getPurchasedItemDialogueForNPC(obj, cue.name, str3,translation); + List rawScrape2 = getPurchasedItemDialogueForNPC(obj, cue.name, str3, translation); foreach (string raw in rawScrape2) { List cleanDialogues2 = sanitizeDialogueFromDictionaries(raw, cue); - foreach (var dia in cleanDialogues2) + foreach (var str in cleanDialogues2) { - cue.addDialogue(dia, new VoiceAudioOptions()); + if (AudioCues.getWavFileReferences(translation).ContainsKey(AudioCues.generateKey(translation, cue.name, "StringsFromCSFiles", pair.Key.ToString()))) + { + AudioCues.getWavFileReferences(translation).TryGetValue(AudioCues.generateKey(translation, cue.name, "StringsFromCSFiles", pair.Key.ToString()), out VoiceAudioOptions value); + cue.addDialogue(str, new VoiceAudioOptions(value.simple, value.full, value.heartEvents, value.simpleAndHeartEvents)); + + } + else + { + cue.addDialogue(str, new VoiceAudioOptions()); + AudioCues.addWavReference(AudioCues.generateKey(translation, cue.name, "StringsFromCSFiles", pair.Key.ToString()), new VoiceAudioOptions()); + } } } } } } - ModHelper.WriteJsonFile(path,cue); + ModHelper.WriteJsonFile(path, cue); //DialogueCues.Add(cue.name, cue); } public static List getEventSpeakerLines(string rawDialogue, string speakerName) { - string[] dialogueSplit= rawDialogue.Split('/'); + string[] dialogueSplit = rawDialogue.Split('/'); List speakingData = new List(); - foreach(var dia in dialogueSplit) + foreach (var dia in dialogueSplit) { //ModMonitor.Log(dia); if (!dia.Contains("speak") && !dia.Contains("textAboveHead")) continue; @@ -2228,7 +3182,7 @@ namespace Vocalization /// /// /// - public static List getPurchasedItemDialogueForNPC(StardewValley.Object i, string npcName, string str3,string translation) + public static List getPurchasedItemDialogueForNPC(StardewValley.Object i, string npcName, string str3, string translation) { NPC n = Game1.getCharacterFromName(npcName); if (n == null) return new List(); @@ -2238,7 +3192,7 @@ namespace Vocalization str3 = Game1.player.Name; string str4 = LocalizedContentManager.CurrentLanguageCode == LocalizedContentManager.LanguageCode.en ? Lexicon.getProperArticleForWord(i.name) : ""; if ((i.Category == -4 || i.Category == -75 || i.Category == -79) && Game1.random.NextDouble() < 0.5) - str4 = config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:SeedShop.cs.9701"),translation); + str4 = config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:SeedShop.cs.9701"), translation); for (int v = 0; v <= 5; v++) { @@ -2249,7 +3203,7 @@ namespace Vocalization case 0: if (i.quality.Value == 1) { - foreach (string str in Vocabulary.getRandomDeliciousAdjectives(translation,n)) + foreach (string str in Vocabulary.getRandomDeliciousAdjectives(translation, n)) { string str19 = config.translationInfo.LoadString(Path.Combine("Data", "ExtraDialogue:PurchasedItem_1_QualityHigh"), translation, (object)str3, (object)str4, (object)i.DisplayName, (object)str); dialogueReturn.Add(str19); @@ -2258,7 +3212,7 @@ namespace Vocalization } if (i.quality.Value == 0) { - foreach (string str in Vocabulary.getRandomNegativeFoodAdjectives(translation,n)) + foreach (string str in Vocabulary.getRandomNegativeFoodAdjectives(translation, n)) { string str18 = config.translationInfo.LoadString(Path.Combine("Data", "ExtraDialogue:PurchasedItem_1_QualityLow"), translation, (object)str3, (object)str4, (object)i.DisplayName, (object)str); dialogueReturn.Add(str18); @@ -2274,13 +3228,14 @@ namespace Vocalization { if (i.quality.Value != 2) { - foreach (var word1 in Vocabulary.getRandomNegativeFoodAdjectives(translation,n)) + foreach (var word1 in Vocabulary.getRandomNegativeFoodAdjectives(translation, n)) { - foreach (string word2 in Vocabulary.getRandomNegativeItemSlanderNouns(translation)) { + foreach (string word2 in Vocabulary.getRandomNegativeItemSlanderNouns(translation)) + { string str17 = config.translationInfo.LoadString(Path.Combine("Data", "ExtraDialogue:PurchasedItem_3_QualityLow_Rude"), translation, (object)str3, (object)str4, (object)i.DisplayName, (object)(i.salePrice() / 2), (object)word1, (object)word2); dialogueReturn.Add(str17); + } } - } break; } foreach (string word1 in Vocabulary.getRandomSlightlyPositiveAdjectivesForEdibleNoun(translation)) @@ -2318,7 +3273,8 @@ namespace Vocalization break; } } - if (n.Age == 1) { + if (n.Age == 1) + { string str16 = config.translationInfo.LoadString(Path.Combine("Data", "ExtraDialogue:PurchasedItem_Teen"), translation, (object)str3, (object)str4, (object)i.DisplayName); dialogueReturn.Add(str16); } @@ -2349,19 +3305,20 @@ namespace Vocalization dialogueReturn.Add(str12); } } - else { + else + { str1 = config.translationInfo.LoadString(Path.Combine("Data", "ExtraDialogue:PurchasedItem_Abigail_QualityHigh"), translation, (object)str3, (object)str4, (object)i.DisplayName); } } - - if (name == "Haley") - str1 = config.translationInfo.LoadString(Path.Combine("Data","ExtraDialogue:PurchasedItem_Haley"), translation, (object)str3, (object)str4, (object)i.DisplayName); - if (name == "Elliott") - str1 = config.translationInfo.LoadString(Path.Combine("Data","ExtraDialogue:PurchasedItem_Elliott"), translation, (object)str3, (object)str4, (object)i.DisplayName); - if (name == "Leah") - str1 = config.translationInfo.LoadString(Path.Combine("Data","ExtraDialogue:PurchasedItem_Leah"), translation, (object)str3, (object)str4, (object)i.DisplayName); + + if (name == "Haley") + str1 = config.translationInfo.LoadString(Path.Combine("Data", "ExtraDialogue:PurchasedItem_Haley"), translation, (object)str3, (object)str4, (object)i.DisplayName); + if (name == "Elliott") + str1 = config.translationInfo.LoadString(Path.Combine("Data", "ExtraDialogue:PurchasedItem_Elliott"), translation, (object)str3, (object)str4, (object)i.DisplayName); + if (name == "Leah") + str1 = config.translationInfo.LoadString(Path.Combine("Data", "ExtraDialogue:PurchasedItem_Leah"), translation, (object)str3, (object)str4, (object)i.DisplayName); if (str1 != "") { dialogueReturn.Add(str1); @@ -2375,7 +3332,7 @@ namespace Vocalization /// /// /// - public static string sanitizeDialogueInGame(string dialogue) + public static string sanitizeDialogueInGame(string dialogue) { if (dialogue.Contains(Game1.player.Name)) { @@ -2386,28 +3343,28 @@ namespace Vocalization { if (dialogue.Contains(Game1.player.getPetName())) { - dialogue=dialogue.Replace(Game1.player.getPetName(), replacementStrings.petName); + dialogue = dialogue.Replace(Game1.player.getPetName(), replacementStrings.petName); } } if (dialogue.Contains(Game1.player.farmName.Value)) { - dialogue=dialogue.Replace(Game1.player.farmName.Value, replacementStrings.farmName); + dialogue = dialogue.Replace(Game1.player.farmName.Value, replacementStrings.farmName); } if (dialogue.Contains(Game1.player.favoriteThing.Value)) { - dialogue=dialogue.Replace(Game1.player.favoriteThing.Value, replacementStrings.favoriteThing); + dialogue = dialogue.Replace(Game1.player.favoriteThing.Value, replacementStrings.favoriteThing); } if (dialogue.Contains(Game1.samBandName)) { - dialogue=dialogue.Replace(Game1.samBandName, replacementStrings.bandName); + dialogue = dialogue.Replace(Game1.samBandName, replacementStrings.bandName); } if (dialogue.Contains(Game1.elliottBookName)) { - dialogue=dialogue.Replace(Game1.elliottBookName, replacementStrings.bookName); + dialogue = dialogue.Replace(Game1.elliottBookName, replacementStrings.bookName); } //Sanitize children names from the dialogue. @@ -2439,7 +3396,7 @@ namespace Vocalization /// /// /// - public static List sanitizeDialogueFromDictionaries(string dialogue,CharacterVoiceCue cue) + public static List sanitizeDialogueFromDictionaries(string dialogue, CharacterVoiceCue cue) { List possibleDialogues = new List(); @@ -2501,7 +3458,7 @@ namespace Vocalization //This is probably the worst possible way to do this but I don't have too much a choice. - for (int i=0; i<=100; i++) + for (int i = 0; i <= 100; i++) { string combine = ""; if (i == 1) continue; @@ -2546,12 +3503,12 @@ namespace Vocalization List finalSplit = new List(); //split across | symbol - foreach(var dia in dialogueSplits1) + foreach (var dia in dialogueSplits1) { if (dia.Contains("|")) //If I can split my string do so and add all the split strings into my orSplit list. { List tempSplits = dia.Split('|').ToList(); - foreach(var v in tempSplits) + foreach (var v in tempSplits) { orSplit.Add(v); } @@ -2562,7 +3519,7 @@ namespace Vocalization } } - foreach(var dia in orSplit) + foreach (var dia in orSplit) { if (dia.Contains("\"") && cue.name.StartsWith("Temp")) //If I can split my string do so and add all the split strings into my orSplit list. { @@ -2654,7 +3611,8 @@ namespace Vocalization //iterate across ll dialogues and return a list of them. - for (int i= 0;i removalList = new List(); //Clean out all dialogue commands. - foreach(var dia in possibleDialogues) + foreach (var dia in possibleDialogues) { if (dia.Contains("$r")) { @@ -2763,7 +3721,7 @@ namespace Vocalization } //Delete all garbage dialogues left over. - foreach(var v in removalList) + foreach (var v in removalList) { possibleDialogues.Remove(v); } @@ -2772,7 +3730,7 @@ namespace Vocalization return possibleDialogues; } - public static string sanitizeDialogueFromSpeechBubblesDictionary(string text) + public static string sanitizeDialogueFromSpeechBubblesDictionary(string text) { if (text.Contains("{0}")) { @@ -2790,7 +3748,7 @@ namespace Vocalization /// /// /// - public static string sanitizeDialogueFromMailDictionary(string mailText) + public static string sanitizeDialogueFromMailDictionary(string mailText) { List texts = mailText.Split('%').ToList(); diff --git a/GeneralMods/Vocalization/Vocalization/Vocalization.csproj b/GeneralMods/Vocalization/Vocalization/Vocalization.csproj index 19772bab..fbe35047 100644 --- a/GeneralMods/Vocalization/Vocalization/Vocalization.csproj +++ b/GeneralMods/Vocalization/Vocalization/Vocalization.csproj @@ -48,6 +48,7 @@ +