// Say something with a custom resolver public void Say(ScriptResolver resolver, Ship ship, string scriptName, Event theEvent = null, int?priority = null, string voice = null, bool sayOutLoud = true, bool invokedFromVA = false) { Dictionary <string, Cottle.Value> dict = createVariables(theEvent); string speech = resolver.resolve(scriptName, dict); if (speech != null) { if (subtitles) { // Log a tidied version of the speech log(Regex.Replace(speech, "<.*?>", string.Empty)); } if (sayOutLoud && !(subtitles && subtitlesOnly)) { SpeechService.Instance.Say(ship, speech, (priority == null ? resolver.priority(scriptName) : (int)priority), voice, false, theEvent?.type, invokedFromVA); } } }
public void TestScript(string scriptName, Dictionary <string, Script> scripts) { // See if we have a sample List <Event> sampleEvents; object sample = Events.SampleByName(scriptName); if (sample == null) { sampleEvents = new List <Event>(); } else if (sample is string) { // It's a string so a journal entry. Parse it sampleEvents = JournalMonitor.ParseJournalEntry((string)sample); } else if (sample is Event) { // It's a direct event sampleEvents = new List <Event>() { (Event)sample }; } else { Logging.Warn("Unknown sample type " + sample.GetType()); sampleEvents = new List <Event>(); } ScriptResolver testScriptResolver = new ScriptResolver(scripts); if (sampleEvents.Count == 0) { sampleEvents.Add(null); } foreach (Event sampleEvent in sampleEvents) { Say(testScriptResolver, null, scriptName, sampleEvent, testScriptResolver.priority(scriptName)); } }
private void testButtonClick(object sender, RoutedEventArgs e) { // Splice the new script in to the existing scripts Dictionary <string, Script> newScripts = new Dictionary <string, Script>(scripts); Script testScript = new Script(ScriptName, ScriptDescription, false, ScriptValue); newScripts.Remove(ScriptName); newScripts.Add(ScriptName, testScript); SpeechResponder responder = new SpeechResponder(); responder.Start(); // See if we have a sample List <Event> sampleEvents; object sample = Events.SampleByName(script.Name); if (sample == null) { sampleEvents = new List <Event>(); } else if (sample is string) { // It's a string so a journal entry. Parse it sampleEvents = JournalMonitor.ParseJournalEntry((string)sample); } else if (sample is Event) { // It's a direct event sampleEvents = new List <Event>() { (Event)sample }; } else { Logging.Warn("Unknown sample type " + sample.GetType()); sampleEvents = new List <Event>(); } ScriptResolver scriptResolver = new ScriptResolver(newScripts); if (sampleEvents.Count == 0) { sampleEvents.Add(null); } foreach (Event sampleEvent in sampleEvents) { responder.Say(scriptResolver, ((ShipMonitor)EDDI.Instance.ObtainMonitor("Ship monitor"))?.GetCurrentShip(), ScriptName, sampleEvent, scriptResolver.priority(script.Name)); } }
private void testScript(object sender, RoutedEventArgs e) { Script script = ((KeyValuePair <string, Script>)((Button)e.Source).DataContext).Value; SpeechResponder responder = new SpeechResponder(); responder.Start(); // See if we have a sample List <Event> sampleEvents; object sample = Events.SampleByName(script.Name); if (sample == null) { sampleEvents = new List <Event>(); } else if (sample is string) { // It's as tring so a journal entry. Parse it sampleEvents = JournalMonitor.ParseJournalEntry((string)sample); } else if (sample is Event) { // It's a direct event sampleEvents = new List <Event>() { (Event)sample }; } else { Logging.Warn("Unknown sample type " + sample.GetType()); sampleEvents = new List <Event>(); } ScriptResolver scriptResolver = new ScriptResolver(Personality.Scripts); if (sampleEvents.Count == 0) { sampleEvents.Add(null); } foreach (Event sampleEvent in sampleEvents) { responder.Say(scriptResolver, ((ShipMonitor)EDDI.Instance.ObtainMonitor("Ship monitor"))?.GetCurrentShip(), script.Name, sampleEvent, scriptResolver.priority(script.Name)); } }
// Say something with a custom resolver public void Say(ScriptResolver resolver, string scriptName, Event theEvent = null, int?priority = null, string voice = null, bool?wait = null) { Dictionary <string, Cottle.Value> dict = createVariables(theEvent); string speech = resolver.resolve(scriptName, dict); if (speech != null) { if (subtitles) { // Log a tidied version of the speech log(Regex.Replace(speech, "<.*?>", string.Empty)); } if (!(subtitles && subtitlesOnly)) { SpeechService.Instance.Say(EDDI.Instance.Ship, speech, (wait == null ? true : (bool)wait), (priority == null ? resolver.priority(scriptName) : (int)priority), voice); } } }
// Say something with a custom resolver public void Say(ScriptResolver resolver, string scriptName, Event theEvent = null, int? priority = null, bool? wait = null) { Dictionary<string, Cottle.Value> dict = createVariables(theEvent); string script = resolver.resolve(scriptName, dict); if (script != null) { SpeechService.Instance.Say(EDDI.Instance.Ship, script, (wait == null ? true : (bool)wait), (priority == null ? resolver.priority(scriptName) : (int)priority)); } }
// Say something with a custom resolver public void Say(ScriptResolver resolver, string scriptName, Event theEvent = null, int?priority = null, bool?wait = null) { Dictionary <string, Cottle.Value> dict = createVariables(theEvent); string script = resolver.resolve(scriptName, dict); if (script != null) { SpeechService.Instance.Say(EDDI.Instance.Ship, script, (wait == null ? true : (bool)wait), (priority == null ? resolver.priority(scriptName) : (int)priority)); } }