From dfe13b1dca4980ab4cda49ae93f6e4db16fbede3 Mon Sep 17 00:00:00 2001 From: Osmodium Date: Thu, 18 Jan 2024 01:00:54 +0100 Subject: [PATCH] Fix load, hovering and remove hooking into various decoration labels --- README.md | 4 ++-- SpeechMod.sln | 1 + SpeechMod/Info.json | 2 +- SpeechMod/Patches/TooltipEngine_Patch.cs | 7 ++++++- SpeechMod/PhoneticDictionary.json | 3 ++- SpeechMod/SpeechMod.csproj | 4 ---- SpeechMod/Unity/Extensions/Hooks.cs | 19 +++++++------------ 7 files changed, 19 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index cdce181..31c2c1c 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ By [Osmodium](https://github.com/Osmodium) ## This mod is made for Warhammer 40K: Rogue Trader and introduces TTS (TextToSpeech) in most places. -Version: 0.9.0 +Version: 0.9.2 **Disclaimer: UNDER DEVELOPMENT** @@ -119,7 +119,7 @@ In the main menu view, a welcome message is shown, this can be played back by ho ### Settings -New keybind setting in the game menu under "Sound" +New keybind setting in the game menu under "Sound" to stop playback. ![Assign keybind(s) to stopping of playback](https://dashvoid.com/speechmod/w40krt/4_Keybinding.png) If enabled in the mod-settings, a notification will be shown when stopping the playback through use of the keybind. diff --git a/SpeechMod.sln b/SpeechMod.sln index 2fca92e..34ec944 100644 --- a/SpeechMod.sln +++ b/SpeechMod.sln @@ -9,6 +9,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Test", "Test\Test.csproj", EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solutionfiles", "Solutionfiles", "{504859E5-17AA-4CD4-BD1C-40BCAFCF4E5F}" ProjectSection(SolutionItems) = preProject + README.md = README.md Todo.txt = Todo.txt EndProjectSection EndProject diff --git a/SpeechMod/Info.json b/SpeechMod/Info.json index 62b06b4..0586fb6 100644 --- a/SpeechMod/Info.json +++ b/SpeechMod/Info.json @@ -7,5 +7,5 @@ "AssemblyName": "W40KRTSpeechMod.dll", "EntryMethod": "SpeechMod.Main.Load", "HomePage": "https://www.nexusmods.com/warhammer40kroguetrader/mods/75", - "Version": "0.9.1" + "Version": "0.9.2" } \ No newline at end of file diff --git a/SpeechMod/Patches/TooltipEngine_Patch.cs b/SpeechMod/Patches/TooltipEngine_Patch.cs index 6413c88..420bd9a 100644 --- a/SpeechMod/Patches/TooltipEngine_Patch.cs +++ b/SpeechMod/Patches/TooltipEngine_Patch.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.Linq; using Kingmaker.Code.UI.MVVM.View.Tooltip.Bricks; +using Kingmaker.Utility; using Owlcat.Runtime.UI.Controls.Button; using TMPro; using UnityEngine; @@ -79,9 +80,13 @@ private static bool ApplyFilter(Transform transform) if (string.IsNullOrWhiteSpace(transform.name)) return false; - return !(transform.name.Trim().Equals("bracket", StringComparison.InvariantCultureIgnoreCase) + return !(transform.GetGameObjectPath().Contains("ComparativeTooltipPCView") + || transform.name.Trim().Equals("bracket", StringComparison.InvariantCultureIgnoreCase) || transform.name.Trim().Equals("Acronim", StringComparison.InvariantCultureIgnoreCase) || transform.name.Trim().Equals("decortext", StringComparison.InvariantCultureIgnoreCase) + || transform.name.Trim().Equals("Text (TMP) (1)", StringComparison.InvariantCultureIgnoreCase) + || transform.name.Trim().Equals("Text (TMP) (2)", StringComparison.InvariantCultureIgnoreCase) + || transform.GetGameObjectPath()!.Contains("/LeftBlock (1)/Empty/Text (TMP)") || transform.parent?.GetComponent() != null); } } \ No newline at end of file diff --git a/SpeechMod/PhoneticDictionary.json b/SpeechMod/PhoneticDictionary.json index 1d88539..64d8e3a 100644 --- a/SpeechMod/PhoneticDictionary.json +++ b/SpeechMod/PhoneticDictionary.json @@ -55,5 +55,6 @@ "technomat": "techno-mat", "mechanised": "mechanized", "heretech": "herree-tech", - "xenotech": "xeenotech" + "xenotech": "xeenotech", + "sceptical": "skeptical" } diff --git a/SpeechMod/SpeechMod.csproj b/SpeechMod/SpeechMod.csproj index 9b67aae..3965f30 100644 --- a/SpeechMod/SpeechMod.csproj +++ b/SpeechMod/SpeechMod.csproj @@ -43,10 +43,6 @@ $(RogueTraderInstallDir)\WH40KRT_Data\Managed\Owlcat.Runtime.UniRx.dll False - - $(RogueTraderInstallDir)\WH40KRT_Data\Managed\RogueTrader.GameCore.dll - False - $(RogueTraderInstallDir)\WH40KRT_Data\Managed\UniRx.dll False diff --git a/SpeechMod/Unity/Extensions/Hooks.cs b/SpeechMod/Unity/Extensions/Hooks.cs index f293e00..b9259fa 100644 --- a/SpeechMod/Unity/Extensions/Hooks.cs +++ b/SpeechMod/Unity/Extensions/Hooks.cs @@ -89,24 +89,14 @@ public static void HookupTextToSpeech(this TextMeshProUGUI textMeshPro, bool for return; } - var skipEventAssignment = false; - var defaultValues = textMeshProTransform.GetComponent(); if (defaultValues == null) { defaultValues = textMeshProTransform.gameObject?.AddComponent(); - defaultValues!.FontStyles = textMeshPro.fontStyle; - defaultValues.Color = textMeshPro.color; - defaultValues.ExtraPadding = textMeshPro.extraPadding; } else - skipEventAssignment = true; - - if (skipEventAssignment) { -#if DEBUG - //Debug.Log("Skipping event assignment!"); -#endif + // Skip event assignment since it should already be hooked up return; } @@ -115,13 +105,18 @@ public static void HookupTextToSpeech(this TextMeshProUGUI textMeshPro, bool for textMeshPro.OnPointerEnterAsObservable().Subscribe( _ => { + defaultValues = textMeshProTransform.gameObject?.AddComponent(); + defaultValues!.FontStyles = textMeshPro.fontStyle; + defaultValues.Color = textMeshPro.color; + defaultValues.ExtraPadding = textMeshPro.extraPadding; + if (Main.Settings!.FontStyleOnHover) { for (int i = 0; i < Main.Settings.FontStyles!.Length; i++) { if (Main.Settings.FontStyles[i]) { - textMeshPro.fontStyle |= (FontStyles)Enum.Parse(typeof(FontStyles), Main.FontStyleNames![i]!, true); + textMeshPro.fontStyle ^= (FontStyles)Enum.Parse(typeof(FontStyles), Main.FontStyleNames![i]!, true); } } textMeshPro.extraPadding = false;