Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
fix: saying things with TextToTalk!
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed May 29, 2023
1 parent 5e1d9be commit 5662865
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 35 deletions.
1 change: 1 addition & 0 deletions Resources/AnimationLockTime.json
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@
"25763": 0.6,
"25766": 0.6,
"25768": 0.6,
"25769": 0.6,
"25771": 0.6,
"25772": 0.6,
"25773": 0.6,
Expand Down
1 change: 0 additions & 1 deletion RotationSolver.Basic/Configuration/PluginConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ public class PluginConfiguration : IPluginConfiguration
{
public int Version { get; set; } = 6;

public int VoiceVolume = 100;
public SortedSet<string> DisabledCombos { get; private set; } = new SortedSet<string>();
public SortedSet<uint> DisabledActions { get; private set; } = new SortedSet<uint>();
public SortedSet<uint> NotInCoolDownActions { get; private set; } = new SortedSet<uint>();
Expand Down
5 changes: 2 additions & 3 deletions RotationSolver/Localization/Localization.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@
"ConfigWindow_Param_TargetColor": "Target color",
"ConfigWindow_Param_SubTargetColor": "Sub-target color",
"ConfigWindow_Param_KeyBoardNoise": "Simulate the effect of pressing",
"ConfigWindow_Param_KeyBoardNoiseBefore": "Simulate before action cast",
"ConfigWindow_Param_KeyBoardNoiseTimes": "Effect times",
"ConfigWindow_Param_VoiceVolume": "Voice volume",
"ConfigWindow_Param_ToastPositional": "Hint positional anticipation by Toast",
"ConfigWindow_Param_SayPositional": "Hint positional anticipation by shouting",
"ConfigWindow_Param_DrawPositional": "Draw Positional on the screen",
Expand Down Expand Up @@ -417,5 +415,6 @@
"Chakra": "Chakra"
},
"HighEndWarning": "Please separately keybind damage reduction / shield cooldowns in case RS fails at a crucial moment in {0}!",
"HighEndBan": "{0} can not be used in High-end Duty!"
"HighEndBan": "{0} can not be used in High-end Duty!",
"TextToTalkWarning": "You didn't install TextToTalk, please install it to make Rotation Solver say something for you!"
}
3 changes: 1 addition & 2 deletions RotationSolver/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,7 @@ internal partial class Strings
public string ConfigWindow_Param_TargetColor { get; set; } = "Target color";
public string ConfigWindow_Param_SubTargetColor { get; set; } = "Sub-target color";
public string ConfigWindow_Param_KeyBoardNoise { get; set; } = "Simulate the effect of pressing";
public string ConfigWindow_Param_KeyBoardNoiseBefore { get; set; } = "Simulate before action cast";
public string ConfigWindow_Param_KeyBoardNoiseTimes { get; set; } = "Effect times";
public string ConfigWindow_Param_VoiceVolume { get; set; } = "Voice volume";
public string ConfigWindow_Param_ToastPositional { get; set; } = "Hint positional anticipation by Toast";
public string ConfigWindow_Param_SayPositional { get; set; } = "Hint positional anticipation by shouting";
public string ConfigWindow_Param_DrawPositional { get; set; } = "Draw Positional on the screen";
Expand Down Expand Up @@ -601,4 +599,5 @@ internal partial class Strings

public string HighEndWarning { get; set; } = "Please separately keybind damage reduction / shield cooldowns in case RS fails at a crucial moment in {0}!";
public string HighEndBan { get; set; } = "{0} can not be used in High-end Duty!";
public string TextToTalkWarning { get; set; } = "You didn't install TextToTalk, please install it to make Rotation Solver say something for you!";
}
5 changes: 4 additions & 1 deletion RotationSolver/RotationSolverPlugin.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
using Dalamud.Game.ClientState.Conditions;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Interface.Windowing;
using Dalamud.Plugin;
using ECommons;
using ECommons.DalamudServices;
using ECommons.GameHelpers;
using ECommons.ImGuiMethods;
using ECommons.Reflection;
using RotationSolver.Basic.Configuration;
using RotationSolver.Commands;
using RotationSolver.Data;
using RotationSolver.Helpers;
using RotationSolver.Localization;
using RotationSolver.UI;
using RotationSolver.Updaters;
using Module = ECommons.Module;

