Skip to content

Commit

Permalink
Update after DLC
Browse files Browse the repository at this point in the history
  • Loading branch information
Osmodium committed Sep 26, 2024
1 parent 2610926 commit 80ae827
Show file tree
Hide file tree
Showing 37 changed files with 247 additions and 220 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.7
Version: 0.9.8

**Disclaimer: UNDER DEVELOPMENT**

Expand Down
2 changes: 1 addition & 1 deletion SpeechMod/Configuration/ModConfigurationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
using Kingmaker.Settings;
using Kingmaker.UI.InputSystems;
using Kingmaker.UI.Models.SettingsUI;
using ModConfiguration.Localization;
using SpeechMod.Configuration.Settings;
using SpeechMod.Configuration.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using SpeechMod.Localization;
using static UnityModManagerNet.UnityModManager;

namespace SpeechMod.Configuration;
Expand Down
4 changes: 2 additions & 2 deletions SpeechMod/Configuration/Settings/ModHotkeySettingEntry.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using ModConfiguration.Localization;
using Kingmaker;
using Kingmaker;
using Kingmaker.Settings;
using Kingmaker.Settings.Entities;
using Kingmaker.UI.Models.SettingsUI.SettingAssets;
using System;
using SpeechMod.Localization;
using UnityEngine;

namespace SpeechMod.Configuration.Settings;
Expand Down
4 changes: 2 additions & 2 deletions SpeechMod/Configuration/Settings/ModToggleSettingEntry.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using Kingmaker.Settings;
using Kingmaker.Settings.Entities;
using Kingmaker.UI.Models.SettingsUI.SettingAssets;
using ModConfiguration.Localization;
using System;
using SpeechMod.Localization;
using UnityEngine;

namespace SpeechMod.Configuration.Settings;
Expand All @@ -12,7 +12,7 @@ public abstract class ModToggleSettingEntry : ModSettingEntry
public readonly SettingsEntityBool SettingEntity;
public UISettingsEntityBool UiSettingEntity { get; private set; }

public ModToggleSettingEntry(string key, string title, string tooltip, bool defaultValue)
protected ModToggleSettingEntry(string key, string title, string tooltip, bool defaultValue)
: base(key, title, tooltip)
{
SettingEntity = new(SettingsController.Instance, $"{ModConfigurationManager.Instance?.SettingsPrefix}.newcontrols.{Key}", defaultValue, false, true);
Expand Down
2 changes: 1 addition & 1 deletion SpeechMod/Configuration/UI/OwlcatUITools.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Kingmaker.UI.Models.SettingsUI;
using Kingmaker.UI.Models.SettingsUI.SettingAssets;
using ModConfiguration.Localization;
using SpeechMod.Localization;
using UnityEngine;

namespace SpeechMod.Configuration.UI;
Expand Down
2 changes: 1 addition & 1 deletion SpeechMod/Info.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
"AssemblyName": "W40KRTSpeechMod.dll",
"EntryMethod": "SpeechMod.Main.Load",
"HomePage": "https://www.nexusmods.com/warhammer40kroguetrader/mods/75",
"Version": "0.9.7"
"Version": "0.9.8"
}
2 changes: 1 addition & 1 deletion SpeechMod/Keybinds/PlaybackStop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private static void StopPlayback(CommonPCView instance)

if (instance.m_WarningsTextView != null)
{
if (!LocalizationManager.Instance!.CurrentPack!.TryGetText("osmodium.speechmod.feature.playback.stop.notification", out string text, false))
if (!LocalizationManager.Instance!.CurrentPack!.TryGetText("osmodium.speechmod.feature.playback.stop.notification", out var text, false))
text = "SpeechMod: Playback stopped!";

if (Main.Settings!.ShowNotificationOnPlaybackStop)
Expand Down
10 changes: 5 additions & 5 deletions SpeechMod/Localization/ModLocalizationManager.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using Kingmaker.Localization;
using System.Collections.Generic;
using System.IO;
using Kingmaker.Localization;
using Kingmaker.Localization.Enums;
using Kingmaker.Localization.Shared;
using Newtonsoft.Json;
using SpeechMod.Configuration;
using System.Collections.Generic;
using System.IO;

namespace ModConfiguration.Localization;
namespace SpeechMod.Localization;

internal class ModLocalizationManager
{
Expand Down Expand Up @@ -56,7 +56,7 @@ private static ModLocalizationPack LoadPack(Locale locale)
{
try
{
using StreamReader file = File.OpenText(packFile);
using var file = File.OpenText(packFile);
using JsonReader jsonReader = new JsonTextReader(file);
JsonSerializer serializer = new();
var enLocalization = serializer.Deserialize<ModLocalizationPack>(jsonReader);
Expand Down
4 changes: 2 additions & 2 deletions SpeechMod/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ private static bool SetAvailableVoices()
}
Logger?.Log("Setting available voices list...");

for (int i = 0; i < availableVoices.Length; i++)
for (var i = 0; i < availableVoices.Length; i++)
{
string[] splitVoice = availableVoices[i]?.Split('#');
var splitVoice = availableVoices[i]?.Split('#');
if (splitVoice?.Length != 2 || string.IsNullOrEmpty(splitVoice[1]))
availableVoices[i] = availableVoices[i]?.Replace("#", "").Trim() + "#Unknown";
}
Expand Down
9 changes: 5 additions & 4 deletions SpeechMod/Patches/BarkPlayer_Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Kingmaker.Mechanics.Entities;
using SpeechMod.Voice;
using System;
using UnityEngine;
#if DEBUG
using UnityEngine;
#endif
Expand All @@ -17,9 +18,9 @@ namespace SpeechMod.Patches;
[HarmonyPatch]
public class BarkPlayer_Patch
{
[HarmonyPatch(typeof(BarkPlayer), "Bark", typeof(Entity), typeof(string), typeof(float), typeof(string), typeof(BaseUnitEntity), typeof(bool))]
[HarmonyPatch(typeof(BarkPlayer), nameof(BarkPlayer.Bark), typeof(Entity), typeof(string), typeof(float), typeof(string), typeof(BaseUnitEntity), typeof(bool), typeof(string), typeof(Color))]
[HarmonyPostfix]
public static void Bark(Entity entity, string text, float duration = -1f, string voiceOver = null, BaseUnitEntity interactUser = null, bool synced = true)
public static void Bark(Entity entity, string text, float duration = -1f, string voiceOver = null, BaseUnitEntity interactUser = null, bool synced = true, string overrideName = null, Color overrideNameColor = default(Color))
{
if (!BarkExtensions.PlayBark())
return;
Expand All @@ -31,7 +32,7 @@ public static void Bark(Entity entity, string text, float duration = -1f, string
BarkExtensions.DoBark(entity, text, voiceOver);
}

[HarmonyPatch(typeof(BarkPlayer), "BarkExploration", typeof(Entity), typeof(string), typeof(float), typeof(string))]
[HarmonyPatch(typeof(BarkPlayer), nameof(BarkPlayer.BarkExploration), typeof(Entity), typeof(string), typeof(float), typeof(string))]
[HarmonyPostfix]
public static void BarkExploration_1(Entity entity, string text, float duration = -1f, string voiceOver = null)
{
Expand All @@ -45,7 +46,7 @@ public static void BarkExploration_1(Entity entity, string text, float duration
BarkExtensions.DoBark(entity, text, voiceOver);
}

[HarmonyPatch(typeof(BarkPlayer), "BarkExploration", typeof(Entity), typeof(string), typeof(string), typeof(float), typeof(string))]
[HarmonyPatch(typeof(BarkPlayer), nameof(BarkPlayer.BarkExploration), typeof(Entity), typeof(string), typeof(string), typeof(float), typeof(string))]
[HarmonyPostfix]
public static void BarkExploration_2(Entity entity, string text, string encyclopediaLink, float duration = -1f, string voiceOver = null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace SpeechMod.Patches;

[HarmonyPatch(typeof(CharGenCareerPhaseDetailedPCView), "BindViewImplementation")]
[HarmonyPatch(typeof(CharGenCareerPhaseDetailedPCView), nameof(CharGenCareerPhaseDetailedPCView.BindViewImplementation))]
public class CharGenCareerPhaseDetailedPCView_Patch
{
private const string CHARGEN_DESCRIPTION_PATH = "/MainMenuPCView(Clone)/UICanvas/CharGenContextPCView/CharGenPCView/Content/PhaseDetailedViews/CharGenCareerPhaseDetailedPCView/CharGenDescription/LevelupDescriptionView/Viewport";
Expand Down
4 changes: 2 additions & 2 deletions SpeechMod/Patches/CharInfoSummaryPCView_Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static void HookLabels(CharInfoSummaryPCView __instance)
__instance.m_MovePointsLabel.HookupTextToSpeech();
}

[HarmonyPatch(typeof(CharInfoStatusEffectsView), "RefreshView")]
[HarmonyPatch(typeof(CharInfoStatusEffectsView), nameof(CharInfoStatusEffectsView.RefreshView))]
[HarmonyPostfix]
public static void HookStatusEffects(CharInfoStatusEffectsView __instance)
{
Expand All @@ -48,7 +48,7 @@ public static void HookStatusEffects(CharInfoStatusEffectsView __instance)
//__instance.m_WidgetEntityView?.m_RankText.HookupTextToSpeech();
}

[HarmonyPatch(typeof(CharInfoProfitFactorItemPCView), "BindViewImplementation")]
[HarmonyPatch(typeof(CharInfoProfitFactorItemPCView), nameof(CharInfoProfitFactorItemPCView.BindViewImplementation))]
[HarmonyPostfix]
public static void HookFator(CharInfoProfitFactorItemPCView __instance)
{
Expand Down
2 changes: 1 addition & 1 deletion SpeechMod/Patches/DialogController_Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace SpeechMod.Patches;

[HarmonyPatch(typeof(DialogController), "SelectAnswer", typeof(BlueprintAnswer), typeof(BaseUnitEntity))]
[HarmonyPatch(typeof(DialogController), nameof(DialogController.SelectAnswer), typeof(BlueprintAnswer), typeof(BaseUnitEntity))]
public class DialogController_Patch
{
public static void Prefix(BlueprintAnswer answer)
Expand Down
2 changes: 1 addition & 1 deletion SpeechMod/Patches/DialogPCView_Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static class DialogPCView_Patch
private const string SURFACE_SCROLL_VIEW_PATH = "/SurfacePCView(Clone)/SurfaceStaticPartPCView/StaticCanvas/SurfaceDialogPCView(Clone)/LeftSide/CueAndHistoryPlace/ScrollView";
private const string SPACE_SCROLL_VIEW_PATH = "/SpacePCView(Clone)/SpaceStaticPartPCView/StaticCanvas/SurfaceDialogPCView(Clone)/LeftSide/CueAndHistoryPlace/ScrollView";

[HarmonyPatch(typeof(SurfaceDialogBaseView<DialogAnswerPCView>), "Initialize")]
[HarmonyPatch(typeof(SurfaceDialogBaseView<DialogAnswerPCView>), nameof(SurfaceDialogBaseView<DialogAnswerPCView>.Initialize))]
[HarmonyPostfix]
public static void AddDialogButton()
{
Expand Down
4 changes: 2 additions & 2 deletions SpeechMod/Patches/Dialog_Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace SpeechMod.Patches;

[HarmonyPatch(typeof(DialogVM), "HandleOnCueShow")]
[HarmonyPatch(typeof(DialogVM), nameof(DialogVM.HandleOnCueShow))]
public static class Dialog_Patch
{
public static void Postfix()
Expand All @@ -28,7 +28,7 @@ public static void Postfix()
return;
}

string key = Game.Instance?.DialogController?.CurrentCue?.Text?.Key;
var key = Game.Instance?.DialogController?.CurrentCue?.Text?.Key;
if (string.IsNullOrWhiteSpace(key))
key = Game.Instance?.DialogController?.CurrentCue?.Text?.Shared?.String?.Key;

Expand Down
6 changes: 3 additions & 3 deletions SpeechMod/Patches/Encyclopedia_Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static class Encyclopedia_Patch
private const string TEXT_VIEW_GLOSSARY_BUTTON_NAME = "SpeechMod_GlossaryButton_EncyclopediaPageBlockTextPCView";
private const string BLOCK_VIEW_GLOSSARY_BUTTON_NAME = "SpeechMod_GlossaryButton_EncyclopediaPageBlockGlossaryEntryPCView";

[HarmonyPatch(typeof(EncyclopediaPageBaseView), "BindViewImplementation")]
[HarmonyPatch(typeof(EncyclopediaPageBaseView), nameof(EncyclopediaPageBaseView.BindViewImplementation))]
[HarmonyPostfix]
public static void AddTitleHook(EncyclopediaPageBaseView __instance)
{
Expand All @@ -31,7 +31,7 @@ public static void AddTitleHook(EncyclopediaPageBaseView __instance)
__instance.m_GlossaryEntryBlockPrefab?.m_Description.TryAddButtonToTextMeshPro(PAGE_VIEW_GLOSSARY_BUTTON_NAME, new Vector2(0f, -4f), new Vector3(0.8f, 0.8f, 1f));
}

[HarmonyPatch(typeof(EncyclopediaPageBlockTextPCView), "BindViewImplementation")]
[HarmonyPatch(typeof(EncyclopediaPageBlockTextPCView), nameof(EncyclopediaPageBlockTextPCView.BindViewImplementation))]
[HarmonyPostfix]
public static void AddPageBlockTextHook(EncyclopediaPageBlockTextPCView __instance)
{
Expand All @@ -43,7 +43,7 @@ public static void AddPageBlockTextHook(EncyclopediaPageBlockTextPCView __instan
__instance.m_Text.TryAddButtonToTextMeshPro(TEXT_VIEW_GLOSSARY_BUTTON_NAME, new Vector2(-1f, -4f), new Vector3(0.8f, 0.8f, 1f));
}

[HarmonyPatch(typeof(EncyclopediaPageBlockGlossaryEntryPCView), "BindViewImplementation")]
[HarmonyPatch(typeof(EncyclopediaPageBlockGlossaryEntryPCView), nameof(EncyclopediaPageBlockGlossaryEntryPCView.BindViewImplementation))]
[HarmonyPostfix]
public static void AddPageBlockGlossaryHooks(EncyclopediaPageBlockGlossaryEntryPCView __instance)
{
Expand Down
4 changes: 2 additions & 2 deletions SpeechMod/Patches/LoadingScreenBaseView_Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace SpeechMod.Patches;
[HarmonyPatch]
public static class LoadingScreenBaseView_Patch
{
[HarmonyPatch(typeof(LoadingScreenBaseView), "BindViewImplementation")]
[HarmonyPatch(typeof(LoadingScreenBaseView), nameof(LoadingScreenBaseView.BindViewImplementation))]
[HarmonyPostfix]
public static void BindViewImplementation(LoadingScreenBaseView __instance)
{
Expand All @@ -28,7 +28,7 @@ public static void BindViewImplementation(LoadingScreenBaseView __instance)
__instance?.m_LocationName.HookupTextToSpeech();
}

[HarmonyPatch(typeof(LoadingScreenBaseView), "Show")]
[HarmonyPatch(typeof(LoadingScreenBaseView), nameof(LoadingScreenBaseView.Show))]
[HarmonyPostfix]
public static void Show(LoadingScreenBaseView __instance)
{
Expand Down
2 changes: 1 addition & 1 deletion SpeechMod/Patches/MainMenuPCView_Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace SpeechMod.Patches;

[HarmonyPatch(typeof(MainMenuPCView), "BindViewImplementation")]
[HarmonyPatch(typeof(MainMenuPCView), nameof(MainMenuPCView.BindViewImplementation))]
public class MainMenuPCView_Patch
{
private const string MAIN_MENU_WELCOME_TEXT_PATH = "/MainMenuPCView(Clone)/UICanvas/WelcomeWindowPCView/Background/ScrollContainer/ServiceWindowStandardScrollView/Viewport/Content/text";
Expand Down
2 changes: 1 addition & 1 deletion SpeechMod/Patches/MessageBoxPCView_Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace SpeechMod.Patches;

[HarmonyPatch(typeof(MessageBoxPCView), "BindViewImplementation")]
[HarmonyPatch(typeof(MessageBoxPCView), nameof(MessageBoxPCView.BindViewImplementation))]
public class MessageBoxPCView_Patch
{
private const string INPUT_BOX_TEXT_PATH = "/MainMenuPCView(Clone)/UICanvas/CharGenContextPCView/CharGenPCView/Content/PhaseDetailedViews/CharGenShipPhaseDetailedPCView/CharGenChangeNameMessageBoxPCView/CommonModalWindow/Panel/Content/Layout/Label_Message";
Expand Down
2 changes: 1 addition & 1 deletion SpeechMod/Patches/NewGamePhaseStoryBaseView_Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace SpeechMod.Patches;
public class NewGamePhaseStoryBaseView_Patch
{
private const string NEWGAME_STORY_FRAME_PATH = "/MainMenuPCView(Clone)/UICanvas/NewGamePCView/Device/Background (1)/Background/ContentGroup/NewGameTabGameModePCView/Screen_view/ItemView (1)/Description/ServiceWindowStandartScrollVew/Viewport/Content/Frame";
[HarmonyPatch(typeof(NewGamePhaseStoryBaseView), "BindViewImplementation")]
[HarmonyPatch(typeof(NewGamePhaseStoryBaseView), nameof(NewGamePhaseStoryBaseView.BindViewImplementation))]
[HarmonyPostfix]
public static void Postfix(NewGamePhaseStoryBaseView __instance)
{
Expand Down
2 changes: 1 addition & 1 deletion SpeechMod/Patches/ShipNameAndPortraitPCView_Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace SpeechMod.Patches;

[HarmonyPatch(typeof(ShipNameAndPortraitPCView), "BindViewImplementation")]
[HarmonyPatch(typeof(ShipNameAndPortraitPCView), nameof(ShipNameAndPortraitPCView.BindViewImplementation))]
public static class ShipNameAndPortraitPCView_Patch
{
private const string SPACE_INFORMATION_LABEL_PATH = "/SpacePCView(Clone)/SpaceStaticPartPCView/StaticCanvas/ServiceWindowsPCView/InventoryLeftCanvas/Background/ShipPart/InformationLabel";
Expand Down
2 changes: 1 addition & 1 deletion SpeechMod/Patches/TermsOfUsePCView_Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace SpeechMod.Patches;

[HarmonyPatch(typeof(TermsOfUsePCView), "BindViewImplementation")]
[HarmonyPatch(typeof(TermsOfUsePCView), nameof(TermsOfUsePCView.BindViewImplementation))]
public class TermsOfUsePCView_Patch
{
private const string TERMS_OF_USE_TITLE_PATH = "/MainMenuPCView(Clone)/UICanvas/TermsOfUsePCView/Body/Device/ContentGroup/TabsGroup/Title";
Expand Down
4 changes: 2 additions & 2 deletions SpeechMod/Patches/TooltipEngine_Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace SpeechMod.Patches;
[HarmonyPatch]
public static class Tooltip_Patch
{
[HarmonyPatch(typeof(InfoBaseView<InfoBaseVM>), "SetPart")]
[HarmonyPatch(typeof(InfoBaseView<InfoBaseVM>), nameof(InfoBaseView<InfoBaseVM>.SetPart))]
[HarmonyPostfix]
public static void SetPart(IEnumerable<TooltipBaseBrickVM> bricks, RectTransform container)
{
Expand All @@ -33,7 +33,7 @@ public static void SetPart(IEnumerable<TooltipBaseBrickVM> bricks, RectTransform
HookBricksByContainer(container);
}

[HarmonyPatch(typeof(TooltipBrickIconStatValueView), "BindViewImplementation")]
[HarmonyPatch(typeof(TooltipBrickIconStatValueView), nameof(TooltipBrickIconStatValueView.BindViewImplementation))]
[HarmonyPostfix]
public static void BrickIconStatValue(TooltipBrickIconStatValueView __instance)
{
Expand Down
4 changes: 2 additions & 2 deletions SpeechMod/Patches/TutorialWindowView_Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace SpeechMod.Patches;

[HarmonyPatch(typeof(TutorialHintWindowPCView), "SetContent")]
[HarmonyPatch(typeof(TutorialHintWindowPCView), nameof(TutorialHintWindowPCView.SetContent))]
public class TutorialWindowView_Patch_Small
{

Expand All @@ -28,7 +28,7 @@ public static void Postfix()
}
}

[HarmonyPatch(typeof(TutorialModalWindowPCView), "BindViewImplementation")]
[HarmonyPatch(typeof(TutorialModalWindowPCView), nameof(TutorialModalWindowPCView.BindViewImplementation))]
public class TutorialWindowView_Patch_Big
{
private const string TUTORIAL_BIG_TITLE_PATH = "/CommonPCView(Clone)/CommonCanvas/TutorialPCView/BigWindowPCView(Clone)/Window/Content/Header/TitleGroup/Title";
Expand Down
2 changes: 1 addition & 1 deletion SpeechMod/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class Settings : UnityModManager.ModSettings
public float HoverColorR = 0f;
public float HoverColorG = 0f;
public float HoverColorB = 0f;
public float HoverColorA = 1f;
public float HoverColorA = 1;

public bool FontStyleOnHover = true;
public bool[] FontStyles = { false, false, false, true, false, false, false, false, false, false, false };
Expand Down
2 changes: 1 addition & 1 deletion SpeechMod/SpeechMod.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(SolutionDir)GamePath.props" Condition="Exists('$(SolutionDir)GamePath.props')" />
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<TargetFramework>net481</TargetFramework>
<AssemblyName>W40KRTSpeechMod</AssemblyName>
<Description>Warhammer 40K: Rogue Trader - SpeechMod</Description>
<Version>1.0.0</Version>
Expand Down
8 changes: 4 additions & 4 deletions SpeechMod/Unity/AppleVoiceUnity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,24 +59,24 @@ public static void SpeakDialog(string text, float delay = 0f)
return;
}

string arguments = "";
var arguments = "";
text = new Regex("<b><color[^>]+><link([^>]+)?>([^<>]*)</link></color></b>").Replace(text, "$2");
text = text.Replace("\\n", " ");
text = text.Replace("\n", " ");
text = text.Replace(";", "");
while (text.IndexOf($"<color=#{Constants.NARRATOR_COLOR_CODE}>", StringComparison.InvariantCultureIgnoreCase) != -1)
{
int position = text.IndexOf($"<color=#{Constants.NARRATOR_COLOR_CODE}>", StringComparison.InvariantCultureIgnoreCase);
var position = text.IndexOf($"<color=#{Constants.NARRATOR_COLOR_CODE}>", StringComparison.InvariantCultureIgnoreCase);
if (position != 0)
{
string argumentsPart = text.Substring(0, position);
var argumentsPart = text.Substring(0, position);
text = text.Substring(position);
arguments = $"{arguments}say -v {GenderVoice} -r {GenderRate} {argumentsPart.Replace("\"", "")};";
}
else
{
position = text.IndexOf("</color>", StringComparison.InvariantCultureIgnoreCase);
string argumentsPart2 = text.Substring(0, position);
var argumentsPart2 = text.Substring(0, position);
text = text.Substring(position);
arguments = $"{arguments}say -v {Main.NarratorVoice} -r {Main.Settings.NarratorRate} {argumentsPart2.Replace("\"", "")};";
}
Expand Down
2 changes: 1 addition & 1 deletion SpeechMod/Unity/Extensions/Hooks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public static void HookupTextToSpeech(this TextMeshProUGUI textMeshPro, bool for

if (Main.Settings!.FontStyleOnHover)
{
for (int i = 0; i < Main.Settings.FontStyles!.Length; i++)
for (var i = 0; i < Main.Settings.FontStyles!.Length; i++)
{
if (Main.Settings.FontStyles[i])
{
Expand Down
Loading

0 comments on commit 80ae827

Please sign in to comment.