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

Commit

Permalink
feat: add print clipping feature.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Jul 18, 2023
1 parent 1329f76 commit b496e02
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ActionTimelineEx/Configurations/DrawingSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,6 @@ public class DrawingSettings
public bool ShowGCDClippingSetting = true;
public bool ShowGCDClipping => IsRotation ? false : ShowGCDClippingSetting;
public float GCDClippingThreshold = 0.15f;
public int GCDClippingMaxTime = 5;
public int GCDClippingMaxTime = 2;
public Vector4 GCDClippingColor = new Vector4(1f, 0.2f, 0.2f, 0.3f);
}
3 changes: 3 additions & 0 deletions ActionTimelineEx/Configurations/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ public class Settings : IPluginConfiguration
//public float StatusCheckDelay = 0.1f;
public DrawingSettings TimelineSetting = new DrawingSettings();
public HashSet<ushort> HideStatusIds = new HashSet<ushort>();
public bool PrintClipping = false;
public int PrintClippingMin = 150;
public int PrintClippingMax = 2000;
public int Version { get; set; } = 6;

public void Save()
Expand Down
18 changes: 15 additions & 3 deletions ActionTimelineEx/Timeline/TimelineManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,22 @@ private void ActionFromSelfAsync(ActionEffectSet set)
});
}

Svc.Chat.Print(set.Header.ActionID.ToString());

var now = DateTime.Now;
var type = GetActionType(set.Header.ActionID, set.Header.ActionType);

if (Plugin.Settings.PrintClipping && type == TimelineItemType.GCD)
{
var lastGcd = _items.LastOrDefault(i => i.Type == TimelineItemType.GCD);
if(lastGcd != null)
{
var time = (int)(now - lastGcd.EndTime).TotalMilliseconds;
if(time >= Plugin.Settings.PrintClippingMin && time <= Plugin.Settings.PrintClippingMax)
{
Svc.Chat.Print($"Clipping: {time} ms ({lastGcd.Name} - {set.Name})");
}
}
}

if (_lastItem != null && _lastItem.CastingTime > 0 && type == TimelineItemType.GCD
&& _lastItem.State == TimelineItemState.Casting) // Finish the casting.
{
Expand All @@ -271,7 +283,7 @@ private void ActionFromSelfAsync(ActionEffectSet set)
{
AddItem(new TimelineItem()
{
StartTime = DateTime.Now,
StartTime = now,
AnimationLockTime = type == TimelineItemType.AutoAttack ? 0 : set.Header.AnimationLockTime,
GCDTime = type == TimelineItemType.GCD ? GCD : 0,
Type = type,
Expand Down
8 changes: 7 additions & 1 deletion ActionTimelineEx/Windows/SettingsWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ private void DrawGeneralSetting()
{
ImGui.Checkbox("Show Only In Duty", ref Settings.ShowTimelineOnlyInDuty);
ImGui.Checkbox("Show Only In Combat", ref Settings.ShowTimelineOnlyInCombat);
ImGui.Checkbox("Print Clipping Time On Chat", ref Settings.PrintClipping);
if (Settings.PrintClipping)
{
ImGui.SameLine();
ImGui.DragIntRange2("Clipping Range", ref Settings.PrintClippingMin, ref Settings.PrintClippingMax);
}

//ImGui.NewLine();

Expand Down Expand Up @@ -390,7 +396,7 @@ private void DrawGCDClippingTab(DrawingSettings settings)
int clippingThreshold = (int)(settings.GCDClippingThreshold * 1000f);
if (ImGui.DragInt("Threshold (ms)", ref clippingThreshold, 0.1f, 0, 1000))
{
settings.GCDClippingThreshold = (float)clippingThreshold / 1000f;
settings.GCDClippingThreshold = clippingThreshold / 1000f;
}
DrawHelper.SetTooltip("This can be used filter out \"false positives\" due to latency or other factors. Any GCD clipping detected that is shorter than this value will be ignored.\nIt is strongly recommended that you test out different values and find out what works best for your setup.");

Expand Down

0 comments on commit b496e02

Please sign in to comment.