private void fVoices_Load(object sender, EventArgs e) { this._ff7 = ConfigurationManager.AppSettings["FF7"]; this._hook = ConfigurationManager.AppSettings["HookDll"]; this._hook = this._hook.Replace("{APPPATH}", Application.CommonAppDataPath); using (Stream input = this._data.Open("index.xml")) this._index = Util.Deserialise <VoiceIndex>(input); this._index.Freeze(); string file = this._index.Lookup(0); if (file != null) { this._global = this.LoadVL(file); } using (Stream input = this._data.Open("ultrasound.xml")) this._ultrasound = Util.Deserialise <Voices.Ultrasound>(input); this._ultrasound.Freeze(); this._output = new ALOutput(this._data) { Log = new Action <string>(this.DoLog) }; new Thread(new ThreadStart(this.ThreadReader)) { Name = "BackgroundVoiceReader", IsBackground = true }.Start(); new Thread(new ThreadStart(this.SoundReader)) { Name = "BackgroundUltrasoundReader", IsBackground = true, Priority = ThreadPriority.AboveNormal }.Start(); Button bTest = this.bTest; Button bDump = this.bDump; string[] commandLineArgs = Environment.GetCommandLineArgs(); Func <string, bool> predicate = (Func <string, bool>)(s => s.Equals("/DUMP", StringComparison.InvariantCultureIgnoreCase)); int num1; bool flag = (num1 = ((IEnumerable <string>)commandLineArgs).Any <string>(predicate) ? 1 : 0) != 0; bDump.Visible = num1 != 0; int num2 = flag ? 1 : 0; bTest.Visible = num2 != 0; ComboBox cbLogging = this.cbLogging; int? nullable = (int?)Registry.GetValue("HKEY_CURRENT_USER\\Software\\Ficedula\\Ultrasound", "Logging", (object)0); int valueOrDefault = (nullable.HasValue ? new int?(nullable.GetValueOrDefault()) : new int?(0)).GetValueOrDefault(); cbLogging.SelectedIndex = valueOrDefault; }
private void NewDialogue( int fieldID, string text, int DID, int SID, int charsInParty, int dlgSel) { this.lbText.Items.Add((object)string.Format("{0}/{2}/{3} ({4:x}): {1}", (object)fieldID, (object)text, (object)DID, (object)SID, (object)charsInParty)); if (fieldID != this._currentFID) { this._current = (VoiceList)null; string file = this._index.Lookup(fieldID); if (file != null) { this._current = this.LoadVL(file); } this._currentFID = fieldID; } VoiceEntry voiceEntry1 = (VoiceEntry)null; if (dlgSel < 0) { if (this._current != null) { voiceEntry1 = this._current.Entries.Find((Predicate <VoiceEntry>)(e => e.Matches(DID, SID, charsInParty) && string.IsNullOrEmpty(e.Choice))); } if (voiceEntry1 == null && this._global != null) { voiceEntry1 = this._global.Entries.Find((Predicate <VoiceEntry>)(e => e.Matches(DID, SID, charsInParty) && string.IsNullOrEmpty(e.Choice))); } if (voiceEntry1 == null) { return; } string logMsg = string.Format("[{0}] {1}", (object)voiceEntry1.File, (object)text); bool flag = this.cbLogging.SelectedIndex == 2; lock (this._curLock) { if (this._curDialogue != null) { this._output.Stop(this._curDialogue); } if (this._curChoice != null) { this._output.Stop(this._curChoice); } System.Diagnostics.Debug.WriteLine("Clearing all current"); this._curChoice = this._curDialogue = (ALOutput.SoundPlay)null; if (this._data.Exists(voiceEntry1.File)) { this.lbText.Items.Add((object)(" --> playing " + voiceEntry1.File)); ALOutput.SoundPlay snd = this.CreateSound(voiceEntry1.File); this._curDialogue = snd; this._curDialogue.OnComplete = (Action)(() => this.DialogueDone(snd)); this._output.Play(this._curDialogue); System.Diagnostics.Debug.WriteLine("Playing " + this._curDialogue.File); logMsg = "[PRESENT] " + logMsg; } else { logMsg = "[MISSING] " + logMsg; flag = this.cbLogging.SelectedIndex >= 1; } } if (flag) { this.DoLog(logMsg); } } else { VoiceEntry voiceEntry2 = (VoiceEntry)null; this.lbText.Items.Add((object)("Choice changed to " + dlgSel.ToString())); if (this._current != null) { voiceEntry2 = this._current.Entries.Find((Predicate <VoiceEntry>)(e => e.Matches(DID, SID, charsInParty) && dlgSel.ToString().Equals(e.Choice))); } if (voiceEntry2 != null && this._data.Exists(voiceEntry2.File)) { this.TriggerChoice(this.CreateSound(voiceEntry2.File)); } } }
public static VoiceList Dump(Stream fieldFile, string name) { int offset1 = Util.ReadIntFrom(fieldFile, 6); Util.ReadIntFrom(fieldFile, offset1); Util.ReadByteFrom(fieldFile, offset1 + 6); Util.ReadByteFrom(fieldFile, offset1 + 7); ushort num1 = Util.ReadUShortFrom(fieldFile, offset1 + 8); Util.ReadUShortFrom(fieldFile, offset1 + 10); int offset2 = offset1 + 4 + (int)num1; ushort num2 = Util.ReadUShortFrom(fieldFile, offset2); List <string[]> strArrayList = new List <string[]>(); if (num2 < (ushort)1000) { foreach (int num3 in Enumerable.Range(0, (int)num2)) { ushort num4 = Util.ReadUShortFrom(fieldFile, offset2 + 2 + 2 * num3); ushort num5 = Util.ReadUShortFrom(fieldFile, offset2 + 4 + 2 * num3); fieldFile.Position = (long)(offset2 + (int)num4); if ((int)num5 < (int)num4) { num5 = (ushort)((uint)num4 + 1024U); } if ((int)num4 > (int)num5) { return((VoiceList)null); } byte[] numArray = new byte[(int)num5 - (int)num4]; fieldFile.Read(numArray, 0, numArray.Length); strArrayList.Add(Util.Translate(numArray, numArray.Length).ToArray <string>()); } } VoiceList voiceList = new VoiceList() { Entries = new List <VoiceEntry>() }; foreach (int index in Enumerable.Range(0, strArrayList.Count)) { char ch = 'a'; string str1 = (string)null; foreach (string str2 in strArrayList[index]) { string str3 = name + "\\" + index.ToString(); if (strArrayList[index].Length > 1) { str3 += ch.ToString(); str1 = ch.ToString(); ++ch; } voiceList.Entries.Add(new VoiceEntry() { Dialogue = str2, File = str3 + ".wav", DID = index, SID = str1 }); } } return(voiceList); }