fix nameplates alignment?

This commit is contained in:
2025-10-07 09:16:58 +09:00
parent ca70c622bc
commit 61267d1b03

View File

@@ -322,21 +322,15 @@ public unsafe class NameplateHandler : IMediatorSubscriber
var positionY = blockTop - verticalPadding - nodeHeight; var positionY = blockTop - verticalPadding - nodeHeight;
var textWidth = System.Math.Abs((int)nameplateObject.TextW); var textWidth = System.Math.Abs((int)nameplateObject.TextW);
if (textWidth > 0)
{
_cachedNameplateTextWidths[nameplateIndex] = textWidth;
}
else
{
textWidth = _cachedNameplateTextWidths[nameplateIndex];
}
if (textWidth <= 0) if (textWidth <= 0)
{ {
textWidth = GetScaledTextWidth(nameText); textWidth = GetScaledTextWidth(nameText);
if (textWidth <= 0) if (textWidth <= 0)
textWidth = nodeWidth; textWidth = nodeWidth;
}
if (textWidth > 0)
{
_cachedNameplateTextWidths[nameplateIndex] = textWidth; _cachedNameplateTextWidths[nameplateIndex] = textWidth;
} }
@@ -358,21 +352,33 @@ public unsafe class NameplateHandler : IMediatorSubscriber
if (config.LightfinderAutoAlign && nameContainer != null && hasValidOffset) 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) switch (config.LabelAlignment)
{ {
case LabelAlignment.Left: case LabelAlignment.Left:
positionX = textOffset; positionX = nameplateWidth / 2 - textWidth / 2;
alignment = AlignmentType.BottomLeft; break;
case LabelAlignment.Center:
positionX = nameplateWidth / 2 - labelWidth / 2;
break; break;
case LabelAlignment.Right: case LabelAlignment.Right:
positionX = textOffset + textWidth - nodeWidth; positionX = nameplateWidth / 2 + textWidth / 2 - labelWidth;
alignment = AlignmentType.BottomRight;
break;
default:
positionX = textOffset + textWidth / 2 - nodeWidth / 2;
alignment = AlignmentType.Bottom;
break; break;
} }
alignment = AlignmentType.BottomLeft;
} }
else else
{ {