From b4dd0ee0e1546173939191a9dcd7f6351613e9ac Mon Sep 17 00:00:00 2001 From: choco Date: Mon, 20 Oct 2025 14:32:21 +0200 Subject: [PATCH] type cleanup --- LightlessSync/Plugin.cs | 6 +-- LightlessSync/UI/LightlessNotificationUI.cs | 46 ++++++++++----------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/LightlessSync/Plugin.cs b/LightlessSync/Plugin.cs index 54a879e..01a4de4 100644 --- a/LightlessSync/Plugin.cs +++ b/LightlessSync/Plugin.cs @@ -255,9 +255,9 @@ public sealed class Plugin : IDalamudPlugin collection.AddScoped((s) => new BroadcastUI(s.GetRequiredService>(), s.GetRequiredService(), s.GetRequiredService(), s.GetRequiredService(), s.GetRequiredService(), s.GetRequiredService(), s.GetRequiredService(), s.GetRequiredService())); collection.AddScoped((s) => new SyncshellFinderUI(s.GetRequiredService>(), s.GetRequiredService(), s.GetRequiredService(), s.GetRequiredService(), s.GetRequiredService(), s.GetRequiredService(), s.GetRequiredService(), s.GetRequiredService(), s.GetRequiredService())); collection.AddScoped(); - collection.AddScoped((s) => - new LightlessNotificationUI( - s.GetRequiredService>(), + collection.AddScoped((s) => + new LightlessNotificationUi( + s.GetRequiredService>(), s.GetRequiredService(), s.GetRequiredService(), s.GetRequiredService())); diff --git a/LightlessSync/UI/LightlessNotificationUI.cs b/LightlessSync/UI/LightlessNotificationUI.cs index 2ac26b7..3d2d748 100644 --- a/LightlessSync/UI/LightlessNotificationUI.cs +++ b/LightlessSync/UI/LightlessNotificationUI.cs @@ -15,17 +15,17 @@ using Dalamud.Bindings.ImGui; namespace LightlessSync.UI; -public class LightlessNotificationUI : WindowMediatorSubscriberBase +public class LightlessNotificationUi : WindowMediatorSubscriberBase { - private const float NotificationMinHeight = 60f; - private const float NotificationMaxHeight = 250f; - private const float WindowPaddingOffset = 6f; - private const float SlideAnimationDistance = 100f; - private const float OutAnimationSpeedMultiplier = 0.7f; - private const float ContentPaddingX = 10f; - private const float ContentPaddingY = 6f; - private const float TitleMessageSpacing = 4f; - private const float ActionButtonSpacing = 8f; + private const float _notificationMinHeight = 60f; + private const float _notificationMaxHeight = 250f; + private const float _windowPaddingOffset = 6f; + private const float _slideAnimationDistance = 100f; + private const float _outAnimationSpeedMultiplier = 0.7f; + private const float _contentPaddingX = 10f; + private const float _contentPaddingY = 6f; + private const float _titleMessageSpacing = 4f; + private const float _actionButtonSpacing = 8f; private readonly List _notifications = new(); private readonly object _notificationLock = new(); @@ -33,7 +33,7 @@ public class LightlessNotificationUI : WindowMediatorSubscriberBase private readonly Dictionary _notificationYOffsets = new(); private readonly Dictionary _notificationTargetYOffsets = new(); - public LightlessNotificationUI(ILogger logger, LightlessMediator mediator, PerformanceCollectorService performanceCollector, LightlessConfigService configService) + public LightlessNotificationUi(ILogger logger, LightlessMediator mediator, PerformanceCollectorService performanceCollector, LightlessConfigService configService) : base(logger, mediator, "Lightless Notifications##LightlessNotifications", performanceCollector) { _configService = configService; @@ -155,8 +155,8 @@ public class LightlessNotificationUI : WindowMediatorSubscriberBase var width = _configService.Current.NotificationWidth; float posX = corner == NotificationCorner.Left - ? viewport.WorkPos.X + offsetX - WindowPaddingOffset - : viewport.WorkPos.X + viewport.WorkSize.X - width - offsetX - WindowPaddingOffset; + ? viewport.WorkPos.X + offsetX - _windowPaddingOffset + : viewport.WorkPos.X + viewport.WorkSize.X - width - offsetX - _windowPaddingOffset; return new Vector2(posX, viewport.WorkPos.Y); } @@ -274,7 +274,7 @@ public class LightlessNotificationUI : WindowMediatorSubscriberBase else if (notification.IsAnimatingOut && notification.AnimationProgress > 0f) { notification.AnimationProgress = Math.Max(0f, - notification.AnimationProgress - deltaTime * _configService.Current.NotificationAnimationSpeed * OutAnimationSpeedMultiplier); + notification.AnimationProgress - deltaTime * _configService.Current.NotificationAnimationSpeed * _outAnimationSpeedMultiplier); } else if (!notification.IsAnimatingOut && !notification.IsDismissed) { @@ -289,7 +289,7 @@ public class LightlessNotificationUI : WindowMediatorSubscriberBase private Vector2 CalculateSlideOffset(float alpha) { - var distance = (1f - alpha) * SlideAnimationDistance; + var distance = (1f - alpha) * _slideAnimationDistance; var corner = _configService.Current.NotificationCorner; return corner == NotificationCorner.Left ? new Vector2(-distance, 0) : new Vector2(distance, 0); } @@ -466,7 +466,7 @@ public class LightlessNotificationUI : WindowMediatorSubscriberBase private void DrawNotificationText(LightlessNotification notification, float alpha) { - var contentPos = new Vector2(ContentPaddingX, ContentPaddingY); + var contentPos = new Vector2(_contentPaddingX, _contentPaddingY); var windowSize = ImGui.GetWindowSize(); var contentWidth = CalculateContentWidth(windowSize.X); @@ -483,7 +483,7 @@ public class LightlessNotificationUI : WindowMediatorSubscriberBase } private float CalculateContentWidth(float windowWidth) => - windowWidth - (ContentPaddingX * 2); + windowWidth - (_contentPaddingX * 2); private bool HasActions(LightlessNotification notification) => notification.Actions.Count > 0; @@ -491,9 +491,9 @@ public class LightlessNotificationUI : WindowMediatorSubscriberBase private void PositionActionsAtBottom(float windowHeight) { var actionHeight = ImGui.GetFrameHeight(); - var bottomY = windowHeight - ContentPaddingY - actionHeight; + var bottomY = windowHeight - _contentPaddingY - actionHeight; ImGui.SetCursorPosY(bottomY); - ImGui.SetCursorPosX(ContentPaddingX); + ImGui.SetCursorPosX(_contentPaddingX); } private float DrawTitle(LightlessNotification notification, float contentWidth, float alpha) @@ -530,7 +530,7 @@ public class LightlessNotificationUI : WindowMediatorSubscriberBase { if (string.IsNullOrEmpty(notification.Message)) return; - var messagePos = contentPos + new Vector2(0f, titleHeight + TitleMessageSpacing); + var messagePos = contentPos + new Vector2(0f, titleHeight + _titleMessageSpacing); var messageColor = new Vector4(0.9f, 0.9f, 0.9f, alpha); ImGui.SetCursorPos(messagePos); @@ -563,13 +563,13 @@ public class LightlessNotificationUI : WindowMediatorSubscriberBase private float CalculateActionButtonWidth(int actionCount, float availableWidth) { - var totalSpacing = (actionCount - 1) * ActionButtonSpacing; + var totalSpacing = (actionCount - 1) * _actionButtonSpacing; return (availableWidth - totalSpacing) / actionCount; } private void PositionActionButton(int index, float startX, float buttonWidth) { - var xPosition = startX + index * (buttonWidth + ActionButtonSpacing); + var xPosition = startX + index * (buttonWidth + _actionButtonSpacing); ImGui.SetCursorPosX(xPosition); } @@ -687,7 +687,7 @@ public class LightlessNotificationUI : WindowMediatorSubscriberBase height += 12f; } - return Math.Clamp(height, NotificationMinHeight, NotificationMaxHeight); + return Math.Clamp(height, _notificationMinHeight, _notificationMaxHeight); } private float CalculateTitleHeight(LightlessNotification notification, float contentWidth)