From 2f2c8f24d51f20cf11e97974195ae48f67fb59c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=8B=E6=B0=B4?= <1123993881@qq.com> Date: Tue, 20 Jun 2023 22:50:28 +0800 Subject: [PATCH] fix: fixed with teaching mode. --- RotationSolver/UI/PainterManager.cs | 2 +- .../UI/RotationConfigWindow_Param.cs | 29 +++-- RotationSolver/Updaters/PreviewUpdater.cs | 106 ------------------ XIVPainter | 2 +- 4 files changed, 15 insertions(+), 124 deletions(-) diff --git a/RotationSolver/UI/PainterManager.cs b/RotationSolver/UI/PainterManager.cs index 8895145c1..af725d98b 100644 --- a/RotationSolver/UI/PainterManager.cs +++ b/RotationSolver/UI/PainterManager.cs @@ -192,7 +192,7 @@ public override void UpdateOnFrame(XIVPainter.XIVPainter painter) internal static XIVPainter.XIVPainter _painter; static PositionalDrawing _positional = new (); - static DrawingHightlightHotbar _highLight = new (); + static DrawingHighlightHotbar _highLight = new (); public static uint ActionId { diff --git a/RotationSolver/UI/RotationConfigWindow_Param.cs b/RotationSolver/UI/RotationConfigWindow_Param.cs index 60e745eb9..24dd7c7ef 100644 --- a/RotationSolver/UI/RotationConfigWindow_Param.cs +++ b/RotationSolver/UI/RotationConfigWindow_Param.cs @@ -166,22 +166,6 @@ private void DrawParamAdvanced() private void DrawParamDisplay() { - DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_TeachingMode, - ref Service.Config.TeachingMode, Service.Default.TeachingMode); - - if (Service.Config.TeachingMode) - { - ImGuiHelper.Spacing(); - - DrawColor4(LocalizationManager.RightLang.ConfigWindow_Param_TeachingModeColor, - ref Service.Config.TeachingModeColor, Service.Default.TeachingModeColor, otherthing: () => - { - PainterManager.HighlightColor = Service.Config.TeachingModeColor; - }); - } - - ImGui.Separator(); - DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_UseOverlayWindow, ref Service.Config.UseOverlayWindow, Service.Default.UseOverlayWindow, LocalizationManager.RightLang.ConfigWindow_Param_UseOverlayWindowDesc, otherThing: () => @@ -191,6 +175,19 @@ private void DrawParamDisplay() if (Service.Config.UseOverlayWindow) { + DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_TeachingMode, + ref Service.Config.TeachingMode, Service.Default.TeachingMode); + + if (Service.Config.TeachingMode) + { + ImGuiHelper.Spacing(); + + DrawColor4(LocalizationManager.RightLang.ConfigWindow_Param_TeachingModeColor, + ref Service.Config.TeachingModeColor, Service.Default.TeachingModeColor, otherthing: () => + { + PainterManager.HighlightColor = Service.Config.TeachingModeColor; + }); + } DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_ShowMoveTarget, ref Service.Config.ShowMoveTarget, Service.Default.ShowMoveTarget); diff --git a/RotationSolver/Updaters/PreviewUpdater.cs b/RotationSolver/Updaters/PreviewUpdater.cs index 6f6caf2ff..fc4ae218c 100644 --- a/RotationSolver/Updaters/PreviewUpdater.cs +++ b/RotationSolver/Updaters/PreviewUpdater.cs @@ -7,12 +7,10 @@ using FFXIVClientStructs.FFXIV.Client.Game.UI; using FFXIVClientStructs.FFXIV.Client.Graphics; using FFXIVClientStructs.FFXIV.Client.System.Framework; -using FFXIVClientStructs.FFXIV.Client.System.Memory; using FFXIVClientStructs.FFXIV.Client.UI; using FFXIVClientStructs.FFXIV.Client.UI.Misc; using FFXIVClientStructs.FFXIV.Component.GUI; using RotationSolver.Commands; -using System.Runtime.InteropServices; namespace RotationSolver.Updaters; @@ -22,7 +20,6 @@ internal static void UpdatePreview() { UpdateEntry(); UpdateCastBar(); - UpdateHightLight(); } static DtrBarEntry _dtrEntry; @@ -100,18 +97,6 @@ private static unsafe void UpdateCastBar() progressBar->AddBlue = c.B; } - static uint _highLightId; - private unsafe static void UpdateHightLight() - { - var actId = ActionUpdater.NextAction?.AdjustedID ?? 0; - if (_highLightId == actId) return; - _highLightId = actId; - - HighLightActionBar((slot, hot) => - { - return Service.Config.TeachingMode && IsActionSlotRight(slot, hot, _highLightId); - }); - } internal static unsafe void PulseActionBar(uint actionID) { @@ -166,99 +151,8 @@ private static unsafe void LoopAllSlotBar(ActionBarAction doingSomething) } } - private static unsafe void HighLightActionBar(ActionBarPredicate shouldShow = null) - { - LoopAllSlotBar((slot, hot, highLightId) => - { - var iconAddon = slot.Icon; - if (!iconAddon->AtkResNode.IsVisible) return false; - - AtkImageNode* highLightPtr = null; - AtkResNode* lastHightLight = null; - AtkResNode* nextNode = null; - - for (int nodeIndex = 8; nodeIndex < iconAddon->Component->UldManager.NodeListCount; nodeIndex++) - { - var node = iconAddon->Component->UldManager.NodeList[nodeIndex]; - if (node->NodeID == highLightId) - { - highLightPtr = (AtkImageNode*)node; - } - else if (node->Type == NodeType.Image) - { - var mayLastNode = (AtkImageNode*)node; - if (mayLastNode->PartId == 16) - { - lastHightLight = node; - continue; - } - } - if (lastHightLight != null && highLightPtr == null) - { - nextNode = node; - break; - } - } - - if (highLightPtr == null) - { - //Create new Addon - highLightPtr = CloneNode((AtkImageNode*)lastHightLight); - highLightPtr->AtkResNode.NodeID = highLightId; - - //Change LinkList - lastHightLight->PrevSiblingNode = (AtkResNode*)highLightPtr; - highLightPtr->AtkResNode.PrevSiblingNode = nextNode; - - nextNode->NextSiblingNode = (AtkResNode*)highLightPtr; - highLightPtr->AtkResNode.NextSiblingNode = lastHightLight; - - iconAddon->Component->UldManager.UpdateDrawNodeList(); - } - - //Refine Color - highLightPtr->AtkResNode.AddRed = 0; - highLightPtr->AtkResNode.AddGreen = 10; - highLightPtr->AtkResNode.AddBlue = 40; - - //Change Color - var color = Service.Config.TeachingModeColor; - highLightPtr->AtkResNode.MultiplyRed = (byte)(color.X * 100); - highLightPtr->AtkResNode.MultiplyGreen = (byte)(color.Y * 100); - highLightPtr->AtkResNode.MultiplyBlue = (byte)(color.Z * 100); - - //Update Location - highLightPtr->AtkResNode.SetPositionFloat(lastHightLight->X, lastHightLight->Y); - highLightPtr->AtkResNode.SetWidth(lastHightLight->Width); - highLightPtr->AtkResNode.SetHeight(lastHightLight->Height); - - //Update Visibility - highLightPtr->AtkResNode.ToggleVisibility(shouldShow?.Invoke(slot, hot) ?? false); - - return false; - }); - } - - private unsafe static AtkImageNode* CloneNode(AtkImageNode* original) - { - var size = sizeof(AtkImageNode); - - var allocation = new IntPtr(IMemorySpace.GetUISpace()->Malloc((ulong)size, 8UL)); - var bytes = new byte[size]; - Marshal.Copy(new IntPtr(original), bytes, 0, bytes.Length); - Marshal.Copy(bytes, 0, allocation, bytes.Length); - - var newNode = (AtkResNode*)allocation; - newNode->ChildNode = null; - newNode->ChildCount = 0; - newNode->PrevSiblingNode = null; - newNode->NextSiblingNode = null; - return (AtkImageNode*)newNode; - } public unsafe static void Dispose() { - //Hide All highLight. - HighLightActionBar(); _dtrEntry?.Dispose(); } } diff --git a/XIVPainter b/XIVPainter index 9946ee499..5840334a5 160000 --- a/XIVPainter +++ b/XIVPainter @@ -1 +1 @@ -Subproject commit 9946ee499be814b0f6ad808010958d2c942cbbdc +Subproject commit 5840334a5ea81e5c1f62c1c303dae61654815d11