コード例 #1
0
 public ViewSelectionMenu(PlayniteSettings settings)
 {
     this.settings = settings;
     InitializeItems();
     Placement = System.Windows.Controls.Primitives.PlacementMode.Bottom;
     StaysOpen = false;
 }
コード例 #2
0
        public static void Main(string[] args)
        {
            if (PlaynitePaths.ProgramPath.Contains(@"temp\rar$", StringComparison.OrdinalIgnoreCase))
            {
                MessageBox.Show(
                    "Playnite is not allowed to run from temporary extracted archive.\rInstall/Extract application properly before starting it.",
                    "Startup Error",
                    MessageBoxButton.OK,
                    MessageBoxImage.Error);
                return;
            }

            var cmdLine = new CmdLineOptions();
            var parsed  = Parser.Default.ParseArguments <CmdLineOptions>(Environment.GetCommandLineArgs());

            if (parsed is Parsed <CmdLineOptions> options)
            {
                cmdLine = options.Value;
            }

            SplashScreen splash    = null;
            var          procCount = Process.GetProcesses().Where(a => a.ProcessName.StartsWith("Playnite.")).Count();

            if (cmdLine.Start.IsNullOrEmpty() && !cmdLine.HideSplashScreen && procCount == 1)
            {
                splash = new SplashScreen("SplashScreen.png");
                splash.Show(false);
            }

            PlayniteSettings.ConfigureLogger();
            var app = new DesktopApplication(new App(), splash, cmdLine);

            app.Run();
        }
コード例 #3
0
        static void Main(string[] args)
        {
            if (args.Count() == 2)
            {
                var sourceDb = args[0];
                var targetDb = args[1];

                if (!File.Exists(sourceDb))
                {
                    Console.WriteLine("Source database file not found!");
                    return;
                }

                try
                {
                    CloneLibrary(sourceDb, targetDb);
                }
                catch (Exception e) when(!Debugger.IsAttached)
                {
                    Console.WriteLine($"Failed to clone database: {e.Message}");
                }
            }
            else
            {
                try
                {
                    var settings   = PlayniteSettings.LoadSettings();
                    var dbPath     = settings.DatabasePath;
                    var dbTempPath = dbPath + "temp";

                    if (File.Exists(dbTempPath))
                    {
                        File.Delete(dbTempPath);
                    }

                    if (!File.Exists(dbPath))
                    {
                        Console.WriteLine($"Couldn't find {dbPath} database file.");
                        return;
                    }

                    File.Move(dbPath, dbTempPath);

                    Console.WriteLine($"Fixing {dbPath} file...");
                    CloneLibrary(dbTempPath, dbPath);
                    File.Delete(dbTempPath);
                    Console.WriteLine("Finished fixing database");
                }
                catch (Exception e) when(!Debugger.IsAttached)
                {
                    Console.WriteLine($"Failed to clone database: {e.Message}");
                }
            }

            Console.WriteLine("Press ENTER to exit...");
            Console.ReadLine();
        }
コード例 #4
0
        public static void Main(string[] args)
        {
            PlayniteSettings.ConfigureLogger();
            LogManager.Init(new NLogLogProvider());

            var app = new App();

            app.Run();
        }
コード例 #5
0
ファイル: ProgramEntry.cs プロジェクト: mazalet/Playnite
        public static void Main(string[] args)
        {
            var splash = new SplashScreen("SplashScreen.png");

            splash.Show(false);
            PlayniteSettings.ConfigureLogger();
            var app = new FullscreenApplication(new App(), splash);

            app.Run();
        }
コード例 #6
0
ファイル: GameGroupMenu.cs プロジェクト: xlizzard/Playnite-1
 public GameGroupMenu(PlayniteSettings settings, DesktopAppViewModel mainModel)
 {
     this.settings      = settings;
     this.mainModel     = mainModel;
     CollapseCommand    = new RelayCommand <object>((a) => Collapse());
     CollapseAllCommand = new RelayCommand <object>((a) => CollapseAll());
     ExpandCommand      = new RelayCommand <object>((a) => Expand());
     ExpandAllCommand   = new RelayCommand <object>((a) => ExpandAll());
     Opened            += GameGroupMenu_Opened;
 }
