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

Commit

Permalink
fix: add Ignore Actions for Rotation Helper.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Jul 13, 2024
1 parent 428ff8b commit e9ba8e1
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 63 deletions.
28 changes: 16 additions & 12 deletions ActionTimelineEx/Configurations/ActionSetting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public override void OnClick(object obj)
base.OnClick(obj);
if (obj is not ActionSetting setting) return;

//TODO: Change the acion ID...
//TODO: Change the action ID...
}

public override string GetDescription(object obj)
Expand Down Expand Up @@ -49,7 +49,7 @@ public class ActionSetting

private uint _actionId;

public uint ActionId
public uint ActionId
{
get => _actionId;
set
Expand All @@ -60,8 +60,9 @@ public uint ActionId
Update();
}
}

[JsonIgnore, UI("Id")]
public int Id { get => (int)ActionId; set => ActionId = (uint) value; }
public int Id { get => (int)ActionId; set => ActionId = (uint)value; }
private ActionSettingType _type;

[UI("Type")]
Expand All @@ -76,20 +77,18 @@ public ActionSettingType Type
Update();
}
}

internal bool Is0GCD => !IsGCD;

[JsonProperty]
private bool _isLast = false;

[JsonIgnore]
[UI("Is the Last Ability during GCD", Parent = nameof(Is0GCD))]
public bool IsLast
public bool IsLast
{
get => _isLast && Is0GCD;
set => _isLast = value;
}

private void Update()
{
ClearData();
Expand Down Expand Up @@ -133,12 +132,6 @@ void ClearData()
}
}

public void Draw(ImDrawListPtr drawList, Vector2 point, float size)
{
drawList.DrawActionIcon(IconId, Type is ActionSettingType.Item, point, size);
if (!string.IsNullOrEmpty(DisplayName) && DrawHelper.IsInRect(point, new Vector2(size))) ImGui.SetTooltip(DisplayName);
}

private static uint GetActionIcon(Lumina.Excel.GeneratedSheets.Action action)
{
var isGAction = action.ActionCategory.Row is 10 or 11;
Expand All @@ -149,4 +142,15 @@ private static uint GetActionIcon(Lumina.Excel.GeneratedSheets.Action action)
if (gAct == null) return action.Icon;
return (uint)gAct.Icon;
}

public void Draw(ImDrawListPtr drawList, Vector2 point, float size)
{
drawList.DrawActionIcon(IconId, Type is ActionSettingType.Item, point, size);
if (!string.IsNullOrEmpty(DisplayName) && DrawHelper.IsInRect(point, new Vector2(size))) ImGui.SetTooltip(DisplayName);
}

public bool IsMatched(uint id, ActionSettingType type)
{
return id == ActionId && type == Type;
}
}
4 changes: 4 additions & 0 deletions ActionTimelineEx/Configurations/RotationSetting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@ public class RotationSetting
[UI("Rotation Name")]
public string Name { get; set; } = "Default";

[UI]
public List<ActionSetting> Actions { get; set; } = [];

[UI("Ignore Actions")]
public List<ActionSetting> IgnoreActions { get; set; } = [];
}
14 changes: 1 addition & 13 deletions ActionTimelineEx/Configurations/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public class Settings : IPluginConfiguration

[JsonIgnore]
[TimelineChoices]
[UI("Rotation Choice", 2)]
[UI("Rotation Choice", Parent = nameof(DrawRotation))]
public string RotationChoice
{
get => EditSetting?.Choice ?? "Default";
Expand All @@ -90,18 +90,6 @@ public string RotationChoice
}
}

[JsonIgnore]
[UI("Rotation Name", 2)]
public string RotationName
{
get => EditSetting?.RotationSetting.Name ?? "Default";
set
{
if (EditSetting == null) return;
EditSetting.RotationSetting.Name = value;
}
}

[JsonIgnore]
[UI("Record Rotation", 2)]
public bool RecordRotation { get; set; } = false;
Expand Down
56 changes: 20 additions & 36 deletions ActionTimelineEx/Helpers/RotationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private static void UpdateHighlight()
var action = ActiveAction;
if (action == null) return;

HotbarID? hotbar = null;
HotbarID? hotBar = null;

switch (action.Type)
{
Expand All @@ -55,21 +55,21 @@ private static void UpdateHighlight()
var gAct = Svc.Data.GetExcelSheet<GeneralAction>()?.FirstOrDefault(g => g.Action.Row == action.ActionId);
if (gAct != null)
{
hotbar = new HotbarID(FFXIVClientStructs.FFXIV.Client.UI.Misc.RaptureHotbarModule.HotbarSlotType.GeneralAction, gAct.RowId);
hotBar = new HotbarID(FFXIVClientStructs.FFXIV.Client.UI.Misc.RaptureHotbarModule.HotbarSlotType.GeneralAction, gAct.RowId);
break;
}
}

