This repository has been archived by the owner on Aug 28, 2024. It is now read-only.
forked from Tischel/ActionTimeline
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: changed the way of showing rotations.
- Loading branch information
1 parent
c8b8232
commit 291f428
Showing
13 changed files
with
559 additions
and
231 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
127 changes: 127 additions & 0 deletions
127
ActionTimelineEx/Configurations/Actions/ActionSetting.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
using ActionTimelineEx.Helpers; | ||
using ECommons.DalamudServices; | ||
using ImGuiNET; | ||
using Lumina.Excel.GeneratedSheets; | ||
using System.Numerics; | ||
using XIVConfigUI; | ||
using XIVConfigUI.Attributes; | ||
using Action = Lumina.Excel.GeneratedSheets.Action; | ||
|
||
namespace ActionTimelineEx.Configurations.Actions; | ||
|
||
|
||
/// <summary> | ||
/// From https://github.com/aers/FFXIVClientStructs/blob/main/FFXIVClientStructs/FFXIV/Client/Game/ActionManager.cs#L373-L395 | ||
/// </summary> | ||
public enum ActionSettingType : byte | ||
{ | ||
Action = 0x01, // Spell, Weaponskill, Ability. Confusing name, I know. | ||
Item = 0x02, | ||
} | ||
|
||
[ActionSetting] | ||
public abstract class ActionSetting | ||
{ | ||
internal uint IconId { get; private set; } = 0; | ||
internal string DisplayName { get; private set; } = ""; | ||
|
||
private uint _actionId; | ||
|
||
public bool IsEmpty => ActionId == 0; | ||
|
||
public uint ActionId | ||
{ | ||
get => _actionId; | ||
set | ||
{ | ||
if (value == _actionId) return; | ||
_actionId = value; | ||
|
||
Update(); | ||
} | ||
} | ||
|
||
internal abstract ActionSettingType Type { get; } | ||
|
||
[UI("Is this Action Highlight")] | ||
public bool Highlight { get; set; } | ||
|
||
protected void Update() | ||
{ | ||
ClearData(); | ||
|
||
switch (Type) | ||
{ | ||
case ActionSettingType.Action: | ||
UpdateAction(); | ||
return; | ||
|
||
case ActionSettingType.Item: | ||
UpdateItem(); | ||
return; | ||
} | ||
|
||
void UpdateItem() | ||
{ | ||
var item = Svc.Data.GetExcelSheet<Item>()?.GetRow(ActionId); | ||
if (item == null) return; | ||
|
||
IconId = IsEmpty ? 0u : item.Icon; | ||
DisplayName = item.Name; | ||
} | ||
|
||
void UpdateAction() | ||
{ | ||
var action = Svc.Data.GetExcelSheet<Action>()?.GetRow(ActionId); | ||
if (action == null) return; | ||
|
||
IconId = IsEmpty ? 0u : GetActionIcon(action); | ||
DisplayName = $"{action.Name} ({(action.IsGcd() ? "GCD" : "oGCD")})"; | ||
} | ||
|
||
void ClearData() | ||
{ | ||
IconId = 0; | ||
DisplayName = string.Empty; | ||
} | ||
} | ||
|
||
private static uint GetActionIcon(Action action) | ||
{ | ||
var isGAction = action.ActionCategory.Row is 10 or 11; | ||
if (!isGAction) return action.Icon; | ||
|
||
var gAct = Svc.Data.GetExcelSheet<GeneralAction>()?.FirstOrDefault(g => g.Action.Row == action.RowId); | ||
|
||
if (gAct == null) return action.Icon; | ||
return (uint)gAct.Icon; | ||
} | ||
|
||
public bool IsMatched(uint id, ActionSettingType type) | ||
{ | ||
return id == ActionId && type == Type; | ||
} | ||
|
||
public void DrawIcon(ImDrawListPtr drawList, Vector2 point, float size, bool passed, ActionSetting? activeAction) | ||
{ | ||
IconType iconType = passed ? IconType.Blacked | ||
: Highlight ? IconType.Highlight : IconType.Normal; | ||
drawList.DrawActionIcon(IconId, Type is ActionSettingType.Item, point, size, iconType); | ||
if (!string.IsNullOrEmpty(DisplayName) && DrawHelper.IsInRect(point, new Vector2(size))) | ||
ImGui.SetTooltip(DisplayName); | ||
if (passed) | ||
{ | ||
if (!RotationHelper.SuccessActions.Contains(this)) | ||
{ | ||
ImGuiHelper.DrawSlotHighlight(drawList, point, size, ImGui.ColorConvertFloat4ToU32(Plugin.Settings.RotationFailedColor)); | ||
} | ||
} | ||
else | ||
{ | ||
if (activeAction == this) | ||
{ | ||
ImGuiHelper.DrawSlotHighlight(drawList, point, size, ImGui.ColorConvertFloat4ToU32(Plugin.Settings.RotationHighlightColor)); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.