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

Commit

Permalink
feat: add game pad or keyboard click event.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Mar 18, 2023
1 parent d7e35c8 commit 6dc943f
Show file tree
Hide file tree
Showing 14 changed files with 405 additions and 51 deletions.
35 changes: 33 additions & 2 deletions RotationSolver.Basic/Configuration/PluginConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Dalamud.Configuration;
using Dalamud.Game.ClientState.GamePad;
using Newtonsoft.Json;
using RotationSolver.Basic.Data;
using System.Numerics;
Expand Down Expand Up @@ -156,13 +157,43 @@ public class PluginConfiguration : IPluginConfiguration

public bool ShowControlWindow = false;
public bool IsControlWindowLock = true;
public Vector4 ControlWindowLockBg = new Vector4(0, 0, 0, 0.5f);
public Vector4 ControlWindowUnlockBg = new Vector4(0, 0, 0, 1);
public bool UseKeyboardCommand = false;
public bool UseGamepadCommand = false;

public Vector4 ControlWindowLockBg = new Vector4(0, 0, 0, 0.6f);
public Vector4 ControlWindowUnlockBg = new Vector4(0, 0, 0, 0.9f);
public float ControlWindowGCDSize = 40;
public float ControlWindow0GCDSize = 30;
public float ControlWindowNextSizeRatio = 1.5f;
public float ControlProgressHeight = 8;

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

