From bc2f6e19d723cca5002512d4e8fe502b47463187 Mon Sep 17 00:00:00 2001 From: CakeAndBanana Date: Fri, 12 Sep 2025 06:55:10 +0200 Subject: [PATCH] Redone check based on kenny's suggestion --- LightlessSync/UI/CompactUI.cs | 59 +++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 23 deletions(-) diff --git a/LightlessSync/UI/CompactUI.cs b/LightlessSync/UI/CompactUI.cs index bfcc5b2..82c3303 100644 --- a/LightlessSync/UI/CompactUI.cs +++ b/LightlessSync/UI/CompactUI.cs @@ -426,36 +426,49 @@ public class CompactUi : WindowMediatorSubscriberBase if (_cachedAnalysis != null) { - var groupedfiles = _cachedAnalysis.First().Value.Select(v => v.Value).GroupBy(f => f.FileType, StringComparer.Ordinal) - .OrderBy(k => k.Key, StringComparer.Ordinal).ToList(); - if (groupedfiles != null) + var firstEntry = _cachedAnalysis.FirstOrDefault(); + var valueDict = firstEntry.Value; + if (valueDict != null && valueDict.Count > 0) { - var actualTriCount = _cachedAnalysis.First().Value.Sum(f => f.Value.Triangles); - var isOverTriHold = actualTriCount > (_playerPerformanceConfig.Current.TrisWarningThresholdThousands * 1000); + var groupedfiles = valueDict + .Select(v => v.Value) + .Where(v => v != null) + .GroupBy(f => f.FileType, StringComparer.Ordinal) + .OrderBy(k => k.Key, StringComparer.Ordinal) + .ToList(); - //Checking of VRAM threshhold - var texGroup = groupedfiles.SingleOrDefault(v => string.Equals(v.Key, "tex", StringComparison.Ordinal)); - var actualVramUsage = texGroup != null ? texGroup.Sum(f => f.OriginalSize) : 0L; - var isOverVRAMUsage = _playerPerformanceConfig.Current.VRAMSizeWarningThresholdMiB * 1024 * 1024 < actualVramUsage; + var actualTriCount = valueDict + .Select(v => v.Value) + .Where(v => v != null) + .Sum(f => f.Triangles); - if ((isOverTriHold || isOverVRAMUsage) && _playerPerformanceConfig.Current.WarnOnExceedingThresholds) + if (groupedfiles != null) { - ImGui.SameLine(); - _uiSharedService.IconText(FontAwesomeIcon.ExclamationTriangle, UIColors.Get("LightlessYellow")); - string warningMessage = ""; - if (isOverTriHold) - { - warningMessage += $"You exceed your own triangles threshold by " + - $"{actualTriCount - _playerPerformanceConfig.Current.TrisWarningThresholdThousands * 1000} triangles."; - warningMessage += Environment.NewLine; + //Checking of VRAM threshhold + var texGroup = groupedfiles.SingleOrDefault(v => string.Equals(v.Key, "tex", StringComparison.Ordinal)); + var actualVramUsage = texGroup != null ? texGroup.Sum(f => f.OriginalSize) : 0L; + var isOverVRAMUsage = _playerPerformanceConfig.Current.VRAMSizeWarningThresholdMiB * 1024 * 1024 < actualVramUsage; + var isOverTriHold = actualTriCount > (_playerPerformanceConfig.Current.TrisWarningThresholdThousands * 1000); - } - if (isOverVRAMUsage) + if ((isOverTriHold || isOverVRAMUsage) && _playerPerformanceConfig.Current.WarnOnExceedingThresholds) { - warningMessage += $"You exceed your own VRAM threshold by " + - $"{UiSharedService.ByteToString(actualVramUsage - (_playerPerformanceConfig.Current.VRAMSizeWarningThresholdMiB * 1024 * 1024))}."; + ImGui.SameLine(); + _uiSharedService.IconText(FontAwesomeIcon.ExclamationTriangle, UIColors.Get("LightlessYellow")); + string warningMessage = ""; + if (isOverTriHold) + { + warningMessage += $"You exceed your own triangles threshold by " + + $"{actualTriCount - _playerPerformanceConfig.Current.TrisWarningThresholdThousands * 1000} triangles."; + warningMessage += Environment.NewLine; + + } + if (isOverVRAMUsage) + { + warningMessage += $"You exceed your own VRAM threshold by " + + $"{UiSharedService.ByteToString(actualVramUsage - (_playerPerformanceConfig.Current.VRAMSizeWarningThresholdMiB * 1024 * 1024))}."; + } + UiSharedService.AttachToolTip(warningMessage); } - UiSharedService.AttachToolTip(warningMessage); } } }