Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
fix: fixed with teaching mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Jun 20, 2023
1 parent 0571ae9 commit 2f2c8f2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 124 deletions.
2 changes: 1 addition & 1 deletion RotationSolver/UI/PainterManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
29 changes: 13 additions & 16 deletions RotationSolver/UI/RotationConfigWindow_Param.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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: () =>
Expand All @@ -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);
Expand Down
106 changes: 0 additions & 106 deletions RotationSolver/Updaters/PreviewUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -22,7 +20,6 @@ internal static void UpdatePreview()
{
UpdateEntry();
UpdateCastBar();
UpdateHightLight();
}

static DtrBarEntry _dtrEntry;
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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();
}
}
2 changes: 1 addition & 1 deletion XIVPainter

0 comments on commit 2f2c8f2

Please sign in to comment.