From 55d979b7c0478feb16fbe9fd5e9241ab17032622 Mon Sep 17 00:00:00 2001 From: CakeAndBanana Date: Sun, 5 Oct 2025 15:41:52 +0200 Subject: [PATCH] Added a check if nameplate is visible to show the lightless text. --- LightlessSync/Services/NameplateHandler.cs | 128 +++++++++++---------- 1 file changed, 70 insertions(+), 58 deletions(-) diff --git a/LightlessSync/Services/NameplateHandler.cs b/LightlessSync/Services/NameplateHandler.cs index 762bc52..5cb2d3e 100644 --- a/LightlessSync/Services/NameplateHandler.cs +++ b/LightlessSync/Services/NameplateHandler.cs @@ -176,66 +176,78 @@ public unsafe class NameplateHandler : IMediatorSubscriber for (int i = 0; i < ui3DModule->NamePlateObjectInfoCount; ++i) { - var objectInfo = ui3DModule->NamePlateObjectInfoPointers[i].Value; - if (objectInfo == null || objectInfo->GameObject == null) - continue; - - var nameplateIndex = objectInfo->NamePlateIndex; - if (nameplateIndex < 0 || nameplateIndex >= AddonNamePlate.NumNamePlateObjects) - continue; - - var pNode = mTextNodes[nameplateIndex]; - if (pNode == null) - continue; - - var cid = DalamudUtilService.GetHashedCIDFromPlayerPointer((nint)objectInfo->GameObject); - - //_logger.LogInformation($"checking cid: {cid}", cid); - - if (cid == null || !_activeBroadcastingCids.Contains(cid)) + var pObjectInfo = ui3DModule->NamePlateObjectInfoPointers[i].Value; + if (pObjectInfo != null && + pObjectInfo->GameObject != null && + pObjectInfo->NamePlateIndex >= 0) { - pNode->AtkResNode.ToggleVisibility(false); - continue; + var objectInfo = ui3DModule->NamePlateObjectInfoPointers[i].Value; + if (objectInfo == null || objectInfo->GameObject == null) + continue; + + var nameplateIndex = objectInfo->NamePlateIndex; + if (nameplateIndex < 0 || nameplateIndex >= AddonNamePlate.NumNamePlateObjects) + continue; + + var pNode = mTextNodes[nameplateIndex]; + if (pNode == null) + continue; + + var cid = DalamudUtilService.GetHashedCIDFromPlayerPointer((nint)objectInfo->GameObject); + + //_logger.LogInformation($"checking cid: {cid}", cid); + + if (cid == null || !_activeBroadcastingCids.Contains(cid)) + { + pNode->AtkResNode.ToggleVisibility(false); + continue; + } + + + + var nameplateObject = mpNameplateAddon->NamePlateObjectArray[nameplateIndex]; + nameplateObject.RootComponentNode->Component->UldManager.UpdateDrawNodeList(); + + var pNameplateIconNode = nameplateObject.MarkerIcon; + var pNameplateResNode = nameplateObject.NameContainer; + var pNameplateTextNode = nameplateObject.NameText; + bool IsVisible = pNameplateIconNode->AtkResNode.IsVisible() || (pNameplateResNode->IsVisible() && pNameplateTextNode->AtkResNode.IsVisible()); + pNode->AtkResNode.ToggleVisibility(IsVisible); + + var nameContainer = nameplateObject.NameContainer; + var nameText = nameplateObject.NameText; + + var labelColor = UIColors.Get("LightlessPurple"); + var edgeColor = UIColors.Get("FullBlack"); + + var labelY = nameContainer->Height - nameplateObject.TextH - (int)(24 * nameText->AtkResNode.ScaleY); + + pNode->AtkResNode.SetPositionShort(58, (short)labelY); + pNode->AtkResNode.SetUseDepthBasedPriority(true); + pNode->AtkResNode.SetScale(0.5f, 0.5f); + + pNode->AtkResNode.Color.A = 255; + + pNode->TextColor.R = (byte)(labelColor.X * 255); + pNode->TextColor.G = (byte)(labelColor.Y * 255); + pNode->TextColor.B = (byte)(labelColor.Z * 255); + pNode->TextColor.A = (byte)(labelColor.W * 255); + + pNode->EdgeColor.R = (byte)(edgeColor.X * 255); + pNode->EdgeColor.G = (byte)(edgeColor.Y * 255); + pNode->EdgeColor.B = (byte)(edgeColor.Z * 255); + pNode->EdgeColor.A = (byte)(edgeColor.W * 255); + + pNode->FontSize = 24; + pNode->AlignmentType = AlignmentType.Center; + pNode->FontType = FontType.MiedingerMed; + pNode->LineSpacing = 24; + pNode->CharSpacing = 1; + + pNode->TextFlags = TextFlags.Edge | TextFlags.Glare; + + pNode->SetText("Lightfinder"); } - - pNode->AtkResNode.ToggleVisibility(true); - - var nameplateObject = mpNameplateAddon->NamePlateObjectArray[nameplateIndex]; - nameplateObject.RootComponentNode->Component->UldManager.UpdateDrawNodeList(); - - var nameContainer = nameplateObject.NameContainer; - var nameText = nameplateObject.NameText; - - var labelColor = UIColors.Get("LightlessPurple"); - var edgeColor = UIColors.Get("FullBlack"); - - var labelY = nameContainer->Height - nameplateObject.TextH - (int)(24 * nameText->AtkResNode.ScaleY); - - pNode->AtkResNode.SetPositionShort(58, (short)labelY); - pNode->AtkResNode.SetUseDepthBasedPriority(true); - pNode->AtkResNode.SetScale(0.5f, 0.5f); - - pNode->AtkResNode.Color.A = 255; - - pNode->TextColor.R = (byte)(labelColor.X * 255); - pNode->TextColor.G = (byte)(labelColor.Y * 255); - pNode->TextColor.B = (byte)(labelColor.Z * 255); - pNode->TextColor.A = (byte)(labelColor.W * 255); - - pNode->EdgeColor.R = (byte)(edgeColor.X * 255); - pNode->EdgeColor.G = (byte)(edgeColor.Y * 255); - pNode->EdgeColor.B = (byte)(edgeColor.Z * 255); - pNode->EdgeColor.A = (byte)(edgeColor.W * 255); - - pNode->FontSize = 24; - pNode->AlignmentType = AlignmentType.Center; - pNode->FontType = FontType.MiedingerMed; - pNode->LineSpacing = 24; - pNode->CharSpacing = 1; - - pNode->TextFlags = TextFlags.Edge | TextFlags.Glare; - - pNode->SetText("Lightfinder"); } }