From 71f5910656fadd9d8d6309bbfdef5c32429b2899 Mon Sep 17 00:00:00 2001 From: Jeremi Biernacki Date: Sun, 5 May 2024 10:07:18 +0200 Subject: [PATCH] Fix small bug that doesn't allow to set _text and text in back to empty string --- .../examples/advanced_text_labels.tscn | 14 ++++++-------- addons/advanced-text/nodes/AdvancedTextLabel.gd | 10 +++++----- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/addons/advanced-text/examples/advanced_text_labels.tscn b/addons/advanced-text/examples/advanced_text_labels.tscn index 255a25c..b95d009 100644 --- a/addons/advanced-text/examples/advanced_text_labels.tscn +++ b/addons/advanced-text/examples/advanced_text_labels.tscn @@ -87,7 +87,7 @@ bold = "**" points = "-" headers = Array[LabelSettings]([SubResource("LabelSettings_mqb2n"), SubResource("LabelSettings_c8yh7"), SubResource("LabelSettings_faw0r"), SubResource("LabelSettings_n4lgb")]) -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ttfn2"] +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_mursv"] content_margin_left = 4.0 content_margin_top = 4.0 content_margin_right = 4.0 @@ -108,7 +108,7 @@ expand_margin_top = 2.0 expand_margin_right = 2.0 expand_margin_bottom = 2.0 -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_omdtg"] +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_5yccs"] content_margin_left = 4.0 content_margin_top = 4.0 content_margin_right = 4.0 @@ -676,12 +676,10 @@ theme_override_fonts/bold_italics_font = ExtResource("4_rc1wt") theme_override_fonts/mono_font = ExtResource("5_fmnql") bbcode_enabled = true text = "[font_size= 64][font=res://addons/material-design-icons/fonts/material_design_icons.ttf]󰾼[/font][/font_size] -[font_size=64][font=res://addons/emojis-for-godot/emojis/NotoColorEmoji.ttf]🍪[/font][/font_size] -" +[font_size=64][font=res://addons/emojis-for-godot/emojis/NotoColorEmoji.ttf]🍪[/font][/font_size]" script = ExtResource("1_uinld") _text = "[icon:format-text-rotation-angle-up, 64] -:cookie, 64: -" +:cookie, 64:" parser = SubResource("Resource_va62r") [node name="AdvancedTextButton" type="Panel" parent="."] @@ -701,8 +699,8 @@ grow_vertical = 2 [node name="AdvancedTextButton" type="RichTextLabel" parent="AdvancedTextButton/VBoxContainer" groups=["test_btn"]] layout_mode = 2 -theme_override_styles/focus = SubResource("StyleBoxFlat_ttfn2") -theme_override_styles/normal = SubResource("StyleBoxFlat_omdtg") +theme_override_styles/focus = SubResource("StyleBoxFlat_mursv") +theme_override_styles/normal = SubResource("StyleBoxFlat_5yccs") bbcode_enabled = true text = "[center][rainbow freq=0.2 sat=10 val=20 ][b]Markdown Button[/b][/rainbow][/center]" fit_content = true diff --git a/addons/advanced-text/nodes/AdvancedTextLabel.gd b/addons/advanced-text/nodes/AdvancedTextLabel.gd index fc6762e..c004b91 100644 --- a/addons/advanced-text/nodes/AdvancedTextLabel.gd +++ b/addons/advanced-text/nodes/AdvancedTextLabel.gd @@ -16,13 +16,13 @@ signal custom_link(url:String) @export_multiline var _text := "": set(value): _text = value - _parse_text() + if value == "": + text = "" + return - get: - if text and _text.is_empty(): - _text = text + _parse_text() - return _text + get: return _text ## TextParser that will be used to parse `_text` @export var parser: TextParser: