Smoothed download bar, fixed many warnings
This commit is contained in:
@@ -23,6 +23,7 @@ public class DownloadUi : WindowMediatorSubscriberBase
|
||||
private readonly UiSharedService _uiShared;
|
||||
private readonly PairProcessingLimiter _pairProcessingLimiter;
|
||||
private readonly ConcurrentDictionary<GameObjectHandler, bool> _uploadingPlayers = new();
|
||||
private readonly Dictionary<GameObjectHandler, Vector2> _smoothed = [];
|
||||
private bool _notificationDismissed = true;
|
||||
private int _lastDownloadStateHash = 0;
|
||||
|
||||
@@ -204,8 +205,18 @@ 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);
|
||||
|
||||
Reference in New Issue
Block a user