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

Commit

Permalink
fix: changed the way of showing rotations.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Jul 18, 2024
1 parent c8b8232 commit 291f428
Show file tree
Hide file tree
Showing 13 changed files with 559 additions and 231 deletions.
156 changes: 0 additions & 156 deletions ActionTimelineEx/Configurations/ActionSetting.cs

This file was deleted.

127 changes: 127 additions & 0 deletions ActionTimelineEx/Configurations/Actions/ActionSetting.cs
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));
}
}
}
}
Loading

0 comments on commit 291f428

Please sign in to comment.