From 49e5fb9d8d25dff8c6cb4b30d9b353d6574193c9 Mon Sep 17 00:00:00 2001 From: defnotken Date: Sun, 5 Oct 2025 18:39:13 -0500 Subject: [PATCH 1/6] Fixing workflow for dev --- .gitea/workflows/lightless-tag-and-release.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/lightless-tag-and-release.yml b/.gitea/workflows/lightless-tag-and-release.yml index e5782af..5c39934 100644 --- a/.gitea/workflows/lightless-tag-and-release.yml +++ b/.gitea/workflows/lightless-tag-and-release.yml @@ -153,8 +153,11 @@ jobs: }' \ "https://git.lightless-sync.org/api/v1/repos/${GITHUB_REPOSITORY}/releases" ) + echo "API response: $response" release_id=$(echo "$response" | jq -r .id) - echo "release_id=$release_id" >> "$GITHUB_OUTPUT" + echo "release_id=$release_id" + echo "release_id=$release_id" >> $GITHUB_OUTPUT || echo "::set-output name=release_id::$release_id" + echo "RELEASE_ID=$release_id" >> $GITHUB_ENV - name: Check asset exists run: | From ca70c622bc1cb99248e1474b66a6e6c0e10c5666 Mon Sep 17 00:00:00 2001 From: CakeAndBanana Date: Mon, 6 Oct 2025 05:29:54 +0200 Subject: [PATCH 2/6] Added new options for visibilties on nameplate. --- .../Configurations/LightlessConfig.cs | 2 ++ LightlessSync/Plugin.cs | 3 ++- LightlessSync/Services/ContextMenuService.cs | 1 + LightlessSync/Services/NameplateHandler.cs | 26 ++++++++++++++++--- LightlessSync/Services/NameplateService.cs | 1 - LightlessSync/UI/SettingsUi.cs | 20 ++++++++++++++ 6 files changed, 47 insertions(+), 6 deletions(-) diff --git a/LightlessSync/LightlessConfiguration/Configurations/LightlessConfig.cs b/LightlessSync/LightlessConfiguration/Configurations/LightlessConfig.cs index b5cb97f..f90472a 100644 --- a/LightlessSync/LightlessConfiguration/Configurations/LightlessConfig.cs +++ b/LightlessSync/LightlessConfiguration/Configurations/LightlessConfig.cs @@ -78,6 +78,8 @@ public class LightlessConfig : ILightlessConfiguration public short LightfinderLabelOffsetX { get; set; } = 0; public short LightfinderLabelOffsetY { get; set; } = 0; public bool LightfinderLabelUseIcon { get; set; } = false; + public bool LightfinderLabelShowOwn { get; set; } = true; + public bool LightfinderLabelShowPaired { get; set; } = true; public string LightfinderLabelIconGlyph { get; set; } = SeIconCharExtensions.ToIconString(SeIconChar.LinkMarker); public float LightfinderLabelScale { get; set; } = 1.0f; public bool LightfinderAutoAlign { get; set; } = true; diff --git a/LightlessSync/Plugin.cs b/LightlessSync/Plugin.cs index 90ed4ae..c1648ca 100644 --- a/LightlessSync/Plugin.cs +++ b/LightlessSync/Plugin.cs @@ -208,7 +208,6 @@ public sealed class Plugin : IDalamudPlugin collection.AddSingleton(); collection.AddSingleton(); collection.AddSingleton(); - collection.AddSingleton(); collection.AddSingleton(s => new BroadcastScannerService( s.GetRequiredService>(), clientState, objectTable, framework, s.GetRequiredService(), s.GetRequiredService(), s.GetRequiredService(), s.GetRequiredService(), s.GetRequiredService())); @@ -253,6 +252,8 @@ public sealed class Plugin : IDalamudPlugin s.GetRequiredService())); collection.AddScoped((s) => new NameplateService(s.GetRequiredService>(), s.GetRequiredService(), namePlateGui, clientState, s.GetRequiredService(), s.GetRequiredService())); + collection.AddScoped((s) => new NameplateHandler(s.GetRequiredService>(), addonLifecycle, gameGui, s.GetRequiredService(), + s.GetRequiredService(), s.GetRequiredService(), clientState, s.GetRequiredService())); collection.AddHostedService(p => p.GetRequiredService()); collection.AddHostedService(p => p.GetRequiredService()); diff --git a/LightlessSync/Services/ContextMenuService.cs b/LightlessSync/Services/ContextMenuService.cs index 12dae60..ad00514 100644 --- a/LightlessSync/Services/ContextMenuService.cs +++ b/LightlessSync/Services/ContextMenuService.cs @@ -158,6 +158,7 @@ internal class ContextMenuService : IHostedService _logger.LogError(ex, "Error sending pair request."); } } + private HashSet VisibleUserIds => [.. _pairManager.GetOnlineUserPairs() .Where(u => u.IsVisible && u.PlayerCharacterId != uint.MaxValue) .Select(u => (ulong)u.PlayerCharacterId)]; diff --git a/LightlessSync/Services/NameplateHandler.cs b/LightlessSync/Services/NameplateHandler.cs index abe6266..969c494 100644 --- a/LightlessSync/Services/NameplateHandler.cs +++ b/LightlessSync/Services/NameplateHandler.cs @@ -7,6 +7,7 @@ using FFXIVClientStructs.FFXIV.Client.UI; using FFXIVClientStructs.FFXIV.Component.GUI; using LightlessSync.LightlessConfiguration; using LightlessSync.LightlessConfiguration.Configurations; +using LightlessSync.PlayerData.Pairs; using LightlessSync.Services.Mediator; using LightlessSync.UI; using LightlessSync.Utils; @@ -25,8 +26,10 @@ public unsafe class NameplateHandler : IMediatorSubscriber private readonly ILogger _logger; private readonly IAddonLifecycle _addonLifecycle; private readonly IGameGui _gameGui; + private readonly IClientState _clientState; private readonly DalamudUtilService _dalamudUtil; private readonly LightlessConfigService _configService; + private readonly PairManager _pairManager; private readonly LightlessMediator _mediator; public LightlessMediator Mediator => _mediator; @@ -44,9 +47,9 @@ public unsafe class NameplateHandler : IMediatorSubscriber private const SeIconChar DefaultIcon = SeIconChar.LinkMarker; private static readonly string DefaultIconGlyph = SeIconCharExtensions.ToIconString(DefaultIcon); - private volatile HashSet _activeBroadcastingCids = new(); + private volatile HashSet _activeBroadcastingCids = []; - public NameplateHandler(ILogger logger, IAddonLifecycle addonLifecycle, IGameGui gameGui, DalamudUtilService dalamudUtil, LightlessConfigService configService, LightlessMediator mediator) + public NameplateHandler(ILogger logger, IAddonLifecycle addonLifecycle, IGameGui gameGui, DalamudUtilService dalamudUtil, LightlessConfigService configService, LightlessMediator mediator, IClientState clientState, PairManager pairManager) { _logger = logger; _addonLifecycle = addonLifecycle; @@ -54,6 +57,8 @@ public unsafe class NameplateHandler : IMediatorSubscriber _dalamudUtil = dalamudUtil; _configService = configService; _mediator = mediator; + _clientState = clientState; + _pairManager = pairManager; System.Array.Fill(_cachedNameplateTextOffsets, int.MinValue); } @@ -218,14 +223,24 @@ public unsafe class NameplateHandler : IMediatorSubscriber var cid = DalamudUtilService.GetHashedCIDFromPlayerPointer((nint)objectInfo->GameObject); - //_logger.LogInformation($"checking cid: {cid}", cid); - if (cid == null || !_activeBroadcastingCids.Contains(cid)) { pNode->AtkResNode.ToggleVisibility(false); continue; } + if (!_configService.Current.LightfinderLabelShowOwn && (objectInfo->GameObject->GetGameObjectId() == _clientState.LocalPlayer.GameObjectId)) + { + pNode->AtkResNode.ToggleVisibility(false); + continue; + } + + if (!_configService.Current.LightfinderLabelShowPaired && VisibleUserIds.Any(u => u == objectInfo->GameObject->GetGameObjectId())) + { + pNode->AtkResNode.ToggleVisibility(false); + continue; + } + var nameplateObject = mpNameplateAddon->NamePlateObjectArray[nameplateIndex]; nameplateObject.RootComponentNode->Component->UldManager.UpdateDrawNodeList(); @@ -503,6 +518,9 @@ public unsafe class NameplateHandler : IMediatorSubscriber var nameplateObject = GetNameplateObject(i); return nameplateObject != null ? nameplateObject.Value.RootComponentNode : null; } + private HashSet VisibleUserIds => [.. _pairManager.GetOnlineUserPairs() + .Where(u => u.IsVisible && u.PlayerCharacterId != uint.MaxValue) + .Select(u => (ulong)u.PlayerCharacterId)]; public void FlagRefresh() { diff --git a/LightlessSync/Services/NameplateService.cs b/LightlessSync/Services/NameplateService.cs index f441a60..8ccc362 100644 --- a/LightlessSync/Services/NameplateService.cs +++ b/LightlessSync/Services/NameplateService.cs @@ -35,7 +35,6 @@ public class NameplateService : DisposableMediatorSubscriberBase _namePlateGui.OnNamePlateUpdate += OnNamePlateUpdate; _namePlateGui.RequestRedraw(); Mediator.Subscribe(this, (_) => _namePlateGui.RequestRedraw()); - } private void OnNamePlateUpdate(INamePlateUpdateContext context, IReadOnlyList handlers) diff --git a/LightlessSync/UI/SettingsUi.cs b/LightlessSync/UI/SettingsUi.cs index 58187a6..0a592f0 100644 --- a/LightlessSync/UI/SettingsUi.cs +++ b/LightlessSync/UI/SettingsUi.cs @@ -1144,6 +1144,26 @@ public class SettingsUi : WindowMediatorSubscriberBase } + var showOwn = _configService.Current.LightfinderLabelShowOwn; + if (ImGui.Checkbox("Show your own Lightfinder indicator", ref showOwn)) + { + _configService.Current.LightfinderLabelShowOwn = showOwn; + _configService.Save(); + _nameplateHandler.FlagRefresh(); + _nameplateService.RequestRedraw(); + } + _uiShared.DrawHelpText("Toggles your own Lightfinder indicator."); + + var showPaired = _configService.Current.LightfinderLabelShowPaired; + if (ImGui.Checkbox("Show paired player(s) Lightfinder indicator", ref showPaired)) + { + _configService.Current.LightfinderLabelShowPaired = showPaired; + _configService.Save(); + _nameplateHandler.FlagRefresh(); + _nameplateService.RequestRedraw(); + } + _uiShared.DrawHelpText("Toggles paired player(s) Lightfinder indicator."); + var useIcon = _configService.Current.LightfinderLabelUseIcon; if (ImGui.Checkbox("Show icon instead of text", ref useIcon)) { From 61267d1b03357a42fd2739ef9caae7a7759b158d Mon Sep 17 00:00:00 2001 From: azyges Date: Tue, 7 Oct 2025 09:16:58 +0900 Subject: [PATCH 3/6] fix nameplates alignment? --- LightlessSync/Services/NameplateHandler.cs | 40 +++++++++++++--------- 1 file changed, 23 insertions(+), 17 deletions(-) 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 { From a7378652c42ca51b76976229782dee0ca8c757af Mon Sep 17 00:00:00 2001 From: defnotken Date: Mon, 6 Oct 2025 21:59:18 -0500 Subject: [PATCH 4/6] Cleaned up and made both Text and Icon align. --- LightlessSync/Services/NameplateHandler.cs | 102 ++++++++++++--------- LightlessSync/UI/SettingsUi.cs | 7 ++ 2 files changed, 68 insertions(+), 41 deletions(-) diff --git a/LightlessSync/Services/NameplateHandler.cs b/LightlessSync/Services/NameplateHandler.cs index 4c8a28c..e0c788e 100644 --- a/LightlessSync/Services/NameplateHandler.cs +++ b/LightlessSync/Services/NameplateHandler.cs @@ -6,7 +6,6 @@ using FFXIVClientStructs.FFXIV.Client.System.Framework; using FFXIVClientStructs.FFXIV.Client.UI; using FFXIVClientStructs.FFXIV.Component.GUI; using LightlessSync.LightlessConfiguration; -using LightlessSync.LightlessConfiguration.Configurations; using LightlessSync.PlayerData.Pairs; using LightlessSync.Services.Mediator; using LightlessSync.UI; @@ -43,8 +42,9 @@ public unsafe class NameplateHandler : IMediatorSubscriber private readonly int[] _cachedNameplateTextOffsets = new int[AddonNamePlate.NumNamePlateObjects]; internal const uint mNameplateNodeIDBase = 0x7D99D500; - private const string DefaultLabelText = "Lightfinder"; + private const string DefaultLabelText = "LightFinder"; private const SeIconChar DefaultIcon = SeIconChar.LinkMarker; + private const int ContainerOffsetX = 50; private static readonly string DefaultIconGlyph = SeIconCharExtensions.ToIconString(DefaultIcon); private volatile HashSet _activeBroadcastingCids = []; @@ -266,11 +266,21 @@ public unsafe class NameplateHandler : IMediatorSubscriber var scaleMultiplier = System.Math.Clamp(config.LightfinderLabelScale, 0.5f, 2.0f); var baseScale = config.LightfinderLabelUseIcon ? 1.0f : 0.5f; var effectiveScale = baseScale * scaleMultiplier; - var nodeWidth = (int)System.Math.Round(AtkNodeHelpers.DefaultTextNodeWidth * effectiveScale); - var nodeHeight = (int)System.Math.Round(AtkNodeHelpers.DefaultTextNodeHeight * effectiveScale); + var labelContent = config.LightfinderLabelUseIcon + ? NormalizeIconGlyph(config.LightfinderLabelIconGlyph) + : DefaultLabelText; - int positionX = 58; - AlignmentType alignment = AlignmentType.Bottom; + pNode->FontType = config.LightfinderLabelUseIcon ? FontType.Axis : FontType.MiedingerMed; + pNode->AtkResNode.SetScale(effectiveScale, effectiveScale); + pNode->SetText(labelContent); + var nodeWidth = (int)pNode->AtkResNode.GetWidth(); + if (nodeWidth <= 0) + nodeWidth = (int)System.Math.Round(AtkNodeHelpers.DefaultTextNodeWidth * effectiveScale); + var nodeHeight = (int)System.Math.Round(AtkNodeHelpers.DefaultTextNodeHeight * effectiveScale); + var baseFontSize = config.LightfinderLabelUseIcon ? 36f : 24f; + var computedFontSize = (int)System.Math.Round(baseFontSize * scaleMultiplier); + pNode->FontSize = (byte)System.Math.Clamp(computedFontSize, 1, 255); + AlignmentType alignment; var textScaleY = nameText->AtkResNode.ScaleY; if (textScaleY <= 0f) @@ -349,49 +359,50 @@ public unsafe class NameplateHandler : IMediatorSubscriber { hasValidOffset = false; } + int positionX; 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); - } - + + if (!config.LightfinderLabelUseIcon && nodeWidth > nameplateWidth) + nodeWidth = nameplateWidth; + + if (!config.LightfinderLabelUseIcon) + pNode->AtkResNode.Width = (ushort)nodeWidth; + + int leftPos = nameplateWidth / 8; + int rightPos = nameplateWidth - nodeWidth - (nameplateWidth / 8); + int centrePos = (nameplateWidth - nodeWidth) / 2; + int staticMargin = 24; + int calcMargin = (int)(nameplateWidth * 0.15f); + switch (config.LabelAlignment) { case LabelAlignment.Left: - positionX = nameplateWidth / 2 - textWidth / 2; - break; - case LabelAlignment.Center: - positionX = nameplateWidth / 2 - labelWidth / 2; + positionX = config.LightfinderLabelUseIcon ? leftPos + staticMargin : calcMargin; + alignment = AlignmentType.BottomLeft; break; case LabelAlignment.Right: - positionX = nameplateWidth / 2 + textWidth / 2 - labelWidth; + positionX = config.LightfinderLabelUseIcon ? rightPos - staticMargin : nameplateWidth - nodeWidth + calcMargin; + alignment = AlignmentType.BottomRight; + break; + default: + positionX = config.LightfinderLabelUseIcon ? centrePos : centrePos + calcMargin; + alignment = AlignmentType.Bottom; break; } - - alignment = AlignmentType.BottomLeft; } else { + positionX = 58 + config.LightfinderLabelOffsetX; alignment = AlignmentType.Bottom; } - positionX += config.LightfinderLabelOffsetX; positionY += config.LightfinderLabelOffsetY; alignment = (AlignmentType)System.Math.Clamp((int)alignment, 0, 8); - pNode->AtkResNode.SetPositionShort((short)System.Math.Clamp(positionX, short.MinValue, short.MaxValue), (short)System.Math.Clamp(positionY, short.MinValue, short.MaxValue)); pNode->AtkResNode.SetUseDepthBasedPriority(true); - pNode->AtkResNode.SetScale(effectiveScale, effectiveScale); pNode->AtkResNode.Color.A = 255; @@ -405,24 +416,25 @@ public unsafe class NameplateHandler : IMediatorSubscriber pNode->EdgeColor.B = (byte)(edgeColor.Z * 255); pNode->EdgeColor.A = (byte)(edgeColor.W * 255); - var baseFontSize = config.LightfinderLabelUseIcon ? 36f : 24f; - var computedFontSize = (int)System.Math.Round(baseFontSize * scaleMultiplier); - pNode->FontSize = (byte)System.Math.Clamp(computedFontSize, 1, 255); - pNode->AlignmentType = alignment; + + if(!config.LightfinderLabelUseIcon) + { + pNode->AlignmentType = AlignmentType.Bottom; + } + else + { + pNode->AlignmentType = alignment; + } + pNode->AtkResNode.SetPositionShort( + (short)System.Math.Clamp(positionX, short.MinValue, short.MaxValue), + (short)System.Math.Clamp(positionY, short.MinValue, short.MaxValue) + ); var computedLineSpacing = (int)System.Math.Round(24 * scaleMultiplier); pNode->LineSpacing = (byte)System.Math.Clamp(computedLineSpacing, 0, byte.MaxValue); pNode->CharSpacing = 1; - pNode->TextFlags = config.LightfinderLabelUseIcon ? TextFlags.Edge | TextFlags.Glare | TextFlags.AutoAdjustNodeSize - : TextFlags.Edge | TextFlags.Glare; - - var labelContent = config.LightfinderLabelUseIcon - ? NormalizeIconGlyph(config.LightfinderLabelIconGlyph) - : DefaultLabelText; - - pNode->FontType = config.LightfinderLabelUseIcon ? FontType.Axis : FontType.MiedingerMed; - pNode->SetText(labelContent); + : TextFlags.Edge | TextFlags.Glare; } } @@ -558,4 +570,12 @@ public unsafe class NameplateHandler : IMediatorSubscriber FlagRefresh(); } + + public void ClearNameplateCaches() + { + System.Array.Clear(_cachedNameplateTextWidths, 0, _cachedNameplateTextWidths.Length); + System.Array.Clear(_cachedNameplateTextHeights, 0, _cachedNameplateTextHeights.Length); + System.Array.Clear(_cachedNameplateContainerHeights, 0, _cachedNameplateContainerHeights.Length); + System.Array.Fill(_cachedNameplateTextOffsets, int.MinValue); + } } diff --git a/LightlessSync/UI/SettingsUi.cs b/LightlessSync/UI/SettingsUi.cs index 0a592f0..95b0311 100644 --- a/LightlessSync/UI/SettingsUi.cs +++ b/LightlessSync/UI/SettingsUi.cs @@ -1071,6 +1071,7 @@ public class SettingsUi : WindowMediatorSubscriberBase { _configService.Current.LightfinderLabelOffsetX = (short)offsetX; _configService.Save(); + _nameplateHandler.ClearNameplateCaches(); _nameplateHandler.FlagRefresh(); _nameplateService.RequestRedraw(); } @@ -1081,6 +1082,7 @@ public class SettingsUi : WindowMediatorSubscriberBase { _configService.Current.LightfinderLabelOffsetY = (short)offsetY; _configService.Save(); + _nameplateHandler.ClearNameplateCaches(); _nameplateHandler.FlagRefresh(); _nameplateService.RequestRedraw(); } @@ -1091,6 +1093,7 @@ public class SettingsUi : WindowMediatorSubscriberBase { _configService.Current.LightfinderLabelScale = labelScale; _configService.Save(); + _nameplateHandler.ClearNameplateCaches(); _nameplateHandler.FlagRefresh(); _nameplateService.RequestRedraw(); } @@ -1101,6 +1104,7 @@ public class SettingsUi : WindowMediatorSubscriberBase { _configService.Current.LightfinderAutoAlign = autoAlign; _configService.Save(); + _nameplateHandler.ClearNameplateCaches(); _nameplateHandler.FlagRefresh(); _nameplateService.RequestRedraw(); } @@ -1149,6 +1153,7 @@ public class SettingsUi : WindowMediatorSubscriberBase { _configService.Current.LightfinderLabelShowOwn = showOwn; _configService.Save(); + _nameplateHandler.ClearNameplateCaches(); _nameplateHandler.FlagRefresh(); _nameplateService.RequestRedraw(); } @@ -1159,6 +1164,7 @@ public class SettingsUi : WindowMediatorSubscriberBase { _configService.Current.LightfinderLabelShowPaired = showPaired; _configService.Save(); + _nameplateHandler.ClearNameplateCaches(); _nameplateHandler.FlagRefresh(); _nameplateService.RequestRedraw(); } @@ -1169,6 +1175,7 @@ public class SettingsUi : WindowMediatorSubscriberBase { _configService.Current.LightfinderLabelUseIcon = useIcon; _configService.Save(); + _nameplateHandler.ClearNameplateCaches(); _nameplateHandler.FlagRefresh(); _nameplateService.RequestRedraw(); From 1d88c04235cde4c7c014285da7cb363466163bb9 Mon Sep 17 00:00:00 2001 From: defnotken Date: Mon, 6 Oct 2025 22:48:50 -0500 Subject: [PATCH 5/6] Fixed Nameplate. --- LightlessSync/Services/NameplateHandler.cs | 30 +++++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/LightlessSync/Services/NameplateHandler.cs b/LightlessSync/Services/NameplateHandler.cs index e0c788e..0c4d65b 100644 --- a/LightlessSync/Services/NameplateHandler.cs +++ b/LightlessSync/Services/NameplateHandler.cs @@ -272,7 +272,6 @@ public unsafe class NameplateHandler : IMediatorSubscriber pNode->FontType = config.LightfinderLabelUseIcon ? FontType.Axis : FontType.MiedingerMed; pNode->AtkResNode.SetScale(effectiveScale, effectiveScale); - pNode->SetText(labelContent); var nodeWidth = (int)pNode->AtkResNode.GetWidth(); if (nodeWidth <= 0) nodeWidth = (int)System.Math.Round(AtkNodeHelpers.DefaultTextNodeWidth * effectiveScale); @@ -365,22 +364,39 @@ public unsafe class NameplateHandler : IMediatorSubscriber { var nameplateWidth = (int)nameContainer->Width; - if (!config.LightfinderLabelUseIcon && nodeWidth > nameplateWidth) - nodeWidth = nameplateWidth; - if (!config.LightfinderLabelUseIcon) + { + pNode->TextFlags &= ~TextFlags.AutoAdjustNodeSize; + pNode->AtkResNode.Width = 0; + pNode->SetText(labelContent); + + nodeWidth = (int)pNode->AtkResNode.GetWidth(); + if (nodeWidth <= 0) + nodeWidth = (int)System.Math.Round(AtkNodeHelpers.DefaultTextNodeWidth * effectiveScale); + + if (nodeWidth > nameplateWidth) + nodeWidth = nameplateWidth; + pNode->AtkResNode.Width = (ushort)nodeWidth; + } + else + { + pNode->TextFlags |= TextFlags.AutoAdjustNodeSize; + pNode->AtkResNode.Width = 0; + pNode->SetText(labelContent); + nodeWidth = (int)pNode->AtkResNode.GetWidth(); + } int leftPos = nameplateWidth / 8; int rightPos = nameplateWidth - nodeWidth - (nameplateWidth / 8); int centrePos = (nameplateWidth - nodeWidth) / 2; int staticMargin = 24; - int calcMargin = (int)(nameplateWidth * 0.15f); - + int calcMargin = (int)(nameplateWidth * 0.08f); + switch (config.LabelAlignment) { case LabelAlignment.Left: - positionX = config.LightfinderLabelUseIcon ? leftPos + staticMargin : calcMargin; + positionX = config.LightfinderLabelUseIcon ? leftPos + staticMargin : leftPos; alignment = AlignmentType.BottomLeft; break; case LabelAlignment.Right: From a772ee4705e7f374e405444f68d47eb13de59429 Mon Sep 17 00:00:00 2001 From: azyges Date: Wed, 8 Oct 2025 01:47:04 +0900 Subject: [PATCH 6/6] improve lightfinder settings --- .../Configurations/LightlessConfig.cs | 2 +- LightlessSync/Services/NameplateHandler.cs | 2 +- LightlessSync/UI/SettingsUi.cs | 59 ++++++++++++++++--- 3 files changed, 53 insertions(+), 10 deletions(-) diff --git a/LightlessSync/LightlessConfiguration/Configurations/LightlessConfig.cs b/LightlessSync/LightlessConfiguration/Configurations/LightlessConfig.cs index f90472a..c20d631 100644 --- a/LightlessSync/LightlessConfiguration/Configurations/LightlessConfig.cs +++ b/LightlessSync/LightlessConfiguration/Configurations/LightlessConfig.cs @@ -80,7 +80,7 @@ public class LightlessConfig : ILightlessConfiguration public bool LightfinderLabelUseIcon { get; set; } = false; public bool LightfinderLabelShowOwn { get; set; } = true; public bool LightfinderLabelShowPaired { get; set; } = true; - public string LightfinderLabelIconGlyph { get; set; } = SeIconCharExtensions.ToIconString(SeIconChar.LinkMarker); + public string LightfinderLabelIconGlyph { get; set; } = SeIconCharExtensions.ToIconString(SeIconChar.Hyadelyn); public float LightfinderLabelScale { get; set; } = 1.0f; public bool LightfinderAutoAlign { get; set; } = true; public LabelAlignment LabelAlignment { get; set; } = LabelAlignment.Left; diff --git a/LightlessSync/Services/NameplateHandler.cs b/LightlessSync/Services/NameplateHandler.cs index 0c4d65b..74edabc 100644 --- a/LightlessSync/Services/NameplateHandler.cs +++ b/LightlessSync/Services/NameplateHandler.cs @@ -43,7 +43,7 @@ public unsafe class NameplateHandler : IMediatorSubscriber internal const uint mNameplateNodeIDBase = 0x7D99D500; private const string DefaultLabelText = "LightFinder"; - private const SeIconChar DefaultIcon = SeIconChar.LinkMarker; + private const SeIconChar DefaultIcon = SeIconChar.Hyadelyn; private const int ContainerOffsetX = 50; private static readonly string DefaultIconGlyph = SeIconCharExtensions.ToIconString(DefaultIcon); diff --git a/LightlessSync/UI/SettingsUi.cs b/LightlessSync/UI/SettingsUi.cs index 95b0311..84e4e94 100644 --- a/LightlessSync/UI/SettingsUi.cs +++ b/LightlessSync/UI/SettingsUi.cs @@ -1066,7 +1066,13 @@ public class SettingsUi : WindowMediatorSubscriberBase if (_uiShared.MediumTreeNode("Lightfinder", UIColors.Get("LightlessPurple"))) { + var autoAlign = _configService.Current.LightfinderAutoAlign; var offsetX = (int)_configService.Current.LightfinderLabelOffsetX; + var offsetY = (int)_configService.Current.LightfinderLabelOffsetY; + var labelScale = _configService.Current.LightfinderLabelScale; + + ImGui.TextUnformatted("Alignment"); + ImGui.BeginDisabled(autoAlign); if (ImGui.SliderInt("Label Offset X", ref offsetX, -200, 200)) { _configService.Current.LightfinderLabelOffsetX = (short)offsetX; @@ -1075,9 +1081,20 @@ public class SettingsUi : WindowMediatorSubscriberBase _nameplateHandler.FlagRefresh(); _nameplateService.RequestRedraw(); } - _uiShared.DrawHelpText("Moves the Lightfinder label horizontally on player nameplates."); + if (ImGui.IsItemClicked(ImGuiMouseButton.Right)) + { + _configService.Current.LightfinderLabelOffsetX = 0; + _configService.Save(); + _nameplateHandler.ClearNameplateCaches(); + _nameplateHandler.FlagRefresh(); + _nameplateService.RequestRedraw(); + } + if (ImGui.IsItemHovered()) + ImGui.SetTooltip("Right click to reset to default."); + ImGui.EndDisabled(); + _uiShared.DrawHelpText("Moves the Lightfinder label horizontally on player nameplates.\nUnavailable when automatic alignment is enabled."); + - var offsetY = (int)_configService.Current.LightfinderLabelOffsetY; if (ImGui.SliderInt("Label Offset Y", ref offsetY, -200, 200)) { _configService.Current.LightfinderLabelOffsetY = (short)offsetY; @@ -1086,9 +1103,18 @@ public class SettingsUi : WindowMediatorSubscriberBase _nameplateHandler.FlagRefresh(); _nameplateService.RequestRedraw(); } + if (ImGui.IsItemClicked(ImGuiMouseButton.Right)) + { + _configService.Current.LightfinderLabelOffsetY = 0; + _configService.Save(); + _nameplateHandler.ClearNameplateCaches(); + _nameplateHandler.FlagRefresh(); + _nameplateService.RequestRedraw(); + } + if (ImGui.IsItemHovered()) + ImGui.SetTooltip("Right click to reset to default."); _uiShared.DrawHelpText("Moves the Lightfinder label vertically on player nameplates."); - var labelScale = _configService.Current.LightfinderLabelScale; if (ImGui.SliderFloat("Label Size", ref labelScale, 0.5f, 2.0f, "%.2fx")) { _configService.Current.LightfinderLabelScale = labelScale; @@ -1097,9 +1123,20 @@ public class SettingsUi : WindowMediatorSubscriberBase _nameplateHandler.FlagRefresh(); _nameplateService.RequestRedraw(); } + if (ImGui.IsItemClicked(ImGuiMouseButton.Right)) + { + _configService.Current.LightfinderLabelScale = 1.0f; + _configService.Save(); + _nameplateHandler.ClearNameplateCaches(); + _nameplateHandler.FlagRefresh(); + _nameplateService.RequestRedraw(); + } + if (ImGui.IsItemHovered()) + ImGui.SetTooltip("Right click to reset to default."); _uiShared.DrawHelpText("Adjusts the Lightfinder label size for both text and icon modes."); - var autoAlign = _configService.Current.LightfinderAutoAlign; + ImGui.Dummy(new Vector2(8)); + if (ImGui.Checkbox("Automatically align with nameplate", ref autoAlign)) { _configService.Current.LightfinderAutoAlign = autoAlign; @@ -1148,8 +1185,11 @@ public class SettingsUi : WindowMediatorSubscriberBase } + _uiShared.ColoredSeparator(UIColors.Get("LightlessPurpleDefault"), 1.5f); + + ImGui.TextUnformatted("Visibility"); var showOwn = _configService.Current.LightfinderLabelShowOwn; - if (ImGui.Checkbox("Show your own Lightfinder indicator", ref showOwn)) + if (ImGui.Checkbox("Show your own Lightfinder label", ref showOwn)) { _configService.Current.LightfinderLabelShowOwn = showOwn; _configService.Save(); @@ -1157,10 +1197,10 @@ public class SettingsUi : WindowMediatorSubscriberBase _nameplateHandler.FlagRefresh(); _nameplateService.RequestRedraw(); } - _uiShared.DrawHelpText("Toggles your own Lightfinder indicator."); + _uiShared.DrawHelpText("Toggles your own Lightfinder label."); var showPaired = _configService.Current.LightfinderLabelShowPaired; - if (ImGui.Checkbox("Show paired player(s) Lightfinder indicator", ref showPaired)) + if (ImGui.Checkbox("Show paired player(s) Lightfinder label", ref showPaired)) { _configService.Current.LightfinderLabelShowPaired = showPaired; _configService.Save(); @@ -1168,8 +1208,11 @@ public class SettingsUi : WindowMediatorSubscriberBase _nameplateHandler.FlagRefresh(); _nameplateService.RequestRedraw(); } - _uiShared.DrawHelpText("Toggles paired player(s) Lightfinder indicator."); + _uiShared.DrawHelpText("Toggles paired player(s) Lightfinder label."); + _uiShared.ColoredSeparator(UIColors.Get("LightlessPurpleDefault"), 1.5f); + + ImGui.TextUnformatted("Label"); var useIcon = _configService.Current.LightfinderLabelUseIcon; if (ImGui.Checkbox("Show icon instead of text", ref useIcon)) {