Skip to content
Permalink
Browse files

[Assets] New game template: set current project to Windows

  • Loading branch information
xen2 committed Sep 21, 2018
1 parent 406a74c commit 56b6774374acd67ecf7f01c985524fbdba976161
@@ -139,12 +139,8 @@ protected override bool Generate(SessionTemplateGeneratorParameters parameters)
// Setup the assets folder
//Directory.CreateDirectory(UPath.Combine(package.RootDirectory, (UDirectory)"Assets/Shared"));

var previousCurrent = session.CurrentProject;

session.Projects.Add(project);

session.CurrentProject = project;

// Load missing references
session.LoadMissingDependencies(parameters.Logger);
// Load dependency assets (needed for camera script template)
@@ -163,7 +159,7 @@ protected override bool Generate(SessionTemplateGeneratorParameters parameters)
};

// Generate executable projects for each platform
ProjectTemplateGeneratorHelper.UpdatePackagePlatforms(packageParameters, platforms, orientation, false);
var platformProjects = ProjectTemplateGeneratorHelper.UpdatePackagePlatforms(packageParameters, platforms, orientation, false).ToList();

// Add asset packages
CopyAssetPacks(parameters, package);
@@ -224,6 +220,9 @@ protected override bool Generate(SessionTemplateGeneratorParameters parameters)
// Log done
ProjectTemplateGeneratorHelper.Progress(logger, "Done", stepCount, stepCount);

// Set current project
session.CurrentProject = platformProjects.FirstOrDefault(x => x.Platform == PlatformType.Windows) ?? project;

return true;
}

@@ -493,7 +493,7 @@ public override void Destroy()

private void AutoSelectCurrentProject()
{
var currentProject = LocalPackages.FirstOrDefault();
var currentProject = LocalPackages.OfType<ProjectViewModel>().FirstOrDefault(x => x.Type == ProjectType.Executable && x.Platform == PlatformType.Windows) ?? LocalPackages.FirstOrDefault();
if (currentProject != null)
{
SetCurrentProject(currentProject);
@@ -61,7 +61,7 @@ public static void AddOption(TemplateGeneratorParameters parameters, string opti
return parameters.Tags.TryGetValue(OptionsKey, out options) ? options : new Dictionary<string, object>();
}

public static void UpdatePackagePlatforms(PackageTemplateGeneratorParameters packageParameters, ICollection<SelectedSolutionPlatform> platforms, DisplayOrientation orientation, bool forcePlatformRegeneration)
public static IEnumerable<SolutionProject> UpdatePackagePlatforms(PackageTemplateGeneratorParameters packageParameters, ICollection<SelectedSolutionPlatform> platforms, DisplayOrientation orientation, bool forcePlatformRegeneration)
{
if (platforms == null) throw new ArgumentNullException(nameof(platforms));
var logger = packageParameters.Logger;
@@ -143,6 +143,8 @@ public static void UpdatePackagePlatforms(PackageTemplateGeneratorParameters pac
package.Session.Projects.Add(newExeProject);

package.Session.IsDirty = true;

yield return newExeProject;
}

foreach (var project in projectsToRemove)
@@ -224,6 +226,8 @@ public static SolutionProject GenerateTemplate(TemplateGeneratorParameters param
projectTemplate.Generate(outputDirectoryPath, projectName, projectGuid, parameters.Logger, options, generatedFiles);

var project = new SolutionProject(package, projectGuid, projectFullPath);
project.Type = projectType;
project.Platform = platformType;

return project;
}

0 comments on commit 56b6774

Please sign in to comment.
You can’t perform that action at this time.