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

Commit

Permalink
fix: gcd check.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Mar 27, 2024
1 parent 20e72e5 commit faa2e7f
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 42 deletions.
2 changes: 1 addition & 1 deletion ActionTimelineEx/ActionTimelineEx.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0-windows</TargetFramework>
<TargetFramework>net8.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Authors>ArchiTed</Authors>
<PlatformTarget>x64</PlatformTarget>
Expand Down
30 changes: 15 additions & 15 deletions ActionTimelineEx/Configurations/DrawingSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public class DrawingSettings
public Vector2 RealDownDirection => IsHorizonal ? Vector2.UnitY : Vector2.UnitX;

public bool Locked = false;
public Vector4 LockedBackgroundColor = new Vector4(0f, 0f, 0f, 0.5f);
public Vector4 UnlockedBackgroundColor = new Vector4(0f, 0f, 0f, 0.75f);
public Vector4 LockedBackgroundColor = new (0f, 0f, 0f, 0.5f);
public Vector4 UnlockedBackgroundColor = new (0f, 0f, 0f, 0.75f);

public float SizePerSecond = 60;
public float CenterOffset = 0;
Expand Down Expand Up @@ -47,19 +47,19 @@ public class DrawingSettings
public Vector4 CriticalColor = ImGuiColors.DalamudOrange;
public Vector4 CriticalDirectColor = ImGuiColors.DPSRed;

public Vector4 BackgroundColor = new Vector4(0.5f, 0.5f, 0.5f, 0.5f);
public Vector4 GCDBorderColor = new Vector4(0.9f, 0.9f, 0.9f, 1f);
public Vector4 BackgroundColor = new (0.5f, 0.5f, 0.5f, 0.5f);
public Vector4 GCDBorderColor = new (0.9f, 0.9f, 0.9f, 1f);
public float GCDThickness = 1.5f;
public float GCDHeightLow = 0.5f;
public float GCDHeightHigh = 0.8f;
public float GCDRound = 2;

public Vector4 CastInProgressColor = new Vector4(0.2f, 0.8f, 0.2f, 1f);
public Vector4 CastFinishedColor = new Vector4(0.5f, 0.5f, 0.5f, 1f);
public Vector4 CastCanceledColor = new Vector4(0.8f, 0.2f, 0.2f, 1f);
public Vector4 CastInProgressColor = new (0.2f, 0.8f, 0.2f, 1f);
public Vector4 CastFinishedColor = new (0.5f, 0.5f, 0.5f, 1f);
public Vector4 CastCanceledColor = new (0.8f, 0.2f, 0.2f, 1f);

public bool ShowAnimationLock = true;
public Vector4 AnimationLockColor = new Vector4(0.8f, 0.7f, 0.6f, 1f);
public Vector4 AnimationLockColor = new (0.8f, 0.7f, 0.6f, 1f);

public bool ShowStatusLine = true;
public float StatusLineSize = 18;
Expand All @@ -74,15 +74,15 @@ public class DrawingSettings
public float GridCenterLineWidth = 1f;
public float GridStartLineWidth = 3;
public float GridSubdivisionLineWidth = 1;
public Vector4 GridLineColor = new Vector4(0.3f, 0.3f, 0.3f, 1f);
public Vector4 GridCenterLineColor = new Vector4(0.5f, 0.5f, 0.5f, 0.3f);
public Vector4 GridStartLineColor = new Vector4(0.3f, 0.5f, 0.2f, 1f);
public Vector4 GridSubdivisionLineColor = new Vector4(0.3f, 0.3f, 0.3f, 0.2f);
public Vector4 GridLineColor = new (0.3f, 0.3f, 0.3f, 1f);
public Vector4 GridCenterLineColor = new (0.5f, 0.5f, 0.5f, 0.3f);
public Vector4 GridStartLineColor = new (0.3f, 0.5f, 0.2f, 1f);
public Vector4 GridSubdivisionLineColor = new (0.3f, 0.3f, 0.3f, 0.2f);

