Fixed many warnings

This commit is contained in:
cake
2025-11-16 07:57:59 +01:00
parent a869b369aa
commit f3a6c7b5b9
14 changed files with 112 additions and 128 deletions

View File

@@ -192,7 +192,7 @@ namespace LightlessSync.UI
ImGui.PopStyleVar(); ImGui.PopStyleVar();
ImGuiHelpers.ScaledDummy(3f); ImGuiHelpers.ScaledDummy(3f);
_uiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 2f); UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 2f);
if (_configService.Current.BroadcastEnabled) if (_configService.Current.BroadcastEnabled)
{ {
@@ -288,7 +288,7 @@ namespace LightlessSync.UI
_uiSharedService.MediumText("Syncshell Finder", UIColors.Get("PairBlue")); _uiSharedService.MediumText("Syncshell Finder", UIColors.Get("PairBlue"));
_uiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 2f); UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 2f);
ImGui.PushTextWrapPos(); ImGui.PushTextWrapPos();
ImGui.Text("Allow your owned Syncshell to be indexed by the Nearby Syncshell Finder."); ImGui.Text("Allow your owned Syncshell to be indexed by the Nearby Syncshell Finder.");
@@ -296,7 +296,7 @@ namespace LightlessSync.UI
ImGui.PopTextWrapPos(); ImGui.PopTextWrapPos();
ImGuiHelpers.ScaledDummy(0.2f); ImGuiHelpers.ScaledDummy(0.2f);
_uiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 2f); UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 2f);
bool ShellFinderEnabled = _configService.Current.SyncshellFinderEnabled; bool ShellFinderEnabled = _configService.Current.SyncshellFinderEnabled;
bool isBroadcasting = _broadcastService.IsBroadcasting; bool isBroadcasting = _broadcastService.IsBroadcasting;

View File

@@ -223,7 +223,7 @@ public class CompactUi : WindowMediatorSubscriberBase
} }
using (ImRaii.PushId("header")) DrawUIDHeader(); using (ImRaii.PushId("header")) DrawUIDHeader();
_uiSharedService.RoundedSeparator(UIColors.Get("LightlessPurple"), 2.5f, 1f, 12f); UiSharedService.RoundedSeparator(UIColors.Get("LightlessPurple"), 2.5f, 1f, 12f);
using (ImRaii.PushId("serverstatus")) DrawServerStatus(); using (ImRaii.PushId("serverstatus")) DrawServerStatus();
ImGui.Separator(); ImGui.Separator();
@@ -540,7 +540,7 @@ public class CompactUi : WindowMediatorSubscriberBase
ImGui.PopStyleColor(); ImGui.PopStyleColor();
ImGuiHelpers.ScaledDummy(0.2f); ImGuiHelpers.ScaledDummy(0.2f);
_uiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 2f); UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 2f);
if (_configService.Current.BroadcastEnabled) if (_configService.Current.BroadcastEnabled)
{ {

View File

@@ -581,10 +581,10 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
ImGui.TableNextRow(); ImGui.TableNextRow();
ImGui.TableNextColumn(); ImGui.TableNextColumn();
ImGui.TextUnformatted($"{kvp.Key} size (compressed for up/download only):"); ImGui.TextUnformatted($"{kvp.Key} size (compressed for up/download only):");
_uiSharedService.ColoredSeparator(UIColors.Get("LightlessPurpleDefault"), 1.5f); UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurpleDefault"), 1.5f);
ImGui.TableNextColumn(); ImGui.TableNextColumn();
ImGui.TextUnformatted(UiSharedService.ByteToString(kvp.Value.Sum(c => c.Value.CompressedSize))); ImGui.TextUnformatted(UiSharedService.ByteToString(kvp.Value.Sum(c => c.Value.CompressedSize)));
_uiSharedService.ColoredSeparator(UIColors.Get("LightlessPurpleDefault"), 1.5f); UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurpleDefault"), 1.5f);
ImGui.TableNextColumn(); ImGui.TableNextColumn();
var vramUsage = groupedfiles.SingleOrDefault(v => string.Equals(v.Key, "tex", StringComparison.Ordinal)); var vramUsage = groupedfiles.SingleOrDefault(v => string.Equals(v.Key, "tex", StringComparison.Ordinal));
@@ -651,7 +651,7 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
ImGui.PopStyleVar(2); ImGui.PopStyleVar(2);
_uiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 2f); UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 2f);
_uiSharedService.MediumText("Selected file:", UIColors.Get("LightlessBlue")); _uiSharedService.MediumText("Selected file:", UIColors.Get("LightlessBlue"));
ImGui.SameLine(); ImGui.SameLine();

View File