hotbar = new HotbarID(FFXIVClientStructs.FFXIV.Client.UI.Misc.RaptureHotbarModule.HotbarSlotType.Action, action.ActionId);
hotBar = new HotbarID(FFXIVClientStructs.FFXIV.Client.UI.Misc.RaptureHotbarModule.HotbarSlotType.Action, action.ActionId);
break;

case ActionSettingType.Item:
hotbar = new HotbarID(FFXIVClientStructs.FFXIV.Client.UI.Misc.RaptureHotbarModule.HotbarSlotType.Item, action.ActionId);
hotBar = new HotbarID(FFXIVClientStructs.FFXIV.Client.UI.Misc.RaptureHotbarModule.HotbarSlotType.Item, action.ActionId);
break;
}

if (hotbar == null) return;
_highLight.HotbarIDs.Add(hotbar.Value);
if (hotBar == null) return;
_highLight.HotbarIDs.Add(hotBar.Value);
}

public static void Init()
Expand Down Expand Up @@ -112,25 +112,25 @@ private static void ActionFromSelf(ActionEffectSet set)
if (set.Source.EntityId != Player.Object.EntityId || !Plugin.Settings.DrawRotation) return;
if ((ActionCate)(set.Action?.ActionCategory.Value?.RowId ?? 0) is ActionCate.AutoAttack) return; //Auto Attack.

var actionSettingType = (ActionSettingType)(byte)set.Header.ActionType;
if (!Enum.IsDefined(typeof(ActionSettingType), actionSettingType)) return;
var actionId = set.Header.ActionID;

if (Plugin.Settings.RecordRotation)
{
RecordRotation(set);
RecordRotation(actionId, actionSettingType);
return;
}

var action = ActiveAction;
if (action == null) return;

bool succeed = set.Header.ActionID == action.ActionId;
switch (set.Header.ActionType)
foreach (var act in RotationSetting.IgnoreActions)
{
case FFXIVClientStructs.FFXIV.Client.Game.ActionType.Action when action.Type != ActionSettingType.Action:
case FFXIVClientStructs.FFXIV.Client.Game.ActionType.Item when action.Type != ActionSettingType.Item:
succeed = false;
break;

if (act.IsMatched(actionId, actionSettingType)) return;
}
if (succeed)

if (action.IsMatched(actionId, actionSettingType))
{
SuccessCount++;
}
Expand All @@ -141,29 +141,13 @@ private static void ActionFromSelf(ActionEffectSet set)
Count++;
}

private static void RecordRotation(in ActionEffectSet set)
private static void RecordRotation(uint actionId, ActionSettingType type)
{
ActionSettingType? type = null;

switch (set.Header.ActionType)
{
case FFXIVClientStructs.FFXIV.Client.Game.ActionType.Action:
type = ActionSettingType.Action;
break;

case FFXIVClientStructs.FFXIV.Client.Game.ActionType.Item:
type = ActionSettingType.Item;
break;
}

if (type != null)
RotationSetting.Actions.Add(new ActionSetting()
{
RotationSetting.Actions.Add(new ActionSetting()
{
ActionId = set.Header.ActionID,
Type = type.Value,
});
}
ActionId = actionId,
Type = type,
});
}


Expand Down
8 changes: 7 additions & 1 deletion ActionTimelineEx/Localization/Localization.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,11 @@
"ActionTimelineEx.Description": "Configurable timeline display of all the actions you use.",
"ActionTimelineEx.Configurations.UiString.AddOneRotation": "Add One Rotation",
"XIVConfigUI.LocalString.Add": "Add",
"ActionTimelineEx.Configurations.ActionSettingName.IsLast": "Is the Last Ability during GCD"
"ActionTimelineEx.Configurations.ActionSettingName.IsLast": "Is the Last Ability during GCD",
"ActionTimelineEx.Configurations.RotationSettingName.Name": "Rotation Name",
"ActionTimelineEx.Configurations.RotationSettingName.Actions": "Actions",
"ActionTimelineEx.Configurations.RotationSettingName.IgnoreActions": "Ignore Actions",
"ActionTimelineEx.Configurations.ActionBaseName.Id": "Id",
"ActionTimelineEx.Configurations.ActionBaseName.Type": "Type",
"ActionTimelineEx.Configurations.ActionBase": "ActionBase"
}
5 changes: 4 additions & 1 deletion ActionTimelineEx/Windows/RotationHelperItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ private static void DrawRotation(ConfigWindow window, RotationsSetting setting)


window.Collection.DrawItems(2);
ConditionDrawer.Draw(setting.RotationSetting.Actions);

ImGui.Separator();

ConditionDrawer.Draw(setting.RotationSetting);
}

private static void DrawTerritoryHeader()
Expand Down

0 comments on commit e9ba8e1

Please sign in to comment.