File tree Expand file tree Collapse file tree 4 files changed +53
-0
lines changed
Expand file tree Collapse file tree 4 files changed +53
-0
lines changed Original file line number Diff line number Diff line change @@ -78,3 +78,9 @@ func serialize_props(prop_names: Array) -> Array:
7878 for p in prop_names :
7979 pairs .append ([p , self .get (p )])
8080 return pairs
81+
82+
83+ func _make_custom_tooltip (for_text ) -> Control :
84+ var tooltip = preload ("res://addons/block_code/ui/tooltip/tooltip.tscn" ).instantiate ()
85+ tooltip .text = for_text
86+ return tooltip
Original file line number Diff line number Diff line change @@ -206,12 +206,21 @@ static func get_general_blocks() -> Array[Block]:
206206 b .block_formats = ["repeat {number: INT} " ]
207207 b .statements = ["for __i in {number} :" ]
208208 b .category = "Loops"
209+ b .tooltip_text = "Run the connected blocks [i]number[/i] times"
209210 block_list .append (b )
210211
211212 b = BLOCKS ["control_block" ].instantiate ()
212213 b .block_formats = ["while {condition: BOOL} " ]
213214 b .statements = ["while {condition} :" ]
214215 b .category = "Loops"
216+ b .tooltip_text = (
217+ """
218+ Run the connected blocks as long as [i]condition[/i] is true.
219+
220+ Hint: snap a [b]Comparison[/b] block into the condition.
221+ """
222+ . dedent ()
223+ )
215224 block_list .append (b )
216225
217226 b = BLOCKS ["statement_block" ].instantiate ()
Original file line number Diff line number Diff line change 1+ @tool
2+ class_name Tooltip
3+ extends RichTextLabel
4+ ## Rich-text control for block tooltips that matches the built-in inspector's tooltips' font styles
5+
6+
7+ func override_font (font_name : StringName , editor_font_name : StringName ) -> Font :
8+ var font = get_theme_font (editor_font_name , & "EditorFonts" )
9+ add_theme_font_override (font_name , font )
10+ return font
11+
12+
13+ func _ready ():
14+ # Set fonts to match documentation tooltips in inspector
15+ override_font (& "normal_font" , & "doc" )
16+ override_font (& "mono_font" , & "doc_source" )
17+ override_font (& "bold_font" , & "doc_bold" )
18+ var italics = override_font (& "italics_font" , & "doc_italic" )
19+
20+ # No doc_ style for bold italic; fake it by emboldening the italic style
21+ var bold_italics = FontVariation .new ()
22+ bold_italics .set_base_font (italics )
23+ bold_italics .set_variation_embolden (1.2 )
24+ add_theme_font_override (& "bold_italics_font" , bold_italics )
Original file line number Diff line number Diff line change 1+ [gd_scene load_steps =2 format =3 uid ="uid://bmxco03vqyq2t" ]
2+
3+ [ext_resource type ="Script" path ="res://addons/block_code/ui/tooltip/tooltip.gd" id ="1_4ko6a" ]
4+
5+ [node name ="Tooltip" type ="RichTextLabel" ]
6+ custom_minimum_size = Vector2 (360 , 48 )
7+ anchors_preset = 15
8+ anchor_right = 1.0
9+ anchor_bottom = 1.0
10+ grow_horizontal = 2
11+ grow_vertical = 2
12+ bbcode_enabled = true
13+ fit_content = true
14+ script = ExtResource ("1_4ko6a" )
You can’t perform that action at this time.
0 commit comments