コード例 #7
0
 public WindowPositionHandler(Window window, string windowName, PlayniteSettings settings)
 {
     Window                  = window;
     WindowName              = windowName;
     Configuration           = settings;
     window.SizeChanged     += Window_SizeChanged;
     window.LocationChanged += Window_LocationChanged;
     window.StateChanged    += Window_StateChanged;
     window.Loaded          += Window_Loaded;
 }
コード例 #8
0
        public void GlobalSetup()
        {
            // To register pack:// scheme
            var current = new Application();

            PlayniteTests.SetEntryAssembly(Assembly.GetExecutingAssembly());
            FileSystem.CreateDirectory(PlayniteTests.TempPath, true);
            NLogLogger.IsTraceEnabled = true;
            PlayniteSettings.ConfigureLogger();
        }
コード例 #9
0
        public ExpanderEx(PlayniteSettings settings) : base()
        {
            if (settings == null || DesignerProperties.GetIsInDesignMode(this))
            {
                return;
            }

            this.settings = settings;
            Loaded       += ExpanderEx_Loaded;
            Unloaded     += ExpanderEx_Unloaded;
        }
コード例 #10
0
ファイル: Settings.cs プロジェクト: wuhan890809/Playnite
 public SettingsBinding(string path) : base(path)
 {
     if (DesignerProperties.GetIsInDesignMode(new DependencyObject()))
     {
         Source = new PlayniteSettings();
     }
     else
     {
         Source = PlayniteApplication.Current.AppSettings;
     }
 }
コード例 #11
0
        public static void GenerateGroupMenu(ItemCollection itemsRoot, PlayniteSettings settings)
        {
            var dontGroupItem = MainMenu.AddMenuChild(itemsRoot, GroupableField.None.GetDescription(), null);

            dontGroupItem.IsCheckable = true;
            MenuHelpers.SetEnumBinding(dontGroupItem, nameof(settings.ViewSettings.GroupingOrder), settings.ViewSettings, GroupableField.None);
            itemsRoot.Add(new Separator());
            MenuHelpers.PopulateEnumOptions <GroupableField>(itemsRoot, nameof(settings.ViewSettings.GroupingOrder), settings.ViewSettings, true,
                                                             new List <GroupableField> {
                GroupableField.None
            });
        }
コード例 #12
0
 public DesktopGamesEditor(
     GameDatabase database,
     GameControllerFactory controllerFactory,
     PlayniteSettings appSettings,
     IDialogsFactory dialogs,
     ExtensionFactory extensions,
     PlayniteApplication app) : base(
         database,
         controllerFactory,
         appSettings,
         dialogs,
         extensions,
         app)
 {
 }
コード例 #13
0
ファイル: ProgramEntry.cs プロジェクト: xlizzard/Playnite-1
        public static void Main(string[] args)
        {
            FileSystem.CreateDirectory(PlaynitePaths.JitProfilesPath);
            ProfileOptimization.SetProfileRoot(PlaynitePaths.JitProfilesPath);
            ProfileOptimization.StartProfile("desktop");

            if (PlaynitePaths.ProgramPath.Contains(@"temp\rar$", StringComparison.OrdinalIgnoreCase))
            {
                MessageBox.Show(
                    "Playnite is not allowed to run from temporary extracted archive.\rInstall/Extract application properly before starting it.",
                    "Startup Error",
                    MessageBoxButton.OK,
                    MessageBoxImage.Error);
                return;
            }
            else if (PlaynitePaths.ProgramPath.Contains("#"))
            {
                MessageBox.Show(
                    "Playnite is unable to run from current directory due to illegal character '#' in the path. Please use different directory.",
                    "Startup Error",
                    MessageBoxButton.OK,
                    MessageBoxImage.Error);
                return;
            }

            var cmdLine = new CmdLineOptions();
            var parsed  = Parser.Default.ParseArguments <CmdLineOptions>(Environment.GetCommandLineArgs());

            if (parsed is Parsed <CmdLineOptions> options)
            {
                cmdLine = options.Value;
            }

            SplashScreen splash    = null;
            var          procCount = Process.GetProcesses().Where(a => a.ProcessName.StartsWith("Playnite.")).Count();

            if (cmdLine.Start.IsNullOrEmpty() && !cmdLine.HideSplashScreen && procCount == 1)
            {
                splash = new SplashScreen("SplashScreen.png");
                splash.Show(false);
            }

            PlayniteSettings.ConfigureLogger();
            LogManager.GetLogger().Info($"App arguments: '{string.Join(",", args)}'");
            var app = new DesktopApplication(new App(), splash, cmdLine);

            app.Run();
        }
