LANCommander/LANCommander.Launcher/Models/DownloadQueueGame.cs
Pat Hartl 9ba9887eb1 Rename project files, namespaces, artifacts
Client has been renamed to launcher, and thus namespaces and artifact names had to change. The server project has also had some artifacts renamed in order to create a more clear separation of builds. This will break auto-updates before v0.9.0.
2024-08-04 17:53:19 -05:00

71 lines
2.2 KiB
C#

using LANCommander.Launcher.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LANCommander.Launcher.Models
{
internal class DownloadQueueGame : IDownloadQueueItem
{
public Guid Id { get; set; }
public string Title { get; set; }
public string Version { get; set; }
public Guid CoverId { get; set; }
public Guid IconId { get; set; }
public DateTime QueuedOn { get; set; }
public DateTime? CompletedOn { get; set; }
public bool IsUpdate { get; set; }
public bool State {
get
{
switch (Status)
{
case DownloadStatus.Downloading:
case DownloadStatus.InstallingRedistributables:
case DownloadStatus.InstallingMods:
case DownloadStatus.InstallingExpansions:
case DownloadStatus.RunningScripts:
case DownloadStatus.DownloadingSaves:
return true;
default:
return false;
}
}
}
public DownloadStatus Status { get; set; }
public SDK.Models.Game Game { get; set; }
public float Progress {
get
{
return BytesDownloaded / (float)TotalBytes;
}
set { }
}
public double TransferSpeed { get; set; }
public long BytesDownloaded { get; set; }
public long TotalBytes { get; set; }
public DownloadQueueGame(SDK.Models.Game game)
{
Game = game;
Id = game.Id;
Title = game.Title;
Version = game.Archives.OrderByDescending(a => a.CreatedOn).FirstOrDefault()?.Version;
QueuedOn = DateTime.Now;
Status = DownloadStatus.Idle;
var cover = game.Media.FirstOrDefault(m => m.Type == SDK.Enums.MediaType.Cover);
if (cover != null)
CoverId = cover.Id;
var icon = game.Media.FirstOrDefault(m => m.Type == SDK.Enums.MediaType.Icon);
if (icon != null)
IconId = icon.Id;
}
}
}