download notification progress and download bar, chat only option for notifications (idk why you would bother even enabling the lightless nofis then)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -24,8 +24,6 @@ public class DownloadUi : WindowMediatorSubscriberBase
|
||||
private readonly ConcurrentDictionary<GameObjectHandler, bool> _uploadingPlayers = new();
|
||||
private bool _notificationDismissed = true;
|
||||
private int _lastDownloadStateHash = 0;
|
||||
private DateTime _lastNotificationUpdate = DateTime.MinValue;
|
||||
private const int NotificationAutoCloseSeconds = 15;
|
||||
|
||||
public DownloadUi(ILogger<DownloadUi> 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));
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user