From 2a3037a5faec6f274a80ae7eb8258bd3e3ac2a10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=8B=E6=B0=B4?= <1123993881@qq.com> Date: Sun, 2 Apr 2023 15:49:59 +0800 Subject: [PATCH] fix: fixed pulse error. --- RotationSolver.Basic/Service.cs | 10 ++++------ RotationSolver/Localization/Localization.json | 7 +++++-- RotationSolver/RotationSolverPlugin.cs | 1 - RotationSolver/UI/ControlWindow.cs | 17 +++++++++++------ RotationSolver/UI/ImGuiHelper.cs | 6 +++--- RotationSolver/UI/InfoWindow.cs | 1 + RotationSolver/UI/NextActionWindow.cs | 1 - RotationSolver/Updaters/MajorUpdater.cs | 3 +++ RotationSolver/Updaters/PreviewUpdater.cs | 16 +++++++++------- RotationSolver/Updaters/TargetUpdater.cs | 5 +++-- 10 files changed, 39 insertions(+), 28 deletions(-) diff --git a/RotationSolver.Basic/Service.cs b/RotationSolver.Basic/Service.cs index 22aedc467..45c0b03e3 100644 --- a/RotationSolver.Basic/Service.cs +++ b/RotationSolver.Basic/Service.cs @@ -102,19 +102,17 @@ public static unsafe uint GetAdjustedActionId(uint id) public static ChatGui ChatGui { get; private set; } [PluginService] - static GameGui GameGui { get; set; } + public static GameGui GameGui { get; set; } public static bool WorldToScreen(Vector3 worldPos, out Vector2 screenPos) => GameGui.WorldToScreen(worldPos, out screenPos); - public unsafe static T[] GetAddon() where T : struct + public unsafe static IEnumerable GetAddon() where T : struct { - if(typeof(T).GetCustomAttribute() is not Addon on) return new T[0]; + if(typeof(T).GetCustomAttribute() is not Addon on) return new IntPtr[0]; return on.AddonIdentifiers .Select(str => GameGui.GetAddonByName(str, 1)) - .Where(ptr => ptr != IntPtr.Zero) - .Select(ptr => *(T*)ptr) - .ToArray(); + .Where(ptr => ptr != IntPtr.Zero); } public static PlayerCharacter Player => ClientState.LocalPlayer; diff --git a/RotationSolver/Localization/Localization.json b/RotationSolver/Localization/Localization.json index 51076b42d..ef7b9e4d5 100644 --- a/RotationSolver/Localization/Localization.json +++ b/RotationSolver/Localization/Localization.json @@ -71,7 +71,7 @@ "ConfigWindow_Param_WeakenDelay": "Set the range of random delay for esuna weakens in second.", "ConfigWindow_Param_HealDelay": "Set the range of random delay for healing people in second.", "ConfigWindow_Param_NotInCombatDelay": "Set the range of random delay for Not In Combat in second.", - "ConfigWindow_Param_StopCastingDelay": "Set the range of random delay for stoping casting when target is no need to cast in second.", + "ConfigWindow_Param_StopCastingDelay": "Set the range of random delay for stopping casting when target is no need to cast in second.", "ConfigWindow_Param_Display": "Display", "ConfigWindow_Param_Advanced": "Advanced", "ConfigWindow_Param_PoslockCasting": "Lock the movement when casting.", @@ -91,6 +91,8 @@ "ConfigWindow_Param_TargetColor": "Target color", "ConfigWindow_Param_SubTargetColor": "Sub-target color", "ConfigWindow_Param_KeyBoardNoise": "Simulate the effect of pressing", + "ConfigWindow_Param_KeyBoardNoiseTimes": "Effect times", + "ConfigWindow_Param_KeyBoardNoiseTime": "Effect interval", "ConfigWindow_Param_VoiceVolume": "Voice volume", "ConfigWindow_Param_VoiceName": "Voice Name", "ConfigWindow_Param_FlytextPositional": "Hint positional anticipation by flytext", @@ -178,7 +180,8 @@ "ConfigWindow_Control_UseKeyboardCommand": "Use Keyboard Command", "ConfigWindow_Control_UseGamepadCommand": "Use GamePad Command", "ConfigWindow_Control_ShowCooldownWindow": "Show Cooldown Window", - "ConfigWindow_Control_IsWindowLock": "Lock", + "ConfigWindow_Control_IsInfoWindowNoInputs": "No Inputs", + "ConfigWindow_Control_IsInfoWindowNoMove": "No Move", "ConfigWindow_Control_ShowItemsCooldown": "Show Items' Cooldown", "ConfigWindow_Control_UseOriginalCooldown": "Show Original Cooldown", "ConfigWindow_Control_CooldownActionOneLine": "The count of cooldown actions in one line.", diff --git a/RotationSolver/RotationSolverPlugin.cs b/RotationSolver/RotationSolverPlugin.cs index 0ce400e66..125ba0d06 100644 --- a/RotationSolver/RotationSolverPlugin.cs +++ b/RotationSolver/RotationSolverPlugin.cs @@ -1,7 +1,6 @@ using Dalamud.Game.ClientState.Conditions; using Dalamud.Interface.Windowing; using Dalamud.Plugin; -using FFXIVClientStructs.FFXIV.Client.Game.Gauge; using Newtonsoft.Json; using RotationSolver.Basic; using RotationSolver.Basic.Configuration; diff --git a/RotationSolver/UI/ControlWindow.cs b/RotationSolver/UI/ControlWindow.cs index 59bba6f51..5dda4d35c 100644 --- a/RotationSolver/UI/ControlWindow.cs +++ b/RotationSolver/UI/ControlWindow.cs @@ -1,9 +1,7 @@ -using Dalamud.Interface; -using Dalamud.Interface.Colors; +using Dalamud.Interface.Colors; using Dalamud.Interface.Windowing; using ImGuiNET; using ImGuiScene; -using Lumina.Excel.GeneratedSheets; using RotationSolver.Basic; using RotationSolver.Basic.Actions; using RotationSolver.Basic.Data; @@ -405,10 +403,17 @@ static void DrawIAction(nint handle, string id, float width, StateCommandType co internal static void DrawIAction(IAction action, float width, float percent) { DrawIAction(GetTexture(action).ImGuiHandle, width, action == null ? -1 : percent); - if(ImGui.IsItemHovered() && ImGui.IsMouseClicked(ImGuiMouseButton.Left)) + if (action != null) ImGuiHelper.HoveredString(action.Name, () => { - DataCenter.AddCommandAction(action, 5); - } + if (DataCenter.StateType == StateCommandType.Cancel) + { + action.Use(); + } + else + { + DataCenter.AddCommandAction(action, 5); + } + }); } static void DrawIAction(nint handle, float width, float percent) diff --git a/RotationSolver/UI/ImGuiHelper.cs b/RotationSolver/UI/ImGuiHelper.cs index 5cdee1908..15c38c88c 100644 --- a/RotationSolver/UI/ImGuiHelper.cs +++ b/RotationSolver/UI/ImGuiHelper.cs @@ -67,7 +67,7 @@ public static void DrawEnableTexture(this T texture, bool isSelected, Action if (ImGui.IsItemHovered()) { showToolTip(desc); - if (ImGui.IsMouseDown(ImGuiMouseButton.Left)) + if (ImGui.IsMouseClicked(ImGuiMouseButton.Left)) { selected?.Invoke(); } @@ -120,7 +120,7 @@ public static void HoveredString(string text, Action selected = null) if (ImGui.IsItemHovered()) { if (!string.IsNullOrEmpty(text)) ImGui.SetTooltip(text); - if (ImGui.IsMouseDown(ImGuiMouseButton.Left)) + if (ImGui.IsMouseClicked(ImGuiMouseButton.Left)) { selected?.Invoke(); } @@ -334,7 +334,7 @@ internal static void DisplayCommandHelp(this T command, string extraCommand = { ImGui.SetTooltip($"{LocalizationManager.RightLang.ConfigWindow_Helper_RunCommand}: {cmdStr}\n{LocalizationManager.RightLang.ConfigWindow_Helper_CopyCommand}: {cmdStr}"); - if (ImGui.IsMouseDown(ImGuiMouseButton.Right)) + if (ImGui.IsMouseClicked(ImGuiMouseButton.Right)) { ImGui.SetClipboardText(cmdStr); } diff --git a/RotationSolver/UI/InfoWindow.cs b/RotationSolver/UI/InfoWindow.cs index 7457ef6ec..9a06a7a34 100644 --- a/RotationSolver/UI/InfoWindow.cs +++ b/RotationSolver/UI/InfoWindow.cs @@ -31,6 +31,7 @@ public override void PreDraw() } //ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(0, 0)); ImGui.PushStyleVar(ImGuiStyleVar.WindowBorderSize, 0); + base.PreDraw(); } public override void PostDraw() diff --git a/RotationSolver/UI/NextActionWindow.cs b/RotationSolver/UI/NextActionWindow.cs index e3293496a..3a8096b75 100644 --- a/RotationSolver/UI/NextActionWindow.cs +++ b/RotationSolver/UI/NextActionWindow.cs @@ -1,5 +1,4 @@ using Dalamud.Interface.Colors; -using Dalamud.Interface.Windowing; using FFXIVClientStructs.FFXIV.Client.Game; using ImGuiNET; using RotationSolver.Basic; diff --git a/RotationSolver/Updaters/MajorUpdater.cs b/RotationSolver/Updaters/MajorUpdater.cs index 884fce5be..ad549047a 100644 --- a/RotationSolver/Updaters/MajorUpdater.cs +++ b/RotationSolver/Updaters/MajorUpdater.cs @@ -1,7 +1,9 @@ using Dalamud.Game; using Dalamud.Logging; +using FFXIVClientStructs.FFXIV.Client.UI; using RotationSolver.Basic; using RotationSolver.Commands; +using System.Collections.Generic; namespace RotationSolver.Updaters; @@ -68,6 +70,7 @@ private static void FrameworkUpdate(Framework framework) UpdateWork(); } } + static bool first = false; public static void Enable() { diff --git a/RotationSolver/Updaters/PreviewUpdater.cs b/RotationSolver/Updaters/PreviewUpdater.cs index 486456305..cae850012 100644 --- a/RotationSolver/Updaters/PreviewUpdater.cs +++ b/RotationSolver/Updaters/PreviewUpdater.cs @@ -100,7 +100,7 @@ private static unsafe void UpdateCastBar() if (!castBars.Any()) return; var castBar = castBars.FirstOrDefault(); - AtkResNode* progressBar = castBar.AtkUnitBase.UldManager.NodeList[5]; + AtkResNode* progressBar = ((AtkUnitBase*)castBar)->UldManager.NodeList[5]; progressBar->AddRed = c.R; progressBar->AddGreen = c.G; @@ -143,14 +143,16 @@ private static unsafe void LoopAllSlotBar(ActionBarAction doingSomething) { var index = 0; var hotBarIndex = 0; - foreach (var actionBar in Service.GetAddon().Select(i => i.AddonActionBarX.AddonActionBarBase) - .Union(Service.GetAddon().Select(i => i.AddonActionBarBase)) - .Union(Service.GetAddon().Select(i => i.ActionBarBase)) - .Union(Service.GetAddon().Where(i => i.ShowDPadSlots > 0).Select(i => i.ActionBarBase))) + foreach (var intPtr in Service.GetAddon() + .Union(Service.GetAddon()) + .Union(Service.GetAddon()) + .Union(Service.GetAddon())) { + if (intPtr == IntPtr.Zero) continue; + var actionBar = (AddonActionBarBase*)intPtr; var hotbar = Framework.Instance()->GetUiModule()->GetRaptureHotbarModule()->HotBar[hotBarIndex]; var slotIndex = 0; - foreach (var slot in actionBar.Slot) + foreach (var slot in actionBar->Slot) { var hotBarSlot = hotbar->Slot[slotIndex]; var highLightId = 0x53550000 + index; @@ -159,7 +161,7 @@ private static unsafe void LoopAllSlotBar(ActionBarAction doingSomething) { var iconAddon = slot.Icon; if (!iconAddon->AtkResNode.IsVisible) continue; - actionBar.PulseActionBarSlot(slotIndex); + actionBar->PulseActionBarSlot(slotIndex); UIModule.PlaySound(12, 0, 0, 0); } slotIndex++; diff --git a/RotationSolver/Updaters/TargetUpdater.cs b/RotationSolver/Updaters/TargetUpdater.cs index 045f7a5b3..c493a5351 100644 --- a/RotationSolver/Updaters/TargetUpdater.cs +++ b/RotationSolver/Updaters/TargetUpdater.cs @@ -124,10 +124,11 @@ private static unsafe uint[] GetEnemies() if(!addons.Any()) return new uint[0]; var addon = addons.FirstOrDefault(); + var enemy = (AddonEnemyList*)addon; var numArray = FFXIVClientStructs.FFXIV.Client.System.Framework.Framework.Instance()->GetUiModule()->GetRaptureAtkModule()->AtkModule.AtkArrayDataHolder.NumberArrays[19]; - List list = new List(addon.EnemyCount); - for (var i = 0; i < addon.EnemyCount; i++) + List list = new List(enemy->EnemyCount); + for (var i = 0; i < enemy->EnemyCount; i++) { list.Add((uint)numArray->IntArray[8 + i * 6]); }