From 55956ea5e59bdd0d8f9eeab34f096059da8c94b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=8B=E6=B0=B4?= <1123993881@qq.com> Date: Tue, 21 Mar 2023 22:35:39 +0800 Subject: [PATCH] fix: fix some bug with next action window. --- .../Configuration/PluginConfiguration.cs | 3 ++- RotationSolver/Localization/Localization.json | 2 +- RotationSolver/Localization/Strings.cs | 2 +- RotationSolver/RotationSolverPlugin.cs | 10 ++++++-- RotationSolver/UI/ControlWindow.cs | 12 ++++++--- RotationSolver/UI/NextActionWindow.cs | 25 ++++++++++--------- .../UI/RotationConfigWindow_Control.cs | 7 +++++- 7 files changed, 40 insertions(+), 21 deletions(-) diff --git a/RotationSolver.Basic/Configuration/PluginConfiguration.cs b/RotationSolver.Basic/Configuration/PluginConfiguration.cs index 6a7e82351..9beaba482 100644 --- a/RotationSolver.Basic/Configuration/PluginConfiguration.cs +++ b/RotationSolver.Basic/Configuration/PluginConfiguration.cs @@ -157,8 +157,9 @@ public class PluginConfiguration : IPluginConfiguration public MacroInfo DutyEnd { get; set; } = new MacroInfo(); public bool ShowControlWindow = false; - public bool ShowNextActionWindow = false; public bool IsControlWindowLock = false; + public bool ShowNextActionWindow = false; + public bool IsNextActionWindowLock = false; public bool UseKeyboardCommand = false; public bool UseGamepadCommand = false; diff --git a/RotationSolver/Localization/Localization.json b/RotationSolver/Localization/Localization.json index f03c23042..9912a2f02 100644 --- a/RotationSolver/Localization/Localization.json +++ b/RotationSolver/Localization/Localization.json @@ -177,7 +177,7 @@ "ConfigWindow_Control_UseKeyboardCommand": "Use Keyboard Command", "ConfigWindow_Control_UseGamepadCommand": "Use GamePad Command", "ConfigWindow_Control_ControlShowCooldown": "Show action's cooldown", - "ConfigWindow_Control_IsControlWindowLock": "Lock", + "ConfigWindow_Control_IsWindowLock": "Lock", "ConfigWindow_Control_BackgroundColor": "Control Window's Background", "ConfigWindow_Control_NextActionWindowBg": "Next Action Window's Background", "ConfigWindow_Control_ControlWindowGCDSize": "GCD icon size", diff --git a/RotationSolver/Localization/Strings.cs b/RotationSolver/Localization/Strings.cs index 679db8532..d90dbea28 100644 --- a/RotationSolver/Localization/Strings.cs +++ b/RotationSolver/Localization/Strings.cs @@ -241,7 +241,7 @@ internal partial class Strings public string ConfigWindow_Control_UseKeyboardCommand { get; set; } = "Use Keyboard Command"; public string ConfigWindow_Control_UseGamepadCommand { get; set; } = "Use GamePad Command"; public string ConfigWindow_Control_ControlShowCooldown { get; set; } = "Show action's cooldown"; - public string ConfigWindow_Control_IsControlWindowLock { get; set; } = "Lock"; + public string ConfigWindow_Control_IsWindowLock { get; set; } = "Lock"; public string ConfigWindow_Control_BackgroundColor { get; set; } = "Control Window's Background"; public string ConfigWindow_Control_NextActionWindowBg { get; set; } = "Next Action Window's Background"; public string ConfigWindow_Control_ControlWindowGCDSize { get; set; } = "GCD icon size"; diff --git a/RotationSolver/RotationSolverPlugin.cs b/RotationSolver/RotationSolverPlugin.cs index ef7c93b5a..1b2f84842 100644 --- a/RotationSolver/RotationSolverPlugin.cs +++ b/RotationSolver/RotationSolverPlugin.cs @@ -1,3 +1,4 @@ +using Dalamud.Game.ClientState.Conditions; using Dalamud.Interface.Windowing; using Dalamud.Plugin; using Newtonsoft.Json; @@ -106,7 +107,12 @@ internal static void OpenConfigWindow() internal static void UpdateDisplayWindow() { - _controlWindow.IsOpen = MajorUpdater.IsValid && Service.Config.ShowControlWindow; - _nextActionWindow.IsOpen = MajorUpdater.IsValid && Service.Config.ShowNextActionWindow; + var isValid = MajorUpdater.IsValid + && !Service.Conditions[ConditionFlag.OccupiedInCutSceneEvent] + && !Service.Conditions[ConditionFlag.BetweenAreas] + && !Service.Conditions[ConditionFlag.BetweenAreas51]; + + _controlWindow.IsOpen = isValid && Service.Config.ShowControlWindow; + _nextActionWindow.IsOpen = isValid && Service.Config.ShowNextActionWindow; } } diff --git a/RotationSolver/UI/ControlWindow.cs b/RotationSolver/UI/ControlWindow.cs index c25a79b37..fa7b93b6e 100644 --- a/RotationSolver/UI/ControlWindow.cs +++ b/RotationSolver/UI/ControlWindow.cs @@ -14,8 +14,14 @@ namespace RotationSolver.UI; internal class ControlWindow : Window { + public const ImGuiWindowFlags BaseFlags = ImGuiWindowFlags.NoScrollbar + | ImGuiWindowFlags.NoCollapse + | ImGuiWindowFlags.NoTitleBar + | ImGuiWindowFlags.NoNav + | ImGuiWindowFlags.NoScrollWithMouse; + public ControlWindow() - : base(nameof(ControlWindow), NextActionWindow.BaseFlags) + : base(nameof(ControlWindow), BaseFlags) { Size = new Vector2(540f, 490f); SizeCondition = ImGuiCond.FirstUseEver; @@ -28,7 +34,7 @@ public override void PreDraw() : Service.Config.ControlWindowUnlockBg; ImGui.PushStyleColor(ImGuiCol.WindowBg, bgColor); - Flags = NextActionWindow.BaseFlags; + Flags = BaseFlags; if (Service.Config.IsControlWindowLock) { @@ -61,7 +67,7 @@ public override void Draw() ImGui.SameLine(); - RotationConfigWindow.DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Control_IsControlWindowLock, + RotationConfigWindow.DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Control_IsWindowLock, ref Service.Config.IsControlWindowLock); ImGui.NextColumn(); diff --git a/RotationSolver/UI/NextActionWindow.cs b/RotationSolver/UI/NextActionWindow.cs index bbe86fb2b..ef2a20c98 100644 --- a/RotationSolver/UI/NextActionWindow.cs +++ b/RotationSolver/UI/NextActionWindow.cs @@ -11,16 +11,11 @@ namespace RotationSolver.UI; internal class NextActionWindow : Window { - public const ImGuiWindowFlags BaseFlags = ImGuiWindowFlags.NoScrollbar - | ImGuiWindowFlags.NoCollapse - | ImGuiWindowFlags.NoTitleBar - | ImGuiWindowFlags.NoNav - | ImGuiWindowFlags.NoScrollWithMouse; - + const ImGuiWindowFlags BaseFlags = ControlWindow.BaseFlags + | ImGuiWindowFlags.AlwaysAutoResize + | ImGuiWindowFlags.NoResize; public NextActionWindow() - : base(nameof(NextActionWindow), BaseFlags - | ImGuiWindowFlags.AlwaysAutoResize - | ImGuiWindowFlags.NoResize) + : base(nameof(NextActionWindow), BaseFlags) { } @@ -28,6 +23,12 @@ public override void PreDraw() { ImGui.PushStyleColor(ImGuiCol.WindowBg, Service.Config.NextActionWindowBg); + Flags = BaseFlags; + if (Service.Config.IsNextActionWindowLock) + { + Flags |= ImGuiWindowFlags.NoInputs; + } + //ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(0, 0)); ImGui.PushStyleVar(ImGuiStyleVar.WindowBorderSize, 0); } @@ -50,17 +51,17 @@ public static unsafe void DrawGcdCooldown(float width, bool drawTittle) { var group = ActionManager.Instance()->GetRecastGroupDetail(ActionHelper.GCDCooldownGroup - 1); var remain = group->Total - group->Elapsed; + var total = DataCenter.WeaponTotal; - if(drawTittle) + if (drawTittle) { - var str = $"{remain:F2}s / {group->Total:F2}s"; + var str = $"{remain:F2}s / {total:F2}s"; ImGui.SetCursorPosX(ImGui.GetCursorPosX() + width / 2 - ImGui.CalcTextSize(str).X / 2); ImGui.Text(str); } var cursor = ImGui.GetCursorPos() + ImGui.GetWindowPos(); var height = Service.Config.ControlProgressHeight; - var total = DataCenter.WeaponTotal; var interval = Service.Config.AbilitiesInterval; ImGui.ProgressBar(group->Elapsed / group->Total, new Vector2(width, height), string.Empty); diff --git a/RotationSolver/UI/RotationConfigWindow_Control.cs b/RotationSolver/UI/RotationConfigWindow_Control.cs index 1525a93d3..c483a73b9 100644 --- a/RotationSolver/UI/RotationConfigWindow_Control.cs +++ b/RotationSolver/UI/RotationConfigWindow_Control.cs @@ -25,14 +25,19 @@ private void DrawControlTab() { DrawColor4(LocalizationManager.RightLang.ConfigWindow_Control_NextActionWindowBg, ref Service.Config.NextActionWindowBg); + + DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Control_IsWindowLock, + ref Service.Config.IsNextActionWindowLock); } + ImGui.Separator(); + DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Control_ShowControlWindow, ref Service.Config.ShowControlWindow); if (!Service.Config.ShowControlWindow) return; - DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Control_IsControlWindowLock, + DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Control_IsWindowLock, ref Service.Config.IsControlWindowLock); DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Control_ControlShowCooldown,