namespace RotationSolver;

Expand All @@ -31,7 +34,7 @@ public sealed class RotationSolverPlugin : IDalamudPlugin, IDisposable
public static DalamudLinkPayload LinkPayload { get; private set; }
public RotationSolverPlugin(DalamudPluginInterface pluginInterface)
{
ECommonsMain.Init(pluginInterface, this);
ECommonsMain.Init(pluginInterface, this, Module.DalamudReflector);
ThreadLoadImageHandler.TryGetIconTextureWrap(0, false, out _);

try
Expand Down
49 changes: 24 additions & 25 deletions RotationSolver/SpeechHelper.cs
Original file line number Diff line number Diff line change
@@ -1,37 +1,36 @@
using System.Diagnostics;
using System.Text;
using Dalamud.Plugin;
using ECommons.DalamudServices;
using ECommons.Reflection;
using RotationSolver.Localization;

namespace RotationSolver;

internal static class SpeechHelper
{
static IDalamudPlugin _textToTalk = null;
static MethodInfo _say = null;
static object _manager = null;
static MethodInfo _stop = null;
static bool _showed = false;
internal static void Speak(string text)
{
ExecuteCommand(
$@"Add-Type -AssemblyName System.speech;
$speak = New-Object System.Speech.Synthesis.SpeechSynthesizer;
$speak.Volume = ""{Service.Config.VoiceVolume}"";
$speak.Speak(""{text}"");");

static void ExecuteCommand(string command)
if(_textToTalk == null)
{
string path = Path.GetTempPath() + Guid.NewGuid() + ".ps1";

// make sure to be using System.Text
using StreamWriter sw = new(path, false, Encoding.UTF8);
sw.Write(command);

ProcessStartInfo start = new()
if (!DalamudReflector.TryGetDalamudPlugin("TextToTalk", out _textToTalk))
{
FileName = @"C:\Windows\System32\windowspowershell\v1.0\powershell.exe",
LoadUserProfile = false,
UseShellExecute = false,
CreateNoWindow = true,
Arguments = $"-executionpolicy bypass -File {path}",
WindowStyle = ProcessWindowStyle.Hidden
};

Process process = Process.Start(start);
if (!_showed)
{
_showed = true;
Svc.Chat.PrintError(LocalizationManager.RightLang.TextToTalkWarning);
}
}
}
_say ??= _textToTalk?.GetType().GetRuntimeMethods().FirstOrDefault(m => m.Name == "Say");
_manager ??= _textToTalk?.GetType().GetRuntimeFields().FirstOrDefault(m => m.Name == "backendManager").GetValue(_textToTalk);
_stop ??= _manager?.GetType().GetRuntimeMethods().FirstOrDefault(m => m.Name == "CancelAllSpeech");


_stop?.Invoke(_manager, Array.Empty<object>());
_say?.Invoke(_textToTalk, new object[] { null, text, 1 });
}
}
3 changes: 0 additions & 3 deletions RotationSolver/UI/RotationConfigWindow_Param.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,6 @@ private void DrawParamDelay()

private void DrawParamAdvanced()
{
DrawIntNumber(LocalizationManager.RightLang.ConfigWindow_Param_VoiceVolume,
ref Service.Config.VoiceVolume, Service.Default.VoiceVolume, max: 100);

DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_SayOutStateChanged,
ref Service.Config.SayOutStateChanged, Service.Default.SayOutStateChanged);

Expand Down

0 comments on commit 5662865

Please sign in to comment.