From b0fe4662c817206367ff6cd561639193d8fe3471 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=8B=E6=B0=B4?= <1123993881@qq.com> Date: Thu, 6 Jul 2023 20:49:35 +0800 Subject: [PATCH] fix: fixed mistake ui. --- RotationSolver/UI/ControlWindow.cs | 12 ++-- RotationSolver/UI/ImGuiHelper.cs | 5 +- RotationSolver/Updaters/ActionUpdater.cs | 77 ++++++++++++------------ 3 files changed, 49 insertions(+), 45 deletions(-) diff --git a/RotationSolver/UI/ControlWindow.cs b/RotationSolver/UI/ControlWindow.cs index 40a42a8bc..0e73faad2 100644 --- a/RotationSolver/UI/ControlWindow.cs +++ b/RotationSolver/UI/ControlWindow.cs @@ -1,4 +1,5 @@ using Dalamud.Interface.Colors; +using Dalamud.Interface.Style; using Dalamud.Interface.Windowing; using ECommons.DalamudServices; using ImGuiScene; @@ -184,11 +185,14 @@ private static void DrawSpecials() ImGui.Text("Auto: " + DataCenter.AutoStatus.ToString()); ImGui.EndGroup(); - ImGui.SameLine(); - ImGui.Text(" Mistake:"); - ImGui.SameLine(); - DrawIAction(DateTime.Now - DidTime < TimeSpan.FromSeconds(5) ? Wrong : null, Service.Config.ControlWindow0GCDSize, 1); + if(Service.Config.MistakeRatio > 0) + { + ImGui.SameLine(); + ImGui.TextColored(ImGuiColors.DPSRed, " | Mistake | \n | Mistake | "); + ImGui.SameLine(); + DrawIAction(DateTime.Now - DidTime < TimeSpan.FromSeconds(5) ? Wrong : null, Service.Config.ControlWindowGCDSize, 1); + } } static void DrawCommandAction(IAction gcd, IAction ability, SpecialCommandType command, Vector4 color) diff --git a/RotationSolver/UI/ImGuiHelper.cs b/RotationSolver/UI/ImGuiHelper.cs index f172a72b2..ebae6d155 100644 --- a/RotationSolver/UI/ImGuiHelper.cs +++ b/RotationSolver/UI/ImGuiHelper.cs @@ -133,11 +133,12 @@ public static void UndoValue(string name, ref T value, T @default, Action oth Spacing(); bool isLast = name == _undoName && DateTime.Now - _lastTime < TimeSpan.FromSeconds(2); + bool isTime = DateTime.Now - _lastTime > TimeSpan.FromSeconds(0.5); - if (isLast) ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.HealerGreen); + if (isLast) ImGui.PushStyleColor(ImGuiCol.Text, isTime ? ImGuiColors.HealerGreen : ImGuiColors.DPSRed); if (IconButton(isLast ? FontAwesomeIcon.Check : FontAwesomeIcon.Undo, $"#{name}: Undo", LocalizationManager.RightLang.ConfigWindow_Param_ResetToDefault) - && DateTime.Now - _lastTime > TimeSpan.FromSeconds(0.5)) + && isTime) { if (isLast) { diff --git a/RotationSolver/Updaters/ActionUpdater.cs b/RotationSolver/Updaters/ActionUpdater.cs index be902474d..cbd997649 100644 --- a/RotationSolver/Updaters/ActionUpdater.cs +++ b/RotationSolver/Updaters/ActionUpdater.cs @@ -27,14 +27,16 @@ internal static void UpdateNextAction() PlayerCharacter localPlayer = Player.Object; var customRotation = RotationUpdater.RightNowRotation; - if (localPlayer != null && customRotation != null) + try { - try + if (localPlayer != null && customRotation != null + && customRotation.TryInvoke(out var newAction, out var gcdAction)) { - if(Service.Config.MistakeRatio > 0) + if (Service.Config.MistakeRatio > 0) { var actions = customRotation.AllActions.Where(a => { + if (a.ID == newAction?.ID) return false; if (a is IBaseAction action) { return !action.IsFriendly @@ -46,55 +48,52 @@ internal static void UpdateNextAction() WrongAction = actions.ElementAt(_wrongRandom.Next(actions.Count())); } - if (customRotation.TryInvoke(out var newAction, out var gcdAction)) - { - NextAction = newAction; + NextAction = newAction; - if (gcdAction is IBaseAction GcdAction) + if (gcdAction is IBaseAction GcdAction) + { + if (NextGCDAction != GcdAction) { - if (NextGCDAction != GcdAction) - { - NextGCDAction = GcdAction; + NextGCDAction = GcdAction; - var rightJobAndTarget = (Player.Object.IsJobCategory(JobRole.Tank) || Player.Object.IsJobCategory(JobRole.Melee)) && GcdAction.Target.IsNPCEnemy(); + var rightJobAndTarget = (Player.Object.IsJobCategory(JobRole.Tank) || Player.Object.IsJobCategory(JobRole.Melee)) && GcdAction.Target.IsNPCEnemy(); - if (rightJobAndTarget && GcdAction.IsSingleTarget) - { - PainterManager.UpdatePositional(GcdAction.EnemyPositional, GcdAction.Target); - } - else - { - PainterManager.ClearPositional(); - } + if (rightJobAndTarget && GcdAction.IsSingleTarget) + { + PainterManager.UpdatePositional(GcdAction.EnemyPositional, GcdAction.Target); + } + else + { + PainterManager.ClearPositional(); + } - if (GcdAction.EnemyPositional != EnemyPositional.None - && GcdAction.Target.HasPositional() - && !localPlayer.HasStatus(true, CustomRotation.TrueNorth.StatusProvide)) - { + if (GcdAction.EnemyPositional != EnemyPositional.None + && GcdAction.Target.HasPositional() + && !localPlayer.HasStatus(true, CustomRotation.TrueNorth.StatusProvide)) + { - if (CheckAction()) - { - string positional = GcdAction.EnemyPositional.ToName(); - if (Service.Config.SayPositional) SpeechHelper.Speak(positional); - if (Service.Config.ToastPositional) Svc.Toasts.ShowQuest(" " + positional, - new Dalamud.Game.Gui.Toast.QuestToastOptions() - { - IconId = GcdAction.IconID, - }); - } + if (CheckAction()) + { + string positional = GcdAction.EnemyPositional.ToName(); + if (Service.Config.SayPositional) SpeechHelper.Speak(positional); + if (Service.Config.ToastPositional) Svc.Toasts.ShowQuest(" " + positional, + new Dalamud.Game.Gui.Toast.QuestToastOptions() + { + IconId = GcdAction.IconID, + }); } } } - return; } + return; } - catch (Exception ex) - { - PluginLog.Error(ex, "Failed to update next action."); - } + } + catch (Exception ex) + { + PluginLog.Error(ex, "Failed to update next action."); } - NextAction = NextGCDAction = null; + WrongAction = NextAction = NextGCDAction = null; PainterManager.ClearPositional(); }