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

Commit

Permalink
fix: removed the icon replacer.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Mar 18, 2023
1 parent 61c69ea commit 5df63d2
Show file tree
Hide file tree
Showing 19 changed files with 182 additions and 146 deletions.
4 changes: 4 additions & 0 deletions RotationSolver.Basic/Configuration/PluginConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ public class PluginConfiguration : IPluginConfiguration
public int TargetingIndex { get; set; } = 0;
public MacroInfo DutyStart { get; set; } = new MacroInfo();
public MacroInfo DutyEnd { get; set; } = new MacroInfo();

public bool ShowControlWindow = false;
public bool IsControlWindowLock = true;

public void Save()
{
Service.Interface.SavePluginConfig(this);
Expand Down
21 changes: 21 additions & 0 deletions RotationSolver.Basic/DataCenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.Game.Fate;
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
using Lumina.Excel.GeneratedSheets;
using RotationSolver.Basic.Actions;
using RotationSolver.Basic.Data;
using RotationSolver.Basic.Helpers;
Expand Down Expand Up @@ -49,6 +50,26 @@ public static void AddOneTimelineAction(IBaseAction act, double time)
NextActs = NextActs.OrderBy(i => i.deadTime).ToList();
}

public static TargetHostileType RightNowTargetToHostileType
{
get
{
if (Service.Player == null) return 0;
var id = Service.Player.ClassJob.Id;
return GetTargetHostileType(Service.GetSheet<ClassJob>().GetRow(id));
}
}

public static TargetHostileType GetTargetHostileType(ClassJob classJob)
{
if (Service.Config.TargetToHostileTypes.TryGetValue(classJob.RowId, out var type))
{
return (TargetHostileType)type;
}

return classJob.GetJobRole() == JobRole.Tank ? TargetHostileType.AllTargetsCanAttack : TargetHostileType.TargetsHaveTarget;
}

public static unsafe ActionID LastComboAction => (ActionID)ActionManager.Instance()->Combo.Action;
public static unsafe float ComboTime => ActionManager.Instance()->Combo.Timer;
internal static TargetingType TargetingType
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver/Commands/RSCommands_Actions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ internal static unsafe void DoAnAction(bool isGCD)
if (DateTime.Now - _fastClickStopwatch < _fastSpan) return;
_fastClickStopwatch = DateTime.Now;

if (SocialUpdater.InHighEndDuty && !RotationUpdater.RightNowRotation.IsAllowed(out var str))
if (!RotationUpdater.RightNowRotation.IsAllowed(out var str))
{
Service.ToastGui.ShowError(string.Format(LocalizationManager.RightLang.HighEndBan, str));
return;
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver/Commands/RSCommands_StateSpecialCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private static void DoOneCommandType<T>(T type, Func<T, JobRole, string> sayout,
doingSomething(role);

//Saying out.
if (Service.Config.SayOutStateChanged) Watcher.Speak(sayout(type, role));
if (Service.Config.SayOutStateChanged) SpeechHelper.Speak(sayout(type, role));
}
}
}
3 changes: 3 additions & 0 deletions RotationSolver/Localization/Localization.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"ConfigWindow_ParamItem": "Param",
"ConfigWindow_EventItem": "Event",
"ConfigWindow_ActionItem": "Action",
"ConfigWindow_ControlItem": "Control",
"ConfigWindow_HelpItem": "Help",
"ConfigWindow_RotationDev": "RotationDev",
"ConfigWindow_ActionItem_Description": "Modify the usage for each action.",
Expand Down Expand Up @@ -169,6 +170,8 @@
"ConfigWindow_Param_ConditionUp": "Up",
"ConfigWindow_Param_ConditionDown": "Down",
"ConfigWindow_Param_ConditionDelete": "Delete",
"ConfigWindow_Control_ShowControlWindow": "Show Control Window",
"ConfigWindow_Control_IsControlWindowLock": "Lock Control Window",
"Timeline_DragdropDescription": "Drag&drop to move,Ctrl+Alt+RightClick to delete.",
"Timeline_SearchBar": "Search Bar",
"Timeline_MustUse": "MustUse",
Expand Down
5 changes: 5 additions & 0 deletions RotationSolver/Localization/Strings_Major.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ internal partial class Strings
public string ConfigWindow_ParamItem { get; set; } = "Param";
public string ConfigWindow_EventItem { get; set; } = "Event";
public string ConfigWindow_ActionItem { get; set; } = "Action";
public string ConfigWindow_ControlItem { get; set; } = "Control";
public string ConfigWindow_HelpItem { get; set; } = "Help";
public string ConfigWindow_RotationDev { get; set; } = "RotationDev";

Expand Down Expand Up @@ -233,6 +234,10 @@ internal partial class Strings
public string ConfigWindow_Param_ConditionUp { get; set; } = "Up";
public string ConfigWindow_Param_ConditionDown { get; set; } = "Down";
public string ConfigWindow_Param_ConditionDelete { get; set; } = "Delete";

