From 281ff0d7d35b7ee56eac1eb219f0e3bccd0c40c3 Mon Sep 17 00:00:00 2001 From: hawkeye116477 Date: Fri, 19 Jan 2024 00:15:36 +0100 Subject: [PATCH] Small bugfixes * Wait until legendary closes and then move game * Fixes for launchable DLCs --- src/LegendaryDownloadManager.xaml.cs | 11 ++++------- src/LegendaryLibrary.cs | 1 + 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/LegendaryDownloadManager.xaml.cs b/src/LegendaryDownloadManager.xaml.cs index 75c56e6..5b49c18 100644 --- a/src/LegendaryDownloadManager.xaml.cs +++ b/src/LegendaryDownloadManager.xaml.cs @@ -161,7 +161,7 @@ public async Task EnqueueJob(string gameID, string gameTitle, string downloadSiz } } - public async Task WaitUntilLegendaryCloses() + public static async Task WaitUntilLegendaryCloses() { if (File.Exists(Path.Combine(LegendaryLauncher.ConfigPath, "installed.json.lock"))) { @@ -319,22 +319,19 @@ public async Task Install(string gameID, string gameTitle, string downloadSize, { var installedGameInfo = installedAppList[gameID]; Playnite.SDK.Models.Game game = new Playnite.SDK.Models.Game(); - if (installedGameInfo.Is_dlc == false) + if (installedGameInfo.Is_dlc == false || !installedGameInfo.Executable.IsNullOrEmpty()) { game = playniteAPI.Database.Games.FirstOrDefault(item => item.PluginId == LegendaryLibrary.Instance.Id && item.GameId == gameID); - } - if (!installedGameInfo.Executable.IsNullOrEmpty()) - { game.InstallDirectory = installedGameInfo.Install_path; game.Version = installedGameInfo.Version; game.InstallSize = (ulong?)installedGameInfo.Install_size; game.IsInstalled = true; } - if (installedGameInfo.Is_dlc == false) + if (installedGameInfo.Is_dlc == false || !installedGameInfo.Executable.IsNullOrEmpty()) { playniteAPI.Database.Games.Update(game); } - else if (!installedGameInfo.Executable.IsNullOrEmpty()) + else { playniteAPI.Database.Games.Add(game); } diff --git a/src/LegendaryLibrary.cs b/src/LegendaryLibrary.cs index 4688800..f71616b 100644 --- a/src/LegendaryLibrary.cs +++ b/src/LegendaryLibrary.cs @@ -599,6 +599,7 @@ public override IEnumerable GetGameMenuItems(GetGameMenuItemsArgs try { StopDownloadManager(); + await LegendaryDownloadManager.WaitUntilLegendaryCloses(); Directory.Move(oldPath, newPath); a.CurrentProgressValue = 1; var rewriteResult = await Cli.Wrap(LegendaryLauncher.ClientExecPath)