2024-08-04 17:53:19 -05:00
|
|
|
|
using LANCommander.Launcher.Data.Models;
|
2024-08-08 18:28:33 -05:00
|
|
|
|
using LANCommander.SDK.Helpers;
|
2024-05-23 23:41:38 -05:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
2024-05-25 15:40:31 -05:00
|
|
|
|
using System.Collections.ObjectModel;
|
2024-05-23 23:41:38 -05:00
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
2024-08-04 17:53:19 -05:00
|
|
|
|
namespace LANCommander.Launcher.Models
|
2024-05-23 23:41:38 -05:00
|
|
|
|
{
|
2024-11-09 17:15:04 -06:00
|
|
|
|
public enum ListItemState
|
2024-05-25 15:40:31 -05:00
|
|
|
|
{
|
|
|
|
|
|
NotInstalled,
|
|
|
|
|
|
Installed,
|
|
|
|
|
|
Queued,
|
|
|
|
|
|
Installing,
|
2025-01-27 00:04:42 -06:00
|
|
|
|
UpdateAvailable,
|
|
|
|
|
|
Uninstalling,
|
2024-05-25 15:40:31 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-09 17:15:04 -06:00
|
|
|
|
public enum ListItemType
|
2024-05-23 23:41:38 -05:00
|
|
|
|
{
|
|
|
|
|
|
Game,
|
|
|
|
|
|
Redistributable
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-09 17:15:04 -06:00
|
|
|
|
public class ListItem
|
2024-05-23 23:41:38 -05:00
|
|
|
|
{
|
|
|
|
|
|
public Guid Key { get; set; }
|
2024-06-05 19:03:04 -05:00
|
|
|
|
public Guid IconId { get; set; }
|
2024-11-09 17:15:04 -06:00
|
|
|
|
public ListItemType Type { get; set; }
|
|
|
|
|
|
public ListItemState State { get; set; }
|
2024-05-23 23:41:38 -05:00
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
|
public string SortName { get; set; }
|
2024-07-08 19:15:57 -05:00
|
|
|
|
public string[] Groups { get; set; }
|
2024-05-23 23:41:38 -05:00
|
|
|
|
public object DataItem { get; set; }
|
|
|
|
|
|
|
2024-11-09 17:15:04 -06:00
|
|
|
|
public ListItem(Collection collection)
|
2024-05-23 23:41:38 -05:00
|
|
|
|
{
|
|
|
|
|
|
Key = collection.Id;
|
2024-11-09 17:15:04 -06:00
|
|
|
|
Type = ListItemType.Game;
|
2024-05-23 23:41:38 -05:00
|
|
|
|
Name = collection.Name;
|
|
|
|
|
|
DataItem = collection;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-09 17:15:04 -06:00
|
|
|
|
public ListItem(Game game)
|
2024-05-23 23:41:38 -05:00
|
|
|
|
{
|
|
|
|
|
|
Key = game.Id;
|
2024-11-09 17:15:04 -06:00
|
|
|
|
Type = ListItemType.Game;
|
2024-05-23 23:41:38 -05:00
|
|
|
|
Name = game.Title;
|
|
|
|
|
|
SortName = game.SortTitle;
|
|
|
|
|
|
DataItem = game;
|
2024-05-25 15:40:31 -05:00
|
|
|
|
|
2024-08-08 18:28:33 -05:00
|
|
|
|
var manifestPath = ManifestHelper.GetPath(game.InstallDirectory, game.Id);
|
|
|
|
|
|
|
2024-05-25 15:40:31 -05:00
|
|
|
|
if (game.Installed && !String.IsNullOrWhiteSpace(game.LatestVersion) && game.InstalledVersion != game.LatestVersion)
|
2024-11-09 17:15:04 -06:00
|
|
|
|
State = ListItemState.UpdateAvailable;
|
2024-08-08 18:28:33 -05:00
|
|
|
|
else if (game.Installed && File.Exists(manifestPath))
|
2024-11-09 17:15:04 -06:00
|
|
|
|
State = ListItemState.Installed;
|
2024-05-25 15:40:31 -05:00
|
|
|
|
else
|
2024-11-09 17:15:04 -06:00
|
|
|
|
State = ListItemState.NotInstalled;
|
2024-06-05 19:03:04 -05:00
|
|
|
|
|
2024-06-19 19:36:04 -05:00
|
|
|
|
var icon = game.Media.FirstOrDefault(m => m.Type == SDK.Enums.MediaType.Icon);
|
2024-06-05 19:03:04 -05:00
|
|
|
|
|
|
|
|
|
|
if (icon != null)
|
|
|
|
|
|
IconId = icon.Id;
|
2024-05-23 23:41:38 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-09 17:15:04 -06:00
|
|
|
|
public ListItem(Redistributable redistributable)
|
2024-05-23 23:41:38 -05:00
|
|
|
|
{
|
|
|
|
|
|
Key = redistributable.Id;
|
2024-11-09 17:15:04 -06:00
|
|
|
|
Type = ListItemType.Redistributable;
|
2024-05-23 23:41:38 -05:00
|
|
|
|
Name = redistributable.Name;
|
|
|
|
|
|
DataItem = redistributable;
|
|
|
|
|
|
}
|
2024-11-09 17:15:04 -06:00
|
|
|
|
|
|
|
|
|
|
public ListItem(SDK.Models.Game game)
|
|
|
|
|
|
{
|
|
|
|
|
|
Key = game.Id;
|
|
|
|
|
|
Type = ListItemType.Game;
|
|
|
|
|
|
Name = game.Title;
|
|
|
|
|
|
SortName = game.SortTitle;
|
|
|
|
|
|
DataItem = game;
|
|
|
|
|
|
}
|
2024-11-12 02:35:28 -06:00
|
|
|
|
|
|
|
|
|
|
public ListItem(SDK.Models.DepotGame game)
|
|
|
|
|
|
{
|
|
|
|
|
|
Key = game.Id;
|
|
|
|
|
|
Type = ListItemType.Game;
|
|
|
|
|
|
Name = game.Title;
|
|
|
|
|
|
SortName = game.SortTitle;
|
|
|
|
|
|
DataItem = game;
|
|
|
|
|
|
}
|
2024-05-23 23:41:38 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|