예제 #1
0
        public async void StartInstallWatcher()
        {
            watcherToken = new CancellationTokenSource();
            var manifest = origin.GetLocalManifest(Game.GameId, 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.PlayAction == null)
                        {
                            Game.PlayAction = origin.GetGamePlayTask(manifest);
                        }

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

                await Task.Delay(2000);
            }
        }
        public async void StartInstallWatcher()
        {
            watcherToken = new CancellationTokenSource();
            var manifest = origin.GetLocalManifest(Game.GameId);

            if (manifest?.publishing == null)
            {
                logger.Error($"No publishing manifest found for Origin game {Game.GameId}, stopping installation check.");
                OnUninstalled(this, new GameControllerEventArgs(this, 0));
                return;
            }

            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 (!executablePath?.CompletePath.IsNullOrEmpty() != null)
                {
                    if (File.Exists(executablePath.CompletePath))
                    {
                        var installInfo = new GameInfo()
                        {
                            PlayAction = new GameAction
                            {
                                Type = GameActionType.URL,
                                Path = Origin.GetLaunchString(Game.GameId),
                                IsHandledByPlugin = true
                            },
                            InstallDirectory = origin.GetInstallDirectory(manifest)
                        };

                        OnInstalled(this, new GameInstalledEventArgs(installInfo, this, 0));
                        return;
                    }
                }

                await Task.Delay(2000);
            }
        }