Volume options, dialogue complexity options, and speech bubble fixes?

This commit is contained in:
2018-08-16 11:50:50 -07:00
parent b598934a17
commit 5d35edea2b
9 changed files with 199 additions and 42 deletions

View File

@ -15,6 +15,8 @@ namespace SimpleSoundManager.Framework
/// Handles playing a sound.
/// </summary>
void play();
void play(float volume);
/// <summary>
/// Handles pausing a song.
/// </summary>

View File

@ -15,6 +15,7 @@ namespace SimpleSoundManager.Framework
public Dictionary<string,Sound> sounds;
public Dictionary<string, XACTMusicPair> musicBanks;
public float volume;
public List<Sound> currentlyPlayingSounds = new List<Sound>();
/// <summary>
@ -25,6 +26,7 @@ namespace SimpleSoundManager.Framework
this.sounds = new Dictionary<string, Sound>();
this.musicBanks = new Dictionary<string, XACTMusicPair>();
currentlyPlayingSounds = new List<Sound>();
this.volume = 1.0f;
}
/// <summary>
@ -167,7 +169,28 @@ namespace SimpleSoundManager.Framework
{
SimpleSoundManagerMod.ModMonitor.Log("Time to play sound: " + soundName);
var s=getSoundClone(soundName);
s.play();
s.play(this.volume);
this.currentlyPlayingSounds.Add(s);
break;
}
}
}
/// <summary>
/// Play the sound with the given name and volume.
/// </summary>
/// <param name="soundName"></param>
/// <param name="volume"></param>
public void playSound(string soundName,float volume=1.0f)
{
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(volume);
this.currentlyPlayingSounds.Add(s);
break;
}

View File

@ -122,7 +122,7 @@ namespace SimpleSoundManager
count = byteArray.Length;//dynamicSound.GetSampleSizeInBytes(TimeSpan.FromMilliseconds(1000));
dynamicSound.BufferNeeded += new EventHandler<EventArgs>(DynamicSound_BufferNeeded);
}
void DynamicSound_BufferNeeded(object sender, EventArgs e)
@ -167,7 +167,19 @@ namespace SimpleSoundManager
{
if (this.isPlaying() == true) return;
LoadWavFromFileToStream();
SimpleSoundManagerMod.ModMonitor.Log("OK NOW WE ACTUALLY PLAY THE SONG");
dynamicSound.Play();
}
/// <summary>
/// Used to play a song.
/// </summary>
/// <param name="name"></param>
/// <param name="volume">How lound the sound is when playing. 0~1.0f</param>
public void play(float volume)
{
if (this.isPlaying() == true) return;
LoadWavFromFileToStream();
dynamicSound.Volume = volume;
dynamicSound.Play();
}

View File

@ -97,6 +97,14 @@ namespace SimpleSoundManager.Framework
this.play(this.soundName);
}
/// <summary>
/// Plays this song.
/// </summary>
public void play(float volume)
{
this.play(this.soundName);
}
/// <summary>
/// Pauses this song.
/// </summary>

View File

