diff --git a/LightlessSync/UI/DownloadUi.cs b/LightlessSync/UI/DownloadUi.cs index a592e43..9080d3a 100644 --- a/LightlessSync/UI/DownloadUi.cs +++ b/LightlessSync/UI/DownloadUi.cs @@ -17,6 +17,7 @@ public class DownloadUi : WindowMediatorSubscriberBase { private readonly LightlessConfigService _configService; private readonly ConcurrentDictionary> _currentDownloads = new(); + private readonly Dictionary _smoothed = []; private readonly DalamudUtilService _dalamudUtilService; private readonly FileUploadManager _fileTransferManager; private readonly UiSharedService _uiShared; @@ -195,8 +196,19 @@ public class DownloadUi : WindowMediatorSubscriberBase foreach (var transfer in _currentDownloads.ToList()) { - var screenPos = _dalamudUtilService.WorldToScreen(transfer.Key.GetGameObject()); - if (screenPos == Vector2.Zero) continue; + var transferKey = transfer.Key; + var rawPos = _dalamudUtilService.WorldToScreen(transferKey.GetGameObject()); + + //If RawPos is zero, remove it from smoothed dictionary + if (rawPos == Vector2.Zero) + { + _smoothed.Remove(transferKey); + continue; + } + + //Smoothing out the movement and fix jitter around the position. + Vector2 screenPos = _smoothed.TryGetValue(transferKey, out var lastPos) ? (rawPos - lastPos).Length() < 4f ? lastPos : rawPos : rawPos; + _smoothed[transferKey] = screenPos; var totalBytes = transfer.Value.Sum(c => c.Value.TotalBytes); var transferredBytes = transfer.Value.Sum(c => c.Value.TransferredBytes);