File tree Expand file tree Collapse file tree 3 files changed +42
-1
lines changed Expand file tree Collapse file tree 3 files changed +42
-1
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,8 @@ const EXTEND_MARGIN: float = 800
66
77@onready var _window : Control = % Window
88@onready var _window_scroll : ScrollContainer = % WindowScroll
9+ @onready var _choose_block_code_label : Label = % ChooseBlockCodeLabel
10+ @onready var _create_block_code_label : Label = % CreateBlockCodeLabel
911
1012var _block_scenes_by_class = {}
1113
@@ -41,10 +43,27 @@ func set_child(n: Node):
4143func bsd_selected (bsd : BlockScriptData ):
4244 clear_canvas ()
4345
46+ _choose_block_code_label .visible = false
47+ _create_block_code_label .visible = false
48+
49+ if not bsd and scene_has_bsd_nodes ():
50+ _choose_block_code_label .visible = true
51+ return
52+ elif not bsd and not scene_has_bsd_nodes ():
53+ _create_block_code_label .visible = true
54+ return
55+
4456 for tree in bsd .block_trees .array :
4557 load_tree (_window , tree )
4658
4759
60+ func scene_has_bsd_nodes () -> bool :
61+ var scene_root = EditorInterface .get_edited_scene_root ()
62+ if not scene_root :
63+ return false
64+ return scene_root .find_children ("*" , "BlockCode" ).size () > 0
65+
66+
4867func clear_canvas ():
4968 for child in _window .get_children ():
5069 child .queue_free ()
Original file line number Diff line number Diff line change @@ -24,3 +24,17 @@ unique_name_in_owner = true
2424layout_mode = 2
2525size_flags_horizontal = 3
2626mouse_filter = 1
27+
28+ [node name ="ChooseBlockCodeLabel" type ="Label" parent ="." ]
29+ unique_name_in_owner = true
30+ visible = false
31+ layout_mode = 2
32+ text = "Choose a BlockCode node in the inspector."
33+ horizontal_alignment = 1
34+
35+ [node name ="CreateBlockCodeLabel" type ="Label" parent ="." ]
36+ unique_name_in_owner = true
37+ visible = false
38+ layout_mode = 2
39+ text = "First, add a BlockCode node to the scene."
40+ horizontal_alignment = 1
Original file line number Diff line number Diff line change @@ -8,6 +8,10 @@ signal block_picked(block: Block)
88
99
1010func bsd_selected (bsd : BlockScriptData ):
11+ if not bsd :
12+ reset_picker ()
13+ return
14+
1115 for class_dict in ProjectSettings .get_global_class_list ():
1216 if class_dict .class == bsd .script_inherits :
1317 var script = load (class_dict .path )
@@ -19,10 +23,14 @@ func bsd_selected(bsd: BlockScriptData):
1923 init_picker (CategoryFactory .get_inherited_categories (bsd .script_inherits ))
2024
2125
22- func init_picker ( extra_blocks : Array [ BlockCategory ] = [] ):
26+ func reset_picker ( ):
2327 for c in _block_list .get_children ():
2428 c .queue_free ()
2529
30+
31+ func init_picker (extra_blocks : Array [BlockCategory ] = []):
32+ reset_picker ()
33+
2634 var block_categories := CategoryFactory .get_general_categories ()
2735
2836 if extra_blocks .size () > 0 :
You can’t perform that action at this time.
0 commit comments