public bool ShowGCDClippingSetting = true;
public bool ShowGCDClipping => IsRotation ? false : ShowGCDClippingSetting;
public bool ShowGCDClipping => !IsRotation && ShowGCDClippingSetting;
public float GCDClippingThreshold = 0.15f;
public int GCDClippingMaxTime = 2;
public Vector4 GCDClippingColor = new Vector4(1f, 0.2f, 0.2f, 0.3f);
public Vector4 GCDClippingTextColor = new Vector4(0.9f, 0.9f, 0.9f, 1f);
public Vector4 GCDClippingColor = new (1f, 0.2f, 0.2f, 0.3f);
public Vector4 GCDClippingTextColor = new (0.9f, 0.9f, 0.9f, 1f);
}
4 changes: 2 additions & 2 deletions ActionTimelineEx/Configurations/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ public class Settings : IPluginConfiguration
public bool HideTimelineInQuestEvent = true;
public bool Record = true;
public bool RecordTargetStatus = true;
public List<DrawingSettings> TimelineSettings = new();
public HashSet<ushort> HideStatusIds = new HashSet<ushort>();
public List<DrawingSettings> TimelineSettings = [];
public HashSet<ushort> HideStatusIds = [];
public bool PrintClipping = false;
public int PrintClippingMin = 150;
public int PrintClippingMax = 2000;
Expand Down
9 changes: 4 additions & 5 deletions ActionTimelineEx/Helpers/DrawHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@
using ECommons.DalamudServices;
using ECommons.ImGuiMethods;
using ImGuiNET;
using ImGuiScene;
using Lumina.Data.Files;
using System.Numerics;

namespace ActionTimeline.Helpers;

internal static class DrawHelper
{
private static readonly Vector2 _uv1 = new Vector2(96 * 5 / 852f, 0),
_uv2 = new Vector2((96 * 5 + 144) / 852f, 0.5f);
private static readonly Vector2 _uv1 = new (96 * 5 / 852f, 0),
_uv2 = new ((96 * 5 + 144) / 852f, 0.5f);

private static IDalamudTextureWrap? _roundTex;
public static void Init()
Expand Down Expand Up @@ -69,8 +68,8 @@ public static Vector4 ChangeAlpha(this Vector4 color, float alpha)
=> ThreadLoadImageHandler.TryGetIconTextureWrap(iconId, highQuality, out var texture) ? texture
: ThreadLoadImageHandler.TryGetIconTextureWrap(0, highQuality, out texture) ? texture : null;

private static Dictionary<uint, uint> textureColorCache = new ();
private static Queue<uint> calculating = new ();
private static readonly Dictionary<uint, uint> textureColorCache = [];
private static readonly Queue<uint> calculating = new ();
public static uint GetTextureAverageColor(uint iconId)
{
if (textureColorCache.TryGetValue(iconId, out var color)) return color;
Expand Down
7 changes: 2 additions & 5 deletions ActionTimelineEx/Timeline/TimelineItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
using Dalamud.Interface;
using Dalamud.Interface.Internal;
using ImGuiNET;
using ImGuiScene;
using RotationSolver.Basic.Data;
using System.Drawing;
using System.Numerics;

namespace ActionTimelineEx.Timeline;
Expand Down Expand Up @@ -82,7 +79,7 @@ private static (IDalamudTextureWrap texture, string? name)[] GetTextures(HashSet
if (texture == null) continue;
result.Add((texture, name));
}
return result.ToArray();
return [.. result];
}

public const float HeightRatio = 4 / 3f;
Expand Down Expand Up @@ -202,7 +199,7 @@ private void DrawItemWithCenter(ImDrawListPtr drawList, Vector2 centerPos, Vecto
//Name
}

private Vector2 MinX(Vector2 pos, Vector2 minPos)
private static Vector2 MinX(Vector2 pos, Vector2 minPos)
{
return new Vector2(MathF.Max(pos.X, minPos.X), MathF.Max(pos.Y, minPos.Y));
}
Expand Down
24 changes: 12 additions & 12 deletions ActionTimelineEx/Timeline/TimelineManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

namespace ActionTimeline.Timeline;

public class TimelineManager
public class TimelineManager : IDisposable
{
internal const byte GCDCooldownGroup = 58;

Expand Down Expand Up @@ -78,11 +78,11 @@ protected void Dispose(bool disposing)
[Signature("40 55 56 48 81 EC ?? ?? ?? ?? 48 8B EA", DetourName = nameof(OnCast))]
private readonly Hook<OnCastDelegate>? _onCastHook = null;

public static SortedSet<ushort> ShowedStatusId { get; } = new SortedSet<ushort>();
public static SortedSet<ushort> ShowedStatusId { get; } = [];

public DateTime EndTime { get; private set; } = DateTime.Now;
private static int kMaxItemCount = 2048;
private readonly Queue<TimelineItem> _items = new Queue<TimelineItem>(kMaxItemCount);
private static readonly int kMaxItemCount = 2048;
private readonly Queue<TimelineItem> _items = new(kMaxItemCount);
private TimelineItem? _lastItem = null;

private DateTime _lastTime = DateTime.MinValue;
Expand Down Expand Up @@ -112,8 +112,8 @@ public List<TimelineItem> GetItems(DateTime time, out DateTime lastEndTime)
return GetItems(_items, time, out lastEndTime);
}

private static int kMaxStatusCount = 256;
private readonly Queue<StatusLineItem> _statusItems = new Queue<StatusLineItem>(kMaxStatusCount);
private static readonly int kMaxStatusCount = 256;
private readonly Queue<StatusLineItem> _statusItems = new(kMaxStatusCount);
private void AddItem(StatusLineItem item)
{
if (item == null) return;
Expand All @@ -129,7 +129,7 @@ public List<StatusLineItem> GetStatus(DateTime time, out DateTime lastEndTime)
return GetItems(_statusItems, time, out lastEndTime);
}

private List<T> GetItems<T>(IEnumerable<T> items, DateTime time, out DateTime lastEndTime) where T : ITimelineItem
private static List<T> GetItems<T>(IEnumerable<T> items, DateTime time, out DateTime lastEndTime) where T : ITimelineItem
{
var result = new List<T>();
lastEndTime = DateTime.Now;
Expand All @@ -153,7 +153,7 @@ public unsafe float GCD
get
{
var cdGrp = ActionManager.Instance()->GetRecastGroupDetail(GCDCooldownGroup - 1);
return cdGrp->Total - cdGrp->Elapsed;
return cdGrp->Total;
}
}

Expand Down Expand Up @@ -193,7 +193,7 @@ private void CancelCasting()
_lastItem.CastingTime = MathF.Min(maxTime, _lastItem.CastingTime);
}