@@ -7,14 +7,12 @@ using LightlessSync.Services.ServerConfiguration;
using LightlessSync.UI.Components; using LightlessSync.UI.Components;
using LightlessSync.UI.Handlers; using LightlessSync.UI.Handlers;
using LightlessSync.WebAPI; using LightlessSync.WebAPI;
using Microsoft.Extensions.Logging;
using System.Collections.Immutable; using System.Collections.Immutable;
namespace LightlessSync.UI; namespace LightlessSync.UI;
public class DrawEntityFactory public class DrawEntityFactory
{ {
private readonly ILogger<DrawEntityFactory> _logger;
private readonly ApiController _apiController; private readonly ApiController _apiController;
private readonly LightlessMediator _mediator; private readonly LightlessMediator _mediator;
private readonly SelectPairForTagUi _selectPairForTagUi; private readonly SelectPairForTagUi _selectPairForTagUi;
@@ -25,19 +23,16 @@ public class DrawEntityFactory
private readonly SelectTagForPairUi _selectTagForPairUi; private readonly SelectTagForPairUi _selectTagForPairUi;
private readonly RenamePairTagUi _renamePairTagUi; private readonly RenamePairTagUi _renamePairTagUi;
private readonly SelectTagForSyncshellUi _selectTagForSyncshellUi; private readonly SelectTagForSyncshellUi _selectTagForSyncshellUi;
private readonly RenameSyncshellTagUi _renameSyncshellTagUi;
private readonly SelectSyncshellForTagUi _selectSyncshellForTagUi;
private readonly TagHandler _tagHandler; private readonly TagHandler _tagHandler;
private readonly IdDisplayHandler _uidDisplayHandler; private readonly IdDisplayHandler _uidDisplayHandler;
public DrawEntityFactory(ILogger<DrawEntityFactory> logger, ApiController apiController, IdDisplayHandler uidDisplayHandler, public DrawEntityFactory(ApiController apiController, IdDisplayHandler uidDisplayHandler,
SelectTagForPairUi selectTagForPairUi, RenamePairTagUi renamePairTagUi, LightlessMediator mediator, SelectTagForPairUi selectTagForPairUi, RenamePairTagUi renamePairTagUi, LightlessMediator mediator,
TagHandler tagHandler, SelectPairForTagUi selectPairForTagUi, TagHandler tagHandler, SelectPairForTagUi selectPairForTagUi,
ServerConfigurationManager serverConfigurationManager, UiSharedService uiSharedService, ServerConfigurationManager serverConfigurationManager, UiSharedService uiSharedService,
PlayerPerformanceConfigService playerPerformanceConfigService, CharaDataManager charaDataManager, PlayerPerformanceConfigService playerPerformanceConfigService, CharaDataManager charaDataManager,
SelectTagForSyncshellUi selectTagForSyncshellUi, RenameSyncshellTagUi renameSyncshellTagUi, SelectSyncshellForTagUi selectSyncshellForTagUi) SelectTagForSyncshellUi selectTagForSyncshellUi, RenameSyncshellTagUi renameSyncshellTagUi, SelectSyncshellForTagUi selectSyncshellForTagUi)
{ {
_logger = logger;
_apiController = apiController; _apiController = apiController;
_uidDisplayHandler = uidDisplayHandler; _uidDisplayHandler = uidDisplayHandler;
_selectTagForPairUi = selectTagForPairUi; _selectTagForPairUi = selectTagForPairUi;
@@ -50,8 +45,6 @@ public class DrawEntityFactory
_playerPerformanceConfigService = playerPerformanceConfigService; _playerPerformanceConfigService = playerPerformanceConfigService;
_charaDataManager = charaDataManager; _charaDataManager = charaDataManager;
_selectTagForSyncshellUi = selectTagForSyncshellUi; _selectTagForSyncshellUi = selectTagForSyncshellUi;
_renameSyncshellTagUi = renameSyncshellTagUi;
_selectSyncshellForTagUi = selectSyncshellForTagUi;
} }
public DrawFolderGroup CreateDrawGroupFolder(GroupFullInfoDto groupFullInfoDto, public DrawFolderGroup CreateDrawGroupFolder(GroupFullInfoDto groupFullInfoDto,

View File

@@ -445,7 +445,7 @@ public sealed class DtrEntry : IDisposable, IHostedService
return ($"{icon} OFF", colors, tooltip.ToString()); return ($"{icon} OFF", colors, tooltip.ToString());
} }
private (string, Colors, string) FormatTooltip(string title, IEnumerable<string> names, string icon, Colors color) private static (string, Colors, string) FormatTooltip(string title, IEnumerable<string> names, string icon, Colors color)
{ {
var list = names.Where(x => !string.IsNullOrEmpty(x)).ToList(); var list = names.Where(x => !string.IsNullOrEmpty(x)).ToList();
var tooltip = new StringBuilder() var tooltip = new StringBuilder()

View File

@@ -171,7 +171,7 @@ public class EditProfileUi : WindowMediatorSubscriberBase
ImGui.Checkbox("Is NSFW", ref nsfw); ImGui.Checkbox("Is NSFW", ref nsfw);
ImGui.EndDisabled(); ImGui.EndDisabled();
_uiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f); UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
ImGui.EndTabItem(); ImGui.EndTabItem();
} }
@@ -293,7 +293,7 @@ public class EditProfileUi : WindowMediatorSubscriberBase
ImGui.BeginDisabled(); ImGui.BeginDisabled();
} }
_uiSharedService.ColoredSeparator(UIColors.Get("LightlessPurpleDefault"), 1.5f); UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurpleDefault"), 1.5f);
_uiSharedService.MediumText("Colored UID", UIColors.Get("LightlessPurple")); _uiSharedService.MediumText("Colored UID", UIColors.Get("LightlessPurple"));
ImGui.Dummy(new Vector2(5)); ImGui.Dummy(new Vector2(5));
@@ -377,7 +377,7 @@ public class EditProfileUi : WindowMediatorSubscriberBase
ImGui.EndDisabled(); ImGui.EndDisabled();
ImGui.Dummy(new Vector2(5)); ImGui.Dummy(new Vector2(5));
_uiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f); UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
if (!hasVanity) if (!hasVanity)
ImGui.EndDisabled(); ImGui.EndDisabled();

View File

@@ -1,5 +1,4 @@
using Dalamud.Bindings.ImGui; using Dalamud.Bindings.ImGui;
using Dalamud.Interface.Colors;
using Dalamud.Interface.Utility; using Dalamud.Interface.Utility;
using Dalamud.Interface.Utility.Raii; using Dalamud.Interface.Utility.Raii;
using LightlessSync.API.Data.Enum; using LightlessSync.API.Data.Enum;

View File

