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

Commit

Permalink
feat: add a keybinding for next action.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Apr 28, 2023
1 parent d8a3986 commit aa67501
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 11 deletions.
3 changes: 3 additions & 0 deletions Resources/AnimationLockTime.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
"7509": 0.6,
"7510": 0.1,
"7511": 0.1,
"7514": 0.1,
"7517": 0.6,
"7518": 0.6,
"7559": 0.6,
"7560": 0.6,
"7561": 0.6,
"7562": 0.6,
"16524": 0.1,
Expand Down
5 changes: 4 additions & 1 deletion RotationSolver.Basic/Configuration/PluginConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public class PluginConfiguration : IPluginConfiguration

public Dictionary<StateCommandType, KeyRecord> KeyState { get; set; } = new Dictionary<StateCommandType, KeyRecord>();
public Dictionary<SpecialCommandType, KeyRecord> KeySpecial { get; set; } = new Dictionary<SpecialCommandType, KeyRecord>();

public KeyRecord KeyDoAction { get; set; } = null;
public Dictionary<StateCommandType, ButtonRecord> ButtonState { get; set; } = new Dictionary<StateCommandType, ButtonRecord>()
{
{StateCommandType.Smart, new ButtonRecord( GamepadButtons.East, false, true) },
Expand All @@ -226,6 +226,9 @@ public class PluginConfiguration : IPluginConfiguration
{SpecialCommandType.AntiKnockback, new ButtonRecord( GamepadButtons.DpadUp, true, false) },

};

public ButtonRecord ButtonDoAction { get; set; } = null;

public void Save()
{
Service.Interface.SavePluginConfig(this);
Expand Down
11 changes: 8 additions & 3 deletions RotationSolver/Commands/RSCommands_Actions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Dalamud.Game.ClientState.Conditions;
using Dalamud.Logging;
using Lumina.Excel.GeneratedSheets;
using RotationSolver.Localization;
using RotationSolver.Updaters;

Expand Down Expand Up @@ -28,6 +29,13 @@ internal static unsafe void DoAnAction(bool isGCD)
(int)(Service.Config.ClickingDelayMin * 1000), (int)(Service.Config.ClickingDelayMax * 1000)))) return;
_fastClickStopwatch = DateTime.Now;

if (!isGCD && ActionUpdater.NextAction is IBaseAction act1 && act1.IsRealGCD) return;

DoAction();
}

public static void DoAction()
{
//Do Action
var nextAction = ActionUpdater.NextAction;
if (nextAction == null) return;
Expand All @@ -46,8 +54,6 @@ internal static unsafe void DoAnAction(bool isGCD)
return;
}

if (!isGCD && nextAction is IBaseAction act1 && act1.IsRealGCD) return;

if (Service.Config.KeyBoardNoise)
{
PreviewUpdater.PulseActionBar(nextAction.AdjustedID);
Expand All @@ -73,7 +79,6 @@ internal static unsafe void DoAnAction(bool isGCD)
}

}
return;
}

static bool started = false;
Expand Down
44 changes: 44 additions & 0 deletions RotationSolver/UI/ControlWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,50 @@ static unsafe void DrawNextAction(float gcd, float ability, float width)
var next = ActionUpdater.NextGCDAction != ActionUpdater.NextAction ? ActionUpdater.NextAction : null;

ImGui.SameLine();

DrawIAction(next, ability, -1);
if (ImGui.IsItemHovered())
{
var help = string.Empty;
if (Service.Config.ButtonDoAction != null)
{
help += "\n" + Service.Config.ButtonDoAction.ToStr();
if (!Service.Config.UseGamepadCommand) help += LocalizationManager.RightLang.ConfigWindow_Control_NeedToEnable;

}
if (Service.Config.KeyDoAction != null)
{
help += "\n" + Service.Config.KeyDoAction.ToStr();
if (!Service.Config.UseKeyboardCommand) help += LocalizationManager.RightLang.ConfigWindow_Control_NeedToEnable;
}
help += "\n \n" + LocalizationManager.RightLang.ConfigWindow_Control_ResetButtonOrKeyCommand;

ImGui.SetTooltip(help);
if (ImGui.IsMouseDown(ImGuiMouseButton.Right) && !InputUpdater.RecordingDoAction)
{
InputUpdater.RecordingTime = DateTime.Now;
InputUpdater.RecordingDoAction = true;
Service.ToastGui.ShowQuest($"Recording: Do Action",
new Dalamud.Game.Gui.Toast.QuestToastOptions()
{
IconId = 101,
});
}

if (ImGui.IsKeyPressed(ImGuiKey.LeftCtrl) && ImGui.IsMouseDown(ImGuiMouseButton.Middle))
{
Service.Config.KeyDoAction = null;
Service.Config.ButtonDoAction = null;
Service.Config.Save();

Service.ToastGui.ShowQuest($"Clear Recording: Do Action",
new Dalamud.Game.Gui.Toast.QuestToastOptions()
{
IconId = 101,
PlaySound = true,
DisplayCheckmark = true,
});
}
}
}
}
36 changes: 29 additions & 7 deletions RotationSolver/Updaters/InputUpdater.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using Dalamud.Game.ClientState.Conditions;
using Dalamud.Game.ClientState.GamePad;
using Dalamud.Game.ClientState.Keys;
using FFXIVClientStructs.FFXIV.Client.Game;
using Lumina.Excel.GeneratedSheets;
using RotationSolver.Commands;

