Esempio n. 1
0
        /// <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();
        }
Esempio n. 2
0
        /// <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)");
        }