Vocalization works, but I need to figure out the weird looping issue???

This commit is contained in:
2018-08-15 13:22:31 -07:00
parent 2cafe14bbe
commit 6262995834
18 changed files with 280 additions and 93 deletions

View File

@ -35,6 +35,7 @@ namespace SimpleSoundManager.Framework
public void loadWavFile(string soundName,string pathToWav)
{
WavSound wav = new WavSound(soundName,pathToWav);
SimpleSoundManagerMod.ModMonitor.Log("Getting sound file:" + soundName);
this.sounds.Add(soundName,wav);
}
@ -47,6 +48,7 @@ namespace SimpleSoundManager.Framework
public void loadWavFile(IModHelper helper,string soundName,string pathToWav)
{
WavSound wav = new WavSound(helper ,soundName,pathToWav);
SimpleSoundManagerMod.ModMonitor.Log("Getting sound file:" + soundName);
this.sounds.Add(soundName,wav);
}
@ -59,6 +61,7 @@ namespace SimpleSoundManager.Framework
public void loadWavFile(IModHelper helper,string songName,List<string> pathToWav)
{
WavSound wav = new WavSound(helper,songName,pathToWav);
SimpleSoundManagerMod.ModMonitor.Log("Getting sound file:" + songName);
this.sounds.Add(songName,wav);
}
@ -136,10 +139,12 @@ namespace SimpleSoundManager.Framework
/// <param name="soundName"></param>
public void playSound(string soundName)
{
SimpleSoundManagerMod.ModMonitor.Log("Trying to play sound: " + soundName);
foreach(var sound in this.sounds)
{
if (sound.Key == soundName)
{
SimpleSoundManagerMod.ModMonitor.Log("Time to play sound: " + soundName);
var s=getSoundClone(soundName);
s.play();
this.currentlyPlayingSounds.Add(s);
@ -190,6 +195,11 @@ namespace SimpleSoundManager.Framework
}
}
public void swapSounds(string newSong)
{
this.playSound(newSong);
}
public void update()
{
List<Sound> removalList = new List<Sound>();

View File

@ -113,7 +113,9 @@ namespace SimpleSoundManager
dynamicSound = new DynamicSoundEffectInstance(sampleRate, (AudioChannels)channels);
count = dynamicSound.GetSampleSizeInBytes(TimeSpan.FromMilliseconds(10000));
count = dynamicSound.GetSampleSizeInBytes(TimeSpan.FromMilliseconds(1000));
dynamicSound.BufferNeeded += new EventHandler<EventArgs>(DynamicSound_BufferNeeded);
}
@ -125,7 +127,7 @@ namespace SimpleSoundManager
}
catch (Exception err)
{
SimpleSoundManagerMod.ModMonitor.Log(err.ToString());
}
position += count;
@ -150,7 +152,8 @@ namespace SimpleSoundManager
public void play()
{
if (this.isPlaying() == true) return;
dynamicSound.BufferNeeded += new EventHandler<EventArgs>(DynamicSound_BufferNeeded);
LoadWavFromFileToStream();
SimpleSoundManagerMod.ModMonitor.Log("OK NOW WE ACTUALLY PLAY THE SONG");
dynamicSound.Play();
}

View File

@ -5,10 +5,12 @@ namespace SimpleSoundManager
public class SimpleSoundManagerMod : Mod
{
internal static IModHelper ModHelper;
internal static IMonitor ModMonitor;
public override void Entry(IModHelper helper)
{
ModHelper = helper;
ModMonitor = Monitor;
}
}
}

View File

