From efa19b2a2504d02f5479f7b5ced4b05c7e3c826c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=8B=E6=B0=B4?= <1123993881@qq.com> Date: Fri, 21 Jul 2023 14:32:19 +0800 Subject: [PATCH] fix: fixed casting icon. --- ActionTimelineEx/Timeline/TimelineManager.cs | 39 ++++++++++++-------- ActionTimelineEx/Windows/SettingsWindow.cs | 8 ++-- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/ActionTimelineEx/Timeline/TimelineManager.cs b/ActionTimelineEx/Timeline/TimelineManager.cs index ad7b8b9..6cf0ca0 100644 --- a/ActionTimelineEx/Timeline/TimelineManager.cs +++ b/ActionTimelineEx/Timeline/TimelineManager.cs @@ -372,19 +372,8 @@ private async void AddStatusLine(TimelineItem? effectItem, ulong targetId) } } - private const string WarningOnActorControl = "Something wrong with OnActorControl!"; private async void OnActorControl(uint entityId, ActorControlCategory type, uint buffID, uint direct, uint actionId, uint sourceId, uint arg4, uint arg5, ulong targetId, byte a10) { - byte stack = 0; - try - { - stack = Player.Object?.StatusList.FirstOrDefault(s => s.StatusId == buffID && s.SourceId == Player.Object.ObjectId)?.StackCount ?? 0; - } - catch(Exception ex) - { - PluginLog.Warning(ex, WarningOnActorControl); - } - _onActorControlHook?.Original(entityId, type, buffID, direct, actionId, sourceId, arg4, arg5, targetId, a10); //#if DEBUG @@ -405,7 +394,9 @@ private async void OnActorControl(uint entityId, ActorControlCategory type, uint break; case ActorControlCategory.LoseEffect: - var icon = GetStatusIcon((ushort)buffID, false, stack); + var stack = Player.Object?.StatusList.FirstOrDefault(s => s.StatusId == buffID && s.SourceId == Player.Object.ObjectId)?.StackCount ?? 0; + + var icon = GetStatusIcon((ushort)buffID, false, ++stack); if (icon == 0) break; var now = DateTime.Now; @@ -448,7 +439,7 @@ private async void OnActorControl(uint entityId, ActorControlCategory type, uint catch (Exception ex) { - PluginLog.Warning(ex, WarningOnActorControl); + PluginLog.Warning(ex, "Something wrong with OnActorControl!"); } } @@ -462,14 +453,30 @@ private unsafe void OnCast(uint sourceId, IntPtr ptr) var actionId = *(ushort*)ptr; + string name = string.Empty; + ushort icon = 0; var action = Svc.Data.GetExcelSheet()?.GetRow(actionId); - var icon = actionId == 4 ? (ushort)118 //Mount - : action?.Icon ?? 0; + if(action?.Cast100ms > 0) + { + name = action?.Name ?? string.Empty; + icon = actionId == 4 ? (ushort)118 //Mount + : action?.Icon ?? 0; + } + else + { + var item = Svc.Data.GetExcelSheet()?.GetRow(actionId); + if (item?.CastTimes > 0) + { + name = item?.Name ?? string.Empty; + icon = item?.Icon ?? 0; + } + } + AddItem(new TimelineItem() { - Name = action?.Name ?? string.Empty, + Name = name, Icon = icon, StartTime = DateTime.Now, GCDTime = GCD, diff --git a/ActionTimelineEx/Windows/SettingsWindow.cs b/ActionTimelineEx/Windows/SettingsWindow.cs index b330173..34cb31c 100644 --- a/ActionTimelineEx/Windows/SettingsWindow.cs +++ b/ActionTimelineEx/Windows/SettingsWindow.cs @@ -332,7 +332,7 @@ private bool DrawGeneralTab(DrawingSettings settings) return result; } - private void DrawIconsTab(DrawingSettings settings) + private static void DrawIconsTab(DrawingSettings settings) { ImGui.DragInt("Icon Size", ref settings.GCDIconSize); @@ -383,7 +383,7 @@ private void DrawIconsTab(DrawingSettings settings) } } - private void DrawBarTab(DrawingSettings settings) + private static void DrawBarTab(DrawingSettings settings) { ImGui.ColorEdit4("Bar Background Color", ref settings.BackgroundColor, ImGuiColorEditFlags.NoInputs); ImGui.ColorEdit4("GCD Border Color", ref settings.GCDBorderColor, ImGuiColorEditFlags.NoInputs); @@ -419,7 +419,7 @@ private void DrawBarTab(DrawingSettings settings) } } - private void DrawGridTab(DrawingSettings settings) + private static void DrawGridTab(DrawingSettings settings) { ImGui.Checkbox("Enabled", ref settings.ShowGrid); @@ -460,7 +460,7 @@ private void DrawGridTab(DrawingSettings settings) ImGui.ColorEdit4("Sub-Division Line Color", ref settings.GridSubdivisionLineColor, ImGuiColorEditFlags.NoInputs); } - private void DrawGCDClippingTab(DrawingSettings settings) + private static void DrawGCDClippingTab(DrawingSettings settings) { ImGui.Checkbox("Enabled", ref settings.ShowGCDClippingSetting); DrawHelper.SetTooltip("This only shown when timeline is not rotation.");