@@ -1,8 +1,6 @@
using Dalamud.Interface; using Dalamud.Interface;
using Dalamud.Interface.Colors;
using Dalamud.Interface.Utility; using Dalamud.Interface.Utility;
using Dalamud.Interface.Utility.Raii; using Dalamud.Interface.Utility.Raii;
using Dalamud.Interface.Windowing;
using LightlessSync.LightlessConfiguration; using LightlessSync.LightlessConfiguration;
using LightlessSync.LightlessConfiguration.Models; using LightlessSync.LightlessConfiguration.Models;
using LightlessSync.Services; using LightlessSync.Services;
@@ -27,11 +25,11 @@ public class LightlessNotificationUi : WindowMediatorSubscriberBase
private const float _titleMessageSpacing = 4f; private const float _titleMessageSpacing = 4f;
private const float _actionButtonSpacing = 8f; private const float _actionButtonSpacing = 8f;
private readonly List<LightlessNotification> _notifications = new(); private readonly List<LightlessNotification> _notifications = [];
private readonly object _notificationLock = new(); private readonly object _notificationLock = new();
private readonly LightlessConfigService _configService; private readonly LightlessConfigService _configService;
private readonly Dictionary<string, float> _notificationYOffsets = new(); private readonly Dictionary<string, float> _notificationYOffsets = [];
private readonly Dictionary<string, float> _notificationTargetYOffsets = new(); private readonly Dictionary<string, float> _notificationTargetYOffsets = [];
public LightlessNotificationUi(ILogger<LightlessNotificationUi> logger, LightlessMediator mediator, PerformanceCollectorService performanceCollector, LightlessConfigService configService) public LightlessNotificationUi(ILogger<LightlessNotificationUi> logger, LightlessMediator mediator, PerformanceCollectorService performanceCollector, LightlessConfigService configService)
: base(logger, mediator, "Lightless Notifications##LightlessNotifications", performanceCollector) : base(logger, mediator, "Lightless Notifications##LightlessNotifications", performanceCollector)
@@ -68,7 +66,7 @@ public class LightlessNotificationUi : WindowMediatorSubscriberBase
{ {
lock (_notificationLock) lock (_notificationLock)
{ {
var existingNotification = _notifications.FirstOrDefault(n => n.Id == notification.Id); var existingNotification = _notifications.FirstOrDefault(n => string.Equals(n.Id, notification.Id, StringComparison.Ordinal));
if (existingNotification != null) if (existingNotification != null)
{ {
UpdateExistingNotification(existingNotification, notification); UpdateExistingNotification(existingNotification, notification);
@@ -103,7 +101,7 @@ public class LightlessNotificationUi : WindowMediatorSubscriberBase
{ {
lock (_notificationLock) lock (_notificationLock)
{ {
var notification = _notifications.FirstOrDefault(n => n.Id == id); var notification = _notifications.FirstOrDefault(n => string.Equals(n.Id, id, StringComparison.Ordinal));
if (notification != null) if (notification != null)
{ {
StartOutAnimation(notification); StartOutAnimation(notification);
@@ -122,13 +120,13 @@ public class LightlessNotificationUi : WindowMediatorSubscriberBase
} }
} }
private void StartOutAnimation(LightlessNotification notification) private static void StartOutAnimation(LightlessNotification notification)
{ {
notification.IsAnimatingOut = true; notification.IsAnimatingOut = true;
notification.IsAnimatingIn = false; notification.IsAnimatingIn = false;
} }
private bool ShouldRemoveNotification(LightlessNotification notification) => private static bool ShouldRemoveNotification(LightlessNotification notification) =>
notification.IsAnimatingOut && notification.AnimationProgress <= 0.01f; notification.IsAnimatingOut && notification.AnimationProgress <= 0.01f;
protected override void DrawInternal() protected override void DrawInternal()
@@ -185,7 +183,7 @@ public class LightlessNotificationUi : WindowMediatorSubscriberBase
ImGui.SetCursorPosY(startY + yOffset); ImGui.SetCursorPosY(startY + yOffset);
} }
DrawNotification(notification, i); DrawNotification(notification);
} }
} }
@@ -304,7 +302,7 @@ public class LightlessNotificationUi : WindowMediatorSubscriberBase
return corner == NotificationCorner.Left ? new Vector2(-distance, 0) : new Vector2(distance, 0); return corner == NotificationCorner.Left ? new Vector2(-distance, 0) : new Vector2(distance, 0);
} }
private void DrawNotification(LightlessNotification notification, int index) private void DrawNotification(LightlessNotification notification)
{ {
var alpha = notification.AnimationProgress; var alpha = notification.AnimationProgress;
if (alpha <= 0f) return; if (alpha <= 0f) return;
@@ -370,7 +368,7 @@ public class LightlessNotificationUi : WindowMediatorSubscriberBase
return bgColor; return bgColor;
} }
private void DrawShadow(ImDrawListPtr drawList, Vector2 windowPos, Vector2 windowSize, float alpha) private static void DrawShadow(ImDrawListPtr drawList, Vector2 windowPos, Vector2 windowSize, float alpha)
{ {
var shadowOffset = new Vector2(1f, 1f); var shadowOffset = new Vector2(1f, 1f);
var shadowColor = new Vector4(0f, 0f, 0f, 0.4f * alpha); var shadowColor = new Vector4(0f, 0f, 0f, 0.4f * alpha);
@@ -394,7 +392,7 @@ public class LightlessNotificationUi : WindowMediatorSubscriberBase
} }
} }
private void DrawBackground(ImDrawListPtr drawList, Vector2 windowPos, Vector2 windowSize, Vector4 bgColor) private static void DrawBackground(ImDrawListPtr drawList, Vector2 windowPos, Vector2 windowSize, Vector4 bgColor)
{ {
drawList.AddRectFilled( drawList.AddRectFilled(
windowPos, windowPos,
@@ -431,7 +429,7 @@ public class LightlessNotificationUi : WindowMediatorSubscriberBase
); );
} }
private void DrawDurationProgressBar(LightlessNotification notification, float alpha, Vector2 windowPos, Vector2 windowSize, ImDrawListPtr drawList) private static void DrawDurationProgressBar(LightlessNotification notification, float alpha, Vector2 windowPos, Vector2 windowSize, ImDrawListPtr drawList)
{ {
var progress = CalculateDurationProgress(notification); var progress = CalculateDurationProgress(notification);
var progressBarColor = UIColors.Get("LightlessBlue"); var progressBarColor = UIColors.Get("LightlessBlue");
@@ -447,7 +445,7 @@ public class LightlessNotificationUi : WindowMediatorSubscriberBase
} }
} }
private void DrawDownloadProgressBar(LightlessNotification notification, float alpha, Vector2 windowPos, Vector2 windowSize, ImDrawListPtr drawList) private static void DrawDownloadProgressBar(LightlessNotification notification, float alpha, Vector2 windowPos, Vector2 windowSize, ImDrawListPtr drawList)
{ {
var progress = Math.Clamp(notification.Progress, 0f, 1f); var progress = Math.Clamp(notification.Progress, 0f, 1f);
var progressBarColor = UIColors.Get("LightlessGreen"); var progressBarColor = UIColors.Get("LightlessGreen");
@@ -464,14 +462,14 @@ public class LightlessNotificationUi : WindowMediatorSubscriberBase
} }
} }
private float CalculateDurationProgress(LightlessNotification notification) private static float CalculateDurationProgress(LightlessNotification notification)
{ {
// Calculate duration timer progress // Calculate duration timer progress
var elapsed = DateTime.UtcNow - notification.CreatedAt; var elapsed = DateTime.UtcNow - notification.CreatedAt;
return Math.Min(1.0f, (float)(elapsed.TotalSeconds / notification.Duration.TotalSeconds)); return Math.Min(1.0f, (float)(elapsed.TotalSeconds / notification.Duration.TotalSeconds));
} }
private void DrawProgressBackground(ImDrawListPtr drawList, Vector2 windowPos, Vector2 windowSize, float progressY, float progressHeight, Vector4 progressBarColor, float alpha) private static void DrawProgressBackground(ImDrawListPtr drawList, Vector2 windowPos, Vector2 windowSize, float progressY, float progressHeight, Vector4 progressBarColor, float alpha)
{ {
var bgProgressColor = new Vector4(progressBarColor.X * 0.3f, progressBarColor.Y * 0.3f, progressBarColor.Z * 0.3f, 0.5f * alpha); var bgProgressColor = new Vector4(progressBarColor.X * 0.3f, progressBarColor.Y * 0.3f, progressBarColor.Z * 0.3f, 0.5f * alpha);
drawList.AddRectFilled( drawList.AddRectFilled(
@@ -482,7 +480,7 @@ public class LightlessNotificationUi : WindowMediatorSubscriberBase
); );
} }
private void DrawProgressForeground(ImDrawListPtr drawList, Vector2 windowPos, float progressY, float progressHeight, float progressWidth, Vector4 progressBarColor, float alpha) private static void DrawProgressForeground(ImDrawListPtr drawList, Vector2 windowPos, float progressY, float progressHeight, float progressWidth, Vector4 progressBarColor, float alpha)
{ {
var progressColor = progressBarColor; var progressColor = progressBarColor;
progressColor.W *= alpha; progressColor.W *= alpha;
@@ -512,13 +510,13 @@ public class LightlessNotificationUi : WindowMediatorSubscriberBase
} }
} }
private float CalculateContentWidth(float windowWidth) => private static float CalculateContentWidth(float windowWidth) =>
windowWidth - (_contentPaddingX * 2); windowWidth - (_contentPaddingX * 2);
private bool HasActions(LightlessNotification notification) => private static bool HasActions(LightlessNotification notification) =>
notification.Actions.Count > 0; notification.Actions.Count > 0;
private void PositionActionsAtBottom(float windowHeight) private static void PositionActionsAtBottom(float windowHeight)
{ {
var actionHeight = ImGui.GetFrameHeight(); var actionHeight = ImGui.GetFrameHeight();
var bottomY = windowHeight - _contentPaddingY - actionHeight; var bottomY = windowHeight - _contentPaddingY - actionHeight;
@@ -546,7 +544,7 @@ public class LightlessNotificationUi : WindowMediatorSubscriberBase
return $"[{timestamp}] {notification.Title}"; return $"[{timestamp}] {notification.Title}";
} }
private float DrawWrappedText(string text, float wrapWidth) private static float DrawWrappedText(string text, float wrapWidth)
{ {
ImGui.PushTextWrapPos(ImGui.GetCursorPosX() + wrapWidth); ImGui.PushTextWrapPos(ImGui.GetCursorPosX() + wrapWidth);
var startY = ImGui.GetCursorPosY(); var startY = ImGui.GetCursorPosY();
@@ -556,7 +554,7 @@ public class LightlessNotificationUi : WindowMediatorSubscriberBase
return height; return height;
} }
private void DrawMessage(LightlessNotification notification, Vector2 contentPos, float contentWidth, float titleHeight, float alpha) private static void DrawMessage(LightlessNotification notification, Vector2 contentPos, float contentWidth, float titleHeight, float alpha)
{ {
if (string.IsNullOrEmpty(notification.Message)) return; if (string.IsNullOrEmpty(notification.Message)) return;
@@ -591,13 +589,13 @@ public class LightlessNotificationUi : WindowMediatorSubscriberBase
} }
} }
private float CalculateActionButtonWidth(int actionCount, float availableWidth) private static float CalculateActionButtonWidth(int actionCount, float availableWidth)
{ {
var totalSpacing = (actionCount - 1) * _actionButtonSpacing; var totalSpacing = (actionCount - 1) * _actionButtonSpacing;
return (availableWidth - totalSpacing) / actionCount; return (availableWidth - totalSpacing) / actionCount;
} }
private void PositionActionButton(int index, float startX, float buttonWidth) private static void PositionActionButton(int index, float startX, float buttonWidth)
{ {
var xPosition = startX + index * (buttonWidth + _actionButtonSpacing); var xPosition = startX + index * (buttonWidth + _actionButtonSpacing);
ImGui.SetCursorPosX(xPosition); ImGui.SetCursorPosX(xPosition);
@@ -625,7 +623,7 @@ public class LightlessNotificationUi : WindowMediatorSubscriberBase
if (action.Icon != FontAwesomeIcon.None) if (action.Icon != FontAwesomeIcon.None)
{ {
buttonPressed = DrawIconTextButton(action.Icon, action.Label, buttonWidth, alpha); buttonPressed = DrawIconTextButton(action.Icon, action.Label, buttonWidth);
} }
else else
{ {
@@ -650,10 +648,10 @@ public class LightlessNotificationUi : WindowMediatorSubscriberBase
} }
} }
private bool DrawIconTextButton(FontAwesomeIcon icon, string text, float width, float alpha) private static bool DrawIconTextButton(FontAwesomeIcon icon, string text, float width)
{ {
var drawList = ImGui.GetWindowDrawList(); var drawList = ImGui.GetWindowDrawList();
var cursorPos = ImGui.GetCursorScreenPos(); ImGui.GetCursorScreenPos();
var frameHeight = ImGui.GetFrameHeight(); var frameHeight = ImGui.GetFrameHeight();
Vector2 iconSize; Vector2 iconSize;
@@ -729,7 +727,7 @@ public class LightlessNotificationUi : WindowMediatorSubscriberBase
return ImGui.CalcTextSize(titleText, true, contentWidth).Y; return ImGui.CalcTextSize(titleText, true, contentWidth).Y;
} }
private float CalculateMessageHeight(LightlessNotification notification, float contentWidth) private static float CalculateMessageHeight(LightlessNotification notification, float contentWidth)
{ {
if (string.IsNullOrEmpty(notification.Message)) return 0f; if (string.IsNullOrEmpty(notification.Message)) return 0f;
@@ -737,7 +735,7 @@ public class LightlessNotificationUi : WindowMediatorSubscriberBase
return 4f + messageHeight; return 4f + messageHeight;
} }
private Vector4 GetNotificationAccentColor(NotificationType type) private static Vector4 GetNotificationAccentColor(NotificationType type)
{ {
return type switch return type switch
{ {

View File

@@ -539,7 +539,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
} }
} }
private bool DrawStyleResetButton(string key, bool hasOverride, string? tooltipOverride = null) private static bool DrawStyleResetButton(string key, bool hasOverride, string? tooltipOverride = null)
{ {
using var id = ImRaii.PushId($"reset-{key}"); using var id = ImRaii.PushId($"reset-{key}");
using var disabled = ImRaii.Disabled(!hasOverride); using var disabled = ImRaii.Disabled(!hasOverride);
@@ -663,7 +663,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
_uiShared.DrawHelpText("Controls how many uploads can run at once."); _uiShared.DrawHelpText("Controls how many uploads can run at once.");
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurple"), 2f); UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 2f);
if (ImGui.Checkbox("Enable Pair Download Limiter", ref limitPairApplications)) if (ImGui.Checkbox("Enable Pair Download Limiter", ref limitPairApplications))
{ {
@@ -710,7 +710,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
ImGui.TextColored(ImGuiColors.DalamudGrey, "Pair apply limiter is disabled."); ImGui.TextColored(ImGuiColors.DalamudGrey, "Pair apply limiter is disabled.");
} }
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurple"), 2f); UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 2f);
if (ImGui.Checkbox("Use Alternative Upload Method", ref useAlternativeUpload)) if (ImGui.Checkbox("Use Alternative Upload Method", ref useAlternativeUpload))
{ {
@@ -826,13 +826,10 @@ public class SettingsUi : WindowMediatorSubscriberBase
using var tree = ImRaii.TreeNode("Speed Test to Servers"); using var tree = ImRaii.TreeNode("Speed Test to Servers");
if (tree) if (tree)
{ {
if (_downloadServersTask == null || ((_downloadServersTask?.IsCompleted ?? false) && if ((_downloadServersTask == null || ((_downloadServersTask?.IsCompleted ?? false) &&
(!_downloadServersTask?.IsCompletedSuccessfully ?? false))) (!_downloadServersTask?.IsCompletedSuccessfully ?? false))) && _uiShared.IconTextButton(FontAwesomeIcon.GroupArrowsRotate, "Update Download Server List"))
{ {
if (_uiShared.IconTextButton(FontAwesomeIcon.GroupArrowsRotate, "Update Download Server List")) _downloadServersTask = GetDownloadServerList();
{
_downloadServersTask = GetDownloadServerList();
}
} }
if (_downloadServersTask != null && _downloadServersTask.IsCompleted && if (_downloadServersTask != null && _downloadServersTask.IsCompleted &&
@@ -1063,9 +1060,9 @@ public class SettingsUi : WindowMediatorSubscriberBase
.DeserializeAsync<List<string>>(await result.Content.ReadAsStreamAsync().ConfigureAwait(false)) .DeserializeAsync<List<string>>(await result.Content.ReadAsStreamAsync().ConfigureAwait(false))
.ConfigureAwait(false); .ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception)
{ {
_logger.LogWarning(ex, "Failed to get download server list"); _logger.LogWarning("Failed to get download server list");
throw; throw;
} }
} }
@@ -1146,7 +1143,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
UiSharedService.TooltipSeparator UiSharedService.TooltipSeparator
+ "Keeping LOD enabled can lead to more crashes. Use at your own risk."); + "Keeping LOD enabled can lead to more crashes. Use at your own risk.");
_uiShared.ColoredSeparator(UIColors.Get("LightlessYellow"), 2f); UiSharedService.ColoredSeparator(UIColors.Get("LightlessYellow"), 2f);
} }
private void DrawFileStorageSettings() private void DrawFileStorageSettings()
@@ -1348,7 +1345,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
} }
} }
_uiShared.ColoredSeparator(UIColors.Get("LightlessYellow"), 1.5f); UiSharedService.ColoredSeparator(UIColors.Get("LightlessYellow"), 1.5f);
ImGui.TreePop(); ImGui.TreePop();
} }
@@ -1380,7 +1377,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
} }
catch (IOException ex) catch (IOException ex)
{ {
_logger.LogWarning(ex, $"Could not delete file {file} because it is in use."); _logger.LogWarning(ex, "Could not delete file {file} because it is in use.", file);
} }
} }
}); });
@@ -1398,7 +1395,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
ImGui.EndDisabled(); ImGui.EndDisabled();
ImGui.Unindent(); ImGui.Unindent();
_uiShared.ColoredSeparator(UIColors.Get("DimRed"), 1.5f); UiSharedService.ColoredSeparator(UIColors.Get("DimRed"), 1.5f);
ImGui.TreePop(); ImGui.TreePop();
} }
} }
@@ -1411,8 +1408,6 @@ public class SettingsUi : WindowMediatorSubscriberBase
} }
_lastTab = "General"; _lastTab = "General";
//UiSharedService.FontText("Experimental", _uiShared.UidFont);
//ImGui.Separator();
_uiShared.UnderlinedBigText("General Settings", UIColors.Get("LightlessBlue")); _uiShared.UnderlinedBigText("General Settings", UIColors.Get("LightlessBlue"));
ImGui.Dummy(new Vector2(10)); ImGui.Dummy(new Vector2(10));
@@ -1449,7 +1444,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
ImGuiColors.DalamudRed); ImGuiColors.DalamudRed);
} }
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f); UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
ImGui.TreePop(); ImGui.TreePop();
} }
@@ -1477,7 +1472,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
_uiShared.DrawHelpText( _uiShared.DrawHelpText(
"This will automatically populate user notes using the first encountered player name if the note was not set prior"); "This will automatically populate user notes using the first encountered player name if the note was not set prior");
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f); UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
ImGui.TreePop(); ImGui.TreePop();
} }
@@ -1545,7 +1540,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
} }
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f); UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
ImGui.TreePop(); ImGui.TreePop();
} }
@@ -1585,7 +1580,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
} }
_uiShared.DrawHelpText("When enabled, Lightfinder will automatically turn on after reconnecting to the Lightless server."); _uiShared.DrawHelpText("When enabled, Lightfinder will automatically turn on after reconnecting to the Lightless server.");
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurpleDefault"), 1.5f); UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurpleDefault"), 1.5f);
ImGui.TextUnformatted("Lightfinder Nameplate Colors"); ImGui.TextUnformatted("Lightfinder Nameplate Colors");
if (ImGui.BeginTable("##LightfinderColorTable", 3, ImGuiTableFlags.Borders | ImGuiTableFlags.RowBg | ImGuiTableFlags.SizingFixedFit)) if (ImGui.BeginTable("##LightfinderColorTable", 3, ImGuiTableFlags.Borders | ImGuiTableFlags.RowBg | ImGuiTableFlags.SizingFixedFit))
@@ -1641,7 +1636,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
ImGui.Spacing(); ImGui.Spacing();
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurpleDefault"), 1.5f); UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurpleDefault"), 1.5f);
ImGui.TextUnformatted("Lightfinder Info Bar"); ImGui.TextUnformatted("Lightfinder Info Bar");
if (ImGui.Checkbox("Show Lightfinder status in Server info bar", ref showLightfinderInDtr)) if (ImGui.Checkbox("Show Lightfinder status in Server info bar", ref showLightfinderInDtr))
@@ -1737,7 +1732,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
} }
ImGui.EndDisabled(); ImGui.EndDisabled();
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurpleDefault"), 1.5f); UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurpleDefault"), 1.5f);
ImGui.TextUnformatted("Alignment"); ImGui.TextUnformatted("Alignment");
ImGui.BeginDisabled(autoAlign); ImGui.BeginDisabled(autoAlign);
@@ -1862,7 +1857,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
} }
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurpleDefault"), 1.5f); UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurpleDefault"), 1.5f);
ImGui.TextUnformatted("Visibility"); ImGui.TextUnformatted("Visibility");
var showOwn = _configService.Current.LightfinderLabelShowOwn; var showOwn = _configService.Current.LightfinderLabelShowOwn;
@@ -1900,7 +1895,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
} }
_uiShared.DrawHelpText("Toggles Lightfinder label when no nameplate(s) is visible."); _uiShared.DrawHelpText("Toggles Lightfinder label when no nameplate(s) is visible.");
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurpleDefault"), 1.5f); UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurpleDefault"), 1.5f);
ImGui.TextUnformatted("Label"); ImGui.TextUnformatted("Label");
var useIcon = _configService.Current.LightfinderLabelUseIcon; var useIcon = _configService.Current.LightfinderLabelUseIcon;
@@ -2006,7 +2001,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
_lightfinderIconPresetIndex = -1; _lightfinderIconPresetIndex = -1;
} }
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f); UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
ImGui.TreePop(); ImGui.TreePop();
} }
@@ -2094,7 +2089,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
ImGui.Spacing(); ImGui.Spacing();
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurpleDefault"), 1.5f); UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurpleDefault"), 1.5f);
ImGui.TextUnformatted("Server Info Bar Colors"); ImGui.TextUnformatted("Server Info Bar Colors");
@@ -2146,7 +2141,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
ImGui.Spacing(); ImGui.Spacing();
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurpleDefault"), 1.5f); UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurpleDefault"), 1.5f);
ImGui.TextUnformatted("Nameplate Colors"); ImGui.TextUnformatted("Nameplate Colors");
@@ -2199,7 +2194,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
ImGui.Spacing(); ImGui.Spacing();
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurpleDefault"), 1.5f); UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurpleDefault"), 1.5f);
ImGui.TextUnformatted("UI Theme"); ImGui.TextUnformatted("UI Theme");
@@ -2221,7 +2216,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
DrawThemeOverridesSection(); DrawThemeOverridesSection();
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f); UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
ImGui.TreePop(); ImGui.TreePop();
} }
@@ -2319,7 +2314,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
_configService.Save(); _configService.Save();
} }
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f); UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
ImGui.TreePop(); ImGui.TreePop();
} }
@@ -2362,7 +2357,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
_uiShared.DrawHelpText("Will show profiles that have the NSFW tag enabled"); _uiShared.DrawHelpText("Will show profiles that have the NSFW tag enabled");
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f); UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
ImGui.TreePop(); ImGui.TreePop();
} }
ImGui.Separator(); ImGui.Separator();
@@ -2444,7 +2439,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
+ "Default: 165 thousand"); + "Default: 165 thousand");
} }
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f); UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
ImGui.TreePop(); ImGui.TreePop();
} }
@@ -2548,7 +2543,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
+ "Default: 250 thousand"); + "Default: 250 thousand");
} }
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f); UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
ImGui.TreePop(); ImGui.TreePop();
} }
@@ -2696,7 +2691,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
ImGui.EndPopup(); ImGui.EndPopup();
} }
_uiShared.ColoredSeparator(UIColors.Get("DimRed"), 1.5f); UiSharedService.ColoredSeparator(UIColors.Get("DimRed"), 1.5f);
ImGui.TreePop(); ImGui.TreePop();
} }
@@ -3274,15 +3269,13 @@ public class SettingsUi : WindowMediatorSubscriberBase
private int _lastSelectedServerIndex = -1; private int _lastSelectedServerIndex = -1;
private Task<(bool Success, bool PartialSuccess, string Result)>? _secretKeysConversionTask = null; private Task<(bool Success, bool PartialSuccess, string Result)>? _secretKeysConversionTask = null;
private CancellationTokenSource _secretKeysConversionCts = new CancellationTokenSource(); private CancellationTokenSource _secretKeysConversionCts = new();
private async Task<(bool Success, bool partialSuccess, string Result)> ConvertSecretKeysToUIDs( private async Task<(bool Success, bool partialSuccess, string Result)> ConvertSecretKeysToUIDs(
ServerStorage serverStorage, CancellationToken token) ServerStorage serverStorage, CancellationToken token)
{ {
List<Authentication> failedConversions = serverStorage.Authentications List<Authentication> failedConversions = [.. serverStorage.Authentications.Where(u => u.SecretKeyIdx == -1 && string.IsNullOrEmpty(u.UID))];
.Where(u => u.SecretKeyIdx == -1 && string.IsNullOrEmpty(u.UID)).ToList(); List<Authentication> conversionsToAttempt = [.. serverStorage.Authentications.Where(u => u.SecretKeyIdx != -1 && string.IsNullOrEmpty(u.UID))];
List<Authentication> conversionsToAttempt = serverStorage.Authentications
.Where(u => u.SecretKeyIdx != -1 && string.IsNullOrEmpty(u.UID)).ToList();
List<Authentication> successfulConversions = []; List<Authentication> successfulConversions = [];
Dictionary<string, List<Authentication>> secretKeyMapping = new(StringComparer.Ordinal); Dictionary<string, List<Authentication>> secretKeyMapping = new(StringComparer.Ordinal);
foreach (var authEntry in conversionsToAttempt) foreach (var authEntry in conversionsToAttempt)
@@ -3352,6 +3345,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
sb.Append(string.Join(", ", failedConversions.Select(k => k.CharacterName))); sb.Append(string.Join(", ", failedConversions.Select(k => k.CharacterName)));
} }
_secretKeysConversionCts.Dispose();
return (true, failedConversions.Count != 0, sb.ToString()); return (true, failedConversions.Count != 0, sb.ToString());
} }
@@ -3720,7 +3714,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
ImGui.Unindent(); ImGui.Unindent();
} }
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f); UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
ImGui.TreePop(); ImGui.TreePop();
} }
@@ -3762,7 +3756,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
_uiShared.DrawHelpText("Click anywhere on a notification to dismiss it. Notifications with action buttons (like pair requests) are excluded."); _uiShared.DrawHelpText("Click anywhere on a notification to dismiss it. Notifications with action buttons (like pair requests) are excluded.");
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f); UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
ImGui.TreePop(); ImGui.TreePop();
} }
@@ -3925,7 +3919,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
ImGui.SetTooltip("Right click to reset to default (3)."); ImGui.SetTooltip("Right click to reset to default (3).");
_uiShared.DrawHelpText("Width of the colored accent bar on the left side."); _uiShared.DrawHelpText("Width of the colored accent bar on the left side.");
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f); UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
ImGui.TreePop(); ImGui.TreePop();
} }
} }
@@ -4020,7 +4014,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
if (ImGui.IsItemHovered()) if (ImGui.IsItemHovered())
ImGui.SetTooltip("Right click to reset to default (20)."); ImGui.SetTooltip("Right click to reset to default (20).");
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f); UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
ImGui.TreePop(); ImGui.TreePop();
} }
@@ -4035,7 +4029,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
_uiShared.DrawHelpText( _uiShared.DrawHelpText(
"Configure which sounds play for each notification type. Use the play button to preview sounds."); "Configure which sounds play for each notification type. Use the play button to preview sounds.");
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f); UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
ImGui.TreePop(); ImGui.TreePop();
} }
@@ -4083,7 +4077,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
"Only show online notifications for pairs where you have set an individual note."); "Only show online notifications for pairs where you have set an individual note.");
ImGui.Unindent(); ImGui.Unindent();
_uiShared.ColoredSeparator(UIColors.Get("LightlessGreen"), 1.5f); UiSharedService.ColoredSeparator(UIColors.Get("LightlessGreen"), 1.5f);
ImGui.TreePop(); ImGui.TreePop();
} }
@@ -4099,7 +4093,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
_uiShared.DrawHelpText( _uiShared.DrawHelpText(
"When you receive a pair request, show Accept/Decline buttons in the notification."); "When you receive a pair request, show Accept/Decline buttons in the notification.");
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f); UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
ImGui.TreePop(); ImGui.TreePop();
} }
@@ -4115,7 +4109,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
_uiShared.DrawHelpText( _uiShared.DrawHelpText(
"When a player exceeds performance thresholds or is auto-paused, show Pause/Unpause buttons in the notification."); "When a player exceeds performance thresholds or is auto-paused, show Pause/Unpause buttons in the notification.");
_uiShared.ColoredSeparator(UIColors.Get("LightlessOrange"), 1.5f); UiSharedService.ColoredSeparator(UIColors.Get("LightlessOrange"), 1.5f);
ImGui.TreePop(); ImGui.TreePop();
} }
@@ -4130,7 +4124,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
_uiShared.DrawHelpText("Disable warning notifications for missing optional plugins."); _uiShared.DrawHelpText("Disable warning notifications for missing optional plugins.");
_uiShared.ColoredSeparator(UIColors.Get("LightlessYellow"), 1.5f); UiSharedService.ColoredSeparator(UIColors.Get("LightlessYellow"), 1.5f);
ImGui.TreePop(); ImGui.TreePop();
} }
@@ -4140,32 +4134,32 @@ public class SettingsUi : WindowMediatorSubscriberBase
} }
} }
private NotificationLocation[] GetLightlessNotificationLocations() private static NotificationLocation[] GetLightlessNotificationLocations()
{ {
return new[] return
{ [
NotificationLocation.LightlessUi, NotificationLocation.Chat, NotificationLocation.ChatAndLightlessUi, NotificationLocation.Nowhere NotificationLocation.LightlessUi, NotificationLocation.Chat, NotificationLocation.ChatAndLightlessUi, NotificationLocation.Nowhere
}; ];
} }
private NotificationLocation[] GetDownloadNotificationLocations() private static NotificationLocation[] GetDownloadNotificationLocations()
{ {
return new[] return
{ [
NotificationLocation.LightlessUi, NotificationLocation.TextOverlay, NotificationLocation.Nowhere NotificationLocation.LightlessUi, NotificationLocation.TextOverlay, NotificationLocation.Nowhere
}; ];
} }
private NotificationLocation[] GetClassicNotificationLocations() private static NotificationLocation[] GetClassicNotificationLocations()
{ {
return new[] return
{ [
NotificationLocation.Toast, NotificationLocation.Chat, NotificationLocation.Both, NotificationLocation.Toast, NotificationLocation.Chat, NotificationLocation.Both,
NotificationLocation.Nowhere NotificationLocation.Nowhere
}; ];
} }
private string GetNotificationLocationLabel(NotificationLocation location) private static string GetNotificationLocationLabel(NotificationLocation location)
{ {
return location switch return location switch
{ {
@@ -4180,7 +4174,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
}; };
} }
private string GetNotificationCornerLabel(NotificationCorner corner) private static string GetNotificationCornerLabel(NotificationCorner corner)
{ {
return corner switch return corner switch
{ {

View File

@@ -552,7 +552,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
} }
} }
} }
_uiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f); UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
ImGui.TreePop(); ImGui.TreePop();
} }
ImGui.Separator(); ImGui.Separator();
@@ -643,7 +643,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
UiSharedService.TextWrapped($"Syncshell was pruned and {_pruneTask.Result} inactive user(s) have been removed."); UiSharedService.TextWrapped($"Syncshell was pruned and {_pruneTask.Result} inactive user(s) have been removed.");
} }
} }
_uiSharedService.ColoredSeparator(UIColors.Get("DimRed"), 1.5f); UiSharedService.ColoredSeparator(UIColors.Get("DimRed"), 1.5f);
ImGui.TreePop(); ImGui.TreePop();
} }
ImGui.Separator(); ImGui.Separator();
@@ -689,7 +689,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
} }
ImGui.EndTable(); ImGui.EndTable();
} }
_uiSharedService.ColoredSeparator(UIColors.Get("LightlessYellow"), 1.5f); UiSharedService.ColoredSeparator(UIColors.Get("LightlessYellow"), 1.5f);
ImGui.TreePop(); ImGui.TreePop();
} }
ImGui.Separator(); ImGui.Separator();

View File

@@ -73,7 +73,7 @@ public class SyncshellFinderUI : WindowMediatorSubscriberBase
protected override void DrawInternal() protected override void DrawInternal()
{ {
_uiSharedService.MediumText("Nearby Syncshells", UIColors.Get("PairBlue")); _uiSharedService.MediumText("Nearby Syncshells", UIColors.Get("PairBlue"));
_uiSharedService.ColoredSeparator(UIColors.Get("PairBlue")); UiSharedService.ColoredSeparator(UIColors.Get("PairBlue"));
if (_nearbySyncshells.Count == 0) if (_nearbySyncshells.Count == 0)
{ {
@@ -82,7 +82,7 @@ public class SyncshellFinderUI : WindowMediatorSubscriberBase
if (!_broadcastService.IsBroadcasting) if (!_broadcastService.IsBroadcasting)
{ {
_uiSharedService.ColoredSeparator(UIColors.Get("LightlessYellow")); UiSharedService.ColoredSeparator(UIColors.Get("LightlessYellow"));
ImGui.TextColored(UIColors.Get("LightlessYellow"), "Lightfinder is currently disabled, to locate nearby syncshells, Lightfinder must be active."); ImGui.TextColored(UIColors.Get("LightlessYellow"), "Lightfinder is currently disabled, to locate nearby syncshells, Lightfinder must be active.");
ImGuiHelpers.ScaledDummy(0.5f); ImGuiHelpers.ScaledDummy(0.5f);

View File

@@ -40,7 +40,7 @@ namespace LightlessSync.UI
return HexToRgba(customColorHex); return HexToRgba(customColorHex);
if (!DefaultHexColors.TryGetValue(name, out var hex)) if (!DefaultHexColors.TryGetValue(name, out var hex))
throw new ArgumentException($"Color '{name}' not found in UIColors."); throw new ArgumentException($"Color '{name}' not found in UIColors.", nameof(name));
return HexToRgba(hex); return HexToRgba(hex);
} }
@@ -48,7 +48,7 @@ namespace LightlessSync.UI
public static void Set(string name, Vector4 color) public static void Set(string name, Vector4 color)
{ {
if (!DefaultHexColors.ContainsKey(name)) if (!DefaultHexColors.ContainsKey(name))
throw new ArgumentException($"Color '{name}' not found in UIColors."); throw new ArgumentException($"Color '{name}' not found in UIColors.", nameof(name));
if (_configService != null) if (_configService != null)
{ {
@@ -78,7 +78,7 @@ namespace LightlessSync.UI
public static Vector4 GetDefault(string name) public static Vector4 GetDefault(string name)
{ {
if (!DefaultHexColors.TryGetValue(name, out var hex)) if (!DefaultHexColors.TryGetValue(name, out var hex))
throw new ArgumentException($"Color '{name}' not found in UIColors."); throw new ArgumentException($"Color '{name}' not found in UIColors.", nameof(name));
return HexToRgba(hex); return HexToRgba(hex);
} }

View File

@@ -475,7 +475,7 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
); );
} }
public void ColoredSeparator(Vector4? color = null, float thickness = 1f, float indent = 0f) public static void ColoredSeparator(Vector4? color = null, float thickness = 1f, float indent = 0f)
{ {
var drawList = ImGui.GetWindowDrawList(); var drawList = ImGui.GetWindowDrawList();
var min = ImGui.GetCursorScreenPos(); var min = ImGui.GetCursorScreenPos();
@@ -494,7 +494,7 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
ImGui.Dummy(new Vector2(0, thickness * ImGuiHelpers.GlobalScale)); ImGui.Dummy(new Vector2(0, thickness * ImGuiHelpers.GlobalScale));
} }
public void RoundedSeparator(Vector4? color = null, float thickness = 2f, float indent = 0f, float rounding = 4f) public static void RoundedSeparator(Vector4? color = null, float thickness = 2f, float indent = 0f, float rounding = 4f)
{ {
float scale = ImGuiHelpers.GlobalScale; float scale = ImGuiHelpers.GlobalScale;

View File

@@ -17,7 +17,7 @@ public static class Crypto
{ {
using SHA1 sha1 = SHA1.Create(); using SHA1 sha1 = SHA1.Create();
using FileStream stream = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete); using FileStream stream = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
return BitConverter.ToString(sha1.ComputeHash(stream)).Replace("-", "", StringComparison.Ordinal); return Convert.ToHexString(sha1.ComputeHash(stream));
} }
public static async Task<string> GetFileHashAsync(string filePath, CancellationToken cancellationToken = default) public static async Task<string> GetFileHashAsync(string filePath, CancellationToken cancellationToken = default)