Skip to content

Commit

Permalink
Generated platformer files are now automatically removed from the pro…
Browse files Browse the repository at this point in the history
…ject if no entities are platformers anymore.

fixes #1346
  • Loading branch information
vchelaru committed Feb 7, 2024
1 parent 7cf4333 commit 73c3ee4
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,14 @@ private static void UpdatePlatformerCodePresenceInProject()
FlatRedBall.PlatformerPlugin.Generators.EnumFileGenerator.Self.GenerateAndSave();
FlatRedBall.PlatformerPlugin.Generators.IPlatformerCodeGenerator.Self.GenerateAndSave();
FlatRedBall.PlatformerPlugin.Generators.PlatformerAnimationControllerGenerator.Self.GenerateAndSave();
}

else
{
// see if there are any references to files which do not exist. If so, let's remove them:
GlueCommands.Self.ProjectCommands.RemoveFromProjects(FlatRedBall.PlatformerPlugin.Generators.EnumFileGenerator.Self.FileLocation);
GlueCommands.Self.ProjectCommands.RemoveFromProjects(FlatRedBall.PlatformerPlugin.Generators.IPlatformerCodeGenerator.Self.FileLocation);
GlueCommands.Self.ProjectCommands.RemoveFromProjects(FlatRedBall.PlatformerPlugin.Generators.PlatformerAnimationControllerGenerator.Self.FileLocation);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ public interface IProjectCommands
void MakeGeneratedCodeItemsNested();

/// <summary>
/// Removes the argument filePath from all currently-loaded files, and saves the projects.
/// Removes the argument filePath from all currently-loaded files, and optionally saves the projects if any file was removed
/// and if saveAfterRemoving is true..
/// </summary>
/// <param name="filePath">The file path to remove</param>
void RemoveFromProjects(FilePath filePath, bool saveAfterRemoving = true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ namespace FlatRedBall.PlatformerPlugin.Generators
{
public class EnumFileGenerator : Singleton<EnumFileGenerator>
{
string RelativeFileLocation => "Platformer/Enums.Generated.cs";
public string RelativeFileLocation => "Platformer/Enums.Generated.cs";
public FilePath FileLocation => (GlueState.Self.CurrentGlueProjectDirectory + RelativeFileLocation);

public void GenerateAndSave()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace FlatRedBall.PlatformerPlugin.Generators
public class IPlatformerCodeGenerator : Singleton<IPlatformerCodeGenerator>
{
string RelativeFileLocation => "Platformer/IPlatformer.Generated.cs";
public FilePath FileLocation => GlueState.Self.CurrentGlueProjectDirectory + RelativeFileLocation;

public void GenerateAndSave()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using FlatRedBall.Glue.Managers;
using FlatRedBall.Glue.Plugins.ExportedImplementations;
using FlatRedBall.Glue.SaveClasses;
using FlatRedBall.IO;
using System;
using System.Collections.Generic;
using System.Text;
Expand All @@ -10,6 +11,7 @@ namespace FlatRedBall.PlatformerPlugin.Generators
public class PlatformerAnimationControllerGenerator : Singleton<PlatformerAnimationControllerGenerator>
{
string RelativeFileLocation => "Platformer/PlatformerAnimationController.Generated.cs";
public FilePath FileLocation => GlueState.Self.CurrentGlueProjectDirectory + RelativeFileLocation;


public void GenerateAndSave()
Expand Down

0 comments on commit 73c3ee4

Please sign in to comment.