-
Notifications
You must be signed in to change notification settings - Fork 25
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
10 changed files
with
170 additions
and
22 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
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,78 @@ | ||
using Automaton.Features; | ||
using Dalamud.Interface.Windowing; | ||
using ECommons.ImGuiMethods; | ||
using ECommons.Interop; | ||
using ECommons.SimpleGui; | ||
using ImGuiNET; | ||
|
||
namespace Automaton.UI; | ||
public class MousePositionOverlay : Window | ||
{ | ||
public MousePositionOverlay() : base("Hyperborea Overlay", ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoNav | ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.NoBackground | ImGuiWindowFlags.NoInputs | ImGuiWindowFlags.AlwaysUseWindowPadding, true) | ||
{ | ||
Position = Vector2.Zero; | ||
PositionCondition = ImGuiCond.Always; | ||
Size = ImGuiHelpers.MainViewport.Size; | ||
SizeCondition = ImGuiCond.Always; | ||
EzConfigGui.WindowSystem.AddWindow(this); | ||
IsOpen = true; | ||
RespectCloseHotkey = false; | ||
} | ||
|
||
public override void PreDraw() => ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, Vector2.Zero); | ||
public override void PostDraw() => ImGui.PopStyleVar(); | ||
public override bool DrawConditions() => DebugTools.ShowMouseOverlay; | ||
|
||
public override void Draw() | ||
{ | ||
var pos = ImGui.GetMousePos(); | ||
if (Svc.GameGui.ScreenToWorld(pos, out var res)) | ||
{ | ||
var col = GradientColor.Get(EColor.RedBright, EColor.YellowBright); | ||
DrawRingWorld(res, 0.5f, col.ToUint(), 2f); | ||
var l = MathF.Sqrt(2f) / 2f * 0.5f; | ||
DrawLineWorld(res + new Vector3(-l, 0, -l), res + new Vector3(l, 0, l), col.ToUint(), 2f); | ||
DrawLineWorld(res + new Vector3(l, 0, -l), res + new Vector3(-l, 0, l), col.ToUint(), 2f); | ||
} | ||
} | ||
|
||
void DrawLineWorld(Vector3 a, Vector3 b, uint color, float thickness) | ||
{ | ||
var result = GetAdjustedLine(a, b); | ||
if (result.posA == null) return; | ||
ImGui.GetWindowDrawList().PathLineTo(new Vector2(result.posA.Value.X, result.posA.Value.Y)); | ||
ImGui.GetWindowDrawList().PathLineTo(new Vector2(result.posB.Value.X, result.posB.Value.Y)); | ||
ImGui.GetWindowDrawList().PathStroke(color, ImDrawFlags.None, thickness); | ||
} | ||
|
||
(Vector2? posA, Vector2? posB) GetAdjustedLine(Vector3 pointA, Vector3 pointB) | ||
{ | ||
var resultA = Svc.GameGui.WorldToScreen(pointA, out Vector2 posA); | ||
var resultB = Svc.GameGui.WorldToScreen(pointB, out Vector2 posB); | ||
//if (!resultA || !resultB) return default; | ||
return (posA, posB); | ||
} | ||
|
||
public void DrawRingWorld(Vector3 position, float radius, uint color, float thickness) | ||
{ | ||
var segments = 50; | ||
int seg = segments / 2; | ||
Vector2?[] elements = new Vector2?[segments]; | ||
for (int i = 0; i < segments; i++) | ||
{ | ||
Svc.GameGui.WorldToScreen( | ||
new Vector3(position.X + radius * (float)Math.Sin(Math.PI / seg * i), | ||
position.Y, | ||
position.Z + radius * (float)Math.Cos(Math.PI / seg * i) | ||
), | ||
out Vector2 pos); | ||
elements[i] = new Vector2(pos.X, pos.Y); | ||
} | ||
foreach (var pos in elements) | ||
{ | ||
if (pos == null) continue; | ||
ImGui.GetWindowDrawList().PathLineTo(pos.Value); | ||
} | ||
ImGui.GetWindowDrawList().PathStroke(color, ImDrawFlags.Closed, thickness); | ||
} | ||
} |
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,41 @@ | ||
using FFXIVClientStructs.FFXIV.Client.UI; | ||
using FFXIVClientStructs.FFXIV.Component.GUI; | ||
using FFXIVClientStructs.Interop; | ||
|
||
namespace Automaton.Utilities; | ||
public unsafe class FocusWatcher : IDisposable | ||
{ | ||
public FocusWatcher() => Svc.Framework.Update += CheckAddonFocus; | ||
|
||
public static event Action<Pointer<AtkUnitBase>> AddonFocusChanged; | ||
public static void OnAddonFocusChange(Pointer<AtkUnitBase> atk) | ||
{ | ||
LastFocusedAddon = atk != null ? atk.Value->NameString : string.Empty; | ||
AddonFocusChanged?.Invoke(atk); | ||
} | ||
|
||
private static string LastFocusedAddon = string.Empty; | ||
private void CheckAddonFocus(IFramework framework) | ||
{ | ||
var focus = AtkStage.Instance()->GetFocus(); | ||
if (focus == null && LastFocusedAddon != string.Empty) | ||
{ | ||
LastFocusedAddon = string.Empty; | ||
Svc.Log.Info($"{nameof(LastFocusedAddon)} is now null"); | ||
AddonFocusChanged?.Invoke(null); | ||
return; | ||
} | ||
for (var i = 0; i < RaptureAtkUnitManager.Instance()->FocusedUnitsList.Count; i++) | ||
{ | ||
var atk = RaptureAtkUnitManager.Instance()->FocusedUnitsList.Entries[i].Value; | ||
if (atk != null && atk->RootNode == GetRootNode(focus) && atk->NameString != LastFocusedAddon) | ||
{ | ||
LastFocusedAddon = atk->NameString; | ||
Svc.Log.Info($"New addon focused {LastFocusedAddon}"); | ||
AddonFocusChanged?.Invoke(atk); | ||
} | ||
} | ||
} | ||
|
||
public void Dispose() => Svc.Framework.Update -= CheckAddonFocus; | ||
} |
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
Submodule ECommons
updated
89 files
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