diff --git a/Vocalization/Vocalization/Framework/CharacterVoiceCue.cs b/Vocalization/Vocalization/Framework/CharacterVoiceCue.cs
index a5ee8796..a2fd7488 100644
--- a/Vocalization/Vocalization/Framework/CharacterVoiceCue.cs
+++ b/Vocalization/Vocalization/Framework/CharacterVoiceCue.cs
@@ -15,6 +15,12 @@ namespace Vocalization.Framework
/// The name of the NPC.
///
public string name;
+
+ ///
+ /// The name of the dialogue file to scrape for inputting values into the dictionary of dialogueCues.
+ ///
+ public string dialogueFileName;
+
///
/// A dictionary of dialogue strings that correspond to audio files.
///
diff --git a/Vocalization/Vocalization/Framework/ReplacementStrings.cs b/Vocalization/Vocalization/Framework/ReplacementStrings.cs
new file mode 100644
index 00000000..e89a3bad
--- /dev/null
+++ b/Vocalization/Vocalization/Framework/ReplacementStrings.cs
@@ -0,0 +1,72 @@
+using StardewValley;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Vocalization.Framework
+{
+ public class ReplacementStrings
+ {
+
+ public string farmerName = "";
+ public string bandName = "";
+ public string bookName = "";
+ public string rivalName = "";
+ public string petName = "";
+ public string farmName = "";
+ public string favoriteThing = "";
+ public string kid1Name = "";
+ public string kid2Name = "";
+
+ public List adjStrings;
+ public List nounStrings;
+ public List placeStrings;
+ public List spouseNames;
+
+
+ public ReplacementStrings()
+ {
+ loadAdjStrings();
+ loadNounStrings();
+ loadPlaceStrings();
+ loadSpouseStrings();
+ }
+
+ public void loadAdjStrings()
+ {
+ adjStrings = new List();
+ }
+
+ public void loadNounStrings()
+ {
+ nounStrings = new List();
+ }
+
+ public void loadPlaceStrings()
+ {
+ placeStrings = new List();
+ }
+
+ ///
+ /// Load all associated spouse names.
+ ///
+ public void loadSpouseStrings()
+ {
+ spouseNames = new List();
+ foreach(var loc in Game1.locations)
+ {
+ foreach(var character in loc.characters)
+ {
+ if (character.datable.Value)
+ {
+ spouseNames.Add(character.Name);
+ }
+ }
+ }
+ }
+
+
+ }
+}
diff --git a/Vocalization/Vocalization/Vocalization.cs b/Vocalization/Vocalization/Vocalization.cs
index 841031ac..9c623c34 100644
--- a/Vocalization/Vocalization/Vocalization.cs
+++ b/Vocalization/Vocalization/Vocalization.cs
@@ -27,11 +27,14 @@ namespace Vocalization
///
/// 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.
+ /// !!!!!!!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 support for different kinds of menus. TV, shops, etc.
+ ///
+ ///
+ /// !!!!!!!!!Make moddable to support other languages, portuguese, russian, etc (Needs testing)
///
public class Vocalization : Mod
{
@@ -53,6 +56,8 @@ namespace Vocalization
///
public static string VoicePath = "";
+ public static ReplacementStrings replacementStrings;
+
///
/// A dictionary that keeps track of all of the npcs whom have voice acting for their dialogue.
@@ -63,6 +68,7 @@ namespace Vocalization
{
StardewModdingAPI.Events.SaveEvents.AfterLoad += SaveEvents_AfterLoad;
DialogueCues = new Dictionary();
+ replacementStrings = new ReplacementStrings();
StardewModdingAPI.Events.GameEvents.UpdateTick += GameEvents_UpdateTick;
StardewModdingAPI.Events.MenuEvents.MenuClosed += MenuEvents_MenuClosed;
@@ -125,7 +131,7 @@ namespace Vocalization
CharacterVoiceCue voice;
DialogueCues.TryGetValue(speakerName,out voice);
- currentDialogue=sanitizeDialogue(currentDialogue); //If contains the stuff in the else statement, change things up.
+ currentDialogue=sanitizeDialogueInGame(currentDialogue); //If contains the stuff in the else statement, change things up.
if (voice.dialogueCues.ContainsKey(currentDialogue))
{
//Not variable messages. Aka messages that don't contain words the user can change such as farm name, farmer name etc.
@@ -150,17 +156,27 @@ namespace Vocalization
string contentPath = Path.Combine(basePath, "Content");
string audioPath = Path.Combine(contentPath, "Audio");
string voicePath = Path.Combine(audioPath, "VoiceFiles");
+
+
+ List translationFolders = new List();
+
+ //TODO: Add more translations.
+ translationFolders.Add(Path.Combine(voicePath, "English"));
+
VoicePath = voicePath; //Set a static reference to my voice files directory.
List characterDialoguePaths = new List();
- //Get a list of all characters in the game and make voice directories for them.
+ //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)
{
- string characterPath = Path.Combine(voicePath, NPC.Name);
- characterDialoguePaths.Add(characterPath);
+ foreach (var translation in translationFolders)
+ {
+ string characterPath = Path.Combine(translation, NPC.Name);
+ characterDialoguePaths.Add(characterPath);
+ }
}
}
@@ -168,6 +184,13 @@ namespace Vocalization
if (!Directory.Exists(audioPath)) Directory.CreateDirectory(audioPath);
if (!Directory.Exists(voicePath)) Directory.CreateDirectory(voicePath);
+
+ //Create all of the necessary folders for different translations.
+ foreach(var dir in translationFolders)
+ {
+ if (!Directory.Exists(dir)) Directory.CreateDirectory(dir);
+ }
+
//Create a list of new directories if the corresponding character directory doesn't exist.
//Note: A modder could also manually add in their own character directory for voice lines instead of having to add it via code.
foreach (var dir in characterDialoguePaths)
@@ -182,40 +205,67 @@ namespace Vocalization
///
public void loadAllVoiceFiles()
{
- List directories = Directory.GetDirectories(VoicePath).ToList();
- foreach(var dir in directories)
+ //get a list of all translations supported by this mod.
+ List translations = Directory.GetDirectories(VoicePath).ToList();
+ foreach (var translation in translations)
{
- List audioClips = Directory.GetFiles(dir, ".wav").ToList();
- //For every .wav file in every character voice clip directory load in the voice clip.
- foreach(var file in audioClips)
+ List characterVoiceLines = Directory.GetDirectories(translation).ToList();
+ //get a list of all characters supported in this translation and load their voice cue file.
+ foreach (var dir in characterVoiceLines)
{
- string fileName = Path.GetFileNameWithoutExtension(file);
- soundManager.loadWavFile(ModHelper, fileName, file);
- ModMonitor.Log("Loaded sound file: " + fileName+ " from: "+ file);
- }
- //Get the character dialogue cues (aka when the character should "speak") from the .json file.
- string voiceCueFile=Path.Combine(dir,"VoiceCues.json");
- string characterName = Path.GetFileName(dir);
+ List audioClips = Directory.GetFiles(dir, ".wav").ToList();
+ //For every .wav file in every character voice clip directory load in the voice clip.
+ foreach (var file in audioClips)
+ {
+ string fileName = Path.GetFileNameWithoutExtension(file);
+ soundManager.loadWavFile(ModHelper, fileName, file);
+ ModMonitor.Log("Loaded sound file: " + fileName + " from: " + file);
+ }
- //If a file was not found, create one and add it to the list of character voice cues.
- if (!File.Exists(voiceCueFile))
- {
- CharacterVoiceCue cue= new CharacterVoiceCue(characterName);
- //Loop through all variations of...
+ //Get the character dialogue cues (aka when the character should "speak") from the .json file.
+ string voiceCueFile = Path.Combine(dir, "VoiceCues.json");
+ string characterName = Path.GetFileName(dir);
+
+ //If a file was not found, create one and add it to the list of character voice cues.
+ if (!File.Exists(voiceCueFile))
+ {
+ CharacterVoiceCue cue = new CharacterVoiceCue(characterName);
+
+ var contentDirectory = Game1.content.RootDirectory;
+
+ var DialogueDict=ModHelper.Content.Load>(cue.dialogueFileName, ContentSource.GameContent);
+
+ foreach(KeyValuePairpair in DialogueDict)
+ {
+ string dialogue = pair.Value;
+ dialogue = sanitizeDialogueFromDictionaries(dialogue);
+ }
+
+ //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.
- ModHelper.WriteJsonFile(Path.Combine(dir, "VoiceCues.json"), cue);
- DialogueCues.Add(characterName, cue);
- }
- else
- {
- CharacterVoiceCue cue=ModHelper.ReadJsonFile(voiceCueFile);
- DialogueCues.Add(characterName,cue);
+
+ //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);
+ }
+
+ else
+ {
+ CharacterVoiceCue cue = ModHelper.ReadJsonFile(voiceCueFile);
+ DialogueCues.Add(characterName, cue);
+ }
}
}
}
@@ -226,48 +276,127 @@ namespace Vocalization
///
///
///
- public string sanitizeDialogue(string dialogue)
+ public string sanitizeDialogueInGame(string dialogue)
{
if (dialogue.Contains(Game1.player.Name))
{
- dialogue = dialogue.Replace(Game1.player.name, ""); //Remove player's name from dialogue.
- dialogue = dialogue.Replace(" ", " "); //Remove awkward double space that is left when removing player's name.
+ dialogue = dialogue.Replace(Game1.player.name, ); //Remove player's name from dialogue.
}
if (Game1.player.hasPet())
{
if (dialogue.Contains(Game1.player.getPetName()))
{
- dialogue.Replace(Game1.player.getPetName(), "");
- dialogue = dialogue.Replace(" ", " "); //Remove awkward double space that is left when removing player's pet's name.
+ dialogue=dialogue.Replace(Game1.player.getPetName(), );
}
}
if (dialogue.Contains(Game1.player.farmName.Value))
{
- dialogue.Replace(Game1.player.farmName.Value, "");
- dialogue = dialogue.Replace(" ", " "); //Remove awkward double space that is left when removing player's farm name.
+ dialogue=dialogue.Replace(Game1.player.farmName.Value, );
}
if (dialogue.Contains(Game1.player.favoriteThing.Value))
{
- dialogue.Replace(Game1.player.favoriteThing.Value, "");
- dialogue = dialogue.Replace(" ", " "); //Remove awkward double space that is left when removing player's favorite thing.
+ dialogue=dialogue.Replace(Game1.player.favoriteThing.Value, );
}
if (dialogue.Contains(Game1.samBandName))
{
- dialogue.Replace(Game1.samBandName, "");
- dialogue = dialogue.Replace(" ", " "); //Remove awkward double space that is left when removing Sam's band name.
+ dialogue=dialogue.Replace(Game1.samBandName, );
}
if (dialogue.Contains(Game1.elliottBookName))
{
- dialogue.Replace(Game1.elliottBookName, "");
- dialogue = dialogue.Replace(" ", " "); //Remove awkward double space that is left when removing Elliott's book name.
+ dialogue=dialogue.Replace(Game1.elliottBookName, );
}
return dialogue;
}
+
+ public string sanitizeDialogueFromDictionaries(string dialogue)
+ {
+
+ if (dialogue.Contains("@"))
+ {
+ //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)
+ {
+ string time = i.ToString();
+ dialogue = dialogue.Replace("%time", time);
+ }
+ }
+
+ 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;
+ }
}
}
diff --git a/Vocalization/Vocalization/obj/Debug/Vocalization.csproj.CoreCompileInputs.cache b/Vocalization/Vocalization/obj/Debug/Vocalization.csproj.CoreCompileInputs.cache
index ce61e3fc..4bd81298 100644
--- a/Vocalization/Vocalization/obj/Debug/Vocalization.csproj.CoreCompileInputs.cache
+++ b/Vocalization/Vocalization/obj/Debug/Vocalization.csproj.CoreCompileInputs.cache
@@ -1 +1 @@
-038fb9dcd07cce9441d42d4051eb2db1b115c7e2
+080c6a8807c043af2887ea474b0027cde5781876