diff --git a/Vocalization/Vocalization.sln b/Vocalization/Vocalization.sln new file mode 100644 index 00000000..ce987ba5 --- /dev/null +++ b/Vocalization/Vocalization.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27428.2037 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vocalization", "Vocalization\Vocalization.csproj", "{1651701C-DB36-43C7-B66D-2700171DD9A9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1651701C-DB36-43C7-B66D-2700171DD9A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1651701C-DB36-43C7-B66D-2700171DD9A9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1651701C-DB36-43C7-B66D-2700171DD9A9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1651701C-DB36-43C7-B66D-2700171DD9A9}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {4C50BF63-11B5-41DB-B244-337AF4EF66DC} + EndGlobalSection +EndGlobal diff --git a/Vocalization/Vocalization/Framework/CharacterVoiceCue.cs b/Vocalization/Vocalization/Framework/CharacterVoiceCue.cs new file mode 100644 index 00000000..a5ee8796 --- /dev/null +++ b/Vocalization/Vocalization/Framework/CharacterVoiceCue.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Vocalization.Framework +{ + /// + /// A class that handles all of the storage of references to the audio files for this character. + /// + public class CharacterVoiceCue + { + /// + /// The name of the NPC. + /// + public string name; + /// + /// A dictionary of dialogue strings that correspond to audio files. + /// + public Dictionary dialogueCues; + + /// + /// Constructor. + /// + /// The name of the NPC. + public CharacterVoiceCue(string name) + { + this.name = name; + this.dialogueCues = new Dictionary(); + } + + /// + /// Plays the associated dialogue file. + /// + /// The current dialogue string to play audio for. + public void speak(string dialogueString) + { + string voiceFileName = ""; + bool exists = dialogueCues.TryGetValue(dialogueString, out voiceFileName); + if (exists) + { + Vocalization.soundManager.swapSounds(voiceFileName); + } + else + { + Vocalization.ModMonitor.Log("The dialogue cue for the current dialogue could not be found. Please ensure that the dialogue is added the character's voice file and that the proper file for the voice exists."); + return; + } + } + + } +} diff --git a/Vocalization/Vocalization/Properties/AssemblyInfo.cs b/Vocalization/Vocalization/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..1218eb86 --- /dev/null +++ b/Vocalization/Vocalization/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Vocalization")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Vocalization")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("1651701c-db36-43c7-b66d-2700171dd9a9")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Vocalization/Vocalization/Vocalization.cs b/Vocalization/Vocalization/Vocalization.cs new file mode 100644 index 00000000..52a699ab --- /dev/null +++ b/Vocalization/Vocalization/Vocalization.cs @@ -0,0 +1,197 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using StardewModdingAPI; +using StardewValley; +using StardewValley.Menus; +using Vocalization.Framework; + +namespace Vocalization +{ + /// + /// TODO: + /// + /// Make a directory where all of the wav files will be stored. (Done?) + /// Load in said wav files.(Done?) + /// + /// Find way to add in supported dialogue via some sort of file system. (Done?) + /// -Make each character folder have a .json that has.... + /// -Character Name(Done?) + /// -Dictionary of supported dialogue lines and values for .wav files. (Done?) + /// -*Note* The value for the dialogue dictionaries is the name of the file excluding the .wav extension. + /// + /// Find way to play said wave files. (Done?) + /// + /// Sanitize input to remove variables such as pet names, farm names, farmer name. + /// + /// Add in dialogue for npcs into their respective VoiceCue.json files. + /// + /// Add support for different kinds of menus. TV, shops, etc. + /// + public class Vocalization : Mod + { + public static IModHelper ModHelper; + public static IMonitor ModMonitor; + + /// + /// A string that keeps track of the previous dialogue said to ensure that dialogue isn't constantly repeated while the text box is open. + /// + public static string previousDialogue; + + /// + /// Simple Sound Manager class that handles playing and stoping dialogue. + /// + public static SimpleSoundManager.Framework.SoundManager soundManager; + + /// + /// The path to the folder where all of the NPC folders for dialogue .wav files are kept. + /// + public static string VoicePath = ""; + + + /// + /// A dictionary that keeps track of all of the npcs whom have voice acting for their dialogue. + /// + public static Dictionary DialogueCues; + + public override void Entry(IModHelper helper) + { + StardewModdingAPI.Events.SaveEvents.AfterLoad += SaveEvents_AfterLoad; + DialogueCues = new Dictionary(); + + StardewModdingAPI.Events.GameEvents.UpdateTick += GameEvents_UpdateTick; + StardewModdingAPI.Events.MenuEvents.MenuClosed += MenuEvents_MenuClosed; + + + previousDialogue = ""; + + ModMonitor = Monitor; + ModHelper = Helper; + + soundManager = new SimpleSoundManager.Framework.SoundManager(); + + } + + /// + /// Runs whenever any onscreen menu is closed. + /// + /// + /// + private void MenuEvents_MenuClosed(object sender, StardewModdingAPI.Events.EventArgsClickableMenuClosed e) + { + //Clean out my previous dialogue when I close any sort of menu. + previousDialogue = ""; + } + + /// + /// Runs after the game is loaded to initialize all of the mod's files. + /// + /// + /// + private void SaveEvents_AfterLoad(object sender, EventArgs e) + { + initialzeDirectories(); + loadAllVoiceFiles(); + } + + /// + /// Runs every game tick to check if the player is talking to an npc. + /// + /// + /// + private void GameEvents_UpdateTick(object sender, EventArgs e) + { + if (Game1.currentSpeaker != null) + { + string speakerName = Game1.currentSpeaker.Name; + if (Game1.activeClickableMenu.GetType() == typeof(StardewValley.Menus.DialogueBox)) + { + StardewValley.Menus.DialogueBox dialogueBox =(DialogueBox)Game1.activeClickableMenu; + string currentDialogue = dialogueBox.getCurrentString(); + if (previousDialogue != currentDialogue) + { + ModMonitor.Log(speakerName); + 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. + + + //Do logic here to figure out what audio clips to play. + //Sanitize input here! + //Load all game dialogue files and then sanitize input for that??? + } + } + } + } + + /// + /// Runs after loading. + /// + private void initialzeDirectories() + { + string basePath = ModHelper.DirectoryPath; + string contentPath = Path.Combine(basePath, "Content"); + string audioPath = Path.Combine(contentPath, "Audio"); + string voicePath = Path.Combine(audioPath, "VoiceFiles"); + 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. + foreach (var loc in Game1.locations) + { + foreach(var NPC in loc.characters) + { + string characterPath = Path.Combine(voicePath, NPC.Name); + characterDialoguePaths.Add(characterPath); + } + } + + //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) + { + if (!Directory.Exists(dir)) Directory.CreateDirectory(dir); + } + } + + + /// + /// Loads in all of the .wav files associated with voice acting clips. + /// + public void loadAllVoiceFiles() + { + List directories = Directory.GetDirectories(VoicePath).ToList(); + foreach(var dir in directories) + { + 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); + } + + //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); + ModHelper.WriteJsonFile(Path.Combine(dir, "VoiceCues.json"), cue); + DialogueCues.Add(characterName, cue); + } + else + { + CharacterVoiceCue cue=ModHelper.ReadJsonFile(voiceCueFile); + DialogueCues.Add(characterName,cue); + } + } + } + } +} diff --git a/Vocalization/Vocalization/Vocalization.csproj b/Vocalization/Vocalization/Vocalization.csproj new file mode 100644 index 00000000..d46ef317 --- /dev/null +++ b/Vocalization/Vocalization/Vocalization.csproj @@ -0,0 +1,63 @@ + + + + + Debug + AnyCPU + {1651701C-DB36-43C7-B66D-2700171DD9A9} + Library + Properties + Vocalization + Vocalization + v4.6.1 + 512 + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Stardew Valley\Netcode.dll + + + + + + + + + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + \ No newline at end of file diff --git a/Vocalization/Vocalization/Vocalization.csproj.user b/Vocalization/Vocalization/Vocalization.csproj.user new file mode 100644 index 00000000..2f196a36 --- /dev/null +++ b/Vocalization/Vocalization/Vocalization.csproj.user @@ -0,0 +1,6 @@ + + + + ShowAllFiles + + \ No newline at end of file diff --git a/Vocalization/Vocalization/bin/Debug/Netcode.dll b/Vocalization/Vocalization/bin/Debug/Netcode.dll new file mode 100644 index 00000000..7df91e3a Binary files /dev/null and b/Vocalization/Vocalization/bin/Debug/Netcode.dll differ diff --git a/Vocalization/Vocalization/bin/Debug/Netcode.pdb b/Vocalization/Vocalization/bin/Debug/Netcode.pdb new file mode 100644 index 00000000..30f4e558 Binary files /dev/null and b/Vocalization/Vocalization/bin/Debug/Netcode.pdb differ diff --git a/Vocalization/Vocalization/bin/Debug/Vocalization 0.0.1.zip b/Vocalization/Vocalization/bin/Debug/Vocalization 0.0.1.zip new file mode 100644 index 00000000..2796371f Binary files /dev/null and b/Vocalization/Vocalization/bin/Debug/Vocalization 0.0.1.zip differ diff --git a/Vocalization/Vocalization/bin/Debug/Vocalization.dll b/Vocalization/Vocalization/bin/Debug/Vocalization.dll new file mode 100644 index 00000000..ace3a2b8 Binary files /dev/null and b/Vocalization/Vocalization/bin/Debug/Vocalization.dll differ diff --git a/Vocalization/Vocalization/bin/Debug/Vocalization.pdb b/Vocalization/Vocalization/bin/Debug/Vocalization.pdb new file mode 100644 index 00000000..13677e06 Binary files /dev/null and b/Vocalization/Vocalization/bin/Debug/Vocalization.pdb differ diff --git a/Vocalization/Vocalization/manifest.json b/Vocalization/Vocalization/manifest.json new file mode 100644 index 00000000..d4cef718 --- /dev/null +++ b/Vocalization/Vocalization/manifest.json @@ -0,0 +1,10 @@ +{ + "Name": "Vocalization", + "Author": "Alpha_Omegasis, DonDemitri, Various Voice Actors/Actresses", + "Version": "0.0.1", + "Description": "A mod that brings voice acting to Stardew Valley.", + "UniqueID": "Omegasis.Vocalization", + "EntryDll": "Vocalization.dll", + "MinimumApiVersion": "2.0", + "UpdateKeys": [] +} diff --git a/Vocalization/Vocalization/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/Vocalization/Vocalization/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 00000000..1faae210 Binary files /dev/null and b/Vocalization/Vocalization/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/Vocalization/Vocalization/obj/Debug/Vocalization.csproj.CoreCompileInputs.cache b/Vocalization/Vocalization/obj/Debug/Vocalization.csproj.CoreCompileInputs.cache new file mode 100644 index 00000000..ce61e3fc --- /dev/null +++ b/Vocalization/Vocalization/obj/Debug/Vocalization.csproj.CoreCompileInputs.cache @@ -0,0 +1 @@ +038fb9dcd07cce9441d42d4051eb2db1b115c7e2 diff --git a/Vocalization/Vocalization/obj/Debug/Vocalization.csproj.FileListAbsolute.txt b/Vocalization/Vocalization/obj/Debug/Vocalization.csproj.FileListAbsolute.txt new file mode 100644 index 00000000..ab0d2eab --- /dev/null +++ b/Vocalization/Vocalization/obj/Debug/Vocalization.csproj.FileListAbsolute.txt @@ -0,0 +1,8 @@ +C:\Users\iD Student\Desktop\Stardew\Vocalization\Vocalization\bin\Debug\Vocalization.dll +C:\Users\iD Student\Desktop\Stardew\Vocalization\Vocalization\bin\Debug\Vocalization.pdb +C:\Users\iD Student\Desktop\Stardew\Vocalization\Vocalization\obj\Debug\Vocalization.csproj.CoreCompileInputs.cache +C:\Users\iD Student\Desktop\Stardew\Vocalization\Vocalization\obj\Debug\Vocalization.dll +C:\Users\iD Student\Desktop\Stardew\Vocalization\Vocalization\obj\Debug\Vocalization.pdb +C:\Users\iD Student\Desktop\Stardew\Vocalization\Vocalization\bin\Debug\Netcode.dll +C:\Users\iD Student\Desktop\Stardew\Vocalization\Vocalization\bin\Debug\Netcode.pdb +C:\Users\iD Student\Desktop\Stardew\Vocalization\Vocalization\obj\Debug\Vocalization.csproj.CopyComplete diff --git a/Vocalization/Vocalization/obj/Debug/Vocalization.csprojResolveAssemblyReference.cache b/Vocalization/Vocalization/obj/Debug/Vocalization.csprojResolveAssemblyReference.cache new file mode 100644 index 00000000..cd918a02 Binary files /dev/null and b/Vocalization/Vocalization/obj/Debug/Vocalization.csprojResolveAssemblyReference.cache differ diff --git a/Vocalization/Vocalization/obj/Debug/Vocalization.dll b/Vocalization/Vocalization/obj/Debug/Vocalization.dll new file mode 100644 index 00000000..ace3a2b8 Binary files /dev/null and b/Vocalization/Vocalization/obj/Debug/Vocalization.dll differ diff --git a/Vocalization/Vocalization/obj/Debug/Vocalization.pdb b/Vocalization/Vocalization/obj/Debug/Vocalization.pdb new file mode 100644 index 00000000..13677e06 Binary files /dev/null and b/Vocalization/Vocalization/obj/Debug/Vocalization.pdb differ diff --git a/Vocalization/Vocalization/packages.config b/Vocalization/Vocalization/packages.config new file mode 100644 index 00000000..96d0f73b --- /dev/null +++ b/Vocalization/Vocalization/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Vocalization/packages/Pathoschild.Stardew.ModBuildConfig.2.0.2/Pathoschild.Stardew.ModBuildConfig.2.0.2.nupkg b/Vocalization/packages/Pathoschild.Stardew.ModBuildConfig.2.0.2/Pathoschild.Stardew.ModBuildConfig.2.0.2.nupkg new file mode 100644 index 00000000..1b4cc5db Binary files /dev/null and b/Vocalization/packages/Pathoschild.Stardew.ModBuildConfig.2.0.2/Pathoschild.Stardew.ModBuildConfig.2.0.2.nupkg differ diff --git a/Vocalization/packages/Pathoschild.Stardew.ModBuildConfig.2.0.2/build/Pathoschild.Stardew.ModBuildConfig.targets b/Vocalization/packages/Pathoschild.Stardew.ModBuildConfig.2.0.2/build/Pathoschild.Stardew.ModBuildConfig.targets new file mode 100644 index 00000000..b49d646d --- /dev/null +++ b/Vocalization/packages/Pathoschild.Stardew.ModBuildConfig.2.0.2/build/Pathoschild.Stardew.ModBuildConfig.targets @@ -0,0 +1,144 @@ + + + + + + + + + + + + + $(DeployModFolderName) + $(DeployModZipTo) + + + $(MSBuildProjectName) + $(TargetDir) + True + True + + + + + + + + $(HOME)/GOG Games/Stardew Valley/game + $(HOME)/.local/share/Steam/steamapps/common/Stardew Valley + + + /Applications/Stardew Valley.app/Contents/MacOS + $(HOME)/Library/Application Support/Steam/steamapps/common/Stardew Valley/Contents/MacOS + + + + + C:\Program Files (x86)\GalaxyClient\Games\Stardew Valley + C:\Program Files (x86)\Steam\steamapps\common\Stardew Valley + $([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\GOG.com\Games\1453375253', 'PATH', null, RegistryView.Registry32)) + $([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 413150', 'InstallLocation', null, RegistryView.Registry64, RegistryView.Registry32)) + + + + + + + + + + + + false + + + false + + + false + + + false + + + $(GamePath)\Stardew Valley.exe + false + + + $(GamePath)\StardewModdingAPI.exe + false + + + $(GamePath)\xTile.dll + false + False + + + + + + Program + $(GamePath)\StardewModdingAPI.exe + $(GamePath) + + + + + + + $(GamePath)\MonoGame.Framework.dll + false + False + + + $(GamePath)\StardewValley.exe + false + + + $(GamePath)\StardewModdingAPI.exe + false + + + $(GamePath)\xTile.dll + false + + + + + + + + + + + + + + + + + + + + + + diff --git a/Vocalization/packages/Pathoschild.Stardew.ModBuildConfig.2.0.2/build/StardewModdingAPI.ModBuildConfig.dll b/Vocalization/packages/Pathoschild.Stardew.ModBuildConfig.2.0.2/build/StardewModdingAPI.ModBuildConfig.dll new file mode 100644 index 00000000..e8e4c168 Binary files /dev/null and b/Vocalization/packages/Pathoschild.Stardew.ModBuildConfig.2.0.2/build/StardewModdingAPI.ModBuildConfig.dll differ