From f4f92a27dfbc47d15dc27de693b1a3928ad4ceb6 Mon Sep 17 00:00:00 2001 From: Victor Chelaru Date: Tue, 26 Dec 2023 07:34:42 -0700 Subject: [PATCH] Added file verison check for bbcode --- FRBDK/Glue/Glue/SaveClasses/GlueProjectSave.cs | 5 +++-- .../GumPlugin/CodeGeneration/TextCodeGenerator.cs | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/FRBDK/Glue/Glue/SaveClasses/GlueProjectSave.cs b/FRBDK/Glue/Glue/SaveClasses/GlueProjectSave.cs index c13e41e6d..6fbad1fae 100644 --- a/FRBDK/Glue/Glue/SaveClasses/GlueProjectSave.cs +++ b/FRBDK/Glue/Glue/SaveClasses/GlueProjectSave.cs @@ -133,14 +133,15 @@ public enum GluxVersions SpriteManagerHasInsertLayer = 48, GumUsesSystemTypes = 49, // Technically this isn't referencing GumCommon project, but it's referencing code from GumCommon - GumCommonCodeReferencing = 50 + GumCommonCodeReferencing = 50, + GumTextSupportsBbCode = 51 } #endregion #region Versions - public const int LatestVersion = (int)GluxVersions.GumCommonCodeReferencing; + public const int LatestVersion = (int)GluxVersions.GumTextSupportsBbCode; public int FileVersion { get; set; } diff --git a/FRBDK/Glue/GumPlugin/GumPlugin/CodeGeneration/TextCodeGenerator.cs b/FRBDK/Glue/GumPlugin/GumPlugin/CodeGeneration/TextCodeGenerator.cs index ff0de3af8..e0a6bd083 100644 --- a/FRBDK/Glue/GumPlugin/GumPlugin/CodeGeneration/TextCodeGenerator.cs +++ b/FRBDK/Glue/GumPlugin/GumPlugin/CodeGeneration/TextCodeGenerator.cs @@ -39,10 +39,19 @@ public void AddStandardGetterSetterReplacements( codeBlock.Line(" ContainedText.Width = 0;"); codeBlock.Line("}"); + var fileVersion = GlueState.Self.CurrentGlueProject?.FileVersion; - codeBlock.Line("ContainedText.RawText = value;"); + // don't directly set it, go through the CustomSetPropertyOnRenderable so bbcode works + if(fileVersion >= (int)GluxVersions.GumTextSupportsBbCode) + { + codeBlock.Line("global::Gum.Wireframe.CustomSetPropertyOnRenderable.TrySetPropertyOnText(ContainedText, this, nameof(Text), value);"); + } + else + { + codeBlock.Line("ContainedText.RawText = value;"); + } - if (GlueState.Self.CurrentGlueProject?.FileVersion >= (int)GluxVersions.GraphicalUiElementINotifyPropertyChanged) + if (fileVersion >= (int)GluxVersions.GraphicalUiElementINotifyPropertyChanged) { codeBlock.Line("NotifyPropertyChanged();"); } @@ -51,7 +60,7 @@ public void AddStandardGetterSetterReplacements( codeBlock.Line("if (shouldUpdate)"); codeBlock.Line("{"); - if (GlueState.Self.CurrentGlueProject?.FileVersion >= (int)GluxVersions.GumTextObjectsUpdateTextWith0ChildDepth) + if (fileVersion >= (int)GluxVersions.GumTextObjectsUpdateTextWith0ChildDepth) { codeBlock.Line(" UpdateLayout(Gum.Wireframe.GraphicalUiElement.ParentUpdateType.IfParentWidthHeightDependOnChildren | Gum.Wireframe.GraphicalUiElement.ParentUpdateType.IfParentStacks, int.MaxValue/2);"); }