コード例 #14
0
 public FullscreenCollectionView(
     IGameDatabase database,
     PlayniteSettings settings,
     ExtensionFactory extensions) : base(database, extensions, settings.Fullscreen.FilterSettings)
 {
     this.settings = settings;
     Database.Games.ItemCollectionChanged += Database_GamesCollectionChanged;
     Database.Games.ItemUpdated           += Database_GameUpdated;
     viewSettings = settings.Fullscreen.ViewSettings;
     viewSettings.PropertyChanged += ViewSettings_PropertyChanged;
     using (CollectionView.DeferRefresh())
     {
         SetViewDescriptions();
         Items.AddRange(Database.Games.Select(x => new GamesCollectionViewEntry(x, GetLibraryPlugin(x), settings)));
     };
 }
コード例 #15
0
ファイル: GamesEditor.cs プロジェクト: southrop/Playnite
 public GamesEditor(
     GameDatabase database,
     GameControllerFactory controllerFactory,
     PlayniteSettings appSettings,
     IDialogsFactory dialogs,
     ExtensionFactory extensions)
 {
     this.dialogs             = dialogs;
     this.database            = database;
     this.appSettings         = appSettings;
     this.extensions          = extensions;
     controllers              = controllerFactory;
     controllers.Installed   += Controllers_Installed;
     controllers.Uninstalled += Controllers_Uninstalled;
     controllers.Started     += Controllers_Started;
     controllers.Stopped     += Controllers_Stopped;
 }
コード例 #16
0
ファイル: Settings.cs プロジェクト: wuhan890809/Playnite
        public Settings(string path) : base(path)
        {
            if (DesignerProperties.GetIsInDesignMode(new DependencyObject()))
            {
                Source   = new PlayniteSettings();
                PathRoot = null;
            }
            else
            {
                Source   = PlayniteApplication.Current;
                PathRoot = nameof(PlayniteApplication.AppSettings);
            }

            if (!path.IsNullOrEmpty())
            {
                PathRoot += ".";
            }
        }
コード例 #17
0
        public DesignMainViewModel()
        {
            MainMenuVisible     = false;
            GameMenuVisible     = false;
            SettingsMenuVisible = false;
            GameListVisible     = true;
            GameDetailsVisible  = false;
            FilterPanelVisible  = true;
            ProgressStatus      = "Status example in progress...";
            ProgressValue       = 50;
            ProgressTotal       = 100;
            ProgressVisible     = true;

            var database = new InMemoryGameDatabase();

            Game.DatabaseReference = database;
            GameDatabase.GenerateSampleData(database);
            var designGame = database.Games.First();

            designGame.CoverImage      = "pack://application:,,,/Playnite;component/Resources/Images/DesignCover.jpg";
            designGame.BackgroundImage = "pack://application:,,,/Playnite;component/Resources/Images/DesignBackground.jpg";
            designGame.Icon            = "pack://application:,,,/Playnite;component/Resources/Images/DesignIcon.png";

            GamesView = new FullscreenCollectionView(
                database,
                new PlayniteSettings(),
                new ExtensionFactory(database, new GameControllerFactory()));

            GameDetailsEntry    = GamesView.Items[0];
            SelectedGame        = GamesView.Items[0];
            SelectedGameDetails = new GameDetailsViewModel(GamesView.Items[0]);

            MainMenuVisible     = false;
            SettingsMenuVisible = false;
            AppSettings         = new PlayniteSettings();
            AppSettings.Fullscreen.ShowBattery           = true;
            AppSettings.Fullscreen.ShowBatteryPercentage = true;
            AppSettings.Fullscreen.ShowClock             = true;
            PlayniteApi = new PlayniteAPI(null, null, null, null, null, null, null, new NotificationsAPI(), null, null);
            PlayniteApi.Notifications.Add(new NotificationMessage("1", "Some testing notification message.", NotificationType.Info));
            PlayniteApi.Notifications.Add(new NotificationMessage("2", "Some really long testing notification message that should be on more lines of text.", NotificationType.Error));
        }
