public SystemCheckerGameView(IPlayniteAPI PlayniteApi, string PluginUserDataPath, Game GameSelected) { this.PlayniteApi = PlayniteApi; InitializeComponent(); // Local SystemConfiguration systemConfiguration = PluginDatabase.Database.PC; LocalOs = systemConfiguration.Os; LocalCpu = systemConfiguration.Cpu; LocalRamUsage = systemConfiguration.RamUsage; LocalGpu = systemConfiguration.GpuName; LocalDisks.ItemsSource = systemConfiguration.Disks; // Minimum & Recommanded GameRequierements gameRequierements = PluginDatabase.Get(GameSelected, true); Requirement Minimum = gameRequierements.GetMinimum(); Requirement Recommanded = gameRequierements.GetRecommanded(); if (Minimum.HasData) { MinimumOs = "Windows " + string.Join(" / ", Minimum.Os); MinimumCpu = Minimum.Cpu; MinimumRamUsage = Minimum.RamUsage; MinimumGpu = Minimum.Gpu; MinimumStorage = Minimum.StorageUsage; } if (Recommanded.HasData) { RecommandedOs = "Windows " + string.Join(" / ", Recommanded.Os); RecommandedCpu = Recommanded.Cpu; RecommandedRamUsage = Recommanded.RamUsage; RecommandedGpu = Recommanded.Gpu; RecommandedStorage = Recommanded.StorageUsage; } // Check config string IsOk = ""; string IsKo = ""; CheckSystem CheckMinimum = SystemApi.CheckConfig(Minimum, systemConfiguration); if (Minimum.HasData) { MinimumCheckOs = IsKo; if (CheckMinimum.CheckOs) { MinimumCheckOs = IsOk; } if (Minimum.Os.Count == 0) { MinimumCheckOs = string.Empty; } MinimumCheckCpu = IsKo; if (CheckMinimum.CheckCpu) { MinimumCheckCpu = IsOk; } if (Minimum.Cpu.Count == 0) { MinimumCheckCpu = string.Empty; } MinimumCheckRam = IsKo; if (CheckMinimum.CheckRam) { MinimumCheckRam = IsOk; } if (Minimum.Ram == 0) { MinimumCheckRam = string.Empty; } MinimumCheckGpu = IsKo; if (CheckMinimum.CheckGpu) { MinimumCheckGpu = IsOk; } if (Minimum.Gpu.Count == 0) { MinimumCheckGpu = string.Empty; } MinimumCheckStorage = IsKo; if (CheckMinimum.CheckStorage) { MinimumCheckStorage = IsOk; } if (Minimum.Storage == 0) { MinimumCheckStorage = string.Empty; } } CheckSystem CheckRecommanded = SystemApi.CheckConfig(Recommanded, systemConfiguration); if (Recommanded.HasData) { RecommandedCheckOs = IsKo; if (CheckRecommanded.CheckOs) { RecommandedCheckOs = IsOk; } if (Recommanded.Os.Count == 0) { RecommandedCheckOs = string.Empty; } RecommandedCheckCpu = IsKo; if (CheckRecommanded.CheckCpu) { RecommandedCheckCpu = IsOk; } if (Recommanded.Cpu.Count == 0) { RecommandedCheckCpu = string.Empty; } RecommandedCheckRam = IsKo; if (CheckRecommanded.CheckRam) { RecommandedCheckRam = IsOk; } if (Recommanded.Ram == 0) { RecommandedCheckRam = string.Empty; } RecommandedCheckGpu = IsKo; if (CheckRecommanded.CheckGpu) { RecommandedCheckGpu = IsOk; } if (Recommanded.Gpu.Count == 0) { RecommandedCheckGpu = string.Empty; } RecommandedCheckStorage = IsKo; if (CheckRecommanded.CheckStorage) { RecommandedCheckStorage = IsOk; } if (Recommanded.Storage == 0) { RecommandedCheckStorage = string.Empty; } } btLink.Visibility = System.Windows.Visibility.Hidden; if (Minimum.HasData || Recommanded.HasData) { btLink.Visibility = System.Windows.Visibility.Visible; btLink.Tag = gameRequierements.Link; } #if DEBUG logger.Debug("CheckMinimum" + JsonConvert.SerializeObject(CheckMinimum)); logger.Debug("CheckRecommanded" + JsonConvert.SerializeObject(CheckRecommanded)); #endif if (!gameRequierements.SourceGameName.IsNullOrEmpty() && !gameRequierements.SourceName.IsNullOrEmpty()) { ScSourceName = resources.GetString("LOCSourceLabel") + ": " + gameRequierements.SourceGameName + $" ({gameRequierements.SourceName})"; } else { ScSourceName = resources.GetString("LOCSourceLabel") + ": " + GameSelected.Name; } DataContext = this; }
public override void RefreshElements(Game GameSelected, bool force = false) { CancellationTokenSource tokenSource = new CancellationTokenSource(); CancellationToken ct = tokenSource.Token; Task TaskRefresh = Task.Run(() => { try { Initial(); // Reset resources List <ResourcesList> resourcesLists = new List <ResourcesList>(); resourcesLists.Add(new ResourcesList { Key = "Scheck_HasData", Value = false }); resourcesLists.Add(new ResourcesList { Key = "Scheck_IsMinimumOK", Value = false }); resourcesLists.Add(new ResourcesList { Key = "Scheck_IsRecommandedOK", Value = false }); resourcesLists.Add(new ResourcesList { Key = "Scheck_IsAllOK", Value = false }); ui.AddResources(resourcesLists); if (!PlayniteTools.IsGameEmulated(_PlayniteApi, GameSelected)) { // Load data if (!PluginDatabase.IsLoaded) { return; } GameRequierements gameRequierements = PluginDatabase.Get(GameSelected); SystemConfiguration systemConfiguration = PluginDatabase.Database.PC; CheckMinimum = new CheckSystem(); CheckRecommanded = new CheckSystem(); resourcesLists = new List <ResourcesList>(); if (gameRequierements.GetMinimum().HasData) { CheckMinimum = SystemApi.CheckConfig(gameRequierements.GetMinimum(), systemConfiguration); #if DEBUG logger.Debug($"SystemChecker - CheckMinimum: {JsonConvert.SerializeObject(CheckMinimum)}"); #endif resourcesLists.Add(new ResourcesList { Key = "Scheck_HasData", Value = true }); resourcesLists.Add(new ResourcesList { Key = "Scheck_IsMinimumOK", Value = CheckMinimum.AllOk }); resourcesLists.Add(new ResourcesList { Key = "Scheck_IsAllOK", Value = CheckMinimum.AllOk }); } if (gameRequierements.GetRecommanded().HasData) { CheckRecommanded = SystemApi.CheckConfig(gameRequierements.GetRecommanded(), systemConfiguration); #if DEBUG logger.Debug($"SystemChecker - CheckRecommanded: {JsonConvert.SerializeObject(CheckRecommanded)}"); #endif resourcesLists.Add(new ResourcesList { Key = "Scheck_HasData", Value = true }); resourcesLists.Add(new ResourcesList { Key = "Scheck_IsRecommandedOK", Value = CheckRecommanded.AllOk }); resourcesLists.Add(new ResourcesList { Key = "Scheck_IsAllOK", Value = CheckRecommanded.AllOk }); } // If not cancel, show if (!ct.IsCancellationRequested && GameSelected.Id == SystemChecker.GameSelected.Id) { ui.AddResources(resourcesLists); if (_PlayniteApi.ApplicationInfo.Mode == ApplicationMode.Desktop) { PluginDatabase.SetCurrent(gameRequierements); } } } else { logger.Info($"SystemChecker - No treatment for emulated game"); } } catch (Exception ex) { Common.LogError(ex, "SystemChecker", $"Error on TaskRefreshBtActionBar()"); } }, ct); taskHelper.Add(TaskRefresh, tokenSource); }