From c3577a281012bcac56250fe3314ca679ce7f7a5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=8B=E6=B0=B4?= <1123993881@qq.com> Date: Mon, 22 Jul 2024 17:09:43 +0800 Subject: [PATCH] fix: fixed some bugs. --- .../Configurations/RotationSetting.cs | 20 +++++--- ActionTimelineEx/Configurations/Settings.cs | 2 +- ActionTimelineEx/Helpers/RotationHelper.cs | 49 ++++++------------- ActionTimelineEx/Plugin.cs | 10 ++-- .../Windows/RotationHelperWindow.cs | 12 ++--- 5 files changed, 39 insertions(+), 54 deletions(-) diff --git a/ActionTimelineEx/Configurations/RotationSetting.cs b/ActionTimelineEx/Configurations/RotationSetting.cs index 029eccb..4cff1ec 100644 --- a/ActionTimelineEx/Configurations/RotationSetting.cs +++ b/ActionTimelineEx/Configurations/RotationSetting.cs @@ -36,21 +36,25 @@ public class RotationSetting return GCDs[Math.Max(0, index)]; } - public void Draw() + public void Draw(float heightReduce) { var gcdHeight = Plugin.Settings.GCDIconSize; var spacing = Plugin.Settings.IconSpacing; - var drawList = ImGui.GetWindowDrawList(); + var drawList = ImGui.GetBackgroundDrawList(); - var pos = ImGui.GetWindowPos() + new Vector2(gcdHeight * 0.2f, + var wholeHeight = ImGui.GetWindowPos().Y - heightReduce; + var windowPos = ImGui.GetWindowPos() + Vector2.UnitY * heightReduce; + + var pos = windowPos + new Vector2(gcdHeight * 0.2f, Plugin.Settings.VerticalDraw ? (Plugin.Settings.Reverse - ? ImGui.GetWindowSize().Y - gcdHeight * 1.4f + ? wholeHeight - gcdHeight * 1.4f : gcdHeight * 0.2f) - : ImGui.GetWindowSize().Y / 2 - gcdHeight / 2); - var maxX = ImGui.GetWindowPos().X + ImGui.GetWindowSize().X; - var minY = ImGui.GetWindowPos().Y; - var maxY = minY + ImGui.GetWindowSize().Y; + : wholeHeight / 2 - gcdHeight / 2); + + var maxX = windowPos.X + ImGui.GetWindowSize().X; + var minY = windowPos.Y; + var maxY = minY + wholeHeight; var minPosX = pos.X; var nextAction = RotationHelper.ActiveAction; diff --git a/ActionTimelineEx/Configurations/Settings.cs b/ActionTimelineEx/Configurations/Settings.cs index 1e4e956..c715b3c 100644 --- a/ActionTimelineEx/Configurations/Settings.cs +++ b/ActionTimelineEx/Configurations/Settings.cs @@ -125,7 +125,7 @@ public float GcdTime } - [JsonProperty()] + [JsonProperty] private Dictionary _rotationHelpers = []; [JsonIgnore] diff --git a/ActionTimelineEx/Helpers/RotationHelper.cs b/ActionTimelineEx/Helpers/RotationHelper.cs index 8e7efcb..7aa70f2 100644 --- a/ActionTimelineEx/Helpers/RotationHelper.cs +++ b/ActionTimelineEx/Helpers/RotationHelper.cs @@ -19,40 +19,29 @@ internal static class RotationHelper internal static readonly List SuccessActions = []; - private static int _index; - public static int GcdUsedCount - { - get => _index; - private set - { - if (_index == value) return; - _index = value; + public static int GcdUsedCount { get; private set; } + public static byte oGcdUsedCount { get; private set; } - UpdateHighlight(); - } - } - private static byte _subIndex = 0; - public static byte oGcdUsedCount + public static void Init() { - get => _subIndex; - private set - { - if (_subIndex == value) return; - _subIndex = value; - - UpdateHighlight(); - } + ActionEffect.ActionEffectEvent += ActionFromSelf; + Svc.DutyState.DutyWiped += DutyState_DutyWiped; + Svc.DutyState.DutyCompleted += DutyState_DutyWiped; + Svc.ClientState.TerritoryChanged += ClientState_TerritoryChanged; + ClientState_TerritoryChanged(Svc.ClientState.TerritoryType); + _highLight = new(); + Svc.Framework.Update += Framework_Update; } - private static void UpdateHighlight() + private static void Framework_Update(Dalamud.Plugin.Services.IFramework framework) { - if (!Plugin.Settings.DrawRotation) return; - if (_highLight == null) return; _highLight.Color = Plugin.Settings.RotationHighlightColor; _highLight.HotbarIDs.Clear(); + if (!Plugin.Settings.DrawRotation) return; + var action = ActiveAction; if (action == null) return; HotbarID? hotBar = null; @@ -83,23 +72,13 @@ private static void UpdateHighlight() _highLight.HotbarIDs.Add(hotBar.Value); } - public static void Init() - { - ActionEffect.ActionEffectEvent += ActionFromSelf; - Svc.DutyState.DutyWiped += DutyState_DutyWiped; - Svc.DutyState.DutyCompleted += DutyState_DutyWiped; - Svc.ClientState.TerritoryChanged += ClientState_TerritoryChanged; - ClientState_TerritoryChanged(Svc.ClientState.TerritoryType); - _highLight = new(); - UpdateHighlight(); - } - public static void Dispose() { ActionEffect.ActionEffectEvent -= ActionFromSelf; Svc.DutyState.DutyWiped -= DutyState_DutyWiped; Svc.DutyState.DutyCompleted -= DutyState_DutyWiped; Svc.ClientState.TerritoryChanged -= ClientState_TerritoryChanged; + Svc.Framework.Update -= Framework_Update; } private static void ClientState_TerritoryChanged(ushort obj) diff --git a/ActionTimelineEx/Plugin.cs b/ActionTimelineEx/Plugin.cs index 41a37f5..4c690e1 100644 --- a/ActionTimelineEx/Plugin.cs +++ b/ActionTimelineEx/Plugin.cs @@ -110,10 +110,14 @@ public void Dispose() public static void PluginCommand(string str) { - if (str == "reset") + switch(str) { - RotationHelper.Clear(); - return; + case "reset": + RotationHelper.Clear(); + return; + case "toggle": + RotationHelperWindow._open = !RotationHelperWindow._open; + return; } _settingsWindow.Toggle(); } diff --git a/ActionTimelineEx/Windows/RotationHelperWindow.cs b/ActionTimelineEx/Windows/RotationHelperWindow.cs index fef3a63..b6dbd68 100644 --- a/ActionTimelineEx/Windows/RotationHelperWindow.cs +++ b/ActionTimelineEx/Windows/RotationHelperWindow.cs @@ -10,7 +10,8 @@ namespace ActionTimelineEx.Windows; internal static class RotationHelperWindow { private static Vector2 _size = default; - private static bool _open = true, _changed = false; + internal static bool _open = true; + private static bool _changed = false; public static void Draw() { var setting = Plugin.Settings; @@ -61,6 +62,8 @@ public static void Draw() } } + var heightReduce = ImGui.GetCursorPosY(); + if (_open) { ImGui.SameLine(); @@ -82,7 +85,7 @@ public static void Draw() ImGui.GetStyle().WindowBorderSize = 0; try { - DrawContent(); + RotationHelper.RotationSetting.Draw(heightReduce); } finally { @@ -93,9 +96,4 @@ public static void Draw() } } } - - private static void DrawContent() - { - RotationHelper.RotationSetting.Draw(); - } }