@ -1,5 +1,7 @@
using System;
using StardewValley;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -139,6 +141,119 @@ namespace Vocalization.Framework
stringsFileNames.Add("SpeechBubbles.xnb");
}
else if (name == "Temp")
{
Vocalization.ModMonitor.Log("Scraping dialogue file: Temp.xnb", StardewModdingAPI.LogLevel.Debug);
//dataFileNames.Add(Path.Combine("Events", "Temp.xnb"));
Dictionary<string, string> meh = Game1.content.Load<Dictionary<string, string>>(Path.Combine("Data", "Events", "Temp.xnb"));
foreach(KeyValuePair<string,string> pair in meh)
{
if(pair.Key== "decorate")
{
string dia = pair.Value;
Vocalization.ModMonitor.Log(dia);
string[]values = dia.Split('\"');
foreach(var v in values)
{
Vocalization.ModMonitor.Log(v);
Vocalization.ModMonitor.Log("HELLO?");
}
List<string> goodValues = new List<string>();
goodValues.Add(values.ElementAt(1));
goodValues.Add(values.ElementAt(3));
goodValues.Add(values.ElementAt(5));
foreach(var sentence in goodValues)
{
List<string> clean = Vocalization.sanitizeDialogueFromDictionaries(sentence);
foreach(var cleanSentence in clean)
{
this.dialogueCues.Add(cleanSentence, "");
}
}
}
if (pair.Key == "leave")
{
string dia = pair.Value;
string[] values = dia.Split('\"');
List<string> goodValues = new List<string>();
goodValues.Add(values.ElementAt(1));
goodValues.Add(values.ElementAt(3));
goodValues.Add(values.ElementAt(5));
foreach (var sentence in goodValues)
{
List<string> clean = Vocalization.sanitizeDialogueFromDictionaries(sentence);
foreach (var cleanSentence in clean)
{
this.dialogueCues.Add(cleanSentence, "");
}
}
}
if (pair.Key == "tooBold")
{
string dia = pair.Value;
string[] values = dia.Split('\"');
List<string> goodValues = new List<string>();
goodValues.Add(values.ElementAt(1));
foreach (var sentence in goodValues)
{
List<string> clean = Vocalization.sanitizeDialogueFromDictionaries(sentence);
foreach (var cleanSentence in clean)
{
this.dialogueCues.Add(cleanSentence, "");
}
}
}
if (pair.Key == "poppy" || pair.Key=="heavy" || pair.Key=="techno"|| pair.Key=="honkytonk")
{
string dia = pair.Value;
string[] values = dia.Split('\"');
List<string> goodValues = new List<string>();
goodValues.Add(values.ElementAt(1));
goodValues.Add(values.ElementAt(3));
goodValues.Add(values.ElementAt(5));
goodValues.Add(values.ElementAt(7));
goodValues.Add(values.ElementAt(9));
goodValues.Add(values.ElementAt(11));
goodValues.Add(values.ElementAt(13));
goodValues.Add(values.ElementAt(15));
goodValues.Add(values.ElementAt(17));
goodValues.Add(values.ElementAt(19));
foreach (var sentence in goodValues)
{
List<string> clean = Vocalization.sanitizeDialogueFromDictionaries(sentence);
foreach (var cleanSentence in clean)
{
try
{
this.dialogueCues.Add(cleanSentence, "");
}
catch (Exception err)
{
}
}
}
}
}
}
else
{
dialogueFileNames.Add(name + ".xnb");

View File

@ -142,7 +142,7 @@ namespace Vocalization
/// -NPC Gift tastes (done)
/// speech bubbles (done)
/// -temp
/// -ui
/// -ui (not needed???)
/// ///
///
/// </summary>
@ -204,9 +204,10 @@ namespace Vocalization
private void MenuEvents_MenuClosed(object sender, StardewModdingAPI.Events.EventArgsClickableMenuClosed e)
{
//Clean out my previous dialogue when I close any sort of menu.
if (String.IsNullOrEmpty(previousDialogue) || soundManager.sounds[previousDialogue]==null) return;
soundManager.stopSound(previousDialogue);
previousDialogue = "";
if (String.IsNullOrEmpty(soundManager.previousSound.Key) || soundManager.previousSound.Value == null) return;
soundManager.stopPreviousSound();
}
/// <summary>
@ -244,6 +245,7 @@ namespace Vocalization
/// <param name="e"></param>
private void GameEvents_UpdateTick(object sender, EventArgs e)
{
soundManager.update();
if (Game1.player != null) {
if (Game1.player.currentLocation != null) {
foreach (NPC v in Game1.currentLocation.characters)
@ -296,21 +298,30 @@ namespace Vocalization
List<string> tries = new List<string>();
tries.Add(speakerName);
tries.Add("ExtraDialogue");
tries.Add("Events");
tries.Add("CharactersStrings");
tries.Add("LocationDialogue");
tries.Add("Utility");
tries.Add("Quests");
tries.Add("NPCGiftTastes");
tries.Add("Temp");
foreach (var v in tries)
{
CharacterVoiceCue voice;
DialogueCues.TryGetValue(v, out voice);
currentDialogue = sanitizeDialogueInGame(currentDialogue); //If contains the stuff in the else statement, change things up.
if (voice == null)
{
ModMonitor.Log("WHY IS MY VOICE NULL??");
}
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.
voice.speak(currentDialogue);
ModMonitor.Log("SPEAK????");
return;
}
else
{
@ -470,6 +481,12 @@ namespace Vocalization
}
}
//Create all of the necessary folders for different translations.
foreach (var dir in config.translations)
{
if (!Directory.Exists(Path.Combine(voicePath,dir))) Directory.CreateDirectory(Path.Combine(voicePath, dir));
}
//Add in folder for TV Shows
foreach (var translation in config.translations)
{
@ -570,22 +587,23 @@ namespace Vocalization
characterDialoguePaths.Add(extra);
}
foreach (var translation in config.translations)
{
string extra = Path.Combine(translation, "Temp");
characterDialoguePaths.Add(extra);
}
if (!Directory.Exists(contentPath)) Directory.CreateDirectory(contentPath);
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 config.translations)
{
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)
{
if (!Directory.Exists(dir)) Directory.CreateDirectory(dir);
if (!Directory.Exists(Path.Combine(voicePath, dir))) Directory.CreateDirectory(Path.Combine(voicePath, dir));
}
}
@ -603,10 +621,12 @@ namespace Vocalization
//get a list of all characters supported in this translation and load their voice cue file.
foreach (var dir in characterVoiceLines)
{
ModMonitor.Log(dir);
string[] clips = Directory.GetFiles(dir,"*.wav");
List<string> 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)
foreach (var file in clips)
{
string fileName = Path.GetFileNameWithoutExtension(file);
soundManager.loadWavFile(ModHelper, fileName, file);
@ -623,11 +643,29 @@ namespace Vocalization
CharacterVoiceCue cue = new CharacterVoiceCue(characterName);
cue.initializeEnglishScrape();
scrapeDictionaries(voiceCueFile,cue);
///??? DO I NEVER ACTUALLY ADD IT IN???
try
{
DialogueCues.Add(characterName, cue);
}
catch(Exception err)
{
}
}
else
{
CharacterVoiceCue cue = ModHelper.ReadJsonFile<CharacterVoiceCue>(voiceCueFile);
scrapeDictionaries(voiceCueFile,cue);
//scrapeDictionaries(voiceCueFile,cue);
try
{
DialogueCues.Add(characterName, cue);
}
catch (Exception err)
{
}
///??? DO I ACTUALLY NEVER ADD IT IN???
}
}
}
@ -1086,7 +1124,7 @@ namespace Vocalization
else if (cue.name == "Quests")
{
foreach (var fileName in cue.stringsFileNames)
foreach (var fileName in cue.dataFileNames)
{
ModMonitor.Log(" Scraping dialogue file: " + fileName, LogLevel.Info);
string dialoguePath2 = Path.Combine(stringsPath, fileName);
@ -1518,7 +1556,7 @@ namespace Vocalization
/// </summary>
/// <param name="dialogue"></param>
/// <returns></returns>
public List<string> sanitizeDialogueFromDictionaries(string dialogue)
public static List<string> sanitizeDialogueFromDictionaries(string dialogue)
{
List<string> possibleDialogues = new List<string>();
@ -1599,6 +1637,8 @@ namespace Vocalization
//Split across choices
List<string> orSplit = new List<string>();
List<string> quoteSplit = new List<string>();
//Split across genders
List<string> finalSplit = new List<string>();
@ -1619,8 +1659,24 @@ namespace Vocalization
}
}
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();
foreach (var v in tempSplits)
{
quoteSplit.Add(v);
}
}
else
{
quoteSplit.Add(dia); //If I can't split the list just add the dialogue and keep processing.
}
}
//split across ^ symbol
foreach (var dia in orSplit)
foreach (var dia in quoteSplit)
{
if (dia.Contains("^")) //If I can split my string do so and add all the split strings into my orSplit list.
{

View File

@ -1,70 +1,71 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{1651701C-DB36-43C7-B66D-2700171DD9A9}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Vocalization</RootNamespace>
<AssemblyName>Vocalization</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Netcode">
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Stardew Valley\Netcode.dll</HintPath>
</Reference>
<Reference Include="SimpleSoundManager">
<HintPath>..\..\Stardew_Valley_Mods-Development\GeneralMods\SimpleSoundManager\bin\Debug\SimpleSoundManager.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Framework\CharacterVoiceCue.cs" />
<Compile Include="Framework\ReplacementStrings.cs" />
<Compile Include="ModConfig.cs" />
<Compile Include="Vocalization.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="manifest.json" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Pathoschild.Stardew.ModBuildConfig.2.0.2\build\Pathoschild.Stardew.ModBuildConfig.targets" Condition="Exists('..\packages\Pathoschild.Stardew.ModBuildConfig.2.0.2\build\Pathoschild.Stardew.ModBuildConfig.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>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}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Pathoschild.Stardew.ModBuildConfig.2.0.2\build\Pathoschild.Stardew.ModBuildConfig.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Pathoschild.Stardew.ModBuildConfig.2.0.2\build\Pathoschild.Stardew.ModBuildConfig.targets'))" />
</Target>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{1651701C-DB36-43C7-B66D-2700171DD9A9}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Vocalization</RootNamespace>
<AssemblyName>Vocalization</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Netcode">
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Stardew Valley\Netcode.dll</HintPath>
</Reference>
<Reference Include="SimpleSoundManager, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\GeneralMods\SimpleSoundManager\bin\Release\SimpleSoundManager.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Framework\CharacterVoiceCue.cs" />
<Compile Include="Framework\ReplacementStrings.cs" />
<Compile Include="ModConfig.cs" />
<Compile Include="Vocalization.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="manifest.json" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Pathoschild.Stardew.ModBuildConfig.2.0.2\build\Pathoschild.Stardew.ModBuildConfig.targets" Condition="Exists('..\packages\Pathoschild.Stardew.ModBuildConfig.2.0.2\build\Pathoschild.Stardew.ModBuildConfig.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>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}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Pathoschild.Stardew.ModBuildConfig.2.0.2\build\Pathoschild.Stardew.ModBuildConfig.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Pathoschild.Stardew.ModBuildConfig.2.0.2\build\Pathoschild.Stardew.ModBuildConfig.targets'))" />
</Target>
</Project>

View File

@ -1 +1 @@
d2f6ea8ff6eabfbcaf9442f44d54892bdeabe452
3b7bd19887cca12ff75f6ac1abe1ec154bb35718

View File

@ -11,9 +11,9 @@ C:\Users\iD Student\Desktop\Stardew\Vocalization\Vocalization\bin\Debug\SimpleSo
C:\Users\iD Student\Desktop\Stardew\Vocalization\Vocalization\obj\Debug\Vocalization.csprojResolveAssemblyReference.cache
C:\Users\owner\Documents\Visual Studio 2015\Projects\github\StardewValleyMods\Vocalization\Vocalization\bin\Debug\Vocalization.dll
C:\Users\owner\Documents\Visual Studio 2015\Projects\github\StardewValleyMods\Vocalization\Vocalization\bin\Debug\Vocalization.pdb
C:\Users\owner\Documents\Visual Studio 2015\Projects\github\StardewValleyMods\Vocalization\Vocalization\bin\Debug\Netcode.pdb
C:\Users\owner\Documents\Visual Studio 2015\Projects\github\StardewValleyMods\Vocalization\Vocalization\bin\Debug\SimpleSoundManager.pdb
C:\Users\owner\Documents\Visual Studio 2015\Projects\github\StardewValleyMods\Vocalization\Vocalization\obj\Debug\Vocalization.csprojResolveAssemblyReference.cache
C:\Users\owner\Documents\Visual Studio 2015\Projects\github\StardewValleyMods\Vocalization\Vocalization\obj\Debug\Vocalization.csproj.CoreCompileInputs.cache
C:\Users\owner\Documents\Visual Studio 2015\Projects\github\StardewValleyMods\Vocalization\Vocalization\obj\Debug\Vocalization.dll
C:\Users\owner\Documents\Visual Studio 2015\Projects\github\StardewValleyMods\Vocalization\Vocalization\obj\Debug\Vocalization.pdb
C:\Users\owner\Documents\Visual Studio 2015\Projects\github\StardewValleyMods\Vocalization\Vocalization\bin\Debug\SimpleSoundManager.dll
C:\Users\owner\Documents\Visual Studio 2015\Projects\github\StardewValleyMods\Vocalization\Vocalization\bin\Debug\SimpleSoundManager.pdb
C:\Users\owner\Documents\Visual Studio 2015\Projects\github\StardewValleyMods\Vocalization\Vocalization\obj\Debug\Vocalization.csprojResolveAssemblyReference.cache