- Fix native tooltip offset

- Improve tooltip clipping handling
This commit is contained in:
Infi
2025-03-27 17:17:53 +01:00
parent bc78f65b50
commit fb89666f8d
4 changed files with 50 additions and 3 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
<Project Sdk="Dalamud.NET.Sdk/12.0.2">
<PropertyGroup>
<Version>1.30.1</Version>
<Version>1.30.2</Version>
<TargetFramework>net9.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
+5 -2
View File
@@ -124,8 +124,11 @@ internal unsafe class GameFunctions : IDisposable
agent->Index = 0;
agent->Flag1 &= 0xEF;
agent->ItemId = id;
agent->Flag2 = 1;
agent->Flag3 = 0;
// agent->Flag2 = 1;
// agent->Flag3 = 0;
// TODO: Revert whenever CS is merged
*(byte*)((nint)agent + 0x21A) = 1;
*(byte*)((nint)agent + 0x21E) = 0;
// This just probably needs to be set
agent->AddonId = addon->Id;
+39
View File
@@ -287,6 +287,45 @@ public sealed class PayloadHandler
var isLeft = chatRect.SizeX < viewportSize.X / 2;
var isTop = chatRect.SizeY < viewportSize.Y / 2;
var mousePos = ImGui.GetMousePos();
// addon spawned left of mouse cursor
if (addonRect.X < mousePos.X)
{
if (isLeft)
addonRect.X = (short)mousePos.X + 5;
}
else
{
if (!isLeft)
addonRect.X = Math.Max(0, (short)mousePos.X - 5 - addonRect.Width);
}
if (!chatRect.HasOverlap(addonRect))
{
atk->SetPosition((short) addonRect.X, (short) addonRect.Y);
return;
}
// addon spawned above mouse cursor
if (addonRect.Y < mousePos.Y)
{
if (isTop)
addonRect.Y = (short)mousePos.Y + 5;
}
else
{
if (!isTop)
addonRect.Y = Math.Max(0, (short)mousePos.Y - 5 - addonRect.Height); // prevent it going below 0
}
if (!chatRect.HasOverlap(addonRect))
{
atk->SetPosition((short) addonRect.X, (short) addonRect.Y);
return;
}
// Spawning right/bottom of mouse cursor didn't solve the overlap, so we spawn it next to the chat
var x = isLeft ? chatRect.SizeX : LogWindow.LastWindowPos.X - atkSize.X;
var y = Math.Clamp(chatRect.SizeY - atkSize.Y, 0, float.MaxValue);
y -= isTop ? 0 : Plugin.Config.TooltipOffset; // offset to prevent cut-off on the bottom
+5
View File
@@ -27,6 +27,11 @@ public static class MathUtil
public Rectangle(Vector2 pos, Vector2 size)
: this((int) pos.X, (int) pos.Y, (int) size.X, (int) size.Y) { }
public override string ToString()
{
return $"X: {X} Y: {Y} Width: {Width} Height: {Height}";
}
}
// From: https://stackoverflow.com/a/306379