/// <summary> /// Loads the games stored in the preferences into the UI. /// </summary> private async Task LoadGames() { GameLoader loader = new GameLoader(); EverlookGameLoadingDialog dialog = EverlookGameLoadingDialog.Create(this); dialog.ShowAll(); foreach (var gameTarget in GamePathStorage.Instance.GamePaths) { try { (PackageGroup group, OptimizedNodeTree nodeTree) = await loader.LoadGameAsync ( gameTarget.Alias, gameTarget.Path, dialog.CancellationSource.Token, dialog.ProgressNotifier ); AddGamePage(gameTarget.Alias, gameTarget.Version, group, nodeTree); } catch (OperationCanceledException) { Log.Info("Cancelled game loading operation."); } } dialog.Destroy(); }
/// <summary> /// Loads the games stored in the preferences into the UI. /// </summary> private async Task LoadGames() { var sw = new Stopwatch(); sw.Start(); var loader = new GameLoader(); var dialog = EverlookGameLoadingDialog.Create(this); dialog.ShowAll(); var loadingProgress = default(OverallLoadingProgress); loadingProgress.OperationCount = GamePathStorage.Instance.GamePaths.Count; var loadedGames = 0; foreach (var gameTarget in GamePathStorage.Instance.GamePaths) { loadedGames++; loadingProgress.FinishedOperations = loadedGames; dialog.OverallProgressNotifier.Report(loadingProgress); if (!Directory.Exists(gameTarget.Path)) { Log.Warn($"Could not find game folder for {gameTarget.Alias}. Has the directory moved?"); continue; } try { (var group, var nodeTree) = await loader.LoadGameAsync ( gameTarget.Alias, gameTarget.Path, dialog.CancellationSource.Token, dialog.GameLoadProgressNotifier ); if (group is null || nodeTree is null) { continue; } AddGamePage(gameTarget.Alias, gameTarget.Version, group, nodeTree); } catch (OperationCanceledException) { Log.Info("Cancelled game loading operation."); break; } } dialog.Destroy(); sw.Stop(); Log.Debug($"Game loading took {sw.Elapsed.TotalMilliseconds}ms ({sw.Elapsed.TotalSeconds}s)"); }
/// <summary> /// Loads the games stored in the preferences into the UI. /// </summary> private async Task LoadGames() { Stopwatch sw = new Stopwatch(); sw.Start(); GameLoader loader = new GameLoader(); EverlookGameLoadingDialog dialog = EverlookGameLoadingDialog.Create(this); dialog.ShowAll(); var loadingProgress = default(OverallLoadingProgress); loadingProgress.OperationCount = GamePathStorage.Instance.GamePaths.Count; int loadedGames = 0; foreach (var gameTarget in GamePathStorage.Instance.GamePaths) { loadedGames++; loadingProgress.FinishedOperations = loadedGames; dialog.OverallProgressNotifier.Report(loadingProgress); try { (PackageGroup group, OptimizedNodeTree nodeTree) = await loader.LoadGameAsync ( gameTarget.Alias, gameTarget.Path, dialog.CancellationSource.Token, dialog.GameLoadProgressNotifier ); AddGamePage(gameTarget.Alias, gameTarget.Version, group, nodeTree); } catch (OperationCanceledException) { Log.Info("Cancelled game loading operation."); break; } } dialog.Destroy(); sw.Stop(); Log.Debug($"Game loading took {sw.Elapsed.TotalMilliseconds}ms ({sw.Elapsed.TotalSeconds}s)"); }