diff --git a/Vocalization/Vocalization/Vocalization.cs b/Vocalization/Vocalization/Vocalization.cs index 9c623c34..5a36d310 100644 --- a/Vocalization/Vocalization/Vocalization.cs +++ b/Vocalization/Vocalization/Vocalization.cs @@ -25,16 +25,22 @@ namespace Vocalization /// /// Find way to play said wave files. (Done?) /// - /// Sanitize input to remove variables such as pet names, farm names, farmer name. (done?) + /// Sanitize input to remove variables such as pet names, farm names, farmer name. (done) /// /// !!!!!!!Loop through common variables and add them to the dialogue list inside of ReplacementString.cs /// - /// !!!!!!!Add in dialogue for npcs into their respective VoiceCue.json files. + /// Add in dialogue for npcs into their respective VoiceCue.json files. (done? Can be improved on) /// /// !!!!!!!Add support for different kinds of menus. TV, shops, etc. /// + /// !!!!!!!Add support for MarriageDialogue strings. + /// + /// !!!!!!!Add support for Extra dialogue via StringsFromCSFiles /// /// !!!!!!!!!Make moddable to support other languages, portuguese, russian, etc (Needs testing) + /// -make mod config have a list of supported languages and a variable that is the currently selected language. + /// + /// !!!!!!!!! Add support for adding dialogue lines when loading CharacterVoiceCue.json if the line doesn't already exist! /// public class Vocalization : Mod { @@ -238,25 +244,15 @@ namespace Vocalization foreach(KeyValuePairpair in DialogueDict) { - string dialogue = pair.Value; - dialogue = sanitizeDialogueFromDictionaries(dialogue); + string rawDialogue = pair.Value; + List cleanDialogues = new List(); + cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue); + foreach(var str in cleanDialogues) + { + cue.dialogueCues.Add(str, ""); //Make a new dialogue line based off of the text, but have the .wav value as empty. + } } - //Loop through all variations of... - //time %time - //adjectives $adj - //nouns %noun - //location %place - //spouse %spouse - - //If found in a string of dialogue in a character file. - /* - *DialogueDict=load dict - * foreach(KeyValuePair pair in ){ - * dialogue= - * - * } - */ ModHelper.WriteJsonFile(Path.Combine(dir, "VoiceCues.json"), cue); DialogueCues.Add(characterName, cue); } @@ -280,123 +276,254 @@ namespace Vocalization { if (dialogue.Contains(Game1.player.Name)) { - dialogue = dialogue.Replace(Game1.player.name, ); //Remove player's name from dialogue. + dialogue = dialogue.Replace(Game1.player.name, replacementStrings.farmerName); //Remove player's name from dialogue. } if (Game1.player.hasPet()) { if (dialogue.Contains(Game1.player.getPetName())) { - dialogue=dialogue.Replace(Game1.player.getPetName(), ); + dialogue=dialogue.Replace(Game1.player.getPetName(), replacementStrings.petName); } } if (dialogue.Contains(Game1.player.farmName.Value)) { - dialogue=dialogue.Replace(Game1.player.farmName.Value, ); + dialogue=dialogue.Replace(Game1.player.farmName.Value, replacementStrings.farmName); } if (dialogue.Contains(Game1.player.favoriteThing.Value)) { - dialogue=dialogue.Replace(Game1.player.favoriteThing.Value, ); + dialogue=dialogue.Replace(Game1.player.favoriteThing.Value, replacementStrings.favoriteThing); } if (dialogue.Contains(Game1.samBandName)) { - dialogue=dialogue.Replace(Game1.samBandName, ); + dialogue=dialogue.Replace(Game1.samBandName, replacementStrings.bandName); } if (dialogue.Contains(Game1.elliottBookName)) { - dialogue=dialogue.Replace(Game1.elliottBookName, ); + dialogue=dialogue.Replace(Game1.elliottBookName, replacementStrings.bookName); } - return dialogue; - } - - public string sanitizeDialogueFromDictionaries(string dialogue) - { - - if (dialogue.Contains("@")) + //Sanitize children names from the dialogue. + if (Game1.player.getChildren().Count > 0) { - //replace with farmer name. - dialogue=dialogue.Replace("@",); - } - - if (dialogue.Contains("%adj")) - { - //??? Loop through all possible adj combinations. - } - - if (dialogue.Contains("%noun")) - { - //??? Loop through all possible noun combinations. - } - - if (dialogue.Contains("%place")) - { - //??? Loop through all place combinations. - } - - if (dialogue.Contains("%spouse")) - { - //Replace with all possible marriageable npcs - } - - if (dialogue.Contains("%time")) - { - //Replace with all times of day. 600-2600. - for(int i = 600; i <= 2600; i += 10) + int count = 1; + foreach (var child in Game1.player.getChildren()) { - string time = i.ToString(); - dialogue = dialogue.Replace("%time", time); + if (dialogue.Contains(child.Name)) + { + if (count == 1) + { + dialogue = dialogue.Replace(child.Name, replacementStrings.kid1Name); + } + if (count == 2) + { + dialogue = dialogue.Replace(child.Name, replacementStrings.kid2Name); + } + } + count++; } } - if (dialogue.Contains("%band")) - { - //Replace with - dialogue = dialogue.Replace("%band", ); - } - - if (dialogue.Contains("%book")) - { - //Replace with - dialogue = dialogue.Replace("%book",); - } - - if (dialogue.Contains("%rival")) - { - //Replace with - dialogue = dialogue.Replace("%rival",); - } - - if (dialogue.Contains("%pet")) - { - //Replace with - dialogue = dialogue.Replace("%pet",); - } - - if (dialogue.Contains("%farm")) - { - //Replace with - } - - if (dialogue.Contains("%favorite")) - { - //Replace with - } - - if (dialogue.Contains("%kid1")) - { - //Replace with - } - - if (dialogue.Contains("%kid2")) - { - //Replace with - } return dialogue; } + + public List sanitizeDialogueFromDictionaries(string dialogue) + { + List possibleDialogues = new List(); + + //remove $ symbols and their corresponding letters. + + if (dialogue.Contains("$neutral")) + { + dialogue = dialogue.Replace("$neutral", ""); + dialogue = dialogue.Replace(" ", " "); //Remove awkward spacing. + } + + if (dialogue.Contains("$h")) + { + dialogue = dialogue.Replace("$h", ""); + dialogue = dialogue.Replace(" ", " "); //Remove awkward spacing. + } + + if (dialogue.Contains("$s")) + { + dialogue = dialogue.Replace("$s", ""); + dialogue = dialogue.Replace(" ", " "); //Remove awkward spacing. + } + + if (dialogue.Contains("$u")) + { + dialogue = dialogue.Replace("$u", ""); + dialogue = dialogue.Replace(" ", " "); //Remove awkward spacing. + } + + if (dialogue.Contains("$l")) + { + dialogue = dialogue.Replace("$l", ""); + dialogue = dialogue.Replace(" ", " "); //Remove awkward spacing. + } + + if (dialogue.Contains("$a")) + { + dialogue = dialogue.Replace("$a", ""); + dialogue = dialogue.Replace(" ", " "); //Remove awkward spacing. + } + + for(int i=0; i<=100; i++) + { + string combine = ""; + if (i == 1) continue; + combine = "$" + i.ToString(); + if (dialogue.Contains(combine)) + { + dialogue = dialogue.Replace(combine, ""); + dialogue = dialogue.Replace(" ", " "); //Remove awkward spacing. + //remove dialogue symbol. + } + } + + //split across % symbol + //Just remove the %symbol for generic text boxes. Not for forks. + if (dialogue.Contains("%") && dialogue.Contains("%fork") == false) + { + dialogue = dialogue.Replace("%", ""); + } + + //split across # symbol + List dialogueSplits1 = dialogue.Split('#').ToList(); //Returns an element size of 1 if # isn't found. + + //Split across choices + List orSplit = new List(); + + //Split across genders + List finalSplit = new List(); + + //split across | symbol + 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(); + orSplit.Concat(tempSplits); //Add the two lists together. + } + else + { + orSplit.Add(dia); //If I can't split the list just add the dialogue and keep processing. + } + } + + //split across ^ symbol + foreach (var dia in orSplit) + { + 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(); + finalSplit.Concat(tempSplits); //Add the two lists together. + } + else + { + finalSplit.Add(dia); //If I can't split the list just add the dialogue and keep processing. + } + } + + //iterate across ll dialogues and return a list of them. + for (int i= 0;i + dia = dia.Replace("%band", replacementStrings.bandName); + } + + if (dia.Contains("%book")) + { + //Replace with + dia = dia.Replace("%book", replacementStrings.bookName); + } + + if (dia.Contains("%rival")) + { + //Replace with + dia = dia.Replace("%rival", replacementStrings.rivalName); + } + + if (dia.Contains("%pet")) + { + //Replace with + dia = dia.Replace("%pet", replacementStrings.petName); + } + + if (dia.Contains("%farm")) + { + dia = dia.Replace("%pet", replacementStrings.farmName); + } + + if (dia.Contains("%favorite")) + { + //Replace with + dia = dia.Replace("%pet", replacementStrings.favoriteThing); + } + + if (dia.Contains("%kid1")) + { + //Replace with + dia = dia.Replace("%pet", replacementStrings.kid1Name); + } + + if (dia.Contains("%kid2")) + { + //Replace with + dia = dia.Replace("%pet", replacementStrings.kid2Name); + } + + if (dia.Contains("%time")) + { + //Replace with all times of day. 600-2600. + for (int t = 600; t <= 2600; t += 10) + { + string time = t.ToString(); + string diaTime = dia.Replace("%time", time); + possibleDialogues.Add(diaTime); + } + } + else + { + possibleDialogues.Add(dia); + } + + } + return possibleDialogues; + } } }