@ -36,7 +36,7 @@ namespace Vocalization.Framework
/// <summary>
/// A dictionary of dialogue strings that correspond to audio files.
/// </summary>
public Dictionary<string, string> dialogueCues;
public Dictionary<string, VoiceAudioOptions> dialogueCues;
/// <summary>
@ -46,7 +46,7 @@ namespace Vocalization.Framework
public CharacterVoiceCue(string name)
{
this.name = name;
this.dialogueCues = new Dictionary<string, string>();
this.dialogueCues = new Dictionary<string, VoiceAudioOptions>();
this.stringsFileNames = new List<string>();
this.dialogueFileNames = new List<string>();
this.dataFileNames = new List<string>();
@ -58,12 +58,12 @@ namespace Vocalization.Framework
/// <param name="dialogueString">The current dialogue string to play audio for.</param>
public void speak(string dialogueString)
{
string voiceFileName = "";
VoiceAudioOptions voiceFileName =new VoiceAudioOptions();
bool exists = dialogueCues.TryGetValue(dialogueString, out voiceFileName);
if (exists)
{
Vocalization.soundManager.stopAllSounds();
Vocalization.soundManager.playSound(voiceFileName);
Vocalization.soundManager.playSound(voiceFileName.getAudioClip());
}
else
{
@ -72,7 +72,7 @@ namespace Vocalization.Framework
}
}
public void addDialogue(string key, string value)
public void addDialogue(string key, VoiceAudioOptions value)
{
if (dialogueCues.ContainsKey(key))
{
@ -98,7 +98,7 @@ namespace Vocalization.Framework
else if (name == "Shops")
{
stringsFileNames.Add("StringsFromCSFiles.xnb");
this.addDialogue("Welcome to Pierre's! Need some supplies?", "");
this.addDialogue("Welcome to Pierre's! Need some supplies?", new VoiceAudioOptions());
}
else if (name == "ExtraDialogue")
{
@ -174,7 +174,7 @@ namespace Vocalization.Framework
List<string> clean = Vocalization.sanitizeDialogueFromDictionaries(sentence,this);
foreach(var cleanSentence in clean)
{
this.dialogueCues.Add(cleanSentence, "");
this.dialogueCues.Add(cleanSentence, new VoiceAudioOptions());
}
}
@ -194,7 +194,7 @@ namespace Vocalization.Framework
List<string> clean = Vocalization.sanitizeDialogueFromDictionaries(sentence,this);
foreach (var cleanSentence in clean)
{
this.dialogueCues.Add(cleanSentence, "");
this.dialogueCues.Add(cleanSentence, new VoiceAudioOptions());
}
}
@ -212,7 +212,7 @@ namespace Vocalization.Framework
List<string> clean = Vocalization.sanitizeDialogueFromDictionaries(sentence,this);
foreach (var cleanSentence in clean)
{
this.dialogueCues.Add(cleanSentence, "");
this.dialogueCues.Add(cleanSentence, new VoiceAudioOptions());
}
}
}
@ -240,7 +240,7 @@ namespace Vocalization.Framework
{
try
{
this.dialogueCues.Add(cleanSentence, "");
this.dialogueCues.Add(cleanSentence, new VoiceAudioOptions());
}
catch (Exception err)
{

View File

@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Vocalization.Framework
{
/// <summary>
/// Deals with determining what mode should play at the current moment.
/// </summary>
public class VoiceAudioOptions
{
/// <summary>
/// The audio clip that plays when the current voice mode is "Simple".
/// </summary>
public string simple;
/// <summary>
/// The audio clip that plays when the current voice mode is "Full".
/// </summary>
public string full;
/// <summary>
/// The audio clip that plays when the current voice mode is "HeartEvents".
/// </summary>
public string heartEvents;
/// <summary>
/// The audio clip that plays when the current voice mode is "SimpleAndHeartEvents".
/// </summary>
public string simpleAndHeartEvents;
public VoiceAudioOptions()
{
simple = "";
full = "";
heartEvents = "";
simpleAndHeartEvents = "";
}
public string getAudioClip()
{
if (Vocalization.config.currentMode == "Simple") return simple;
if (Vocalization.config.currentMode == "Full") return full;
if (Vocalization.config.currentMode == "HeartEvents") return heartEvents;
if (Vocalization.config.currentMode == "SimpleAndHeartEvents") return simpleAndHeartEvents;
return ""; //The current mode must not have been valid for some reason???
}
}
}

View File

@ -20,11 +20,49 @@ namespace Vocalization
/// </summary>
public string currentTranslation;
/// <summary>
/// Keeps track of the voice modes for determining how much audio is played.
/// </summary>
public List<string> modes;
/// <summary>
/// The curent mode for the mod.
/// </summary>
public string currentMode;
/// <summary>
/// The volume at which the sound for voices is played at.
/// </summary>
public float voiceVolume;
public ModConfig()
{
translations = new List<string>();
modes = new List<string>();
modes.Add("Simple");
modes.Add("Full");
modes.Add("HeartEvents");
modes.Add("SimpleAndHeartEvents");
currentMode = "Full";
translations.Add("English");
currentTranslation = "English";
this.voiceVolume = 1.0f;
}
/// <summary>
/// Validates
/// </summary>
public void verifyValidMode()
{
if (!modes.Contains(currentMode))
{
Vocalization.ModMonitor.Log("Invalid configuration: " + currentMode + ". Changing to Full voiced mode.");
currentMode = "Full";
}
}

View File

@ -172,7 +172,9 @@ namespace Vocalization
public static ModConfig config;
public List<string> onScreenSpeechBubbleDialogues;
/// <summary>
/// A dictionary that keeps track of all of the npcs whom have voice acting for their dialogue.
/// </summary>
@ -188,12 +190,16 @@ namespace Vocalization
DialogueCues = new Dictionary<string, CharacterVoiceCue>();
replacementStrings = new ReplacementStrings();
onScreenSpeechBubbleDialogues = new List<string>();
previousDialogue = "";
soundManager = new SimpleSoundManager.Framework.SoundManager();
config = new ModConfig();
ModHelper.ReadConfig<ModConfig>();
config = ModHelper.ReadConfig<ModConfig>();
config.verifyValidMode(); //Make sure the current mode is valid.
soundManager.volume = config.voiceVolume; //Set the volume for voices.
}
/// <summary>
@ -257,9 +263,12 @@ namespace Vocalization
{
string text = (string)GetInstanceField(typeof(NPC), v, "textAboveHead");
int timer = (int)GetInstanceField(typeof(NPC), v, "textAboveHeadTimer");
if (text == null || timer<=0) continue;
if (text == null) continue;
string currentDialogue = text;
if (previousDialogue != currentDialogue)
if (onScreenSpeechBubbleDialogues.Contains(currentDialogue) && timer > 0) continue; //If I have already added this dialogue and the timer has not run out, do nothing.
if (!onScreenSpeechBubbleDialogues.Contains(currentDialogue) && timer>0) //If I have not added this dialogue and the timer has not run out, add it.
{
List<string> tries = new List<string>();
tries.Add("SpeechBubbles");
@ -272,6 +281,8 @@ namespace Vocalization
{
//Not variable messages. Aka messages that don't contain words the user can change such as farm name, farmer name etc.
voice.speak(currentDialogue);
onScreenSpeechBubbleDialogues.Add(currentDialogue);
return;
}
else
{
@ -281,6 +292,17 @@ namespace Vocalization
}
}
}
else
{
if (timer <= 0 && onScreenSpeechBubbleDialogues.Contains(currentDialogue)) //If the timer has run out and I still contain the dialogue, remove it.
{
onScreenSpeechBubbleDialogues.Remove(currentDialogue);
}
if(timer<=0 && !onScreenSpeechBubbleDialogues.Contains(currentDialogue)) //If the timer has run out and I no longer contain the dialogue, continue on.
{
continue;
}
}
}
}
}
@ -736,7 +758,7 @@ namespace Vocalization
cleanDialogues = sanitizeDialogueFromDictionaries(cookingDialogue,cue);
foreach (var str in cleanDialogues)
{
cue.addDialogue(str, ""); //Make a new dialogue line based off of the text, but have the .wav value as empty.
cue.addDialogue(str,new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty.
}
}
@ -758,7 +780,7 @@ namespace Vocalization
cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue,cue);
foreach (var str in cleanDialogues)
{
cue.addDialogue(str, ""); //Make a new dialogue line based off of the text, but have the .wav value as empty.
cue.addDialogue(str,new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty.
}
}
@ -779,7 +801,7 @@ namespace Vocalization
cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue,cue);
foreach (var str in cleanDialogues)
{
cue.addDialogue(str, ""); //Make a new dialogue line based off of the text, but have the .wav value as empty.
cue.addDialogue(str,new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty.
}
}
@ -812,7 +834,7 @@ namespace Vocalization
foreach (var str in cleanDialogues)
{
string ahh = sanitizeDialogueFromMailDictionary(str);
cue.addDialogue(ahh, ""); //Make a new dialogue line based off of the text, but have the .wav value as empty.
cue.addDialogue(ahh, new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty.
}
}
@ -853,7 +875,7 @@ namespace Vocalization
cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue,cue);
foreach (var str in cleanDialogues)
{
cue.addDialogue(str, ""); //Make a new dialogue line based off of the text, but have the .wav value as empty.
cue.addDialogue(str,new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty.
}
}
@ -891,7 +913,7 @@ namespace Vocalization
cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue,cue);
foreach (var str in cleanDialogues)
{
cue.addDialogue(str, ""); //Make a new dialogue line based off of the text, but have the .wav value as empty.
cue.addDialogue(str,new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty.
}
}
@ -925,7 +947,7 @@ namespace Vocalization
cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue,cue);
foreach (var str in cleanDialogues)
{
cue.addDialogue(str, ""); //Make a new dialogue line based off of the text, but have the .wav value as empty.
cue.addDialogue(str,new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty.
}
}
@ -960,7 +982,7 @@ namespace Vocalization
cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue,cue);
foreach (var str in cleanDialogues)
{
cue.addDialogue(str, ""); //Make a new dialogue line based off of the text, but have the .wav value as empty.
cue.addDialogue(str,new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty.
}
}
}
@ -977,7 +999,7 @@ namespace Vocalization
cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue,cue);
foreach (var str in cleanDialogues)
{
cue.addDialogue(str, ""); //Make a new dialogue line based off of the text, but have the .wav value as empty.
cue.addDialogue(str,new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty.
}
}
}
@ -1007,7 +1029,7 @@ namespace Vocalization
string cleanDialogue = "";
cleanDialogue = sanitizeDialogueFromMailDictionary(rawDialogue);
cue.addDialogue(cleanDialogue, ""); //Make a new dialogue line based off of the text, but have the .wav value as empty
cue.addDialogue(cleanDialogue, new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty
}
}
}
@ -1039,7 +1061,7 @@ namespace Vocalization
cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue,cue);
foreach (var str in cleanDialogues)
{
cue.addDialogue(str, ""); //Make a new dialogue line based off of the text, but have the .wav value as empty.
cue.addDialogue(str,new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty.
}
}
@ -1075,7 +1097,7 @@ namespace Vocalization
cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue,cue);
foreach (var str in cleanDialogues)
{
cue.addDialogue(str, ""); //Make a new dialogue line based off of the text, but have the .wav value as empty.
cue.addDialogue(str,new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty.
}
}
@ -1105,7 +1127,7 @@ namespace Vocalization
cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue,cue);
foreach (var str in cleanDialogues)
{
cue.addDialogue(str, ""); //Make a new dialogue line based off of the text, but have the .wav value as empty.
cue.addDialogue(str,new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty.
}
}
@ -1141,7 +1163,7 @@ namespace Vocalization
foreach (var v in cleanDialogue)
{
cue.addDialogue(v, ""); //Make a new dialogue line based off of the text, but have the .wav value as empty
cue.addDialogue(v, new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty
}
}
}
@ -1188,7 +1210,7 @@ namespace Vocalization
cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue,cue);
foreach (var str in cleanDialogues)
{
cue.addDialogue(str, ""); //Make a new dialogue line based off of the text, but have the .wav value as empty.
cue.addDialogue(str,new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty.
}
}
}
@ -1261,7 +1283,7 @@ namespace Vocalization
cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue,cue);
foreach (var str in cleanDialogues)
{
cue.addDialogue(str, ""); //Make a new dialogue line based off of the text, but have the .wav value as empty.
cue.addDialogue(str,new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty.
}
}
}
@ -1290,7 +1312,7 @@ namespace Vocalization
string key = pair.Key;
string rawDialogue = pair.Value;
string cleanString = sanitizeDialogueFromSpeechBubblesDictionary(rawDialogue);
cue.addDialogue(cleanString, ""); //Make a new dialogue line based off of the text, but have the .wav value as empty.
cue.addDialogue(cleanString, new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty.
}
continue;
}
@ -1331,7 +1353,7 @@ namespace Vocalization
cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue,cue);
foreach (var str in cleanDialogues)
{
cue.addDialogue(str, ""); //Make a new dialogue line based off of the text, but have the .wav value as empty.
cue.addDialogue(str,new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty.
}
}
}
@ -1367,7 +1389,7 @@ namespace Vocalization
cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue,cue);
foreach (var str in cleanDialogues)
{
cue.addDialogue(str, ""); //Make a new dialogue line based off of the text, but have the .wav value as empty.
cue.addDialogue(str,new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty.
}
}
}
@ -1392,7 +1414,7 @@ namespace Vocalization
cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue,cue);
foreach (var str in cleanDialogues)
{
cue.addDialogue(str, ""); //Make a new dialogue line based off of the text, but have the .wav value as empty.
cue.addDialogue(str,new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty.
}
}
}
@ -1404,7 +1426,7 @@ namespace Vocalization
cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue,cue);
foreach (var str in cleanDialogues)
{
cue.addDialogue(str, ""); //Make a new dialogue line based off of the text, but have the .wav value as empty.
cue.addDialogue(str,new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty.
}
}
}
@ -1438,7 +1460,7 @@ namespace Vocalization
cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue,cue);
foreach (var str in cleanDialogues)
{
cue.addDialogue(str, ""); //Make a new dialogue line based off of the text, but have the .wav value as empty.
cue.addDialogue(str,new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty.
}
}
}
@ -1473,7 +1495,7 @@ namespace Vocalization
cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue,cue);
foreach (var str in cleanDialogues)
{
cue.addDialogue(str, ""); //Make a new dialogue line based off of the text, but have the .wav value as empty.
cue.addDialogue(str,new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty.
}
}
}
@ -1501,7 +1523,7 @@ namespace Vocalization
cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue,cue);
foreach (var str in cleanDialogues)
{
cue.addDialogue(str, ""); //Make a new dialogue line based off of the text, but have the .wav value as empty.
cue.addDialogue(str,new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty.
}
}

View File

@ -50,6 +50,7 @@
<ItemGroup>
<Compile Include="Framework\CharacterVoiceCue.cs" />
<Compile Include="Framework\ReplacementStrings.cs" />
<Compile Include="Framework\VoiceAudioOptions.cs" />
<Compile Include="ModConfig.cs" />
<Compile Include="Vocalization.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />