From 95e7f2daa7607676e38bc8d55524358553e4db0c Mon Sep 17 00:00:00 2001 From: choco Date: Mon, 10 Nov 2025 21:59:20 +0100 Subject: [PATCH] download notification progress and download bar, chat only option for notifications (idk why you would bother even enabling the lightless nofis then) --- .../Configurations/LightlessConfig.cs | 2 +- LightlessSync/UI/DownloadUi.cs | 17 --------- LightlessSync/UI/LightlessNotificationUI.cs | 35 +++++++++++++++---- LightlessSync/UI/SettingsUi.cs | 6 ++-- 4 files changed, 32 insertions(+), 28 deletions(-) diff --git a/LightlessSync/LightlessConfiguration/Configurations/LightlessConfig.cs b/LightlessSync/LightlessConfiguration/Configurations/LightlessConfig.cs index f849c87..929cbbc 100644 --- a/LightlessSync/LightlessConfiguration/Configurations/LightlessConfig.cs +++ b/LightlessSync/LightlessConfiguration/Configurations/LightlessConfig.cs @@ -113,7 +113,7 @@ public class LightlessConfig : ILightlessConfiguration public int WarningNotificationDurationSeconds { get; set; } = 15; public int ErrorNotificationDurationSeconds { get; set; } = 20; public int PairRequestDurationSeconds { get; set; } = 180; - public int DownloadNotificationDurationSeconds { get; set; } = 300; + public int DownloadNotificationDurationSeconds { get; set; } = 30; public int PerformanceNotificationDurationSeconds { get; set; } = 20; public uint CustomInfoSoundId { get; set; } = 2; // Se2 public uint CustomWarningSoundId { get; set; } = 16; // Se15 diff --git a/LightlessSync/UI/DownloadUi.cs b/LightlessSync/UI/DownloadUi.cs index 4f64c38..aa3132a 100644 --- a/LightlessSync/UI/DownloadUi.cs +++ b/LightlessSync/UI/DownloadUi.cs @@ -24,8 +24,6 @@ public class DownloadUi : WindowMediatorSubscriberBase private readonly ConcurrentDictionary _uploadingPlayers = new(); private bool _notificationDismissed = true; private int _lastDownloadStateHash = 0; - private DateTime _lastNotificationUpdate = DateTime.MinValue; - private const int NotificationAutoCloseSeconds = 15; public DownloadUi(ILogger logger, DalamudUtilService dalamudUtilService, LightlessConfigService configService, PairProcessingLimiter pairProcessingLimiter, FileUploadManager fileTransferManager, LightlessMediator mediator, UiSharedService uiShared, @@ -149,20 +147,6 @@ public class DownloadUi : WindowMediatorSubscriberBase _notificationDismissed = true; _lastDownloadStateHash = 0; } - - // Auto-dismiss notification if no updates for 15 seconds - if (!_notificationDismissed && _lastNotificationUpdate != DateTime.MinValue) - { - var timeSinceLastUpdate = (DateTime.UtcNow - _lastNotificationUpdate).TotalSeconds; - if (timeSinceLastUpdate > NotificationAutoCloseSeconds) - { - _logger.LogDebug("Auto-dismissing download notification after {Seconds}s of inactivity", timeSinceLastUpdate); - Mediator.Publish(new LightlessNotificationDismissMessage("pair_download_progress")); - _notificationDismissed = true; - _lastDownloadStateHash = 0; - _lastNotificationUpdate = DateTime.MinValue; - } - } } else { @@ -379,7 +363,6 @@ public class DownloadUi : WindowMediatorSubscriberBase if (currentHash != _lastDownloadStateHash) { _lastDownloadStateHash = currentHash; - _lastNotificationUpdate = DateTime.UtcNow; if (downloadStatus.Count > 0 || queueWaiting > 0) { Mediator.Publish(new PairDownloadStatusMessage(downloadStatus, queueWaiting)); diff --git a/LightlessSync/UI/LightlessNotificationUI.cs b/LightlessSync/UI/LightlessNotificationUI.cs index 65a6c69..8cb6922 100644 --- a/LightlessSync/UI/LightlessNotificationUI.cs +++ b/LightlessSync/UI/LightlessNotificationUI.cs @@ -90,7 +90,8 @@ public class LightlessNotificationUi : WindowMediatorSubscriberBase existing.ShowProgress = updated.ShowProgress; existing.Title = updated.Title; - if (updated.Type == NotificationType.Download && updated.Progress < 1.0f) + // Reset the duration timer on every update for download notifications + if (updated.Type == NotificationType.Download) { existing.CreatedAt = DateTime.UtcNow; } @@ -344,6 +345,13 @@ public class LightlessNotificationUi : WindowMediatorSubscriberBase DrawBackground(drawList, windowPos, windowSize, bgColor); DrawAccentBar(drawList, windowPos, windowSize, accentColor); DrawDurationProgressBar(notification, alpha, windowPos, windowSize, drawList); + + // Draw download progress bar above duration bar for download notifications + if (notification.Type == NotificationType.Download && notification.ShowProgress) + { + DrawDownloadProgressBar(notification, alpha, windowPos, windowSize, drawList); + } + DrawNotificationText(notification, alpha); } @@ -425,7 +433,7 @@ public class LightlessNotificationUi : WindowMediatorSubscriberBase private void DrawDurationProgressBar(LightlessNotification notification, float alpha, Vector2 windowPos, Vector2 windowSize, ImDrawListPtr drawList) { - var progress = CalculateProgress(notification); + var progress = CalculateDurationProgress(notification); var progressBarColor = UIColors.Get("LightlessBlue"); var progressHeight = 2f; var progressY = windowPos.Y + windowSize.Y - progressHeight; @@ -439,13 +447,26 @@ public class LightlessNotificationUi : WindowMediatorSubscriberBase } } - private float CalculateProgress(LightlessNotification notification) + private void DrawDownloadProgressBar(LightlessNotification notification, float alpha, Vector2 windowPos, Vector2 windowSize, ImDrawListPtr drawList) { - if (notification.Type == NotificationType.Download && notification.ShowProgress) - { - return Math.Clamp(notification.Progress, 0f, 1f); - } + var progress = Math.Clamp(notification.Progress, 0f, 1f); + var progressBarColor = UIColors.Get("LightlessGreen"); + var progressHeight = 3f; + // Position above the duration bar (2px duration bar + 1px spacing) + var progressY = windowPos.Y + windowSize.Y - progressHeight - 3f; + var progressWidth = windowSize.X * progress; + DrawProgressBackground(drawList, windowPos, windowSize, progressY, progressHeight, progressBarColor, alpha); + + if (progress > 0) + { + DrawProgressForeground(drawList, windowPos, progressY, progressHeight, progressWidth, progressBarColor, alpha); + } + } + + private float CalculateDurationProgress(LightlessNotification notification) + { + // Calculate duration timer progress var elapsed = DateTime.UtcNow - notification.CreatedAt; return Math.Min(1.0f, (float)(elapsed.TotalSeconds / notification.Duration.TotalSeconds)); } diff --git a/LightlessSync/UI/SettingsUi.cs b/LightlessSync/UI/SettingsUi.cs index c841fd7..1b8aa12 100644 --- a/LightlessSync/UI/SettingsUi.cs +++ b/LightlessSync/UI/SettingsUi.cs @@ -3993,9 +3993,9 @@ public class SettingsUi : WindowMediatorSubscriberBase ImGui.SetTooltip("Right click to reset to default (180)."); int downloadDuration = _configService.Current.DownloadNotificationDurationSeconds; - if (ImGui.SliderInt("Download Duration (seconds)", ref downloadDuration, 60, 120)) + if (ImGui.SliderInt("Download Duration (seconds)", ref downloadDuration, 15, 120)) { - _configService.Current.DownloadNotificationDurationSeconds = Math.Clamp(downloadDuration, 60, 120); + _configService.Current.DownloadNotificationDurationSeconds = Math.Clamp(downloadDuration, 15, 120); _configService.Save(); } if (ImGui.IsItemClicked(ImGuiMouseButton.Right)) @@ -4144,7 +4144,7 @@ public class SettingsUi : WindowMediatorSubscriberBase { return new[] { - NotificationLocation.LightlessUi, NotificationLocation.ChatAndLightlessUi, NotificationLocation.Nowhere + NotificationLocation.LightlessUi, NotificationLocation.Chat, NotificationLocation.ChatAndLightlessUi, NotificationLocation.Nowhere }; }