Skip to content

Commit

Permalink
Oops caused too much codegen for forms.
Browse files Browse the repository at this point in the history
  • Loading branch information
vchelaru committed Nov 22, 2023
1 parent 1d14927 commit 1658ddb
Showing 1 changed file with 28 additions and 22 deletions.
50 changes: 28 additions & 22 deletions FRBDK/Glue/GumPlugin/GumPlugin/Managers/CodeGeneratorManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -391,33 +391,39 @@ public GenerationResult GenerateCodeFor(Gum.DataTypes.ElementSave element, bool

#region Custom Forms

string customFormsSaveLocation = CustomFormsCodeLocationFor(element).FullPath;
var customFormsCode = CustomCodeGenerator.Self.GetCustomFormsCodeTemplateCode(element);
// Check if generated code is created. If not, don't create a custom.
// Generated may not be created if this maps to a standard Forms object
// like Button.
if (shouldGeneratedFormsBeInProject)
{
string customFormsSaveLocation = CustomFormsCodeLocationFor(element).FullPath;
var customFormsCode = CustomCodeGenerator.Self.GetCustomFormsCodeTemplateCode(element);

if(string.IsNullOrEmpty(customFormsCode))
{
resultToReturn.DidSaveCustomForms = false;
}
else if(!System.IO.File.Exists(customFormsSaveLocation))
{
resultToReturn.DidSaveCustomForms = true;
}
if(string.IsNullOrEmpty(customFormsCode))
{
resultToReturn.DidSaveCustomForms = false;
}
else if(!System.IO.File.Exists(customFormsSaveLocation))
{
resultToReturn.DidSaveCustomForms = true;
}

if (resultToReturn.DidSaveCustomForms)
{
if (resultToReturn.DidSaveCustomForms)
{

var directory = FileManager.GetDirectory(customFormsSaveLocation);
System.IO.Directory.CreateDirectory(directory);
var directory = FileManager.GetDirectory(customFormsSaveLocation);
System.IO.Directory.CreateDirectory(directory);

GlueCommands.Self.TryMultipleTimes(() =>
System.IO.File.WriteAllText(customFormsSaveLocation, customFormsCode));
GlueCommands.Self.TryMultipleTimes(() =>
System.IO.File.WriteAllText(customFormsSaveLocation, customFormsCode));

bool wasAnythingAdded =
FlatRedBall.Glue.ProjectManager.CodeProjectHelper.AddFileToCodeProjectIfNotAlreadyAdded(
GlueState.Self.CurrentMainProject, customFormsSaveLocation);
if (wasAnythingAdded)
{
shouldSaveProject = true;
bool wasAnythingAdded =
FlatRedBall.Glue.ProjectManager.CodeProjectHelper.AddFileToCodeProjectIfNotAlreadyAdded(
GlueState.Self.CurrentMainProject, customFormsSaveLocation);
if (wasAnythingAdded)
{
shouldSaveProject = true;
}
}
}

Expand Down

0 comments on commit 1658ddb

Please sign in to comment.