Skip to content

Commit

Permalink
More fixes to codegen for variants that reference gum variable types.
Browse files Browse the repository at this point in the history
  • Loading branch information
vchelaru committed Feb 22, 2024
1 parent f824632 commit 5a94d4e
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion FRBDK/Glue/Glue/CodeGeneration/CustomVariableCodeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,18 @@ public static string GetRightSideOfEquals(CustomVariable customVariable, GlueEle
{
rightSide = "Microsoft.Xna.Framework.Color." + rightSide.Replace("\"", "");

}
else if(IsQualifiedGumState(customVariable?.Type))
{
if(!string.IsNullOrEmpty(rightSide))
{
var type = customVariable.Type;
if(type.EndsWith("?"))
{
type = type.Substring(0, type.Length - 1);
}
rightSide = type + "." + rightSide.Replace("\"", "");
}
}
//This code was setting the variable to "null" but if it's explicitly "", then we should leave it as that because that's what is used
//for instructions. We want instructions and variables to work the same way, I think, but I'm leaving this here incase it does cause complications
Expand Down Expand Up @@ -1640,7 +1652,7 @@ private static bool IsQualifiedGumState(string type)
// For the sake of speed, we're going to just look at the prefix and guess based on that. A full
// implementation would do a browsing of Gum files and look for states but....that's not easy because
// all of that code is in a plugin, and we can approximate it here:
return type.StartsWith($"{GlueState.Self.ProjectNamespace}.GumRuntimes");
return type?.StartsWith($"{GlueState.Self.ProjectNamespace}.GumRuntimes") == true;
}
}
}

0 comments on commit 5a94d4e

Please sign in to comment.