Skip to content

Commit

Permalink
Added file verison check for bbcode
Browse files Browse the repository at this point in the history
  • Loading branch information
vchelaru committed Dec 26, 2023
1 parent ca1cbb5 commit f4f92a2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
5 changes: 3 additions & 2 deletions FRBDK/Glue/Glue/SaveClasses/GlueProjectSave.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down
15 changes: 12 additions & 3 deletions FRBDK/Glue/GumPlugin/GumPlugin/CodeGeneration/TextCodeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();");
}
Expand All @@ -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);");
}
Expand Down

0 comments on commit f4f92a2

Please sign in to comment.