Added another try on fetching download status
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using Dalamud.Bindings.ImGui;
|
using Dalamud.Bindings.ImGui;
|
||||||
|
using Dalamud.Game.ClientState.Statuses;
|
||||||
using Dalamud.Interface.Colors;
|
using Dalamud.Interface.Colors;
|
||||||
using LightlessSync.LightlessConfiguration;
|
using LightlessSync.LightlessConfiguration;
|
||||||
using LightlessSync.LightlessConfiguration.Models;
|
using LightlessSync.LightlessConfiguration.Models;
|
||||||
@@ -167,22 +168,30 @@ public class DownloadUi : WindowMediatorSubscriberBase
|
|||||||
List<KeyValuePair<GameObjectHandler, Dictionary<string, FileDownloadStatus>>> transfers;
|
List<KeyValuePair<GameObjectHandler, Dictionary<string, FileDownloadStatus>>> transfers;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
transfers = _currentDownloads.ToList();
|
transfers = _currentDownloads?.ToList() ?? [];
|
||||||
}
|
}
|
||||||
catch (ArgumentException)
|
catch (ArgumentException)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
foreach (var transfer in transfers)
|
foreach (var transfer in transfers)
|
||||||
{
|
{
|
||||||
var transferKey = transfer.Key;
|
var transferKey = transfer.Key;
|
||||||
|
if (transferKey is null)
|
||||||
// Skip if no valid game object
|
|
||||||
if (transferKey.GetGameObject() == null)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
var statusDict = transfer.Value;
|
||||||
|
if (statusDict is null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var gameObj = transferKey.GetGameObject();
|
||||||
|
if (gameObj is null)
|
||||||
|
{
|
||||||
|
_smoothed.Remove(transferKey);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
var rawPos = _dalamudUtilService.WorldToScreen(transferKey.GetGameObject());
|
var rawPos = _dalamudUtilService.WorldToScreen(transferKey.GetGameObject());
|
||||||
|
|
||||||
// If RawPos is zero, remove it from smoothed dictionary
|
// If RawPos is zero, remove it from smoothed dictionary
|
||||||
@@ -207,25 +216,29 @@ public class DownloadUi : WindowMediatorSubscriberBase
|
|||||||
var dlProg = 0;
|
var dlProg = 0;
|
||||||
var dlDecomp = 0;
|
var dlDecomp = 0;
|
||||||
|
|
||||||
foreach (var entry in transfer.Value)
|
try
|
||||||
{
|
{
|
||||||
var fileStatus = entry.Value;
|
foreach (var entry in statusDict)
|
||||||
switch (fileStatus.DownloadStatus)
|
|
||||||
{
|
{
|
||||||
case DownloadStatus.WaitingForSlot:
|
var fileStatus = entry.Value;
|
||||||
dlSlot++;
|
if (fileStatus is null) continue;
|
||||||
break;
|
|
||||||
case DownloadStatus.WaitingForQueue:
|
totalBytes += fileStatus.TotalBytes;
|
||||||
dlQueue++;
|
transferredBytes += fileStatus.TransferredBytes;
|
||||||
break;
|
|
||||||
case DownloadStatus.Downloading:
|
switch (fileStatus.DownloadStatus)
|
||||||
dlProg++;
|
{
|
||||||
break;
|
case DownloadStatus.WaitingForSlot: dlSlot++; break;
|
||||||
case DownloadStatus.Decompressing:
|
case DownloadStatus.WaitingForQueue: dlQueue++; break;
|
||||||
dlDecomp++;
|
case DownloadStatus.Downloading: dlProg++; break;
|
||||||
break;
|
case DownloadStatus.Decompressing: dlDecomp++; break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (InvalidOperationException)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
string statusText;
|
string statusText;
|
||||||
if (dlProg > 0)
|
if (dlProg > 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user