diff --git a/RemoteDownloaderPlugin/Game/GameDownload.cs b/RemoteDownloaderPlugin/Game/GameDownload.cs index 3a58df5..b17bcf9 100644 --- a/RemoteDownloaderPlugin/Game/GameDownload.cs +++ b/RemoteDownloaderPlugin/Game/GameDownload.cs @@ -15,10 +15,12 @@ public class GameDownload : ProgressStatus public string Version { get; private set; } public GameType Type { get; private set; } public string BaseFileName { get; private set; } + public ContentTypes InstalledEntries { get; private set; } public GameDownload(IEntry entry) { _entry = entry; + InstalledEntries = new(); } private void OnProgressUpdate(object? obj, float progress) @@ -65,6 +67,7 @@ private async Task DownloadEmu(IApp app, EmuEntry entry) for (int i = 0; i < entry.Files.Count; i++) { + Progress localProcess = new(); localProcess.ProgressChanged += (sender, f) => { @@ -75,7 +78,8 @@ private async Task DownloadEmu(IApp app, EmuEntry entry) var fileEntry = entry.Files[i]; var destPath = Path.Join(fileEntry.Type == "base" ? basePath : extraFilesPath, fileEntry.Name); - + InstalledEntries.Add(fileEntry.Type); + if (fileEntry.Type == "base") { baseGamePath = destPath; diff --git a/RemoteDownloaderPlugin/Game/InstalledGame.cs b/RemoteDownloaderPlugin/Game/InstalledGame.cs index da4259c..f17c155 100644 --- a/RemoteDownloaderPlugin/Game/InstalledGame.cs +++ b/RemoteDownloaderPlugin/Game/InstalledGame.cs @@ -15,6 +15,15 @@ public class InstalledGame : IGame public long? Size => Game.GameSize; public bool HasImage(ImageType type) => ImageTypeToUri(type) != null; + + public bool IsEmu => _type == GameType.Emu; + + public ContentTypes InstalledContentTypes => IsEmu + ? _emuGame.Types + : new ContentTypes() + { + Base = 1 + }; public Task GetImage(ImageType type) { @@ -28,11 +37,11 @@ public bool HasImage(ImageType type) public InstalledStatus InstalledStatus => InstalledStatus.Installed; - public Platform EstimatedGamePlatform => (_type == GameType.Emu) + public Platform EstimatedGamePlatform => IsEmu ? LauncherGamePlugin.Utils.GuessPlatformBasedOnString(_plugin.Storage.Data.EmuProfiles.FirstOrDefault(x => x.Platform == _emuGame!.Emu)?.ExecPath) : LauncherGamePlugin.Utils.GuessPlatformBasedOnString(_pcLaunchDetails!.LaunchExec); - public string GamePlatform => (_type == GameType.Emu) + public string GamePlatform => IsEmu ? _emuGame!.Emu : "Pc"; @@ -70,7 +79,7 @@ public void Play() { try { - if (_type == GameType.Emu) + if (IsEmu) { var emuProfile = _plugin.Storage.Data.EmuProfiles.FirstOrDefault(x => x.Platform == _emuGame!.Emu); @@ -103,7 +112,7 @@ public void Play() public void Delete() { - if (_type == GameType.Emu) + if (IsEmu) { var baseGamePath = Path.Join(_plugin.App.GameDir, "Remote", _emuGame!.Emu, _emuGame.BaseFilename); var extraDir = Path.Join(_plugin.App.GameDir, "Remote", _emuGame!.Emu, Game.Id); @@ -152,7 +161,7 @@ public void Delete() public void OpenInFileManager() { - LauncherGamePlugin.Utils.OpenFolder(_type == GameType.Emu + LauncherGamePlugin.Utils.OpenFolder(IsEmu ? Path.Join(_plugin.App.GameDir, "Remote", _emuGame!.Emu) : Path.Join(_plugin.App.GameDir, "Remote", "Pc", Game.Id)); } diff --git a/RemoteDownloaderPlugin/Game/OnlineGame.cs b/RemoteDownloaderPlugin/Game/OnlineGame.cs index 96ed2cb..16e7b31 100644 --- a/RemoteDownloaderPlugin/Game/OnlineGame.cs +++ b/RemoteDownloaderPlugin/Game/OnlineGame.cs @@ -72,7 +72,8 @@ public async Task Download() GameSize = _download.TotalSize, Version = _download.Version, BaseFilename = _download.BaseFileName, - Images = Entry.Img + Images = Entry.Img, + Types = _download.InstalledEntries }); } else diff --git a/RemoteDownloaderPlugin/Plugin.cs b/RemoteDownloaderPlugin/Plugin.cs index 723e369..1c6313e 100644 --- a/RemoteDownloaderPlugin/Plugin.cs +++ b/RemoteDownloaderPlugin/Plugin.cs @@ -55,19 +55,32 @@ public List GetGameCommands(IGame game) if (game is InstalledGame installedGame) { - return new() + var commands = new List() { new Command(game.IsRunning ? "Running" : "Launch", installedGame.Play), new Command("Open in File Manager", installedGame.OpenInFileManager), new Command($"Version: {installedGame.Game.Version}"), new Command($"Platform: {installedGame.GamePlatform}"), - new Command("Uninstall", () => - App.Show2ButtonTextPrompt($"Do you want to uninstall {game.Name}?", "Yes", "No", _ => - { - installedGame.Delete(); - App.HideForm(); - }, _ => App.HideForm(), game)) }; + + if (installedGame.IsEmu) + { + commands.Add(new()); + commands.Add(new($"Base: {installedGame.InstalledContentTypes.Base}")); + commands.Add(new($"Update: {installedGame.InstalledContentTypes.Update}")); + commands.Add(new($"Dlc: {installedGame.InstalledContentTypes.Dlc}")); + commands.Add(new($"Extra: {installedGame.InstalledContentTypes.Extra}")); + commands.Add(new()); + } + + commands.Add(new Command("Uninstall", () => + App.Show2ButtonTextPrompt($"Do you want to uninstall {game.Name}?", "Yes", "No", _ => + { + installedGame.Delete(); + App.HideForm(); + }, _ => App.HideForm(), game))); + + return commands; } throw new NotImplementedException(); diff --git a/RemoteDownloaderPlugin/Store.cs b/RemoteDownloaderPlugin/Store.cs index 9ac7dd8..805f589 100644 --- a/RemoteDownloaderPlugin/Store.cs +++ b/RemoteDownloaderPlugin/Store.cs @@ -17,6 +17,33 @@ public interface IInstalledGame public Images Images { get; } } +public class ContentTypes +{ + public int Base { get; set; } + public int Update { get; set; } + public int Dlc { get; set; } + public int Extra { get; set; } + + public void Add(string type) + { + switch (type) + { + case "base": + Base++; + break; + case "update": + Update++; + break; + case "dlc": + Dlc++; + break; + case "extra": + Extra++; + break; + } + } +} + public class InstalledEmuGame : IInstalledGame { public string Id { get; set; } @@ -26,6 +53,7 @@ public class InstalledEmuGame : IInstalledGame public string Version { get; set; } public string BaseFilename { get; set; } public Images Images { get; set; } + public ContentTypes Types { get; set; } = new(); } public class InstalledPcGame : IInstalledGame