From fe1ecc44b155f7e866ce6911842c1b50f1ddff14 Mon Sep 17 00:00:00 2001 From: Date: Mon, 20 Aug 2018 12:58:08 -0700 Subject: [PATCH] Degeneralized shops for Vocalization, fixed output garbage for symphony. --- .../Framework/Music/MusicManager.cs | 4 +- .../Vocalization/Framework/TranslationInfo.cs | 32 +++++- .../Vocalization/Framework/Vocabulary.cs | 98 ++++++++++++++----- .../Vocalization/Vocalization/Vocalization.cs | 53 +++++++++- 4 files changed, 161 insertions(+), 26 deletions(-) diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/MusicManager.cs b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/MusicManager.cs index 254d173a..e4f928f4 100644 --- a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/MusicManager.cs +++ b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/MusicManager.cs @@ -429,7 +429,7 @@ namespace StardewSymphonyRemastered.Framework public Dictionary> getLocationSpecificMusic() { Dictionary> listOfValidDictionaries = new Dictionary>(); - StardewSymphony.ModMonitor.Log(SongSpecifics.getCurrentConditionalString(true)); + //StardewSymphony.ModMonitor.Log(SongSpecifics.getCurrentConditionalString(true)); foreach (var v in this.musicPacks) { @@ -520,7 +520,7 @@ namespace StardewSymphonyRemastered.Framework } else { - StardewSymphony.ModMonitor.Log("HELLO??? LOCATION????"); + //StardewSymphony.ModMonitor.Log("HELLO??? LOCATION????"); //Try to play a generalized festival song. var listOfLocationPacks = this.getLocationSpecificMusic(); if (listOfLocationPacks.Count > 0) diff --git a/GeneralMods/Vocalization/Vocalization/Framework/TranslationInfo.cs b/GeneralMods/Vocalization/Vocalization/Framework/TranslationInfo.cs index 84ab908e..a4844752 100644 --- a/GeneralMods/Vocalization/Vocalization/Framework/TranslationInfo.cs +++ b/GeneralMods/Vocalization/Vocalization/Framework/TranslationInfo.cs @@ -28,6 +28,8 @@ namespace Vocalization.Framework /// public Dictionary translationFileInfo; + + public Dictionary translationCodes; /// /// Default constructor. /// @@ -36,7 +38,7 @@ namespace Vocalization.Framework translations = new List(); translationFileInfo = new Dictionary(); - + translationCodes = new Dictionary(); translations.Add("English"); translations.Add("Spanish"); translations.Add("Chinese"); @@ -56,6 +58,34 @@ namespace Vocalization.Framework translationFileInfo.Add("Brazillian Portuguese", ".pt-BR.xnb"); + translationCodes.Add("English", LocalizedContentManager.LanguageCode.en); + translationCodes.Add("Spanish", LocalizedContentManager.LanguageCode.es); + translationCodes.Add("Chinese", LocalizedContentManager.LanguageCode.zh); + translationCodes.Add("Japanese", LocalizedContentManager.LanguageCode.ja); + translationCodes.Add("Russian", LocalizedContentManager.LanguageCode.ru); + translationCodes.Add("German", LocalizedContentManager.LanguageCode.de); + translationCodes.Add("Brazillian Portuguese", LocalizedContentManager.LanguageCode.pt); + + } + + public string getTranslationNameFromPath(string fullPath) + { + return Path.GetFileName(fullPath); + } + + + public void changeLocalizedContentManagerFromTranslation(string translation) + { + string tra = getTranslationNameFromPath(translation); + bool f = translationCodes.TryGetValue(tra, out LocalizedContentManager.LanguageCode code); + if (f == false) LocalizedContentManager.CurrentLanguageCode = LocalizedContentManager.LanguageCode.en; + else LocalizedContentManager.CurrentLanguageCode = code; + return; + } + + public void resetLocalizationCode() + { + LocalizedContentManager.CurrentLanguageCode = LocalizedContentManager.LanguageCode.en; } /// diff --git a/GeneralMods/Vocalization/Vocalization/Framework/Vocabulary.cs b/GeneralMods/Vocalization/Vocalization/Framework/Vocabulary.cs index 237e81e7..e19c580d 100644 --- a/GeneralMods/Vocalization/Vocalization/Framework/Vocabulary.cs +++ b/GeneralMods/Vocalization/Vocalization/Framework/Vocabulary.cs @@ -1,11 +1,16 @@ -using StardewValley; +using Microsoft.Xna.Framework; +using Netcode; +using StardewModdingAPI; +using StardewValley; +using StardewValley.BellsAndWhistles; +using StardewValley.Objects; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; - +using sObj = StardewValley.Object; namespace Vocalization.Framework { public class Vocabulary @@ -13,67 +18,116 @@ namespace Vocalization.Framework public static string[] getRandomNegativeItemSlanderNouns(string translation) { - string[] strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings","Lexicon:RandomNegativeItemNoun"),translation).Split('#'); + string[] strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomNegativeItemNoun"), translation).Split('#'); return strArray; } - public static string[] getRandomDeliciousAdjectives(string translation,NPC n = null) + public static string[] getRandomDeliciousAdjectives(string translation, NPC n = null) { string[] strArray; if (n != null && n.Age == 2) - strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings","Lexicon:RandomDeliciousAdjective_Child"),translation).Split('#'); + strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomDeliciousAdjective_Child"), translation).Split('#'); else - strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings","Lexicon:RandomDeliciousAdjective"),translation).Split('#'); + strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomDeliciousAdjective"), translation).Split('#'); return strArray; } - public static string[] getRandomNegativeFoodAdjectives(string translation,NPC n = null) + public static string[] getRandomNegativeFoodAdjectives(string translation, NPC n = null) { string[] strArray; if (n != null && n.Age == 2) - strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings","Lexicon:RandomNegativeFoodAdjective_Child"),translation).Split('#'); + strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomNegativeFoodAdjective_Child"), translation).Split('#'); else if (n != null && n.Manners == 1) - strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings","Lexicon:RandomNegativeFoodAdjective_Polite"),translation).Split('#'); + strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomNegativeFoodAdjective_Polite"), translation).Split('#'); else - strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings","Lexicon:RandomNegativeFoodAdjective"),translation).Split('#'); + strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomNegativeFoodAdjective"), translation).Split('#'); return strArray; } - public static string[] getRandomSlightlyPositiveAdjectivesForEdibleNoun(string translation,NPC n = null) + public static string[] getRandomSlightlyPositiveAdjectivesForEdibleNoun(string translation, NPC n = null) { - string[] strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings","Lexicon:RandomSlightlyPositiveFoodAdjective"),translation).Split('#'); + string[] strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomSlightlyPositiveFoodAdjective"), translation).Split('#'); return strArray; } - public static string[] getRandomNegativeAdjectivesForEventOrPerson(string translation,NPC n = null) + public static string[] getRandomNegativeAdjectivesForEventOrPerson(string translation, NPC n = null) { Random random = new Random((int)Game1.stats.DaysPlayed + (int)Game1.uniqueIDForThisGame / 2); string[] strArray; if (n != null && n.Age != 0) - strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings","Lexicon:RandomNegativeAdjective_Child"),translation).Split('#'); + strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomNegativeAdjective_Child"), translation).Split('#'); else if (n != null && n.Gender == 0) - strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings","Lexicon:RandomNegativeAdjective_AdultMale"),translation).Split('#'); + strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomNegativeAdjective_AdultMale"), translation).Split('#'); else if (n != null && n.Gender == 1) - strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings","Lexicon:RandomNegativeAdjective_AdultFemale"),translation).Split('#'); + strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomNegativeAdjective_AdultFemale"), translation).Split('#'); else - strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings","Lexicon:RandomNegativeAdjective_PlaceOrEvent"),translation).Split('#'); + strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomNegativeAdjective_PlaceOrEvent"), translation).Split('#'); return strArray; } - public static string[] getRandomPositiveAdjectivesForEventOrPerson(string translation,NPC n = null) + public static string[] getRandomPositiveAdjectivesForEventOrPerson(string translation, NPC n = null) { Random random = new Random((int)Game1.stats.DaysPlayed + (int)Game1.uniqueIDForThisGame / 2); string[] strArray; if (n != null && n.Age != 0) - strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings","Lexicon:RandomPositiveAdjective_Child"),translation).Split('#'); + strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomPositiveAdjective_Child"), translation).Split('#'); else if (n != null && n.Gender == 0) - strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings","Lexicon:RandomPositiveAdjective_AdultMale"),translation).Split('#'); + strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomPositiveAdjective_AdultMale"), translation).Split('#'); else if (n != null && n.Gender == 1) - strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings","Lexicon:RandomPositiveAdjective_AdultFemale"),translation).Split('#'); + strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomPositiveAdjective_AdultFemale"), translation).Split('#'); else - strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings","Lexicon:RandomPositiveAdjective_PlaceOrEvent"),translation).Split('#'); + strArray = Vocalization.config.translationInfo.LoadString(Path.Combine("Strings", "Lexicon:RandomPositiveAdjective_PlaceOrEvent"), translation).Split('#'); return strArray; } + + public static List getCarpenterStock(string translation) + { + List stock = new List(); + Vocalization.config.translationInfo.changeLocalizedContentManagerFromTranslation(translation); + + for(int i=0; i <= 1854; i++) + { + try + { + Furniture f = new Furniture(i, Vector2.Zero); + stock.Add(f.DisplayName); + } + catch(Exception err) + { + + } + } + Vocalization.config.translationInfo.resetLocalizationCode(); + return stock; + } + + public static List getMerchantStock(string translation) + { + 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); + foreach (KeyValuePair pair in objDict) + { + for (int i = 0; i <= 3; i++) + { + StardewValley.Object obj = new StardewValley.Object(pair.Key, 1, false, -1, i); + stock.Add(obj.DisplayName); + } + } + foreach(var item in getCarpenterStock(translation)) + { + stock.Add(item); + } + return stock; + } + + public static string getProperArticleForWord(string displayName, string translation) + { + Vocalization.config.translationInfo.changeLocalizedContentManagerFromTranslation(translation); + string s=Lexicon.getProperArticleForWord(displayName); + Vocalization.config.translationInfo.resetLocalizationCode(); + return s; + } } } diff --git a/GeneralMods/Vocalization/Vocalization/Vocalization.cs b/GeneralMods/Vocalization/Vocalization/Vocalization.cs index 8b9236f8..2ceedf80 100644 --- a/GeneralMods/Vocalization/Vocalization/Vocalization.cs +++ b/GeneralMods/Vocalization/Vocalization/Vocalization.cs @@ -277,6 +277,7 @@ namespace Vocalization { List tries = new List(); tries.Add("SpeechBubbles"); + tries.Add(v.Name); foreach (var speech in tries) { CharacterVoiceCue voice; @@ -875,7 +876,57 @@ namespace Vocalization if (!key.Contains("ShopMenu")) continue; //If the key contains the character's name. - List cleanDialogues = new List(); + + if(key== "ShopMenu.cs.11464") + { + 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)); + 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. + } + } + } + continue; + } + 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) + { + cue.addDialogue(str, new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty. + } + + } + continue; + } + + if (key == "ShopMenu.cs.11512") + { + foreach (var obj in Vocabulary.getMerchantStock(translation)) + { + rawDialogue = config.translationInfo.LoadString(Path.Combine("Strings", "StringsFromCSFiles:ShopMenu.cs.11512"), translation, (object)obj); + 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. + } + + } + continue; + } + + List cleanDialogues = new List(); cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue,cue); foreach (var str in cleanDialogues) {