More sanitation work.
Should work for the most part, just need to add in adjectives, nouns, and places.
This commit is contained in:
parent
2acd5f32a1
commit
fd5972d0b9
|
@ -25,16 +25,22 @@ namespace Vocalization
|
||||||
///
|
///
|
||||||
/// Find way to play said wave files. (Done?)
|
/// 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
|
/// !!!!!!!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 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 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!
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Vocalization : Mod
|
public class Vocalization : Mod
|
||||||
{
|
{
|
||||||
|
@ -238,25 +244,15 @@ namespace Vocalization
|
||||||
|
|
||||||
foreach(KeyValuePair<string,string>pair in DialogueDict)
|
foreach(KeyValuePair<string,string>pair in DialogueDict)
|
||||||
{
|
{
|
||||||
string dialogue = pair.Value;
|
string rawDialogue = pair.Value;
|
||||||
dialogue = sanitizeDialogueFromDictionaries(dialogue);
|
List<string> cleanDialogues = new List<string>();
|
||||||
|
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<string,string> pair in ){
|
|
||||||
* dialogue=
|
|
||||||
*
|
|
||||||
* }
|
|
||||||
*/
|
|
||||||
ModHelper.WriteJsonFile<CharacterVoiceCue>(Path.Combine(dir, "VoiceCues.json"), cue);
|
ModHelper.WriteJsonFile<CharacterVoiceCue>(Path.Combine(dir, "VoiceCues.json"), cue);
|
||||||
DialogueCues.Add(characterName, cue);
|
DialogueCues.Add(characterName, cue);
|
||||||
}
|
}
|
||||||
|
@ -280,123 +276,254 @@ namespace Vocalization
|
||||||
{
|
{
|
||||||
if (dialogue.Contains(Game1.player.Name))
|
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 (Game1.player.hasPet())
|
||||||
{
|
{
|
||||||
if (dialogue.Contains(Game1.player.getPetName()))
|
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))
|
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))
|
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))
|
if (dialogue.Contains(Game1.samBandName))
|
||||||
{
|
{
|
||||||
dialogue=dialogue.Replace(Game1.samBandName, );
|
dialogue=dialogue.Replace(Game1.samBandName, replacementStrings.bandName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dialogue.Contains(Game1.elliottBookName))
|
if (dialogue.Contains(Game1.elliottBookName))
|
||||||
{
|
{
|
||||||
dialogue=dialogue.Replace(Game1.elliottBookName, );
|
dialogue=dialogue.Replace(Game1.elliottBookName, replacementStrings.bookName);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Sanitize children names from the dialogue.
|
||||||
|
if (Game1.player.getChildren().Count > 0)
|
||||||
|
{
|
||||||
|
int count = 1;
|
||||||
|
foreach (var child in Game1.player.getChildren())
|
||||||
|
{
|
||||||
|
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++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return dialogue;
|
return dialogue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string sanitizeDialogueFromDictionaries(string dialogue)
|
public List<string> sanitizeDialogueFromDictionaries(string dialogue)
|
||||||
{
|
{
|
||||||
|
List<string> possibleDialogues = new List<string>();
|
||||||
|
|
||||||
if (dialogue.Contains("@"))
|
//remove $ symbols and their corresponding letters.
|
||||||
|
|
||||||
|
if (dialogue.Contains("$neutral"))
|
||||||
{
|
{
|
||||||
//replace with farmer name.
|
dialogue = dialogue.Replace("$neutral", "");
|
||||||
dialogue=dialogue.Replace("@",);
|
dialogue = dialogue.Replace(" ", " "); //Remove awkward spacing.
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dialogue.Contains("%adj"))
|
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<string> dialogueSplits1 = dialogue.Split('#').ToList(); //Returns an element size of 1 if # isn't found.
|
||||||
|
|
||||||
|
//Split across choices
|
||||||
|
List<string> orSplit = new List<string>();
|
||||||
|
|
||||||
|
//Split across genders
|
||||||
|
List<string> finalSplit = new List<string>();
|
||||||
|
|
||||||
|
//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<string> 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<string> 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<finalSplit.Count(); i++)
|
||||||
|
{
|
||||||
|
string dia = finalSplit.ElementAt(i);
|
||||||
|
if (dia.Contains("@"))
|
||||||
|
{
|
||||||
|
//replace with farmer name.
|
||||||
|
dia = dia.Replace("@", replacementStrings.farmerName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dia.Contains("%adj"))
|
||||||
{
|
{
|
||||||
//??? Loop through all possible adj combinations.
|
//??? Loop through all possible adj combinations.
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dialogue.Contains("%noun"))
|
if (dia.Contains("%noun"))
|
||||||
{
|
{
|
||||||
//??? Loop through all possible noun combinations.
|
//??? Loop through all possible noun combinations.
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dialogue.Contains("%place"))
|
if (dia.Contains("%place"))
|
||||||
{
|
{
|
||||||
//??? Loop through all place combinations.
|
//??? Loop through all place combinations.
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dialogue.Contains("%spouse"))
|
if (dia.Contains("%spouse"))
|
||||||
{
|
{
|
||||||
//Replace with all possible marriageable npcs
|
//Replace with all possible marriageable npcs
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dialogue.Contains("%time"))
|
if (dia.Contains("%band"))
|
||||||
{
|
|
||||||
//Replace with all times of day. 600-2600.
|
|
||||||
for(int i = 600; i <= 2600; i += 10)
|
|
||||||
{
|
|
||||||
string time = i.ToString();
|
|
||||||
dialogue = dialogue.Replace("%time", time);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dialogue.Contains("%band"))
|
|
||||||
{
|
{
|
||||||
//Replace with<Sam's Band Name>
|
//Replace with<Sam's Band Name>
|
||||||
dialogue = dialogue.Replace("%band", );
|
dia = dia.Replace("%band", replacementStrings.bandName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dialogue.Contains("%book"))
|
if (dia.Contains("%book"))
|
||||||
{
|
{
|
||||||
//Replace with<Elliott's Book Name>
|
//Replace with<Elliott's Book Name>
|
||||||
dialogue = dialogue.Replace("%book",);
|
dia = dia.Replace("%book", replacementStrings.bookName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dialogue.Contains("%rival"))
|
if (dia.Contains("%rival"))
|
||||||
{
|
{
|
||||||
//Replace with<Rival Name>
|
//Replace with<Rival Name>
|
||||||
dialogue = dialogue.Replace("%rival",);
|
dia = dia.Replace("%rival", replacementStrings.rivalName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dialogue.Contains("%pet"))
|
if (dia.Contains("%pet"))
|
||||||
{
|
{
|
||||||
//Replace with <Pet Name>
|
//Replace with <Pet Name>
|
||||||
dialogue = dialogue.Replace("%pet",);
|
dia = dia.Replace("%pet", replacementStrings.petName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dialogue.Contains("%farm"))
|
if (dia.Contains("%farm"))
|
||||||
{
|
{
|
||||||
//Replace with <Farm Name>
|
dia = dia.Replace("%pet", replacementStrings.farmName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dialogue.Contains("%favorite"))
|
if (dia.Contains("%favorite"))
|
||||||
{
|
{
|
||||||
//Replace with <Favorite thing>
|
//Replace with <Favorite thing>
|
||||||
|
dia = dia.Replace("%pet", replacementStrings.favoriteThing);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dialogue.Contains("%kid1"))
|
if (dia.Contains("%kid1"))
|
||||||
{
|
{
|
||||||
//Replace with <Kid 1's Name>
|
//Replace with <Kid 1's Name>
|
||||||
|
dia = dia.Replace("%pet", replacementStrings.kid1Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dialogue.Contains("%kid2"))
|
if (dia.Contains("%kid2"))
|
||||||
{
|
{
|
||||||
//Replace with <Kid 2's Name>
|
//Replace with <Kid 2's Name>
|
||||||
|
dia = dia.Replace("%pet", replacementStrings.kid2Name);
|
||||||
}
|
}
|
||||||
return dialogue;
|
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue