This repository has been archived by the owner on Nov 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
129 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
using Dalamud.Interface.Utility; | ||
using ECommons.DalamudServices; | ||
using FFXIVClientStructs.FFXIV.Client.UI; | ||
using FFXIVClientStructs.FFXIV.Component.GUI; | ||
using ImGuiNET; | ||
using System; | ||
using System.Numerics; | ||
using System.Runtime.InteropServices; | ||
using XIVSlothCombo.CustomComboNS.Functions; | ||
using XIVSlothCombo.Services; | ||
|
||
|
||
namespace XIVSlothCombo.Window; | ||
|
||
internal class TargetHelper : Dalamud.Interface.Windowing.Window | ||
{ | ||
internal TargetHelper() : base("###SlothComboTargeteHelper", ImGuiWindowFlags.NoBackground | ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoBackground | ImGuiWindowFlags.AlwaysUseWindowPadding | ImGuiWindowFlags.AlwaysAutoResize, true) | ||
{ | ||
this.IsOpen = true; | ||
} | ||
|
||
internal unsafe void DrawTargetHelper() | ||
{ | ||
if (Combos.JobHelpers.AST.AST_QuickTargetCards.SelectedRandomMember is not null) | ||
{ | ||
for (int i = 1; i <= 8; i++) | ||
{ | ||
if (CustomComboFunctions.GetPartySlot(i) is null) continue; | ||
if (CustomComboFunctions.GetPartySlot(i).GameObjectId == Combos.JobHelpers.AST.AST_QuickTargetCards.SelectedRandomMember.GameObjectId) | ||
{ | ||
IntPtr partyPTR = Service.GameGui.GetAddonByName("_PartyList", 1); | ||
if (partyPTR == IntPtr.Zero) | ||
return; | ||
|
||
AddonPartyList plist = Marshal.PtrToStructure<AddonPartyList>(partyPTR); | ||
|
||
var member = i switch | ||
{ | ||
1 => plist.PartyMembers[0].TargetGlow, | ||
2 => plist.PartyMembers[1].TargetGlow, | ||
3 => plist.PartyMembers[2].TargetGlow, | ||
4 => plist.PartyMembers[3].TargetGlow, | ||
5 => plist.PartyMembers[4].TargetGlow, | ||
6 => plist.PartyMembers[5].TargetGlow, | ||
7 => plist.PartyMembers[6].TargetGlow, | ||
8 => plist.PartyMembers[7].TargetGlow, | ||
_ => plist.PartyMembers[0].TargetGlow, | ||
}; | ||
|
||
DrawOutline(member->AtkResNode.PrevSiblingNode); | ||
|
||
} | ||
} | ||
} | ||
} | ||
|
||
private unsafe void DrawOutline(AtkResNode* node) | ||
{ | ||
var position = GetNodePosition(node); | ||
var scale = GetNodeScale(node); | ||
var size = new Vector2(node->Width, node->Height) * scale; | ||
|
||
position += ImGuiHelpers.MainViewport.Pos; | ||
|
||
var colour = Service.Configuration.TargetHighlightColor; | ||
ImGui.GetForegroundDrawList(ImGuiHelpers.MainViewport).AddRect(position, position + size, ImGui.GetColorU32(colour), 0, ImDrawFlags.RoundCornersAll, 2); | ||
} | ||
public unsafe Vector2 GetNodePosition(AtkResNode* node) | ||
{ | ||
var pos = new Vector2(node->X, node->Y); | ||
var par = node->ParentNode; | ||
while (par != null) | ||
{ | ||
pos *= new Vector2(par->ScaleX, par->ScaleY); | ||
pos += new Vector2(par->X, par->Y); | ||
par = par->ParentNode; | ||
} | ||
|
||
return pos; | ||
} | ||
|
||
public unsafe Vector2 GetNodeScale(AtkResNode* node) | ||
{ | ||
if (node == null) return new Vector2(1, 1); | ||
var scale = new Vector2(node->ScaleX, node->ScaleY); | ||
while (node->ParentNode != null) | ||
{ | ||
node = node->ParentNode; | ||
scale *= new Vector2(node->ScaleX, node->ScaleY); | ||
} | ||
|
||
return scale; | ||
} | ||
|
||
public override void Draw() => DrawTargetHelper(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters