diff --git a/LightlessSync/Services/NameplateHandler.cs b/LightlessSync/Services/NameplateHandler.cs index 969c494..4c8a28c 100644 --- a/LightlessSync/Services/NameplateHandler.cs +++ b/LightlessSync/Services/NameplateHandler.cs @@ -322,21 +322,15 @@ public unsafe class NameplateHandler : IMediatorSubscriber var positionY = blockTop - verticalPadding - nodeHeight; var textWidth = System.Math.Abs((int)nameplateObject.TextW); - if (textWidth > 0) - { - _cachedNameplateTextWidths[nameplateIndex] = textWidth; - } - else - { - textWidth = _cachedNameplateTextWidths[nameplateIndex]; - } - if (textWidth <= 0) { textWidth = GetScaledTextWidth(nameText); if (textWidth <= 0) textWidth = nodeWidth; + } + if (textWidth > 0) + { _cachedNameplateTextWidths[nameplateIndex] = textWidth; } @@ -358,21 +352,33 @@ public unsafe class NameplateHandler : IMediatorSubscriber if (config.LightfinderAutoAlign && nameContainer != null && hasValidOffset) { + var nameplateWidth = (int)nameContainer->Width; + + int labelWidth; + if (config.LightfinderLabelUseIcon) + { + var iconSize = (int)System.Math.Round(config.LightfinderLabelUseIcon ? 36f : 24f * scaleMultiplier); + labelWidth = iconSize; + } + else + { + labelWidth = (int)System.Math.Round(AtkNodeHelpers.DefaultTextNodeWidth * effectiveScale); + } + switch (config.LabelAlignment) { case LabelAlignment.Left: - positionX = textOffset; - alignment = AlignmentType.BottomLeft; + positionX = nameplateWidth / 2 - textWidth / 2; + break; + case LabelAlignment.Center: + positionX = nameplateWidth / 2 - labelWidth / 2; break; case LabelAlignment.Right: - positionX = textOffset + textWidth - nodeWidth; - alignment = AlignmentType.BottomRight; - break; - default: - positionX = textOffset + textWidth / 2 - nodeWidth / 2; - alignment = AlignmentType.Bottom; + positionX = nameplateWidth / 2 + textWidth / 2 - labelWidth; break; } + + alignment = AlignmentType.BottomLeft; } else {