From b7904fc451fea1d27f65c2d0502e9ef9447180e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=8B=E6=B0=B4?= <1123993881@qq.com> Date: Wed, 5 Apr 2023 16:08:55 +0800 Subject: [PATCH] fix: add a feature to control if shown in cooldown window. --- .../Actions/BaseAction_BasicInfo.cs | 16 ++++++++++++ RotationSolver.Basic/Actions/BaseItem.cs | 16 ++++++++++++ RotationSolver.Basic/Actions/IAction.cs | 2 ++ .../Configuration/PluginConfiguration.cs | 3 +++ RotationSolver/UI/CooldownWindow.cs | 2 +- RotationSolver/UI/ImGuiHelper.cs | 26 ++++++++++++++++--- 6 files changed, 60 insertions(+), 5 deletions(-) diff --git a/RotationSolver.Basic/Actions/BaseAction_BasicInfo.cs b/RotationSolver.Basic/Actions/BaseAction_BasicInfo.cs index 3d6f0ac7f..6ab65325e 100644 --- a/RotationSolver.Basic/Actions/BaseAction_BasicInfo.cs +++ b/RotationSolver.Basic/Actions/BaseAction_BasicInfo.cs @@ -39,6 +39,22 @@ public bool IsEnabled } } } + + public bool IsInCooldown + { + get => !Service.Config.NotInCoolDownActions.Contains(ID); + set + { + if (value) + { + Service.Config.NotInCoolDownActions.Remove(ID); + } + else + { + Service.Config.NotInCoolDownActions.Add(ID); + } + } + } public uint ID => _action.RowId; public uint AdjustedID => (uint)Service.GetAdjustedActionId((ActionID)ID); diff --git a/RotationSolver.Basic/Actions/BaseItem.cs b/RotationSolver.Basic/Actions/BaseItem.cs index 8687109d1..d489d3141 100644 --- a/RotationSolver.Basic/Actions/BaseItem.cs +++ b/RotationSolver.Basic/Actions/BaseItem.cs @@ -35,6 +35,22 @@ public bool IsEnabled } } + public bool IsInCooldown + { + get => !Service.Config.NotInCoolDownItems.Contains(ID); + set + { + if (value) + { + Service.Config.NotInCoolDownItems.Remove(ID); + } + else + { + Service.Config.NotInCoolDownItems.Add(ID); + } + } + } + public string Description => string.Empty; public unsafe float RecastTimeOneCharge => ActionManager.Instance()->GetRecastTime(ActionType.Item, ID); diff --git a/RotationSolver.Basic/Actions/IAction.cs b/RotationSolver.Basic/Actions/IAction.cs index df920452e..4d6f21446 100644 --- a/RotationSolver.Basic/Actions/IAction.cs +++ b/RotationSolver.Basic/Actions/IAction.cs @@ -21,4 +21,6 @@ public interface IAction : ITexture bool EnoughLevel { get; } internal byte Level { get; } + + bool IsInCooldown { get; set; } } diff --git a/RotationSolver.Basic/Configuration/PluginConfiguration.cs b/RotationSolver.Basic/Configuration/PluginConfiguration.cs index 76bb0f690..534da5e24 100644 --- a/RotationSolver.Basic/Configuration/PluginConfiguration.cs +++ b/RotationSolver.Basic/Configuration/PluginConfiguration.cs @@ -12,7 +12,10 @@ public class PluginConfiguration : IPluginConfiguration public string VoiceName = string.Empty; public SortedSet DisabledCombos { get; private set; } = new SortedSet(); public SortedSet DisabledActions { get; private set; } = new SortedSet(); + public SortedSet NotInCoolDownActions { get; private set; } = new SortedSet(); public SortedSet DisabledItems { get; private set; } = new SortedSet(); + public SortedSet NotInCoolDownItems { get; private set; } = new SortedSet(); + public List Events { get; private set; } = new List(); public Dictionary>> RotationsConfigurations { get; private set; } = new Dictionary>>(); diff --git a/RotationSolver/UI/CooldownWindow.cs b/RotationSolver/UI/CooldownWindow.cs index f6c52b668..d68c887fd 100644 --- a/RotationSolver/UI/CooldownWindow.cs +++ b/RotationSolver/UI/CooldownWindow.cs @@ -17,7 +17,7 @@ public override void Draw() { foreach (var pair in RotationUpdater.AllGroupedActions) { - IEnumerable showItems = pair.OrderBy(a => a.ID); + var showItems = pair.OrderBy(a => a.ID).Where(a => a.IsInCooldown); if (!Service.Config.ShowGCDCooldown) showItems = showItems.Where(i => !(i is IBaseAction a && a.IsGeneralGCD)); if (!showItems.Any()) continue; diff --git a/RotationSolver/UI/ImGuiHelper.cs b/RotationSolver/UI/ImGuiHelper.cs index 8d4daadf3..b4828634c 100644 --- a/RotationSolver/UI/ImGuiHelper.cs +++ b/RotationSolver/UI/ImGuiHelper.cs @@ -62,11 +62,9 @@ public static void DrawEnableTexture(this T texture, bool isSelected, Action } ImGui.NextColumn(); - bool enable = false; - if (isSelected) ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudYellow); - enable = texture.IsEnabled; - if (ImGui.Checkbox($"{texture.Name}##{texture.Name}", ref enable)) + var enable = texture.IsEnabled; + if (ImGui.Checkbox($"{texture.Name}##{texture.Name}Enabled", ref enable)) { texture.IsEnabled = enable; Service.Config.Save(); @@ -549,6 +547,16 @@ private unsafe static void Display(this IBaseAction action, bool IsActive) => ac ImGui.SameLine(); Spacing(); + var enable = action.IsInCooldown; + if (ImGui.Checkbox($"CD##{action.Name}InCooldown", ref enable)) + { + action.IsInCooldown = enable; + Service.Config.Save(); + } + + ImGui.SameLine(); + Spacing(); + OtherCommandType.ToggleActions.DisplayCommandHelp(action.ToString()); if (action.IsTimeline) OtherCommandType.DoActions.DisplayCommandHelp($"{action}-{5}", @@ -585,6 +593,16 @@ private unsafe static void Display(this IBaseAction action, bool IsActive) => ac public unsafe static void Display(this IBaseItem item, bool IsActive) => item.DrawEnableTexture(false, null, otherThing: () => { + ImGui.SameLine(); + Spacing(); + + var enable = item.IsInCooldown; + if (ImGui.Checkbox($"CD##{item.Name}InCooldown", ref enable)) + { + item.IsInCooldown = enable; + Service.Config.Save(); + } + if (Service.Config.InDebug) { ImGui.Text("Status: " + ActionManager.Instance()->GetActionStatus(ActionType.Item, item.ID).ToString());