private uint GetStatusIcon(ushort id, bool isGain, out string? name, byte stack = byte.MaxValue)
private static uint GetStatusIcon(ushort id, bool isGain, out string? name, byte stack = byte.MaxValue)
{
name = null;
if (Plugin.Settings.HideStatusIds.Contains(id)) return 0;
Expand Down Expand Up @@ -229,7 +229,7 @@ private void ActionFromSelf(ActionEffectSet set)
if (set.Source.ObjectId != Player.Object.ObjectId || !Plugin.Settings.Record) return;

DamageType damage = DamageType.None;
SortedSet<(uint, string?)> statusGain = new (), statusLose = new ();
SortedSet<(uint, string?)> statusGain = [], statusLose = [];

for (int i = 0; i < set.Header.TargetCount; i++)
{
Expand Down Expand Up @@ -335,9 +335,9 @@ private async void AddStatusLine(TimelineItem? effectItem, ulong targetId)

await Task.Delay(50);

if (!effectItem.StatusGainIcon.Any()) return;
if (effectItem.StatusGainIcon.Count == 0) return;

List<StatusLineItem> list = new List<StatusLineItem>(4);
List<StatusLineItem> list = new(4);
foreach (var icon in effectItem.StatusGainIcon)
{
if (Plugin.IconStack.TryGetValue(icon.icon, out var stack))
Expand Down
2 changes: 1 addition & 1 deletion ActionTimelineEx/packages.lock.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": 1,
"dependencies": {
"net7.0-windows7.0": {
"net8.0-windows7.0": {
"DalamudPackager": {
"type": "Direct",
"requested": "[2.1.12, )",
Expand Down

0 comments on commit faa2e7f

Please sign in to comment.