From 4951f4872dbb46bd0d4b757222ec59f68f923eb7 Mon Sep 17 00:00:00 2001 From: barkermn01 Date: Tue, 21 Jan 2020 19:44:09 +0000 Subject: [PATCH 1/2] Fixed issue #2 and issue #3 needed to apply file path modifer from the config xml. --- .../Ultrasound7H/Ultrasound7H.csproj | 4 ---- Ultrasound 7H/Ultrasound7H/fVoices.cs | 10 ++++------ ...gnTimeResolveAssemblyReferencesInput.cache | Bin 7544 -> 7448 bytes UltrasoundInputHooker/Plugin.cs | 2 ++ 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/Ultrasound 7H/Ultrasound7H/Ultrasound7H.csproj b/Ultrasound 7H/Ultrasound7H/Ultrasound7H.csproj index d399112..d783ddd 100644 --- a/Ultrasound 7H/Ultrasound7H/Ultrasound7H.csproj +++ b/Ultrasound 7H/Ultrasound7H/Ultrasound7H.csproj @@ -98,10 +98,6 @@ {e614a97e-9dc7-4272-b7ff-ab9504379fda} UltrasoundLib - - {8687ae4b-adfb-49c0-896f-b86bc6d39def} - Ultrasound - diff --git a/Ultrasound 7H/Ultrasound7H/fVoices.cs b/Ultrasound 7H/Ultrasound7H/fVoices.cs index f5295d5..69a6c61 100644 --- a/Ultrasound 7H/Ultrasound7H/fVoices.cs +++ b/Ultrasound 7H/Ultrasound7H/fVoices.cs @@ -20,7 +20,6 @@ using System.Text; using System.Threading; using System.Windows.Forms; -using Ultrasound; namespace Voices { @@ -312,7 +311,7 @@ private void NewDialogue( this.lbText.TopIndex = this.lbText.Items.Count - itemsPerPage; if (this._current != null) voiceEntry2 = this._current.Entries.Find((Predicate)(e => e.Matches(DID, SID, charsInParty) && dlgSel.ToString().Equals(e.Choice))); - if (voiceEntry2 != null && this._data.Exists(voiceEntry2.File)) + if (voiceEntry2 != null && this._data.Exists(this._config.strightApplyAudioPath(voiceEntry2.File))) this.TriggerChoice(this.CreateSound(voiceEntry2.DID, voiceEntry2.File)); } } @@ -336,13 +335,13 @@ private int GetSoundLength(string fileName) private void IncomingSEvent(fVoices.SoundEvent se) { Sound s = this._ultrasound.Select((int)se.Sound, (int)se.FieldID, (int)se.PPV); - if (s == null || !this._data.Exists(s.File)) + if (s == null || !this._data.Exists(this._config.strightApplyAudioPath(s.File))) return; - this.Invoke(new Action(() => this.LogSEvent(" --> playing " + s.File + " with length of " + GetSoundLength(s.File).ToString() + " Frames"))); + this.Invoke(new Action(() => this.LogSEvent(" --> playing " + s.File + " with length of " + GetSoundLength(s.File).ToString() + " Frames"))); this._output.Play(new ALOutput.SoundPlay() { - File = s.File, + File = this._config.strightApplyAudioPath(s.File), Pan = Math.Max(Math.Min(1f, (float)se.Pan / 128f), 0.0f), Volume = 1f, OnComplete = new Action(() => { @@ -526,7 +525,6 @@ private void bTest_Click(object sender, EventArgs e) private void bTools_Click(object sender, EventArgs e) { - new fTools().Show(); } private void fVoices_FormClosed(object sender, FormClosedEventArgs e) diff --git a/Ultrasound 7H/Ultrasound7H/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/Ultrasound 7H/Ultrasound7H/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache index 049be6b8ea3bdf011d4680b3eae87df7a816f505..4e7b9499d86702d181e5a9a67863099d6f44cc87 100644 GIT binary patch delta 208 zcmexiHN$GdejY}F%?Egt*)}^1N3cq3G9Z8;8<5Qi#B5qXB6zZaV6cfGJ4{R)$Y60R z&Bz{qq~_ML834tlszW9_Fp05L*0LE+4(E0k wF#-zmRtF`PyJhC2`X%P3*0LE-UMrc!Y66r1JBNwQbaJ6oCZpEo+fuen0FhfX1ONa4 diff --git a/UltrasoundInputHooker/Plugin.cs b/UltrasoundInputHooker/Plugin.cs index 575c592..b8cf29b 100644 --- a/UltrasoundInputHooker/Plugin.cs +++ b/UltrasoundInputHooker/Plugin.cs @@ -122,6 +122,8 @@ private void getProccess() if (test.IsMatch(procExeName)) { ff7 = proc; + procPath[procPath.Length - 1] = ""; + BasePath = String.Join("\\", procPath); break; } } From db051ec6422216dd1109047873fef683934df00a Mon Sep 17 00:00:00 2001 From: barkermn01 Date: Tue, 21 Jan 2020 19:53:15 +0000 Subject: [PATCH 2/2] Fixes issue #4 --- Ultrasound 7H/Ultrasound7H/fVoices.cs | 1 - UltrasoundInputHooker/Plugin.cs | 45 +++++++++++++++++---------- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/Ultrasound 7H/Ultrasound7H/fVoices.cs b/Ultrasound 7H/Ultrasound7H/fVoices.cs index 69a6c61..eb73b64 100644 --- a/Ultrasound 7H/Ultrasound7H/fVoices.cs +++ b/Ultrasound 7H/Ultrasound7H/fVoices.cs @@ -531,7 +531,6 @@ private void fVoices_FormClosed(object sender, FormClosedEventArgs e) { this._output.Terminate(); Registry.SetValue("HKEY_CURRENT_USER\\Software\\Ficedula\\Ultrasound", "Logging", (object)this.cbLogging.SelectedIndex); - Application.Exit(); } protected override void Dispose(bool disposing) diff --git a/UltrasoundInputHooker/Plugin.cs b/UltrasoundInputHooker/Plugin.cs index b8cf29b..0481379 100644 --- a/UltrasoundInputHooker/Plugin.cs +++ b/UltrasoundInputHooker/Plugin.cs @@ -130,10 +130,13 @@ private void getProccess() catch (Exception) { } } - inputSim = new WindowsInput.InputSimulator(); - keySim = new WindowsInput.KeyboardSimulator(inputSim); - - windowHandle = ff7.MainWindowHandle; + try + { + inputSim = new WindowsInput.InputSimulator(); + keySim = new WindowsInput.KeyboardSimulator(inputSim); + windowHandle = ff7.MainWindowHandle; + } + catch (Exception) { } } private Dictionary Keys { get; set; } @@ -141,14 +144,19 @@ private void getProccess() private void getKeys() { - DateTime lastWrite = File.GetLastWriteTime(BasePath + "ff7input.cfg"); - - if (lastWrite > keysLastUpdated) + try { - Keys = readUserInputs(); - keysLastUpdated = lastWrite; + DateTime lastWrite = File.GetLastWriteTime(BasePath + "ff7input.cfg"); + + if (lastWrite > keysLastUpdated) + { + Keys = readUserInputs(); + keysLastUpdated = lastWrite; + } + } + catch (Exception) { + } - } public override void Start(RuntimeMod mod) @@ -163,13 +171,16 @@ public override void Start(RuntimeMod mod) { Console.WriteLine("Voice from file " + f + " has finished"); - getKeys(); - IntPtr thisThread = GetCurrentThreadId(); - AttachThreadInput(thisThread, new IntPtr(ff7.Threads[0].Id), true); - keySim.KeyDown((WindowsInput.Native.VirtualKeyCode)Keys[KeyBoardBindings.OK]); - Thread.Sleep(200); - keySim.KeyUp((WindowsInput.Native.VirtualKeyCode)Keys[KeyBoardBindings.OK]); - AttachThreadInput(thisThread, new IntPtr(ff7.Threads[0].Id), false); + if (!ff7.HasExited) + { + getKeys(); + IntPtr thisThread = GetCurrentThreadId(); + AttachThreadInput(thisThread, new IntPtr(ff7.Threads[0].Id), true); + keySim.KeyDown((WindowsInput.Native.VirtualKeyCode)Keys[KeyBoardBindings.OK]); + Thread.Sleep(200); + keySim.KeyUp((WindowsInput.Native.VirtualKeyCode)Keys[KeyBoardBindings.OK]); + AttachThreadInput(thisThread, new IntPtr(ff7.Threads[0].Id), false); + } })); initId = hooks_instance.hookInit(new InitAction(() => {