public async void StartInstallWatcher()
        {
            watcherToken = new CancellationTokenSource();
            await Task.Run(async() =>
            {
                var manifest = origin.GetLocalManifest(Game.ProviderId, null, true);
                var platform = manifest.publishing.softwareList.software.FirstOrDefault(a => a.softwarePlatform == "PCWIN");

                while (true)
                {
                    if (watcherToken.IsCancellationRequested)
                    {
                        return;
                    }

                    var executablePath = origin.GetPathFromPlatformPath(platform.fulfillmentAttributes.installCheckOverride);
                    if (!string.IsNullOrEmpty(executablePath))
                    {
                        if (File.Exists(executablePath))
                        {
                            if (Game.PlayTask == null)
                            {
                                Game.PlayTask = origin.GetGamePlayTask(manifest);
                            }

                            Game.InstallDirectory = Path.GetDirectoryName(executablePath);
                            OnInstalled(this, new GameControllerEventArgs(this, 0));
                            return;
                        }
                    }

                    await Task.Delay(2000);
                }
            });
        }
示例#2
0
        public async void StartInstallWatcher()
        {
            watcherToken = new CancellationTokenSource();
            await Task.Factory.StartNew(() =>
            {
                var manifest = origin.GetLocalManifest(Game.ProviderId, null, true);
                var platform = manifest.publishing.softwareList.software.FirstOrDefault(a => a.softwarePlatform == "PCWIN");

                while (true)
                {
                    if (watcherToken.IsCancellationRequested)
                    {
                        return;
                    }

                    var executablePath = origin.GetPathFromPlatformPath(platform.fulfillmentAttributes.installCheckOverride);
                    if (!string.IsNullOrEmpty(executablePath))
                    {
                        if (File.Exists(executablePath))
                        {
                            if (Game.PlayTask == null)
                            {
                                origin.GetGamePlayTask(manifest);
                            }

                            Game.InstallDirectory = Path.GetDirectoryName(executablePath);
                            OnInstalled(this, new GameControllerEventArgs(this, 0));
                            return;
                        }
                    }
                    else
                    {
                        if (PlayniteEnvironment.ThrowAllErrors)
                        {
                            throw new Exception($"Cannot start installation of {Game.Name} Origin game, cannot determine install location.");
                        }

                        logger.Error($"Cannot start installation of {Game.Name} Origin game, cannot determine install location.");
                        return;
                    }

                    Thread.Sleep(2000);
                }
            });
        }