2.0.0 (#92)
All checks were successful
Tag and Release Lightless / tag-and-release (push) Successful in 2m27s
All checks were successful
Tag and Release Lightless / tag-and-release (push) Successful in 2m27s
2.0.0 Changes: - Reworked shell finder UI with compact or list view with profile tags showing with the listing, allowing moderators to broadcast the syncshell as well to have it be used more. - Reworked user list in syncshell admin screen to have filter visible and moved away from table to its own thing, allowing to copy uid/note/alias when clicking on the name. - Reworked download bars and download box to make it look more modern, removed the jitter around, so it shouldn't vibrate around much. - Chat has been added to the top menu, working in Zone or in Syncshells to be used there. - Paired system has been revamped to make pausing and unpausing faster, and loading people should be faster as well. - Moved to the internal object table to have faster load times for users; people should load in faster - Compactor is running on a multi-threaded level instead of single-threaded; this should increase the speed of compacting files - Nameplate Service has been reworked so it wouldn't use the nameplate handler anymore. - Files can be resized when downloading to reduce load on users if they aren't compressed. (can be toggled to resize all). - Penumbra Collections are now only made when people are visible, reducing the load on boot-up when having many syncshells in your list. - Lightfinder plates have been moved away from using Nameplates, but will use an overlay. - Main UI has been changed a bit with a gradient, and on hover will glow up now. - Reworked Profile UI for Syncshell and Users to be more user-facing with more customizable items. - Reworked Settings UI to look more modern. - Performance should be better due to new systems that would dispose of the collections and better caching of items. Co-authored-by: defnotken <itsdefnotken@gmail.com> Co-authored-by: azyges <aaaaaa@aaa.aaa> Co-authored-by: choco <choco@patat.nl> Co-authored-by: cake <admin@cakeandbanana.nl> Co-authored-by: Minmoose <KennethBohr@outlook.com> Reviewed-on: #92
This commit was merged in pull request #92.
This commit is contained in:
@@ -10,13 +10,16 @@ using LightlessSync.Services.ServerConfiguration;
|
||||
using LightlessSync.UI.Style;
|
||||
using LightlessSync.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
|
||||
namespace LightlessSync.UI.Handlers;
|
||||
|
||||
public class IdDisplayHandler
|
||||
{
|
||||
private readonly LightlessConfigService _lightlessConfigService;
|
||||
private readonly PlayerPerformanceConfigService _playerPerformanceConfigService;
|
||||
private readonly LightlessMediator _mediator;
|
||||
private readonly ServerConfigurationManager _serverManager;
|
||||
private readonly Dictionary<string, bool> _showIdForEntry = new(StringComparer.Ordinal);
|
||||
@@ -30,11 +33,16 @@ public class IdDisplayHandler
|
||||
private Vector4 _currentBg = new(0.15f, 0.15f, 0.15f, 1f);
|
||||
private float _highlightBoost;
|
||||
|
||||
public IdDisplayHandler(LightlessMediator mediator, ServerConfigurationManager serverManager, LightlessConfigService lightlessConfigService)
|
||||
public IdDisplayHandler(
|
||||
LightlessMediator mediator,
|
||||
ServerConfigurationManager serverManager,
|
||||
LightlessConfigService lightlessConfigService,
|
||||
PlayerPerformanceConfigService playerPerformanceConfigService)
|
||||
{
|
||||
_mediator = mediator;
|
||||
_serverManager = serverManager;
|
||||
_lightlessConfigService = lightlessConfigService;
|
||||
_playerPerformanceConfigService = playerPerformanceConfigService;
|
||||
}
|
||||
|
||||
public void DrawGroupText(string id, GroupFullInfoDto group, float textPosX, Func<float> editBoxWidth)
|
||||
@@ -43,10 +51,18 @@ public class IdDisplayHandler
|
||||
(bool textIsUid, string playerText) = GetGroupText(group);
|
||||
if (!string.Equals(_editEntry, group.GID, StringComparison.Ordinal))
|
||||
{
|
||||
ImGui.AlignTextToFramePadding();
|
||||
|
||||
using (ImRaii.PushFont(UiBuilder.MonoFont, textIsUid))
|
||||
{
|
||||
ImGui.AlignTextToFramePadding();
|
||||
ImGui.TextUnformatted(playerText);
|
||||
}
|
||||
|
||||
if (ImGui.IsItemHovered())
|
||||
{
|
||||
ImGui.SetTooltip("Left click to switch between ID display and alias"
|
||||
+ Environment.NewLine + "Right click to edit notes for this syncshell"
|
||||
+ Environment.NewLine + "Middle Mouse Button to open syncshell profile in a separate window");
|
||||
}
|
||||
|
||||
if (ImGui.IsItemClicked(ImGuiMouseButton.Left))
|
||||
{
|
||||
@@ -73,6 +89,11 @@ public class IdDisplayHandler
|
||||
_editEntry = group.GID;
|
||||
_editIsUid = false;
|
||||
}
|
||||
|
||||
if (ImGui.IsItemClicked(ImGuiMouseButton.Middle))
|
||||
{
|
||||
_mediator.Publish(new GroupProfileOpenStandaloneMessage(group.Group));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -97,112 +118,121 @@ public class IdDisplayHandler
|
||||
{
|
||||
ImGui.SameLine(textPosX);
|
||||
(bool textIsUid, string playerText) = GetPlayerText(pair);
|
||||
var compactPerformanceText = BuildCompactPerformanceUsageText(pair);
|
||||
|
||||
if (!string.Equals(_editEntry, pair.UserData.UID, StringComparison.Ordinal))
|
||||
{
|
||||
ImGui.AlignTextToFramePadding();
|
||||
|
||||
var targetFontSize = ImGui.GetFontSize();
|
||||
var font = textIsUid ? UiBuilder.MonoFont : ImGui.GetFont();
|
||||
var rowWidth = MathF.Max(editBoxWidth.Invoke(), 0f);
|
||||
float rowRightLimit = 0f;
|
||||
Vector2 nameRectMin = Vector2.Zero;
|
||||
Vector2 nameRectMax = Vector2.Zero;
|
||||
float rowTopForStats = 0f;
|
||||
float frameHeightForStats = 0f;
|
||||
|
||||
Vector4? textColor = null;
|
||||
Vector4? glowColor = null;
|
||||
|
||||
if (pair.UserData.HasVanity)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(pair.UserData.TextColorHex))
|
||||
{
|
||||
textColor = UIColors.HexToRgba(pair.UserData.TextColorHex);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(pair.UserData.TextGlowColorHex))
|
||||
{
|
||||
glowColor = UIColors.HexToRgba(pair.UserData.TextGlowColorHex);
|
||||
}
|
||||
}
|
||||
|
||||
var useVanityColors = _lightlessConfigService.Current.useColoredUIDs && (textColor != null || glowColor != null);
|
||||
var seString = useVanityColors
|
||||
? SeStringUtils.BuildFormattedPlayerName(playerText, textColor, glowColor)
|
||||
: SeStringUtils.BuildPlain(playerText);
|
||||
|
||||
var rowStart = ImGui.GetCursorScreenPos();
|
||||
var drawList = ImGui.GetWindowDrawList();
|
||||
bool useHighlight = false;
|
||||
float highlightPadX = 0f;
|
||||
float highlightPadY = 0f;
|
||||
|
||||
if (useVanityColors)
|
||||
{
|
||||
float boost = Luminance.ComputeHighlight(textColor, glowColor);
|
||||
|
||||
if (boost > 0f)
|
||||
{
|
||||
var style = ImGui.GetStyle();
|
||||
useHighlight = true;
|
||||
highlightPadX = MathF.Max(style.FramePadding.X * 0.6f, 2f * ImGuiHelpers.GlobalScale);
|
||||
highlightPadY = MathF.Max(style.FramePadding.Y * 0.55f, 1.25f * ImGuiHelpers.GlobalScale);
|
||||
drawList.ChannelsSplit(2);
|
||||
drawList.ChannelsSetCurrent(1);
|
||||
|
||||
_highlightBoost = boost;
|
||||
}
|
||||
else
|
||||
{
|
||||
_highlightBoost = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
Vector2 itemMin;
|
||||
Vector2 itemMax;
|
||||
Vector2 textSize;
|
||||
using (ImRaii.PushFont(font, textIsUid))
|
||||
{
|
||||
SeStringUtils.RenderSeStringWithHitbox(seString, rowStart, font, pair.UserData.UID);
|
||||
itemMin = ImGui.GetItemRectMin();
|
||||
itemMax = ImGui.GetItemRectMax();
|
||||
//textSize = itemMax - itemMin;
|
||||
}
|
||||
ImGui.AlignTextToFramePadding();
|
||||
var rowStart = ImGui.GetCursorScreenPos();
|
||||
rowRightLimit = rowStart.X + rowWidth;
|
||||
|
||||
if (useHighlight)
|
||||
Vector4? textColor = null;
|
||||
Vector4? glowColor = null;
|
||||
|
||||
if (pair.UserData.HasVanity)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(pair.UserData.TextColorHex))
|
||||
{
|
||||
textColor = UIColors.HexToRgba(pair.UserData.TextColorHex);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(pair.UserData.TextGlowColorHex))
|
||||
{
|
||||
glowColor = UIColors.HexToRgba(pair.UserData.TextGlowColorHex);
|
||||
}
|
||||
}
|
||||
|
||||
var useVanityColors = _lightlessConfigService.Current.useColoredUIDs && (textColor != null || glowColor != null);
|
||||
var seString = useVanityColors
|
||||
? SeStringUtils.BuildFormattedPlayerName(playerText, textColor, glowColor)
|
||||
: SeStringUtils.BuildPlain(playerText);
|
||||
|
||||
var drawList = ImGui.GetWindowDrawList();
|
||||
bool useHighlight = false;
|
||||
float highlightPadX = 0f;
|
||||
float highlightPadY = 0f;
|
||||
|
||||
if (useVanityColors)
|
||||
{
|
||||
float boost = Luminance.ComputeHighlight(textColor, glowColor);
|
||||
|
||||
if (boost > 0f)
|
||||
{
|
||||
var style = ImGui.GetStyle();
|
||||
useHighlight = true;
|
||||
highlightPadX = MathF.Max(style.FramePadding.X * 0.6f, 2f * ImGuiHelpers.GlobalScale);
|
||||
highlightPadY = MathF.Max(style.FramePadding.Y * 0.55f, 1.25f * ImGuiHelpers.GlobalScale);
|
||||
drawList.ChannelsSplit(2);
|
||||
drawList.ChannelsSetCurrent(1);
|
||||
|
||||
_highlightBoost = boost;
|
||||
}
|
||||
else
|
||||
{
|
||||
_highlightBoost = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
SeStringUtils.RenderSeStringWithHitbox(seString, rowStart, targetFontSize, font, pair.UserData.UID);
|
||||
nameRectMin = ImGui.GetItemRectMin();
|
||||
nameRectMax = ImGui.GetItemRectMax();
|
||||
|
||||
if (useHighlight)
|
||||
{
|
||||
var style = ImGui.GetStyle();
|
||||
var frameHeight = ImGui.GetFrameHeight();
|
||||
var rowTop = rowStart.Y - style.FramePadding.Y;
|
||||
var rowBottom = rowTop + frameHeight;
|
||||
|
||||
var highlightMin = new Vector2(nameRectMin.X - highlightPadX, rowTop - highlightPadY);
|
||||
var highlightMax = new Vector2(nameRectMax.X + highlightPadX, rowBottom + highlightPadY);
|
||||
|
||||
var windowPos = ImGui.GetWindowPos();
|
||||
var contentMin = windowPos + ImGui.GetWindowContentRegionMin();
|
||||
var contentMax = windowPos + ImGui.GetWindowContentRegionMax();
|
||||
highlightMin.X = MathF.Max(highlightMin.X, contentMin.X);
|
||||
highlightMax.X = MathF.Min(highlightMax.X, contentMax.X);
|
||||
highlightMin.Y = MathF.Max(highlightMin.Y, contentMin.Y);
|
||||
highlightMax.Y = MathF.Min(highlightMax.Y, contentMax.Y);
|
||||
|
||||
var highlightColor = new Vector4(
|
||||
0.25f + _highlightBoost,
|
||||
0.25f + _highlightBoost,
|
||||
0.25f + _highlightBoost,
|
||||
1f
|
||||
);
|
||||
|
||||
highlightColor = Luminance.BackgroundContrast(textColor, glowColor, highlightColor, ref _currentBg);
|
||||
|
||||
float rounding = style.FrameRounding > 0f ? style.FrameRounding : 5f * ImGuiHelpers.GlobalScale;
|
||||
drawList.ChannelsSetCurrent(0);
|
||||
drawList.AddRectFilled(highlightMin, highlightMax, ImGui.GetColorU32(highlightColor), rounding);
|
||||
|
||||
var borderColor = style.Colors[(int)ImGuiCol.Border];
|
||||
borderColor.W *= 0.25f;
|
||||
drawList.AddRect(highlightMin, highlightMax, ImGui.GetColorU32(borderColor), rounding);
|
||||
drawList.ChannelsMerge();
|
||||
}
|
||||
}
|
||||
{
|
||||
var style = ImGui.GetStyle();
|
||||
var frameHeight = ImGui.GetFrameHeight();
|
||||
var rowTop = rowStart.Y - style.FramePadding.Y;
|
||||
var rowBottom = rowTop + frameHeight;
|
||||
|
||||
var highlightMin = new Vector2(itemMin.X - highlightPadX, rowTop - highlightPadY);
|
||||
var highlightMax = new Vector2(itemMax.X + highlightPadX, rowBottom + highlightPadY);
|
||||
|
||||
var windowPos = ImGui.GetWindowPos();
|
||||
var contentMin = windowPos + ImGui.GetWindowContentRegionMin();
|
||||
var contentMax = windowPos + ImGui.GetWindowContentRegionMax();
|
||||
highlightMin.X = MathF.Max(highlightMin.X, contentMin.X);
|
||||
highlightMax.X = MathF.Min(highlightMax.X, contentMax.X);
|
||||
highlightMin.Y = MathF.Max(highlightMin.Y, contentMin.Y);
|
||||
highlightMax.Y = MathF.Min(highlightMax.Y, contentMax.Y);
|
||||
|
||||
var highlightColor = new Vector4(
|
||||
0.25f + _highlightBoost,
|
||||
0.25f + _highlightBoost,
|
||||
0.25f + _highlightBoost,
|
||||
1f
|
||||
);
|
||||
|
||||
highlightColor = Luminance.BackgroundContrast(textColor, glowColor, highlightColor, ref _currentBg);
|
||||
|
||||
float rounding = style.FrameRounding > 0f ? style.FrameRounding : 5f * ImGuiHelpers.GlobalScale;
|
||||
drawList.ChannelsSetCurrent(0);
|
||||
drawList.AddRectFilled(highlightMin, highlightMax, ImGui.GetColorU32(highlightColor), rounding);
|
||||
|
||||
var borderColor = style.Colors[(int)ImGuiCol.Border];
|
||||
borderColor.W *= 0.25f;
|
||||
drawList.AddRect(highlightMin, highlightMax, ImGui.GetColorU32(borderColor), rounding);
|
||||
drawList.ChannelsMerge();
|
||||
frameHeightForStats = ImGui.GetFrameHeight();
|
||||
rowTopForStats = nameRectMin.Y - style.FramePadding.Y;
|
||||
}
|
||||
|
||||
if (ImGui.IsItemHovered())
|
||||
{
|
||||
if (!string.Equals(_lastMouseOverUid, id))
|
||||
if (!string.Equals(_lastMouseOverUid, id, StringComparison.Ordinal))
|
||||
{
|
||||
_popupTime = DateTime.UtcNow.AddSeconds(_lightlessConfigService.Current.ProfileDelay);
|
||||
}
|
||||
@@ -223,7 +253,7 @@ public class IdDisplayHandler
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string.Equals(_lastMouseOverUid, id))
|
||||
if (string.Equals(_lastMouseOverUid, id, StringComparison.Ordinal))
|
||||
{
|
||||
_mediator.Publish(new ProfilePopoutToggle(Pair: null));
|
||||
_lastMouseOverUid = string.Empty;
|
||||
@@ -261,12 +291,40 @@ public class IdDisplayHandler
|
||||
{
|
||||
_mediator.Publish(new ProfileOpenStandaloneMessage(pair));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(compactPerformanceText))
|
||||
{
|
||||
ImGui.SameLine();
|
||||
|
||||
const float compactFontScale = 0.85f;
|
||||
ImGui.SetWindowFontScale(compactFontScale);
|
||||
var compactHeight = ImGui.GetTextLineHeight();
|
||||
var targetPos = ImGui.GetCursorScreenPos();
|
||||
var availableWidth = MathF.Max(rowRightLimit - targetPos.X, 0f);
|
||||
var centeredY = rowTopForStats + MathF.Max((frameHeightForStats - compactHeight) * 0.5f, 0f);
|
||||
ImGui.SetCursorScreenPos(new Vector2(targetPos.X, centeredY));
|
||||
|
||||
var performanceText = string.Empty;
|
||||
var wasTruncated = false;
|
||||
if (availableWidth > 0f)
|
||||
{
|
||||
performanceText = TruncateTextToWidth(compactPerformanceText, availableWidth, out wasTruncated);
|
||||
}
|
||||
|
||||
ImGui.TextDisabled(performanceText);
|
||||
ImGui.SetWindowFontScale(1f);
|
||||
|
||||
if (wasTruncated && ImGui.IsItemHovered())
|
||||
{
|
||||
ImGui.SetTooltip(compactPerformanceText);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.AlignTextToFramePadding();
|
||||
|
||||
ImGui.SetNextItemWidth(editBoxWidth.Invoke());
|
||||
ImGui.SetNextItemWidth(MathF.Max(editBoxWidth.Invoke(), 0f));
|
||||
if (ImGui.InputTextWithHint("##" + pair.UserData.UID, "Nick/Notes", ref _editComment, 255, ImGuiInputTextFlags.EnterReturnsTrue))
|
||||
{
|
||||
_serverManager.SetNoteForUid(pair.UserData.UID, _editComment);
|
||||
@@ -346,6 +404,57 @@ public class IdDisplayHandler
|
||||
return (textIsUid, playerText!);
|
||||
}
|
||||
|
||||
private string? BuildCompactPerformanceUsageText(Pair pair)
|
||||
{
|
||||
var config = _playerPerformanceConfigService.Current;
|
||||
if (!config.ShowPerformanceIndicator || !config.ShowPerformanceUsageNextToName)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var vramBytes = pair.LastAppliedApproximateEffectiveVRAMBytes >= 0
|
||||
? pair.LastAppliedApproximateEffectiveVRAMBytes
|
||||
: pair.LastAppliedApproximateVRAMBytes;
|
||||
var triangleCount = pair.LastAppliedDataTris;
|
||||
if (vramBytes < 0 && triangleCount < 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var segments = new List<string>(2);
|
||||
if (vramBytes >= 0)
|
||||
{
|
||||
segments.Add(UiSharedService.ByteToString(vramBytes));
|
||||
}
|
||||
|
||||
if (triangleCount >= 0)
|
||||
{
|
||||
segments.Add(FormatTriangleCount(triangleCount));
|
||||
}
|
||||
|
||||
return segments.Count == 0 ? null : string.Join(" / ", segments);
|
||||
}
|
||||
|
||||
private static string FormatTriangleCount(long triangleCount)
|
||||
{
|
||||
if (triangleCount < 0)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
if (triangleCount >= 1_000_000)
|
||||
{
|
||||
return FormattableString.Invariant($"{triangleCount / 1_000_000d:0.#}m tris");
|
||||
}
|
||||
|
||||
if (triangleCount >= 1_000)
|
||||
{
|
||||
return FormattableString.Invariant($"{triangleCount / 1_000d:0.#}k tris");
|
||||
}
|
||||
|
||||
return $"{triangleCount} tris";
|
||||
}
|
||||
|
||||
internal void Clear()
|
||||
{
|
||||
_editEntry = string.Empty;
|
||||
@@ -370,4 +479,52 @@ public class IdDisplayHandler
|
||||
|
||||
return showidInsteadOfName;
|
||||
}
|
||||
}
|
||||
|
||||
private static string TruncateTextToWidth(string text, float maxWidth, out bool wasTruncated)
|
||||
{
|
||||
wasTruncated = false;
|
||||
if (string.IsNullOrEmpty(text) || maxWidth <= 0f)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
var fullWidth = ImGui.CalcTextSize(text).X;
|
||||
if (fullWidth <= maxWidth)
|
||||
{
|
||||
return text;
|
||||
}
|
||||
|
||||
wasTruncated = true;
|
||||
|
||||
const string Ellipsis = "...";
|
||||
var ellipsisWidth = ImGui.CalcTextSize(Ellipsis).X;
|
||||
if (ellipsisWidth >= maxWidth)
|
||||
{
|
||||
return Ellipsis;
|
||||
}
|
||||
|
||||
var builder = new StringBuilder(text.Length);
|
||||
var remainingWidth = maxWidth - ellipsisWidth;
|
||||
|
||||
foreach (var rune in text.EnumerateRunes())
|
||||
{
|
||||
var runeText = rune.ToString();
|
||||
var runeWidth = ImGui.CalcTextSize(runeText).X;
|
||||
if (runeWidth > remainingWidth)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
builder.Append(runeText);
|
||||
remainingWidth -= runeWidth;
|
||||
}
|
||||
|
||||
if (builder.Length == 0)
|
||||
{
|
||||
return Ellipsis;
|
||||
}
|
||||
|
||||
builder.Append(Ellipsis);
|
||||
return builder.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user