lightfinder nearby badge icon
This commit is contained in:
@@ -170,8 +170,22 @@ public class TopTabMenu
|
||||
{
|
||||
Selune.RegisterHighlight(ImGui.GetItemRectMin(), ImGui.GetItemRectMax(), SeluneHighlightMode.Both, true, buttonBorderThickness, exactSize: true, clipToElement: true, roundingOverride: buttonRounding);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var nearbyCount = GetNearbySyncshellCount();
|
||||
if (nearbyCount > 0)
|
||||
{
|
||||
var buttonMax = ImGui.GetItemRectMax();
|
||||
var badgeRadius = 8f * ImGuiHelpers.GlobalScale;
|
||||
var badgeCenter = new Vector2(buttonMax.X - badgeRadius * 0.5f, buttonMax.Y - buttonSize.Y + badgeRadius * 0.5f);
|
||||
var badgeText = nearbyCount > 99 ? "99+" : nearbyCount.ToString();
|
||||
var textSize = ImGui.CalcTextSize(badgeText);
|
||||
|
||||
drawList.AddCircleFilled(badgeCenter, badgeRadius + 1f, ImGui.GetColorU32(new Vector4(0, 0, 0, 0.6f)));
|
||||
drawList.AddCircleFilled(badgeCenter, badgeRadius, ImGui.GetColorU32(UIColors.Get("LightlessPurple")));
|
||||
|
||||
var textPos = new Vector2(badgeCenter.X - textSize.X * 0.5f, badgeCenter.Y - textSize.Y * 0.5f);
|
||||
drawList.AddText(textPos, ImGui.GetColorU32(new Vector4(1, 1, 1, 1)), badgeText);
|
||||
}
|
||||
UiSharedService.AttachToolTip(GetLightfinderTooltip());
|
||||
|
||||
@@ -805,6 +819,31 @@ public class TopTabMenu
|
||||
return nearbyCount > 0 ? $"Lightfinder ({nearbyCount} nearby)" : "Open Lightfinder";
|
||||
}
|
||||
|
||||
private int GetNearbySyncshellCount()
|
||||
{
|
||||
if (!_lightFinderService.IsBroadcasting)
|
||||
return 0;
|
||||
|
||||
string? myHashedCid = null;
|
||||
try
|
||||
{
|
||||
var cid = _dalamudUtilService.GetCID();
|
||||
myHashedCid = cid.ToString().GetHash256();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
|
||||
return _lightFinderScannerService
|
||||
.GetActiveSyncshellBroadcasts()
|
||||
.Where(b =>
|
||||
!string.IsNullOrEmpty(b.GID) &&
|
||||
!string.Equals(b.HashedCID, myHashedCid, StringComparison.Ordinal))
|
||||
.Select(b => b.GID!)
|
||||
.Distinct(StringComparer.Ordinal)
|
||||
.Count();
|
||||
}
|
||||
|
||||
private void DrawUserConfig(float availableWidth, float spacingX)
|
||||
{
|
||||
var buttonX = (availableWidth - spacingX) / 2f;
|
||||
|
||||
Reference in New Issue
Block a user