コード例 #18
0
        public DesignMainViewModel()
        {
            ProgressStatus  = "Status example in progress...";
            ProgressValue   = 50;
            ProgressTotal   = 100;
            ProgressVisible = true;

            var database = new InMemoryGameDatabase();

            Game.DatabaseReference = database;
            GameDatabase.GenerateSampleData(database);
            var designGame = database.Games.First();

            designGame.CoverImage      = "pack://application:,,,/Playnite;component/Resources/Images/DesignCover.jpg";
            designGame.BackgroundImage = "pack://application:,,,/Playnite;component/Resources/Images/DesignBackground.jpg";
            designGame.Icon            = "pack://application:,,,/Playnite;component/Resources/Images/DesignIcon.png";

            AppSettings = new PlayniteSettings();
            AppSettings.ExplorerPanelVisible               = true;
            AppSettings.GridViewSideBarVisible             = true;
            AppSettings.ShowNamesUnderCovers               = true;
            AppSettings.ShowNameEmptyCover                 = true;
            AppSettings.ViewSettings.SelectedExplorerField = GroupableField.LastActivity;

            Extensions = new ExtensionFactory(database, new GameControllerFactory());
            GamesView  = new DesktopCollectionView(database, AppSettings, Extensions);

            SelectedGame  = GamesView.Items[0];
            SelectedGames = new List <GamesCollectionViewEntry>()
            {
                SelectedGame
            };
            SelectedGameDetails = new GameDetailsViewModel(GamesView.Items[0], AppSettings);
            DatabaseExplorer    = new DatabaseExplorer(database, Extensions, AppSettings);

            PlayniteApi = new PlayniteAPI(null, null, null, null, null, null, null, new NotificationsAPI(), null, null);
            PlayniteApi.Notifications.Add(new NotificationMessage("1", "Some testing notification message.", NotificationType.Info));
            PlayniteApi.Notifications.Add(new NotificationMessage("2", "Some really long testing notification message that should be on more lines of text.", NotificationType.Error));
        }
コード例 #19
0
        public DesignMainViewModel()
        {
            MainMenuVisible     = false;
            GameMenuVisible     = false;
            SettingsMenuVisible = false;
            GameListVisible     = true;
            GameDetailsVisible  = false;
            FilterPanelVisible  = true;
            ProgressStatus      = "Status example in progress...";
            ProgressValue       = 50;
            ProgressTotal       = 100;
            ProgressVisible     = true;

            var database = new InMemoryGameDatabase();

            for (int i = 0; i < 25; i++)
            {
                database.Games.Add(new Game($"Test Game {i}")
                {
                    //Icon = ThemeFile.GetFilePath("Images/custom_cover_background.png", ThemeFile.GetDesignTimeDefaultTheme())
                });
            }

            GamesView = new FullscreenCollectionView(
                database,
                new PlayniteSettings(),
                new ExtensionFactory(database, new GameControllerFactory()));

            MainMenuVisible     = false;
            SettingsMenuVisible = false;
            AppSettings         = new PlayniteSettings();
            AppSettings.Fullscreen.ShowBattery           = true;
            AppSettings.Fullscreen.ShowBatteryPercentage = true;
            AppSettings.Fullscreen.ShowClock             = true;
            PlayniteApi = new PlayniteAPI(null, null, null, null, null, null, null, new NotificationsAPI());
            PlayniteApi.Notifications.Add(new NotificationMessage("1", "Some testing notification message.", NotificationType.Info));
            PlayniteApi.Notifications.Add(new NotificationMessage("2", "Some really long testing notification message that should be on more lines of text.", NotificationType.Error));
        }
