LANCommander/LANCommander.Launcher/UI/Components/CurrentDownloadItem.razor
Pat Hartl 27d6ea6486 Add ability to modify a game's installation
- DownloadService has been renamed to InstallService
- In the library item context menu, there is a new option "Modify". This allows the user to selsct any additional addons to install as well as move the game to a separate storage location.
- Fixed issue where transfers were being double updated for installs
- Force UI update whenever queue is updates
2024-10-26 15:48:47 -05:00

72 lines
2.6 KiB
Text

@using LANCommander.Launcher.Models
@using System.Diagnostics
@inject InstallService InstallService
@inject SDK.Client Client
@inject GameService GameService
@if (CurrentQueueItem != null)
{
<div class="downloader-current">
@if (ShowIcon)
{
<div class="downloader-current-icon">
<MediaImage Id="@CurrentQueueItem.IconId" />
</div>
}
<div class="downloader-current-info">
<div class="downloader-current-upper">
<div class="downloader-current-upper-status">
@if (CurrentQueueItem.Status == SDK.Enums.GameInstallStatus.Downloading && CurrentQueueItem.Progress > 0)
{
<Text>@CurrentQueueItem.Status.GetDisplayName(): @CurrentQueueItem.Progress.ToString("0%")</Text>
}
else
{
<Text>@CurrentQueueItem.Status.GetDisplayName()</Text>
}
</div>
@if (CurrentQueueItem.TransferSpeed > 0)
{
<div class="downloader-current-upper-time-remaining">
@TimeSpan.FromSeconds((CurrentQueueItem.TotalBytes - CurrentQueueItem.BytesDownloaded) / CurrentQueueItem.TransferSpeed).ToShortTime()
</div>
}
</div>
<div class="downloader-current-progress">
<Progress Percent="(CurrentQueueItem.Progress * 100)" />
</div>
<div class="downloader-current-lower">
<div class="downloader-current-lower-data">
@ByteSizeLib.ByteSize.FromBytes(CurrentQueueItem.BytesDownloaded).ToString() / @ByteSizeLib.ByteSize.FromBytes(CurrentQueueItem.TotalBytes).ToString()
</div>
<div class="downloader-current-lower-speed">
@ByteSizeLib.ByteSize.FromBytes(CurrentQueueItem.TransferSpeed).ToString()/s
</div>
</div>
</div>
</div>
}
@code {
[Parameter] public bool ShowIcon { get; set; }
IInstallQueueItem CurrentQueueItem = null;
Stopwatch Stopwatch = new Stopwatch();
protected override async Task OnInitializedAsync()
{
InstallService.OnInstallComplete += async (game) =>
{
Stopwatch.Stop();
};
InstallService.OnQueueChanged += async () =>
{
CurrentQueueItem = InstallService.Queue.OrderByDescending(qi => qi.QueuedOn).FirstOrDefault(qi => qi.State);
await InvokeAsync(StateHasChanged);
await Task.Yield();
};
}
}