namespace RotationSolver.Updaters;
Expand All @@ -14,6 +12,7 @@ internal static class InputUpdater

public static SpecialCommandType RecordingSpecialType { get ; set; }
public static StateCommandType RecordingStateType { get ; set; }
public static bool RecordingDoAction { get; set; }
public static DateTime RecordingTime { get; set; } = DateTime.MinValue;

internal static unsafe void UpdateCommand()
Expand All @@ -33,6 +32,7 @@ internal static unsafe void UpdateCommand()
{
RecordingSpecialType = SpecialCommandType.None;
RecordingStateType = StateCommandType.None;
RecordingDoAction = false;
}

foreach (var key in Service.KeyState.GetValidVirtualKeys())
Expand Down Expand Up @@ -93,7 +93,7 @@ private static void KeyDown(KeyRecord key)
Service.Config.Save();
return;
}
else if (RecordingStateType != StateCommandType.None )
else if (RecordingStateType != StateCommandType.None )
{
Service.Config.KeyState[RecordingStateType] = key;
Service.ToastGui.ShowQuest($"{RecordingStateType}: {key.ToStr()}",
Expand All @@ -103,6 +103,14 @@ private static void KeyDown(KeyRecord key)
Service.Config.Save();
return;
}
else if (RecordingDoAction)
{
Service.Config.KeyDoAction = key;
Service.ToastGui.ShowQuest($"Do Action: {key.ToStr()}", QUEST);
RecordingDoAction = false;
Service.Config.Save();
return;
}

if (!Service.Config.UseKeyboardCommand) return;

Expand All @@ -111,12 +119,15 @@ private static void KeyDown(KeyRecord key)
Service.CommandManager.ProcessCommand(Service.Config.KeyState
.FirstOrDefault(k => k.Value == key && k.Key != StateCommandType.None).Key.GetCommandStr());
}

if (Service.Config.KeySpecial.ContainsValue(key))
else if (Service.Config.KeySpecial.ContainsValue(key))
{
Service.CommandManager.ProcessCommand(Service.Config.KeySpecial
.FirstOrDefault(k => k.Value == key && k.Key != SpecialCommandType.None).Key.GetCommandStr());
}
else if(Service.Config.KeyDoAction == key)
{
RSCommands.DoAction();
}
}

private static void ButtonDown(ButtonRecord button)
Expand All @@ -141,6 +152,14 @@ private static void ButtonDown(ButtonRecord button)
Service.Config.Save();
return;
}
else if (RecordingDoAction)
{
Service.Config.ButtonDoAction = button;
Service.ToastGui.ShowQuest($"Do Action: {button.ToStr()}", QUEST);
RecordingDoAction = false;
Service.Config.Save();
return;
}

if (!Service.Config.UseGamepadCommand) return;

Expand All @@ -149,11 +168,14 @@ private static void ButtonDown(ButtonRecord button)
Service.CommandManager.ProcessCommand(Service.Config.ButtonState
.FirstOrDefault(k => k.Value == button && k.Key != StateCommandType.None).Key.GetCommandStr());
}

if (Service.Config.ButtonSpecial.ContainsValue(button))
else if (Service.Config.ButtonSpecial.ContainsValue(button))
{
Service.CommandManager.ProcessCommand(Service.Config.ButtonSpecial
.FirstOrDefault(k => k.Value == button && k.Key != SpecialCommandType.None).Key.GetCommandStr());
}
else if (Service.Config.ButtonDoAction == button)
{
RSCommands.DoAction();
}
}
}

0 comments on commit aa67501

Please sign in to comment.