public Dictionary<StateCommandType, ButtonRecord> ButtonState { get; set; } = new Dictionary<StateCommandType, ButtonRecord>()
{
{StateCommandType.Smart, new ButtonRecord( GamepadButtons.East, false, true) },
{StateCommandType.Manual, new ButtonRecord( GamepadButtons.North, false, true) },
{StateCommandType.Cancel, new ButtonRecord( GamepadButtons.South, false, true) },
};
public Dictionary<SpecialCommandType, ButtonRecord> ButtonSpecial { get; set; } = new Dictionary<SpecialCommandType, ButtonRecord>()
{
{SpecialCommandType.EndSpecial, new ButtonRecord( GamepadButtons.West, false, true) },

{SpecialCommandType.EsunaStanceNorth, new ButtonRecord( GamepadButtons.DpadRight, false, true) },
{SpecialCommandType.MoveForward, new ButtonRecord( GamepadButtons.DpadUp, false, true) },
{SpecialCommandType.MoveBack, new ButtonRecord( GamepadButtons.DpadDown, false, true) },
{SpecialCommandType.RaiseShirk, new ButtonRecord( GamepadButtons.DpadLeft, false, true) },

{SpecialCommandType.DefenseArea, new ButtonRecord( GamepadButtons.North, true, false) },
{SpecialCommandType.DefenseSingle, new ButtonRecord( GamepadButtons.East, true, false) },
{SpecialCommandType.HealArea, new ButtonRecord( GamepadButtons.South, true, false) },
{SpecialCommandType.HealSingle, new ButtonRecord( GamepadButtons.West, true, false) },

{SpecialCommandType.Burst, new ButtonRecord( GamepadButtons.DpadDown, true, false) },
{SpecialCommandType.AntiKnockback, new ButtonRecord( GamepadButtons.DpadUp, true, false) },

};
public void Save()
{
Service.Interface.SavePluginConfig(this);
Expand Down
27 changes: 27 additions & 0 deletions RotationSolver.Basic/Data/KeyButton.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Dalamud.Game.ClientState.GamePad;
using Dalamud.Game.ClientState.Keys;

namespace RotationSolver.Basic.Data;

public record KeyRecord(VirtualKey key, bool control, bool alt, bool shift);
public record ButtonRecord(GamepadButtons button, bool l2, bool r2);

public static class RecordExtension
{
public static string ToStr(this ButtonRecord record)
{
string result = "";
if (record.l2) result += "LT + ";
if (record.r2) result += "RT + ";
return result + record.button.ToString();
}

public static string ToStr(this KeyRecord record)
{
string result = "";
if (record.control) result += "Ctrl + ";
if (record.alt) result += "Alt + ";
if (record.shift) result += "Shift + ";
return result + record.key.ToString();
}
}
2 changes: 2 additions & 0 deletions RotationSolver.Basic/Data/RSCommandType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

public enum SpecialCommandType : byte
{
None,
EndSpecial,
HealArea,
HealSingle,
Expand All @@ -17,6 +18,7 @@ public enum SpecialCommandType : byte

public enum StateCommandType : byte
{
None,
Cancel,
Smart,
Manual,
Expand Down
1 change: 1 addition & 0 deletions RotationSolver.Basic/Helpers/TargetFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ internal static BattleChara GetDeathPeople(IEnumerable<BattleChara> deathAll, IE

public unsafe static IEnumerable<BattleChara> GetDeath(this IEnumerable<BattleChara> charas) => charas.Where(item =>
{
if (item == null) return false;
if (!item.IsDead) return false;
if (item.CurrentHp != 0) return false;

Expand Down
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Rotations/CustomRotation_Invoke.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public bool TryInvoke(out IAction newAction, out IAction gcdAction)
var role = Job.GetJobRole();

ActionMoveForwardGCD = MoveForwardGCD(out var act) ? act : null;
ActionMoveForwardAbility = MoveForwardAbility(DataCenter.AbilityRemainCount, out act, recordTarget: false) ? act : null;
ActionMoveForwardAbility = MoveForwardAbility(1, out act, recordTarget: false) ? act : null;
MoveTarget = act is IBaseAction a ? a.Target : null;

ActionMoveBackAbility = MoveBackAbility(DataCenter.AbilityRemainCount, out act) ? act : null;
Expand Down
3 changes: 1 addition & 2 deletions RotationSolver/Commands/RSCommands_StateSpecialCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ private static void DoOneCommandType<T>(T type, Func<T, JobRole, string> sayout,
where T : struct, Enum
{
//Get jobrole.
var role = Service.GetSheet<ClassJob>().GetRow(
Service.Player.ClassJob.Id).GetJobRole();
var role = Service.Player.ClassJob.GameData.GetJobRole();

doingSomething(role);

Expand Down
6 changes: 5 additions & 1 deletion RotationSolver/Localization/Localization.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,15 @@
"ConfigWindow_Param_ConditionDown": "Down",
"ConfigWindow_Param_ConditionDelete": "Delete",
"ConfigWindow_Control_ShowControlWindow": "Show Control Window",
"ConfigWindow_Control_IsControlWindowLock": "Lock Control Window",
"ConfigWindow_Control_UseKeyboardCommand": "Use Keyboard Command",
"ConfigWindow_Control_UseGamepadCommand": "Use GamePad Command",
"ConfigWindow_Control_IsControlWindowLock": "Lock",
"ConfigWindow_Control_BackgroundColor": "Control Window's Background",
"ConfigWindow_Control_ControlWindowGCDSize": "GCD icon size",
"ConfigWindow_Control_ControlWindow0GCDSize": "0GCD icon size",
"ConfigWindow_Control_ControlWindowNextSizeRatio": "Next Action Size Ratio",
"ConfigWindow_Control_ResetButtonOrKeyCommand": "Right click to reset the gamepad button or key board key.\nHold Left Ctrl and right click to clear the key setting.",
"ConfigWindow_Control_NeedToEnable": " (Need to enable)",
"Timeline_DragdropDescription": "Drag&drop to move,Ctrl+Alt+RightClick to delete.",
"Timeline_SearchBar": "Search Bar",
"Timeline_MustUse": "MustUse",
Expand Down
6 changes: 5 additions & 1 deletion RotationSolver/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,15 @@ internal partial class Strings
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";
public string ConfigWindow_Control_UseKeyboardCommand { get; set; } = "Use Keyboard Command";
public string ConfigWindow_Control_UseGamepadCommand { get; set; } = "Use GamePad Command";
public string ConfigWindow_Control_IsControlWindowLock { get; set; } = "Lock";
public string ConfigWindow_Control_BackgroundColor { get; set; } = "Control Window's Background";
public string ConfigWindow_Control_ControlWindowGCDSize { get; set; } = "GCD icon size";
public string ConfigWindow_Control_ControlWindow0GCDSize { get; set; } = "0GCD icon size";
public string ConfigWindow_Control_ControlWindowNextSizeRatio { get; set; } = "Next Action Size Ratio";
public string ConfigWindow_Control_ResetButtonOrKeyCommand { get; set; } = "Right click to reset the gamepad button or key board key.\nHold Left Ctrl and right click to clear the key setting.";
public string ConfigWindow_Control_NeedToEnable { get; set; } = " (Need to enable)";

#endregion

Expand Down
1 change: 0 additions & 1 deletion RotationSolver/SigReplacers/MovingController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,4 @@ private static bool MovingDetour(IntPtr ptr)
}
return movingHook.Original(ptr);
}

}
Loading

0 comments on commit 6dc943f

Please sign in to comment.