protected sealed override bool Generate(SessionTemplateGeneratorParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }
            parameters.Validate();

            var logger  = parameters.Logger;
            var name    = parameters.Name;
            var session = parameters.Session;

            // Log progress
            var projectName = name;

            ProjectTemplateGeneratorHelper.Progress(logger, $"Generating {projectName}...", 0, 1);

            // Generate the library
            List <string> generatedFiles;

            ProjectTemplateGeneratorHelper.AddOption(parameters, "Platforms", AssetRegistry.SupportedPlatforms);
            var project = ProjectTemplateGeneratorHelper.GenerateTemplate(parameters, "ProjectLibrary/ProjectLibrary.ttproj", projectName, PlatformType.Shared, null, ProjectType.Library, out generatedFiles);

            session.Projects.Add(project);

            // Load missing references
            session.LoadMissingReferences(parameters.Logger);

            // Log done
            ProjectTemplateGeneratorHelper.Progress(logger, "Done", 1, 1);
            return(true);
        }
Ejemplo n.º 2
0
        public sealed override bool Run(PackageTemplateGeneratorParameters parameters)
        {
            if (parameters == null) throw new ArgumentNullException(nameof(parameters));
            parameters.Validate();

            var logger = parameters.Logger;
            var name = parameters.Name;
            var package = parameters.Package;

            // Make sure we have a shared profile
            var sharedProfile = package.Profiles.FindSharedProfile();
            if (sharedProfile == null)
            {
                sharedProfile = PackageProfile.NewShared();
                package.Profiles.Add(sharedProfile);
            }

            // Log progress
            var projectName = name;
            ProjectTemplateGeneratorHelper.Progress(logger, $"Generating {projectName}...", 0, 1);

            // Generate the library
            List<string> generatedFiles;
            ProjectTemplateGeneratorHelper.AddOption(parameters, "Platforms", AssetRegistry.SupportedPlatforms);
            var projectGameRef = ProjectTemplateGeneratorHelper.GenerateTemplate(parameters, package, "ProjectLibrary/ProjectLibrary.ttproj", projectName, PlatformType.Shared, null, ProjectType.Library, out generatedFiles);
            projectGameRef.Type = ProjectType.Library;
            sharedProfile.ProjectReferences.Add(projectGameRef);

            // Log done
            ProjectTemplateGeneratorHelper.Progress(logger, "Done", 1, 1);
            return true;
        }
        private static ProjectTemplate PrepareTemplate(PackageTemplateGeneratorParameters parameters, UFile templateRelativePath, PlatformType platformType, string currentProfile, GraphicsPlatform?graphicsPlatform, ProjectType projectType)
        {
            ProjectTemplateGeneratorHelper.AddOption(parameters, "Platforms", parameters.GetTag(PlatformsKey).Select(x => x.Platform).ToList());
            ProjectTemplateGeneratorHelper.AddOption(parameters, "CurrentPlatform", platformType);
            ProjectTemplateGeneratorHelper.AddOption(parameters, "CurrentProfile", currentProfile);
            ProjectTemplateGeneratorHelper.AddOption(parameters, "Orientation", parameters.GetTag(OrientationKey));
            var package = parameters.Package;

            return(ProjectTemplateGeneratorHelper.PrepareTemplate(parameters, package, templateRelativePath, platformType, graphicsPlatform, projectType));
        }