Skip to content

Commit

Permalink
Fixed bug where general response success was false when adding a new …
Browse files Browse the repository at this point in the history
…file - breaking the creation of new projects.

Added earlier error check when creating new file for whether new file was created.
  • Loading branch information
vchelaru committed Nov 13, 2024
1 parent 7cf3189 commit 15f70a0
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1364,7 +1364,7 @@ public ReferencedFileSave CreateReferencedFileSaveForExistingFile(IElement conta
string fileWithoutPath = FileManager.RemovePath(FileManager.RemoveExtension(absoluteFileName));

bool isValid =
NameVerifier.IsReferencedFileNameValid(fileWithoutPath, ati, referencedFileSaveToReturn, containerForFile, out whyItIsntValid);
NameVerifier.IsReferencedFileNameValid(fileWithoutPath, ati, referencedFileSaveToReturn, (GlueElement)containerForFile, out whyItIsntValid);

if (!isValid)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -819,12 +819,12 @@ out string errorMessage
out string creationReport,
out string errorMessage
);


generalResponse.Succeeded = generalResponse.Data != null;

if(!string.IsNullOrEmpty(errorMessage))
{
if(generalResponse.Data == null)
{
generalResponse.Succeeded = false;
}
generalResponse.Message = errorMessage;
}

Expand Down
8 changes: 4 additions & 4 deletions FRBDK/Glue/Glue/SaveClasses/NameVerifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public static bool IsDirectoryNameValid(string directory, out string whyItIsntVa

#region Referenced File Save

public static bool IsReferencedFileNameValid(string name, AssetTypeInfo ati, ReferencedFileSave rfs, IElement container, out string whyItIsntValid)
public static bool IsReferencedFileNameValid(string name, AssetTypeInfo ati, ReferencedFileSave rfs, GlueElement container, out string whyItIsntValid)
{
whyItIsntValid = "";

Expand Down Expand Up @@ -274,7 +274,7 @@ public static bool IsReferencedFileNameValid(string name, AssetTypeInfo ati, Ref
return returnValue;
}

private static void CheckForRfsWithMatchingFileName(IElement container, string name, ReferencedFileSave rfsToSkip, ref string whyItIsntValid)
private static void CheckForRfsWithMatchingFileName(GlueElement container, string name, ReferencedFileSave rfsToSkip, ref string whyItIsntValid)
{

if (container == null)
Expand All @@ -294,7 +294,7 @@ private static void CheckForRfsWithMatchingFileName(IElement container, string n
}
else
{
// We need to see if there is already a file with the same name in Global Content
// We need to see if there is already a file with the same name in this container
ReferencedFileSave existingRfs = container.ReferencedFiles.FirstOrDefault(
rfs =>
{
Expand All @@ -305,7 +305,7 @@ private static void CheckForRfsWithMatchingFileName(IElement container, string n
});
if (existingRfs != null)
{
whyItIsntValid += $"{container.Name} is trying to add {name} but that name is already in use here: {existingRfs.Name}";
whyItIsntValid += $"{container.Name} is trying to add {name} but that name is already in use here: {existingRfs}";
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ private void ReactToChangedRuntimeType(ReferencedFileSave rfs, object oldValue,

}

public static void ReactToRenamedReferencedFile(string oldName, string newName, ReferencedFileSave rfs, IElement container)
public static void ReactToRenamedReferencedFile(string oldName, string newName, ReferencedFileSave rfs, GlueElement container)
{
string oldDirectory = FileManager.GetDirectory(oldName);
string newDirectory = FileManager.GetDirectory(newName);
Expand Down
5 changes: 5 additions & 0 deletions FRBDK/Glue/GumPlugin/GumPlugin/Managers/RightClickManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,11 @@ public async Task AddGumScreenScreenByName(string gumScreenName, FlatRedBall.Glu
var newRfs =
await AddExistingFileManager.Self.AddSingleFile(fullFileName, elementToAddTo: glueScreen);

if(newRfs == null)
{
throw new InvalidOperationException($"Critical Error: Could not add an RFS for file {fullFileName}");
}

// prior to doing any codegen, need to refresh the project specific ATIs:
AssetTypeInfoManager.Self.RefreshProjectSpecificAtis();

Expand Down

0 comments on commit 15f70a0

Please sign in to comment.