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

Commit

Permalink
fix: add time limit for recording key or button.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Mar 18, 2023
1 parent fbd8d66 commit 7c6a541
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
6 changes: 4 additions & 2 deletions RotationSolver.Basic/Data/RSCommandType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

public enum SpecialCommandType : byte
{
None,
EndSpecial,
HealArea,
HealSingle,
Expand All @@ -14,14 +13,17 @@ public enum SpecialCommandType : byte
MoveBack,
AntiKnockback,
Burst,

None,
}

public enum StateCommandType : byte
{
None,
Cancel,
Smart,
Manual,

None,
}

public enum OtherCommandType : byte
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver.Basic/DataCenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public static unsafe ushort FateId
static SpecialCommandType _specialType = SpecialCommandType.EndSpecial;
public static SpecialCommandType SpecialType =>
SpecialTimeLeft < 0 ? SpecialCommandType.EndSpecial : _specialType;
public static StateCommandType StateType { get; set; }
public static StateCommandType StateType { get; set; } = StateCommandType.Cancel;

public static void SetSpecialType(SpecialCommandType specialType)
{
Expand Down
4 changes: 3 additions & 1 deletion RotationSolver/UI/ControlWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public override void Draw()

DrawCommandAction(61751, StateCommandType.Manual, ImGuiColors.DPSRed);

DrawCommandAction(61764, StateCommandType.Cancel, ImGuiColors.DPSRed);
DrawCommandAction(61764, StateCommandType.Cancel, ImGuiColors.DalamudWhite2);

ImGui.SameLine();

Expand Down Expand Up @@ -279,6 +279,7 @@ static void DrawIAction(nint handle, string id, float width, SpecialCommandType
}
if(InputUpdater.RecordingSpecialType == SpecialCommandType.None)
{
InputUpdater.RecordingTime = DateTime.Now;
InputUpdater.RecordingSpecialType = command;
Service.ToastGui.ShowQuest($"Recording: {command}",
new Dalamud.Game.Gui.Toast.QuestToastOptions()
Expand Down Expand Up @@ -319,6 +320,7 @@ static void DrawIAction(nint handle, string id, float width, StateCommandType co
}
if (InputUpdater.RecordingStateType == StateCommandType.None)
{
InputUpdater.RecordingTime = DateTime.Now;
InputUpdater.RecordingStateType = command;
Service.ToastGui.ShowQuest($"Recording: {command}",
new Dalamud.Game.Gui.Toast.QuestToastOptions()
Expand Down
8 changes: 7 additions & 1 deletion RotationSolver/Updaters/InputUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,16 @@ internal static class InputUpdater

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

internal static void UpdateCommand()
{
if(DateTime.Now - RecordingTime > TimeSpan.FromSeconds(10))
{
RecordingSpecialType = SpecialCommandType.None;
RecordingStateType = StateCommandType.None;
}

foreach (var key in Service.KeyState.GetValidVirtualKeys())
{
if (key is VirtualKey.CONTROL) continue;
Expand All @@ -33,7 +40,6 @@ internal static void UpdateCommand()
}
}
_keys[key] = value;

}

foreach (var button in Enum.GetValues<GamepadButtons>())
Expand Down

0 comments on commit 7c6a541

Please sign in to comment.