From 5a94d4e045e8077c24656e946770e67a0ce2ffbb Mon Sep 17 00:00:00 2001 From: Victor Date: Wed, 21 Feb 2024 19:50:48 -0700 Subject: [PATCH] More fixes to codegen for variants that reference gum variable types. --- .../CodeGeneration/CustomVariableCodeGenerator.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/FRBDK/Glue/Glue/CodeGeneration/CustomVariableCodeGenerator.cs b/FRBDK/Glue/Glue/CodeGeneration/CustomVariableCodeGenerator.cs index 58cd67107..195e324ce 100644 --- a/FRBDK/Glue/Glue/CodeGeneration/CustomVariableCodeGenerator.cs +++ b/FRBDK/Glue/Glue/CodeGeneration/CustomVariableCodeGenerator.cs @@ -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 @@ -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; } } }