Parsed events? Just need to test to make sure festivals and events work properly.

This commit is contained in:
2018-08-19 10:56:19 -07:00
parent e7f679b036
commit 3184888152
2 changed files with 89 additions and 1 deletions

View File

@ -38,6 +38,7 @@ namespace Vocalization.Framework
public List<string> eventFileNames;
/// <summary>
/// A dictionary of dialogue strings that correspond to audio files.
/// </summary>
@ -188,6 +189,16 @@ namespace Vocalization.Framework
festivalFileNames.Add("winter8.xnb");
festivalFileNames.Add("winter25.xnb");
string content = Game1.content.RootDirectory;
string dir = Path.Combine(content, "Data", "Events");
string[] files = Directory.GetFiles(dir);
foreach(var file in files)
{
string eventFileName = Path.GetFileNameWithoutExtension(file)+".xnb";
if (eventFileNames.Contains(eventFileName)) continue;
else eventFileNames.Add(eventFileName);
}
}
}
@ -225,6 +236,24 @@ namespace Vocalization.Framework
stringsFileNames[i] = s;
Vocalization.ModMonitor.Log(stringsFileNames.ElementAt(i));
}
for (int i = 0; i < this.festivalFileNames.Count; i++)
{
Vocalization.ModMonitor.Log(festivalFileNames.ElementAt(i));
string s = festivalFileNames.ElementAt(i);
s = festivalFileNames.ElementAt(i).Replace(".xnb", Vocalization.config.translationInfo.getFileExtentionForTranslation(translation));
festivalFileNames[i] = s;
Vocalization.ModMonitor.Log(festivalFileNames.ElementAt(i));
}
for (int i = 0; i < this.eventFileNames.Count; i++)
{
Vocalization.ModMonitor.Log(eventFileNames.ElementAt(i));
string s = eventFileNames.ElementAt(i);
s = eventFileNames.ElementAt(i).Replace(".xnb", Vocalization.config.translationInfo.getFileExtentionForTranslation(translation));
eventFileNames[i] = s;
Vocalization.ModMonitor.Log(eventFileNames.ElementAt(i));
}
}

View File

@ -728,6 +728,7 @@ namespace Vocalization
var stringsPath = Path.Combine("Strings"); //Used for all sorts of extra strings and stuff for like StringsFromCS
var dataPath = Path.Combine("Data"); //Used for engagement dialogue strings, and ExtraDialogue, Notes, Secret Notes, Mail
var festivalPath = Path.Combine(dataPath, "Festivals");
var eventPath = Path.Combine(dataPath, "Events");
ModMonitor.Log("Scraping dialogue for character: " + cue.name,LogLevel.Info);
//If the "character"'s name is TV which means I'm watching tv, scrape the data from the TV shows.
@ -1722,6 +1723,46 @@ namespace Vocalization
}
}
}
foreach (var fileName in cue.eventFileNames)
{
ModMonitor.Log(" Scraping event file: " + fileName, LogLevel.Info);
//basically this will never run but can be used below to also add in dialogue.
if (!String.IsNullOrEmpty(fileName))
{
string dialoguePath2 = Path.Combine(eventPath, fileName);
string root = Game1.content.RootDirectory;///////USE THIS TO CHECK FOR EXISTENCE!!!!!
if (!File.Exists(Path.Combine(root, dialoguePath2)))
{
ModMonitor.Log("Dialogue file not found for:" + fileName + ". This might not necessarily be a mistake just a safety check.");
continue; //If the file is not found for some reason...
}
var DialogueDict = ModHelper.Content.Load<Dictionary<string, string>>(dialoguePath2, ContentSource.GameContent);
foreach (KeyValuePair<string, string> pair in DialogueDict)
{
string key = pair.Key;
if (key != cue.name) continue;
string rawDialogue = pair.Value;
List<string> speakingLines = getEventSpeakerLines(rawDialogue, cue.name);
//Sanitize Event info here!
List<string> cleanDialogues = new List<string>();
cleanDialogues = sanitizeDialogueFromDictionaries(rawDialogue, cue);
foreach (var str in cleanDialogues)
{
cue.addDialogue(str, new VoiceAudioOptions()); //Make a new dialogue line based off of the text, but have the .wav value as empty.
}
}
}
}
foreach (var fileName in cue.dataFileNames)
{
ModMonitor.Log(" Scraping dialogue file: " + fileName, LogLevel.Info);
@ -1940,6 +1981,24 @@ namespace Vocalization
//DialogueCues.Add(cue.name, cue);
}
public List<string> getEventSpeakerLines(string rawDialogue, string speakerName)
{
string[] dialogueSplit= rawDialogue.Split('/');
List<string> speakingData = new List<string>();
foreach(var dia in dialogueSplit)
{
if (!dia.Contains("speak") && !dia.Contains("textAboveHead") && !dia.Contains(speakerName)) continue;
string[] actualDialogue = dia.Split(new string[] { "\"" }, StringSplitOptions.None);
ModMonitor.Log(actualDialogue[1]);
//Get the actual dialogue line from this npc.
speakingData.Add(actualDialogue[1]);
}
return speakingData;
}
/// <summary>
/// Function taken from game code to satisfy all dialogue options.