コード例 #20
0
ファイル: ProgramEntry.cs プロジェクト: sharazy/Playnite
        public static void Main(string[] args)
        {
            var cmdLine = new CmdLineOptions();
            var parsed  = Parser.Default.ParseArguments <CmdLineOptions>(Environment.GetCommandLineArgs());

            if (parsed is Parsed <CmdLineOptions> options)
            {
                cmdLine = options.Value;
            }

            SplashScreen splash = null;

            if (cmdLine.Start.IsNullOrEmpty())
            {
                splash = new SplashScreen("SplashScreen.png");
                splash.Show(false);
            }

            PlayniteSettings.ConfigureLogger();
            var app = new FullscreenApplication(new App(), splash, cmdLine);

            app.Run();
        }
コード例 #21
0
        public static void Main(string[] args)
        {
            var cmdLine = new CmdLineOptions();
            var parsed  = Parser.Default.ParseArguments <CmdLineOptions>(Environment.GetCommandLineArgs());

            if (parsed is Parsed <CmdLineOptions> options)
            {
                cmdLine = options.Value;
            }

            SplashScreen splash    = null;
            var          procCount = Process.GetProcesses().Where(a => a.ProcessName.StartsWith("Playnite.")).Count();

            if (cmdLine.Start.IsNullOrEmpty() && !cmdLine.HideSplashScreen && procCount == 1)
            {
                splash = new SplashScreen("SplashScreen.png");
                splash.Show(false);
            }

            PlayniteSettings.ConfigureLogger();
            var app = new FullscreenApplication(new App(), splash, cmdLine);

            app.Run();
        }
コード例 #22
0
 public WebViewFactory(PlayniteSettings settings)
 {
     appSettings = settings;
 }
コード例 #23
0
 public static void GenerateSortMenu(ItemCollection itemsRoot, PlayniteSettings settings)
 {
     MenuHelpers.PopulateEnumOptions <SortOrderDirection>(itemsRoot, nameof(settings.ViewSettings.SortingOrderDirection), settings.ViewSettings);
     itemsRoot.Add(new Separator());
     MenuHelpers.PopulateEnumOptions <SortOrder>(itemsRoot, nameof(settings.ViewSettings.SortingOrder), settings.ViewSettings, true);
 }
コード例 #24
0
 public ViewSettingsMenu(PlayniteSettings settings)
 {
     this.settings = settings;
     InitializeItems();
 }
コード例 #25
0
 public AddonsAPI(ExtensionFactory extensions, PlayniteSettings settings)
 {
     this.extensions = extensions;
     this.settings   = settings;
 }
コード例 #26
0
 public PlayniteSettingsAPI(PlayniteSettings settings)
 {
     this.settings = settings;
 }
