From c4aaab8bdc21d7e41f41fb597f61079f32b13627 Mon Sep 17 00:00:00 2001 From: Frog Date: Thu, 18 Jun 2026 01:10:01 -0700 Subject: [PATCH] Improve Game/Library Scan Logging - Add per-platform library scan timing and per-game detection logs --- CreamInstaller/Forms/SelectForm.cs | 41 +++++++++++++------ CreamInstaller/Platforms/Epic/EpicLibrary.cs | 17 ++++++++ .../Platforms/Steam/SteamLibrary.cs | 5 ++- .../Platforms/Ubisoft/UbisoftLibrary.cs | 15 ++++++- 4 files changed, 64 insertions(+), 14 deletions(-) diff --git a/CreamInstaller/Forms/SelectForm.cs b/CreamInstaller/Forms/SelectForm.cs index 9efc140..2ccec04 100644 --- a/CreamInstaller/Forms/SelectForm.cs +++ b/CreamInstaller/Forms/SelectForm.cs @@ -151,6 +151,8 @@ internal sealed partial class SelectForm : CustomForm Stopwatch scanTimer = Stopwatch.StartNew(); double totalLibraryScanSeconds = 0; int totalGamesDetected = 0; + int steamCount = 0, epicCount = 0, ubisoftCount = 0; + double steamSeconds = 0, epicSeconds = 0, ubiSeconds = 0; if (!uninstallAll && programsToScan is { Count: > 0 }) { string platforms = string.Join(", ", programsToScan.Select(p => p.platform.ToString()).Distinct()); @@ -184,9 +186,11 @@ internal sealed partial class SelectForm : CustomForm List<(string appId, string name, string branch, int buildId, string gameDirectory)> steamGames = await SteamLibrary.GetGames(); steamLibTimer.Stop(); - totalLibraryScanSeconds += steamLibTimer.Elapsed.TotalSeconds; - ProgramData.Log($"[Steam] Scanned library: {steamGames.Count} games in {steamLibTimer.Elapsed.TotalSeconds:F1}s"); - totalGamesDetected += steamGames.Count; + steamCount = steamGames.Count; + steamSeconds = steamLibTimer.Elapsed.TotalSeconds; + totalLibraryScanSeconds += steamSeconds; + ProgramData.Log($"[Steam] Scanned library: {steamCount} games in {steamSeconds:F1}s"); + totalGamesDetected += steamCount; int steamToProcess = 0, steamBlocked = 0, steamNotSelected = 0; steamGamesToCheck = steamGames.Count; foreach ((string appId, string name, string branch, int buildId, string gameDirectory) in steamGames) @@ -441,9 +445,11 @@ internal sealed partial class SelectForm : CustomForm Stopwatch epicLibTimer = Stopwatch.StartNew(); List epicGames = await EpicLibrary.GetGames(); epicLibTimer.Stop(); - totalLibraryScanSeconds += epicLibTimer.Elapsed.TotalSeconds; - ProgramData.Log($"[Epic] Scanned library: {epicGames.Count} games in {epicLibTimer.Elapsed.TotalSeconds:F1}s"); - totalGamesDetected += epicGames.Count; + epicCount = epicGames.Count; + epicSeconds = epicLibTimer.Elapsed.TotalSeconds; + totalLibraryScanSeconds += epicSeconds; + ProgramData.Log($"[Epic] Scanned library: {epicCount} games in {epicSeconds:F1}s"); + totalGamesDetected += epicCount; int epicToProcess = 0, epicBlocked = 0, epicNotSelected = 0; foreach (Manifest manifest in epicGames) { @@ -577,9 +583,11 @@ internal sealed partial class SelectForm : CustomForm Stopwatch ubiLibTimer = Stopwatch.StartNew(); List<(string gameId, string name, string gameDirectory)> ubisoftGames = await UbisoftLibrary.GetGames(); ubiLibTimer.Stop(); - totalLibraryScanSeconds += ubiLibTimer.Elapsed.TotalSeconds; - ProgramData.Log($"[Ubisoft] Scanned library: {ubisoftGames.Count} games in {ubiLibTimer.Elapsed.TotalSeconds:F1}s"); - totalGamesDetected += ubisoftGames.Count; + ubisoftCount = ubisoftGames.Count; + ubiSeconds = ubiLibTimer.Elapsed.TotalSeconds; + totalLibraryScanSeconds += ubiSeconds; + ProgramData.Log($"[Ubisoft] Scanned library: {ubisoftCount} games in {ubiSeconds:F1}s"); + totalGamesDetected += ubisoftCount; int ubiToProcess = 0, ubiBlocked = 0, ubiNotSelected = 0; foreach ((string gameId, string name, string gameDirectory) in ubisoftGames) { @@ -648,8 +656,6 @@ internal sealed partial class SelectForm : CustomForm ProgramData.Log($"[Ubisoft] Will process {ubiToProcess} selected game(s) ({ubiBlocked} blocked, {ubiNotSelected} not in current selection)"); } - if (!uninstallAll) - ProgramData.Log($"[Scan] Total games detected across all libraries: {totalGamesDetected}"); Stopwatch gameDlcTimer = Stopwatch.StartNew(); foreach (Task task in appTasks) { @@ -662,7 +668,15 @@ internal sealed partial class SelectForm : CustomForm gameQueriesDone.TrySetResult(); scanTimer.Stop(); - ProgramData.Log($"[Scan] Library scan total: {totalLibraryScanSeconds:F1}s across all platforms"); + if (!uninstallAll) + { + if (steamCount > 0) + ProgramData.Log($"[Steam] Total games detected: {steamCount} in {(steamSeconds >= 60 ? $"{steamSeconds / 60:F1} minutes" : $"{steamSeconds:F1}s")}"); + if (epicCount > 0) + ProgramData.Log($"[Epic] Total games detected: {epicCount} in {(epicSeconds >= 60 ? $"{epicSeconds / 60:F1} minutes" : $"{epicSeconds:F1}s")}"); + if (ubisoftCount > 0) + ProgramData.Log($"[Ubisoft] Total games detected: {ubisoftCount} in {(ubiSeconds >= 60 ? $"{ubiSeconds / 60:F1} minutes" : $"{ubiSeconds:F1}s")}"); + } ProgramData.Log($"[Scan] Game and DLC data gathering: {gameDlcTimer.Elapsed.TotalSeconds:F1}s"); ProgramData.Log($"[Scan] Scan completed in {scanTimer.Elapsed.TotalSeconds:F1}s"); } @@ -703,6 +717,7 @@ internal sealed partial class SelectForm : CustomForm } if (!scan && (programsToScan is null || programsToScan.Count < 1 || forceProvideChoices) && !skipScanDialog) { + Stopwatch selectionTimer = Stopwatch.StartNew(); List<(Platform platform, string id, string name, bool alreadySelected)> gameChoices = new(); if (ParadoxLauncher.InstallPath.DirectoryExists()) gameChoices.Add((Platform.Paradox, "PL", "Paradox Launcher", @@ -726,6 +741,8 @@ internal sealed partial class SelectForm : CustomForm gameChoices.Add((Platform.Ubisoft, gameId, name, programsToScan is not null && programsToScan.Any(p => p.platform is Platform.Ubisoft && p.id == gameId))); + selectionTimer.Stop(); + ProgramData.Log($"[Total] Total time spent detecting games and libraries: {(selectionTimer.Elapsed.TotalSeconds >= 60 ? $"{selectionTimer.Elapsed.TotalSeconds / 60:F1} minutes" : $"{selectionTimer.Elapsed.TotalSeconds:F1}s")}"); if (gameChoices.Count > 0) { using SelectDialogForm form = new(this); diff --git a/CreamInstaller/Platforms/Epic/EpicLibrary.cs b/CreamInstaller/Platforms/Epic/EpicLibrary.cs index 1d28fb0..e04c78d 100644 --- a/CreamInstaller/Platforms/Epic/EpicLibrary.cs +++ b/CreamInstaller/Platforms/Epic/EpicLibrary.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Threading.Tasks; using CreamInstaller.Platforms.Epic.Heroic; @@ -33,6 +34,7 @@ internal static class EpicLibrary internal static async Task> GetGames() => await Task.Run(async () => { + Stopwatch timer = Stopwatch.StartNew(); List games = new(); foreach (Manifest test in TestManifests) @@ -40,7 +42,10 @@ internal static class EpicLibrary games.Add(test); string manifests = EpicManifestsPath; + ProgramData.Log($"[Epic] Manifests directory: {manifests ?? "(not found)"}"); if (manifests.DirectoryExists()) + { + ProgramData.Log($"[Epic] Scanning manifests: {manifests}"); foreach (string item in manifests.EnumerateDirectory("*.item")) { if (Program.Canceled) @@ -52,17 +57,29 @@ internal static class EpicLibrary if (manifest is not null && (manifest.InstallLocation = manifest.InstallLocation.ResolvePath()) is not null && games.All(g => g.CatalogNamespace != manifest.CatalogNamespace)) + { games.Add(manifest); + ProgramData.Log($"[Epic] Detected game: {manifest.DisplayName} ({manifest.CatalogNamespace}) | Dir: {manifest.InstallLocation}"); + } } catch { // ignored } } + } if (Program.Canceled) return games; + int beforeHeroic = games.Count; await HeroicLibrary.GetGames(games); + int heroicCount = games.Count - beforeHeroic; + if (heroicCount > 0) + ProgramData.Log($"[Epic] Found {heroicCount} game(s) from Heroic Games Launcher"); + if (TestManifests.Count > 0) + ProgramData.Log($"[Epic] Injected {TestManifests.Count} test game(s)."); + timer.Stop(); + ProgramData.Log($"[Epic] Total games detected: {games.Count} in {(timer.Elapsed.TotalSeconds >= 60 ? $"{timer.Elapsed.TotalSeconds / 60:F1} minutes" : $"{timer.Elapsed.TotalSeconds:F1}s")}"); return games; }); } \ No newline at end of file diff --git a/CreamInstaller/Platforms/Steam/SteamLibrary.cs b/CreamInstaller/Platforms/Steam/SteamLibrary.cs index f4b67db..4e128e8 100644 --- a/CreamInstaller/Platforms/Steam/SteamLibrary.cs +++ b/CreamInstaller/Platforms/Steam/SteamLibrary.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Diagnostics; using System.IO; using System.Linq; using System.Threading.Tasks; @@ -30,6 +31,7 @@ internal static class SteamLibrary GetGames() => await Task.Run(async () => { + Stopwatch timer = Stopwatch.StartNew(); List<(string appId, string name, string branch, int buildId, string gameDirectory)> games = new(); HashSet gameLibraryDirectories = await GetLibraryDirectories(); ProgramData.Log($"[Steam] Found {gameLibraryDirectories.Count} library folder(s)."); @@ -49,7 +51,8 @@ internal static class SteamLibrary games.Add(testGame); if (TestGames.Count > 0) ProgramData.Log($"[Steam] Injected {TestGames.Count} test game(s)."); - ProgramData.Log($"[Steam] Total games detected: {games.Count}"); + timer.Stop(); + ProgramData.Log($"[Steam] Total games detected: {games.Count} in {(timer.Elapsed.TotalSeconds >= 60 ? $"{timer.Elapsed.TotalSeconds / 60:F1} minutes" : $"{timer.Elapsed.TotalSeconds:F1}s")}"); return games; }); diff --git a/CreamInstaller/Platforms/Ubisoft/UbisoftLibrary.cs b/CreamInstaller/Platforms/Ubisoft/UbisoftLibrary.cs index f38fcb2..a5ebe7c 100644 --- a/CreamInstaller/Platforms/Ubisoft/UbisoftLibrary.cs +++ b/CreamInstaller/Platforms/Ubisoft/UbisoftLibrary.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Diagnostics; using System.IO; using System.Linq; using System.Threading.Tasks; @@ -25,23 +26,35 @@ internal static class UbisoftLibrary internal static async Task> GetGames() => await Task.Run(() => { + Stopwatch timer = Stopwatch.StartNew(); List<(string gameId, string name, string gameDirectory)> games = new(); RegistryKey installsKey = InstallsKey; if (installsKey is not null) + { + ProgramData.Log($"[Ubisoft] Scanning registry: HKLM\\SOFTWARE\\WOW6432Node\\Ubisoft\\Launcher\\Installs"); foreach (string gameId in installsKey.GetSubKeyNames()) { RegistryKey installKey = installsKey.OpenSubKey(gameId); string installDir = installKey?.GetValue("InstallDir")?.ToString()?.ResolvePath(); if (installDir is not null && games.All(g => g.gameId != gameId)) + { games.Add((gameId, new DirectoryInfo(installDir).Name, installDir)); + ProgramData.Log($"[Ubisoft] Detected game: {new DirectoryInfo(installDir).Name} ({gameId}) | Dir: {installDir}"); + } } + } + else + { + ProgramData.Log($"[Ubisoft] Registry key not found: HKLM\\SOFTWARE\\WOW6432Node\\Ubisoft\\Launcher\\Installs"); + } foreach ((string gameId, string name, string gameDirectory) testGame in TestGames.Where(t => games.All(g => g.gameId != t.gameId))) games.Add(testGame); if (TestGames.Count > 0) ProgramData.Log($"[Ubisoft] Injected {TestGames.Count} test game(s)."); - + timer.Stop(); + ProgramData.Log($"[Ubisoft] Total games detected: {games.Count} in {(timer.Elapsed.TotalSeconds >= 60 ? $"{timer.Elapsed.TotalSeconds / 60:F1} minutes" : $"{timer.Elapsed.TotalSeconds:F1}s")}"); return games; }); } \ No newline at end of file