- Check all tooltips for clipping
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<Version>1.29.19</Version>
|
||||
<Version>1.29.20</Version>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
@@ -54,10 +54,10 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DalamudPackager" Version="11.0.0" />
|
||||
<PackageReference Include="MessagePack" Version="3.0.238-rc.1" />
|
||||
<PackageReference Include="MessagePack" Version="3.1.3" />
|
||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="9.0.0" />
|
||||
<PackageReference Include="Pidgin" Version="3.3.0" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.5" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.7" />
|
||||
<PackageReference Include="Watson.Lite" Version="6.2.3" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -259,9 +259,6 @@ public sealed class PayloadHandler
|
||||
|
||||
public unsafe void MoveTooltip(AddonEvent type, AddonArgs args)
|
||||
{
|
||||
if (!HandleTooltips)
|
||||
return;
|
||||
|
||||
// Only move if user has "Next to Cursor" option selected
|
||||
if (!Plugin.GameConfig.TryGet(UiControlOption.DetailTrackingType, out uint selected) || selected != 0)
|
||||
return;
|
||||
@@ -273,16 +270,25 @@ public sealed class PayloadHandler
|
||||
if (atk->WindowNode == null)
|
||||
return;
|
||||
|
||||
if (!atk->IsVisible)
|
||||
return;
|
||||
|
||||
var component = atk->WindowNode->AtkResNode;
|
||||
var atkPos = new Vector2(component.ScreenX, component.ScreenY);
|
||||
var atkSize = new Vector2(component.GetWidth() * component.ScaleX, component.GetHeight() * component.GetScaleY());
|
||||
|
||||
var chatRect = MathUtil.Rectangle.FromPosAndSize(LogWindow.LastWindowPos, LogWindow.LastWindowSize);
|
||||
var addonRect = MathUtil.Rectangle.FromPosAndSize(atkPos, atkSize);
|
||||
|
||||
if (!MathUtil.CheckRectOverlap(chatRect, addonRect))
|
||||
return;
|
||||
|
||||
var atkSize = (X: component.GetWidth() * component.ScaleX, Y: component.GetHeight() * component.GetScaleY());
|
||||
var viewportSize = ImGuiHelpers.MainViewport.Size;
|
||||
var window = LogWindow.LastWindowPos + LogWindow.LastWindowSize;
|
||||
var isLeft = window.X < viewportSize.X / 2;
|
||||
var isTop = window.Y < viewportSize.Y / 2;
|
||||
var isLeft = chatRect.SizeX < viewportSize.X / 2;
|
||||
var isTop = chatRect.SizeY < viewportSize.Y / 2;
|
||||
|
||||
var x = isLeft ? window.X : LogWindow.LastWindowPos.X - atkSize.X;
|
||||
var y = Math.Clamp(window.Y - atkSize.Y, 0, float.MaxValue);
|
||||
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
|
||||
|
||||
atk->SetPosition((short) x, (short) y);
|
||||
|
||||
@@ -102,12 +102,14 @@ public sealed class ChatLogWindow : Window
|
||||
Plugin.ClientState.Login += Login;
|
||||
Plugin.ClientState.Logout += Logout;
|
||||
|
||||
Plugin.AddonLifecycle.RegisterListener(AddonEvent.PostRequestedUpdate, "ItemDetail", PayloadHandler.MoveTooltip);
|
||||
Plugin.AddonLifecycle.RegisterListener(AddonEvent.PostUpdate, "ItemDetail", PayloadHandler.MoveTooltip);
|
||||
Plugin.AddonLifecycle.RegisterListener(AddonEvent.PostUpdate, "ActionDetail", PayloadHandler.MoveTooltip);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Plugin.AddonLifecycle.UnregisterListener(AddonEvent.PostRequestedUpdate, "ItemDetail", PayloadHandler.MoveTooltip);
|
||||
Plugin.AddonLifecycle.UnregisterListener(AddonEvent.PostUpdate, "ItemDetail", PayloadHandler.MoveTooltip);
|
||||
Plugin.AddonLifecycle.UnregisterListener(AddonEvent.PostUpdate, "ActionDetail", PayloadHandler.MoveTooltip);
|
||||
Plugin.ClientState.Logout -= Logout;
|
||||
Plugin.ClientState.Login -= Login;
|
||||
Plugin.Commands.Register("/chat2").Execute -= ToggleChat;
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
using System.Numerics;
|
||||
|
||||
namespace ChatTwo.Util;
|
||||
|
||||
public static class MathUtil
|
||||
{
|
||||
public struct Rectangle
|
||||
{
|
||||
public int X;
|
||||
public int Y;
|
||||
public int Width;
|
||||
public int Height;
|
||||
|
||||
public static Rectangle FromPosAndSize(Vector2 pos, Vector2 size)
|
||||
{
|
||||
return new Rectangle
|
||||
{
|
||||
X = (int) pos.X,
|
||||
Y = (int) pos.Y,
|
||||
Width = (int) size.X,
|
||||
Height = (int) size.Y
|
||||
};
|
||||
}
|
||||
|
||||
public int SizeX => X + Width;
|
||||
public int SizeY => Y + Height;
|
||||
}
|
||||
|
||||
// From: https://stackoverflow.com/a/306379
|
||||
public static bool CheckRectOverlap(Rectangle a, Rectangle b)
|
||||
{
|
||||
bool ValueInRange(int value, int min, int max)
|
||||
=> value > min && value < max;
|
||||
|
||||
var xOverlap = ValueInRange(a.X, b.X, b.X + b.Width) || ValueInRange(b.X, a.X, a.X + a.Width);
|
||||
var yOverlap = ValueInRange(a.Y, b.Y, b.Y + b.Height) || ValueInRange(b.Y, a.Y, a.Y + a.Height);
|
||||
|
||||
return xOverlap && yOverlap;
|
||||
}
|
||||
}
|
||||
+12
-12
@@ -10,12 +10,12 @@
|
||||
},
|
||||
"MessagePack": {
|
||||
"type": "Direct",
|
||||
"requested": "[3.0.238-rc.1, )",
|
||||
"resolved": "3.0.238-rc.1",
|
||||
"contentHash": "gAVmHb2gswXviGFpAmUgGBVvZEjYGph7Co5hp6IbshEooIuZT34Rv4YcBKvVnUCHdoqxQvK6DZIOPSLSYv3LjQ==",
|
||||
"requested": "[3.1.3, )",
|
||||
"resolved": "3.1.3",
|
||||
"contentHash": "UiNv3fknvPzh5W+S0VV96R17RBZQQU71qgmsMnjjRZU2rtQM/XcTnOB+klT2dA6T1mxjnNKYrEm164AoXvGmYg==",
|
||||
"dependencies": {
|
||||
"MessagePack.Annotations": "3.0.238-rc.1",
|
||||
"MessagePackAnalyzer": "3.0.238-rc.1",
|
||||
"MessagePack.Annotations": "3.1.3",
|
||||
"MessagePackAnalyzer": "3.1.3",
|
||||
"Microsoft.NET.StringTools": "17.11.4"
|
||||
}
|
||||
},
|
||||
@@ -38,9 +38,9 @@
|
||||
},
|
||||
"SixLabors.ImageSharp": {
|
||||
"type": "Direct",
|
||||
"requested": "[3.1.5, )",
|
||||
"resolved": "3.1.5",
|
||||
"contentHash": "lNtlq7dSI/QEbYey+A0xn48z5w4XHSffF8222cC4F4YwTXfEImuiBavQcWjr49LThT/pRmtWJRcqA/PlL+eJ6g=="
|
||||
"requested": "[3.1.7, )",
|
||||
"resolved": "3.1.7",
|
||||
"contentHash": "9fIOOAsyLFid6qKypM2Iy0Z3Q9yoanV8VoYAHtI2sYGMNKzhvRTjgFDHonIiVe+ANtxIxM6SuqUzj0r91nItpA=="
|
||||
},
|
||||
"Watson.Lite": {
|
||||
"type": "Direct",
|
||||
@@ -64,13 +64,13 @@
|
||||
},
|
||||
"MessagePack.Annotations": {
|
||||
"type": "Transitive",
|
||||
"resolved": "3.0.238-rc.1",
|
||||
"contentHash": "yvnpKGuxZuFHnYZ9N8WQXQn0J28w2f0evh0RekDtuxIEKGPw/qQLQXyQWFzMunfb/+pKTWYlUZR1rvvNcwl10A=="
|
||||
"resolved": "3.1.3",
|
||||
"contentHash": "XTy4njgTAf6UVBKFj7c7ad5R0WVKbvAgkbYZy4f00kplzX2T3VOQ34AUke/Vn/QgQZ7ETdd34/IDWS3KBInSGA=="
|
||||
},
|
||||
"MessagePackAnalyzer": {
|
||||
"type": "Transitive",
|
||||
"resolved": "3.0.238-rc.1",
|
||||
"contentHash": "qweXSZ+3mrf3RAqBs71vrF20SiNmqQdbrrt/L3749jh7OPpvdyZcHhOd20BSk+THQXgmmQfqF5F3o/J7S7tGCQ=="
|
||||
"resolved": "3.1.3",
|
||||
"contentHash": "19u1oVNv2brCs5F/jma8O8CnsKMMpYwNqD0CAEDEzvqwDTAhqC9r7xHZP4stPb3APs/ryO/zVn7LvjoEHfvs7Q=="
|
||||
},
|
||||
"Microsoft.Data.Sqlite.Core": {
|
||||
"type": "Transitive",
|
||||
|
||||
Reference in New Issue
Block a user