Example #1
0
        public override async Task <bool> PrepareForRun(SessionTemplateGeneratorParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }
            parameters.Validate();

            if (!parameters.Unattended)
            {
                var window = new UpdatePlatformsWindow(new[] { PlatformType.Windows })
                {
                    ForcePlatformRegenerationVisible = false
                };

                await window.ShowModal();

                if (window.Result == DialogResult.Cancel)
                {
                    return(false);
                }

                parameters.SetTag(PlatformsKey, new List <SelectedSolutionPlatform>(window.SelectedPlatforms));
            }
            return(true);
        }
Example #2
0
        public override async Task <bool> PrepareForRun(PackageTemplateGeneratorParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }
            parameters.Validate();

            var package           = parameters.Package;
            var gameSettingsAsset = package.GetGameSettingsAsset();

            if (gameSettingsAsset == null)
            {
                parameters.Logger.Error($"Could not find game settings asset at location [{GameSettingsAsset.GameSettingsLocation}]");
                return(false);
            }

            // If there are no executable/shared projects in this package, we can't work on it
            var sharedProfile = package.Profiles.FindSharedProfile();
            var existingPlatformTypesWithExe = new HashSet <PlatformType>(package.Profiles.Where(profile => profile.Platform != PlatformType.Shared && profile.ProjectReferences.Any(projectRef => projectRef.Type == ProjectType.Executable)).Select(item => item.Platform));

            if (sharedProfile == null || existingPlatformTypesWithExe.Count == 0)
            {
                parameters.Logger.Error("The selected package does not contain a shared profile with executable projects");
                return(false);
            }

            var defaultNamespace = GetDefaultNamespace(parameters);

            if (parameters.Unattended)
            {
                if (!parameters.HasTag(PlatformsKey))
                {
                    throw new InvalidOperationException("The platforms must be set with SetPlatforms before calling PrepareForRun if DontAskForPlatforms is true.");
                }
                parameters.SetTag(ForcePlatformRegenerationKey, true);
            }
            else
            {
                var window = new UpdatePlatformsWindow(existingPlatformTypesWithExe)
                {
                    ForcePlatformRegenerationVisible = parameters.TryGetTag(ForcePlatformRegenerationKey)
                };

                await window.ShowModal();

                if (window.Result == DialogResult.Cancel)
                {
                    return(false);
                }

                parameters.SetTag(PlatformsKey, new List <SelectedSolutionPlatform>(window.SelectedPlatforms));
                parameters.SetTag(ForcePlatformRegenerationKey, window.ForcePlatformRegeneration);
            }
            parameters.SetTag(OrientationKey, (DisplayOrientation)gameSettingsAsset.GetOrCreate <RenderingSettings>().DisplayOrientation);
            parameters.Namespace = defaultNamespace;

            return(true);
        }