public string ConfigWindow_Control_ShowControlWindow { get; set; } = "Show Control Window";
public string ConfigWindow_Control_IsControlWindowLock { get; set; } = "Lock Control Window";

#endregion

#region ScriptWindow
Expand Down
5 changes: 3 additions & 2 deletions RotationSolver/RotationSolver.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0-windows</TargetFramework>
Expand All @@ -13,7 +13,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DalamudPackager" Version="2.1.10" />
<PackageReference Include="DalamudPackager" Version="2.1.11" />
<PackageReference Include="System.Speech" Version="7.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
13 changes: 11 additions & 2 deletions RotationSolver/RotationSolverPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public sealed class RotationSolverPlugin : IDalamudPlugin, IDisposable
{
private readonly WindowSystem windowSystem;

private static RotationConfigWindow _comboConfigWindow;
static RotationConfigWindow _comboConfigWindow;
static ControlWindow _controlWindow;

static readonly List<IDisposable> _dis = new List<IDisposable>();
public string Name => "Rotation Solver";
Expand All @@ -39,8 +40,10 @@ public unsafe RotationSolverPlugin(DalamudPluginInterface pluginInterface)
}

_comboConfigWindow = new();
_controlWindow = new();
windowSystem = new WindowSystem(Name);
windowSystem.AddWindow(_comboConfigWindow);
windowSystem.AddWindow(_controlWindow);

Service.Interface.UiBuilder.OpenConfigUi += OnOpenConfigUi;
Service.Interface.UiBuilder.Draw += windowSystem.Draw;
Expand All @@ -50,7 +53,6 @@ public unsafe RotationSolverPlugin(DalamudPluginInterface pluginInterface)
TimeLineUpdater.Enable(pluginInterface.ConfigDirectory.FullName);
SocialUpdater.Enable();
_dis.Add(new Watcher());
_dis.Add(new IconReplacer());
_dis.Add(new MovingController());

var manager = new LocalizationManager();
Expand All @@ -61,6 +63,7 @@ public unsafe RotationSolverPlugin(DalamudPluginInterface pluginInterface)
ChangeUITranslation();

RotationUpdater.GetAllCustomRotations();
OpenControlWindow();
}


Expand Down Expand Up @@ -102,4 +105,10 @@ internal static void OpenConfigWindow()
{
_comboConfigWindow.Toggle();
}

internal static void OpenControlWindow()
{
_controlWindow.IsOpen = Service.Config.ShowControlWindow;
}

}
100 changes: 0 additions & 100 deletions RotationSolver/SigReplacers/IconReplacer.cs

This file was deleted.

36 changes: 2 additions & 34 deletions RotationSolver/SigReplacers/Watcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Speech.Synthesis;
using System.Text;
using System.Text.RegularExpressions;
using Action = Lumina.Excel.GeneratedSheets.Action;
Expand Down Expand Up @@ -89,45 +90,12 @@ private static unsafe void RecordAction(GameObject tar, Action action, byte flag
ImGui.GetColorU32(ImGuiColors.DPSRed), 94662, action.Icon);
if (!string.IsNullOrEmpty(Service.Config.PositionalErrorText))
{
Speak(Service.Config.PositionalErrorText);
SpeechHelper.Speak(Service.Config.PositionalErrorText);
}
}
}

internal static void Speak(string text, bool wait = false)
{
ExecuteCommand(
$@"Add-Type -AssemblyName System.speech;
$speak = New-Object System.Speech.Synthesis.SpeechSynthesizer;
$speak.Volume = ""{Service.Config.VoiceVolume}"";
$speak.Speak(""{text}"");");

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

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

ProcessStartInfo start = new ProcessStartInfo()
{
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 (wait)
process.WaitForExit();
}
}
}

public void Dispose()
{
Expand Down
55 changes: 55 additions & 0 deletions RotationSolver/SpeechHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using RotationSolver.Basic;
using System.Diagnostics;
using System.Speech.Synthesis;
using System.Text;

namespace RotationSolver;

internal static class SpeechHelper
{
static SpeechSynthesizer _speech;
internal static void Speak(string text)
{
try
{
_speech ??= new SpeechSynthesizer();
_speech.Volume = Service.Config.VoiceVolume;
_speech.SpeakAsyncCancelAll();
_speech.SpeakAsync(text);

//When I got win 11, I'll do that.
//_speech.GetInstalledVoices().FirstOrDefault().VoiceInfo;
}
catch
{
ExecuteCommand(
$@"Add-Type -AssemblyName System.speech;
$speak = New-Object System.Speech.Synthesis.SpeechSynthesizer;
$speak.Volume = ""{Service.Config.VoiceVolume}"";
$speak.Speak(""{text}"");");

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

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

ProcessStartInfo start = new ProcessStartInfo()
{
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);
}
}
}
}
}
Loading

0 comments on commit 5df63d2

Please sign in to comment.