コード例 #27
0
        public Task DownloadMetadataAsync(
            List <Game> games,
            MetadataDownloaderSettings settings,
            PlayniteSettings playniteSettings,
            Action <Game, int, int> progressCallback,
            CancellationToken cancelToken)
        {
            return(Task.Run(() =>
            {
                if (games == null || games.Count == 0)
                {
                    return;
                }

                for (int i = 0; i < games.Count; i++)
                {
                    Game game = null;
                    var existingStoreData = new Dictionary <Guid, GameMetadata>();
                    var existingPluginData = new Dictionary <Guid, OnDemandMetadataProvider>();

                    try
                    {
                        if (cancelToken.IsCancellationRequested == true)
                        {
                            return;
                        }

                        GameMetadata gameData = null;

                        // We need to get new instance from DB in case game got edited or deleted.
                        // We don't want to block game editing while metadata is downloading for other games.
                        game = database.Games[games[i].Id]?.GetClone();
                        if (game == null)
                        {
                            logger.Warn($"Game {game.Id} no longer in DB, skipping metadata download.");
                            progressCallback?.Invoke(null, i, games.Count);
                            continue;
                        }

                        var dataModified = false;
                        game.PropertyChanged += (_, __) => dataModified = true;

                        if (game != null)
                        {
                            progressCallback?.Invoke(game, i, games.Count);
                        }

                        logger.Debug($"Downloading metadata for {game.Name}, {game.GameId}, {game.PluginId}");

                        // Name
                        if (!game.IsCustomGame && settings.Name.Import)
                        {
                            gameData = ProcessField(game, settings.Name, MetadataField.Name, (a) => a.Name, existingStoreData, existingPluginData, cancelToken);
                            if (!string.IsNullOrEmpty(gameData?.Name))
                            {
                                game.Name = StringExtensions.RemoveTrademarks(gameData.Name);
                                var sortingName = StringExtensions.ConvertToSortableName(game.Name);
                                if (sortingName != game.Name)
                                {
                                    game.SortingName = sortingName;
                                }
                            }
                        }

                        // Genre
                        if (settings.Genre.Import)
                        {
                            if (!settings.SkipExistingValues || (settings.SkipExistingValues && !game.GenreIds.HasItems()))
                            {
                                gameData = ProcessField(game, settings.Genre, MetadataField.Genres, (a) => a.Genres, existingStoreData, existingPluginData, cancelToken);
                                if (gameData?.Genres.HasItems() == true)
                                {
                                    game.GenreIds = database.Genres.Add(gameData.Genres).Select(a => a.Id).ToList();
                                }
                            }
                        }

                        // Release Date
                        if (settings.ReleaseDate.Import)
                        {
                            if (!settings.SkipExistingValues || (settings.SkipExistingValues && game.ReleaseDate == null))
                            {
                                gameData = ProcessField(game, settings.ReleaseDate, MetadataField.ReleaseDate, (a) => a.ReleaseDate, existingStoreData, existingPluginData, cancelToken);
                                game.ReleaseDate = gameData?.ReleaseDate ?? game.ReleaseDate;
                            }
                        }

                        // Developer
                        if (settings.Developer.Import)
                        {
                            if (!settings.SkipExistingValues || (settings.SkipExistingValues && !game.DeveloperIds.HasItems()))
                            {
                                gameData = ProcessField(game, settings.Developer, MetadataField.Developers, (a) => a.Developers, existingStoreData, existingPluginData, cancelToken);
                                if (gameData?.Developers.HasItems() == true)
                                {
                                    game.DeveloperIds = database.Companies.Add(gameData.Developers).Select(a => a.Id).ToList();
                                }
                            }
                        }

                        // Publisher
                        if (settings.Publisher.Import)
                        {
                            if (!settings.SkipExistingValues || (settings.SkipExistingValues && !game.PublisherIds.HasItems()))
                            {
                                gameData = ProcessField(game, settings.Publisher, MetadataField.Publishers, (a) => a.Publishers, existingStoreData, existingPluginData, cancelToken);
                                if (gameData?.Publishers.HasItems() == true)
                                {
                                    game.PublisherIds = database.Companies.Add(gameData.Publishers).Select(a => a.Id).ToList();
                                }
                            }
                        }

                        // Tags
                        if (settings.Tag.Import)
                        {
                            if (!settings.SkipExistingValues || (settings.SkipExistingValues && !game.TagIds.HasItems()))
                            {
                                gameData = ProcessField(game, settings.Tag, MetadataField.Tags, (a) => a.Tags, existingStoreData, existingPluginData, cancelToken);
                                if (gameData?.Tags.HasItems() == true)
                                {
                                    game.TagIds = database.Tags.Add(gameData.Tags).Select(a => a.Id).ToList();
                                }
                            }
                        }

                        // Features
                        if (settings.Feature.Import)
                        {
                            if (!settings.SkipExistingValues || (settings.SkipExistingValues && !game.FeatureIds.HasItems()))
                            {
                                gameData = ProcessField(game, settings.Feature, MetadataField.Features, (a) => a.Features, existingStoreData, existingPluginData, cancelToken);
                                if (gameData?.Features.HasItems() == true)
                                {
                                    game.FeatureIds = database.Features.Add(gameData.Features).Select(a => a.Id).ToList();
                                }
                            }
                        }

                        // Description
                        if (settings.Description.Import)
                        {
                            if (!settings.SkipExistingValues || (settings.SkipExistingValues && string.IsNullOrEmpty(game.Description)))
                            {
                                gameData = ProcessField(game, settings.Description, MetadataField.Description, (a) => a.Description, existingStoreData, existingPluginData, cancelToken);
                                game.Description = string.IsNullOrEmpty(gameData?.Description) == true ? game.Description : gameData.Description;
                            }
                        }

                        // Links
                        if (settings.Links.Import)
                        {
                            if (!settings.SkipExistingValues || (settings.SkipExistingValues && !game.Links.HasItems()))
                            {
                                gameData = ProcessField(game, settings.Links, MetadataField.Links, (a) => a.Links, existingStoreData, existingPluginData, cancelToken);
                                if (gameData?.Links.HasItems() == true)
                                {
                                    game.Links = gameData.Links.ToObservable();
                                }
                            }
                        }

                        // Age rating
                        if (settings.AgeRating.Import)
                        {
                            if (!settings.SkipExistingValues || (settings.SkipExistingValues && !game.AgeRatingIds.HasItems()))
                            {
                                gameData = ProcessField(game, settings.AgeRating, MetadataField.AgeRating, (a) => a.AgeRatings, existingStoreData, existingPluginData, cancelToken);
                                if (gameData?.AgeRatings.HasItems() == true)
                                {
                                    game.AgeRatingIds = database.AgeRatings.Add(gameData.AgeRatings).Select(a => a.Id).ToList();
                                }
                            }
                        }

                        // Region
                        if (settings.Region.Import)
                        {
                            if (!settings.SkipExistingValues || (settings.SkipExistingValues && !game.RegionIds.HasItems()))
                            {
                                gameData = ProcessField(game, settings.Region, MetadataField.Region, (a) => a.Regions, existingStoreData, existingPluginData, cancelToken);
                                if (gameData?.Regions.HasItems() == true)
                                {
                                    game.RegionIds = database.Regions.Add(gameData.Regions).Select(a => a.Id).ToList();
                                }
                            }
                        }

                        // Series
                        if (settings.Series.Import)
                        {
                            if (!settings.SkipExistingValues || (settings.SkipExistingValues && !game.SeriesIds.HasItems()))
                            {
                                gameData = ProcessField(game, settings.Series, MetadataField.Series, (a) => a.Series, existingStoreData, existingPluginData, cancelToken);
                                if (gameData?.Series.HasItems() == true)
                                {
                                    game.SeriesIds = database.Series.Add(gameData.Series).Select(a => a.Id).ToList();
                                }
                            }
                        }

                        // Platform
                        if (settings.Platform.Import)
                        {
                            if (!settings.SkipExistingValues || (settings.SkipExistingValues && !game.PlatformIds.HasItems()))
                            {
                                gameData = ProcessField(game, settings.Platform, MetadataField.Platform, (a) => a.Platforms, existingStoreData, existingPluginData, cancelToken);
                                if (gameData?.Platforms.HasItems() == true)
                                {
                                    game.PlatformIds = database.Platforms.Add(gameData.Platforms).Select(a => a.Id).ToList();
                                }
                            }
                        }

                        // Critic Score
                        if (settings.CriticScore.Import)
                        {
                            if (!settings.SkipExistingValues || (settings.SkipExistingValues && game.CriticScore == null))
                            {
                                gameData = ProcessField(game, settings.CriticScore, MetadataField.CriticScore, (a) => a.CriticScore, existingStoreData, existingPluginData, cancelToken);
                                game.CriticScore = gameData?.CriticScore == null ? game.CriticScore : gameData.CriticScore;
                            }
                        }

                        // Community Score
                        if (settings.CommunityScore.Import)
                        {
                            if (!settings.SkipExistingValues || (settings.SkipExistingValues && game.CommunityScore == null))
                            {
                                gameData = ProcessField(game, settings.CommunityScore, MetadataField.CommunityScore, (a) => a.CommunityScore, existingStoreData, existingPluginData, cancelToken);
                                game.CommunityScore = gameData?.CommunityScore == null ? game.CommunityScore : gameData.CommunityScore;
                            }
                        }

                        // BackgroundImage
                        if (settings.BackgroundImage.Import)
                        {
                            if (!settings.SkipExistingValues || (settings.SkipExistingValues && string.IsNullOrEmpty(game.BackgroundImage)))
                            {
                                gameData = ProcessField(game, settings.BackgroundImage, MetadataField.BackgroundImage, (a) => a.BackgroundImage, existingStoreData, existingPluginData, cancelToken);
                                if (gameData?.BackgroundImage != null)
                                {
                                    if (playniteSettings.DownloadBackgroundsImmediately && gameData.BackgroundImage.HasImageData)
                                    {
                                        game.BackgroundImage = database.AddFile(gameData.BackgroundImage, game.Id, true);
                                    }
                                    else if (!playniteSettings.DownloadBackgroundsImmediately &&
                                             !gameData.BackgroundImage.Path.IsNullOrEmpty())
                                    {
                                        game.BackgroundImage = gameData.BackgroundImage.Path;
                                    }
                                    else if (gameData.BackgroundImage.HasImageData)
                                    {
                                        game.BackgroundImage = database.AddFile(gameData.BackgroundImage, game.Id, true);
                                    }
                                }
                            }
                        }

                        // Cover
                        if (settings.CoverImage.Import)
                        {
                            if (!settings.SkipExistingValues || (settings.SkipExistingValues && string.IsNullOrEmpty(game.CoverImage)))
                            {
                                gameData = ProcessField(game, settings.CoverImage, MetadataField.CoverImage, (a) => a.CoverImage, existingStoreData, existingPluginData, cancelToken);
                                if (gameData?.CoverImage != null)
                                {
                                    game.CoverImage = database.AddFile(gameData.CoverImage, game.Id, true);
                                }
                            }
                        }

                        // Icon
                        if (settings.Icon.Import)
                        {
                            if (!settings.SkipExistingValues || (settings.SkipExistingValues && string.IsNullOrEmpty(game.Icon)))
                            {
                                gameData = ProcessField(game, settings.Icon, MetadataField.Icon, (a) => a.Icon, existingStoreData, existingPluginData, cancelToken);
                                if (gameData?.Icon != null)
                                {
                                    game.Icon = database.AddFile(gameData.Icon, game.Id, true);
                                }
                            }
                        }

                        // Just to be sure check if somebody didn't remove game while downloading data
                        if (database.Games.FirstOrDefault(a => a.Id == games[i].Id) != null && dataModified)
                        {
                            game.Modified = DateTime.Now;
                            database.Games.Update(game);
                        }
                        else
                        {
                            logger.Warn($"Game {game.Id} no longer in DB, skipping metadata update in DB.");
                        }
                    }
                    catch (Exception e) when(!PlayniteEnvironment.ThrowAllErrors)
                    {
                        logger.Error(e, $"Failed to download metadata for game {game?.Name}, {game?.Id}");
                    }
                    finally
                    {
                        foreach (var plugin in existingPluginData.Values)
                        {
                            plugin.Dispose();
                        }
                    }
                }
            }));
        }