From b600eda78e3dd5bd374f7a60fc153733826792e9 Mon Sep 17 00:00:00 2001 From: Mohammad Shoaib Khan Date: Sun, 9 Oct 2022 13:50:35 +0530 Subject: [PATCH] Added command to toggle tts --- stardew-access/CustomCommands.cs | 8 ++++++++ stardew-access/ModConfig.cs | 1 + stardew-access/ScreenReader/ScreenReaderLinux.cs | 13 ++++++++----- stardew-access/ScreenReader/ScreenReaderWindows.cs | 3 +++ 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/stardew-access/CustomCommands.cs b/stardew-access/CustomCommands.cs index 7f231ad..df18be3 100644 --- a/stardew-access/CustomCommands.cs +++ b/stardew-access/CustomCommands.cs @@ -521,6 +521,14 @@ namespace stardew_access MainClass.DebugLog("Warnings is " + (MainClass.Config.Warning ? "on" : "off")); }); + + helper.ConsoleCommands.Add("tts", "Toggles the screen reader/tts", (string commmand, string[] args) => + { + MainClass.Config.TTS = !MainClass.Config.TTS; + helper.WriteConfig(MainClass.Config); + + MainClass.DebugLog("TTS is " + (MainClass.Config.TTS ? "on" : "off")); + }); #endregion } } diff --git a/stardew-access/ModConfig.cs b/stardew-access/ModConfig.cs index 76f057d..f4ea1de 100644 --- a/stardew-access/ModConfig.cs +++ b/stardew-access/ModConfig.cs @@ -78,6 +78,7 @@ namespace stardew_access public Boolean VerboseCoordinates { get; set; } = true; public Boolean SnapMouse { get; set; } = true; // Toggles the snap mouse feature public Boolean Warning { get; set; } = true; // Toggles the warnings feature + public Boolean TTS { get; set; } = true; // Toggles the screen reader/tts. // TODO add command to toggle warning feature #endregion diff --git a/stardew-access/ScreenReader/ScreenReaderLinux.cs b/stardew-access/ScreenReader/ScreenReaderLinux.cs index d058cd6..0cbe1f3 100644 --- a/stardew-access/ScreenReader/ScreenReaderLinux.cs +++ b/stardew-access/ScreenReader/ScreenReaderLinux.cs @@ -62,11 +62,14 @@ namespace stardew_access.ScreenReader if (text == null) return; - if (initialized) - { - GoString str = new GoString(text, text.Length); - Speak(str, interrupt); - } + if (!initialized) + return; + + if (!MainClass.Config.TTS) + return; + + GoString str = new GoString(text, text.Length); + Speak(str, interrupt); } public void SayWithChecker(string text, bool interrupt) diff --git a/stardew-access/ScreenReader/ScreenReaderWindows.cs b/stardew-access/ScreenReader/ScreenReaderWindows.cs index deb8a73..a52d546 100644 --- a/stardew-access/ScreenReader/ScreenReaderWindows.cs +++ b/stardew-access/ScreenReader/ScreenReaderWindows.cs @@ -62,6 +62,9 @@ namespace stardew_access.ScreenReader if (screenReader == null) return; + if (!MainClass.Config.TTS) + return; + screenReader.Speak(text, interrupt); }