Use AtkResNode to get height for tooltips

This commit is contained in:
Infi
2024-04-07 21:25:10 +02:00
parent d9114aeb0e
commit aad4fc70af
2 changed files with 6 additions and 3 deletions
+1 -1
View File
@@ -45,7 +45,7 @@ internal class Configuration : IPluginConfiguration {
public string GlobalFont = Fonts.GlobalFonts[0].Name; public string GlobalFont = Fonts.GlobalFonts[0].Name;
public string JapaneseFont = Fonts.JapaneseFonts[0].Item1; public string JapaneseFont = Fonts.JapaneseFonts[0].Item1;
public float TooltipOffset = 10f; public float TooltipOffset;
public float WindowAlpha = 100f; public float WindowAlpha = 100f;
public Dictionary<ChatType, uint> ChatColours = new(); public Dictionary<ChatType, uint> ChatColours = new();
public List<Tab> Tabs = new(); public List<Tab> Tabs = new();
+5 -2
View File
@@ -239,10 +239,12 @@ public sealed class PayloadHandler {
return; return;
var atk = (AtkUnitBase*) args.Addon; var atk = (AtkUnitBase*) args.Addon;
if (atk == null) if (atk->WindowNode == null)
return; return;
var atkSize = (X: atk->GetScaledWidth(true), Y: atk->GetScaledHeight(true)); var component = atk->WindowNode->AtkResNode;
var atkSize = (X: component.GetWidth() * component.ScaleX, Y: component.GetHeight() * component.GetScaleY());
var viewportSize = ImGuiHelpers.MainViewport.Size; var viewportSize = ImGuiHelpers.MainViewport.Size;
var window = LogWindow.LastWindowPos + LogWindow.LastWindowSize; var window = LogWindow.LastWindowPos + LogWindow.LastWindowSize;
var isLeft = window.X < viewportSize.X / 2; var isLeft = window.X < viewportSize.X / 2;
@@ -251,6 +253,7 @@ public sealed class PayloadHandler {
var x = isLeft ? window.X : LogWindow.LastWindowPos.X - atkSize.X; var x = isLeft ? window.X : LogWindow.LastWindowPos.X - atkSize.X;
var y = Math.Clamp(window.Y - atkSize.Y, 0, float.MaxValue); var y = Math.Clamp(window.Y - atkSize.Y, 0, float.MaxValue);
y -= isTop ? 0 : LogWindow.Plugin.Config.TooltipOffset; // offset to prevent cut-off on the bottom y -= isTop ? 0 : LogWindow.Plugin.Config.TooltipOffset; // offset to prevent cut-off on the bottom
atk->SetPosition((short) x, (short) y); atk->SetPosition((short) x, (short) y);
} }