Skip to content

Commit ebcd851

Browse files
committed
Update ParameterInput visibility when blocks are attached
https://phabricator.endlessm.com/T35519
1 parent 154c705 commit ebcd851

File tree

2 files changed

+27
-14
lines changed

2 files changed

+27
-14
lines changed

addons/block_code/ui/blocks/utilities/parameter_input/parameter_input.gd

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -100,18 +100,7 @@ func _ready():
100100
snap_point.block_type = block_type
101101
snap_point.variant_type = variant_type
102102

103-
match variant_type:
104-
TYPE_COLOR:
105-
switch_input(_color_input)
106-
TYPE_VECTOR2:
107-
switch_input(_vector2_input)
108-
TYPE_BOOL:
109-
switch_input(_bool_input)
110-
_:
111-
switch_input(_text_input)
112-
113-
if option:
114-
switch_input(_option_input)
103+
_update_visible_input()
115104

116105

117106
func get_snapped_block() -> Block:
@@ -148,11 +137,29 @@ func _on_line_edit_text_changed(new_text):
148137
modified.emit()
149138

150139

151-
func switch_input(node: Node):
140+
func _update_visible_input():
141+
if snap_point.has_snapped_block():
142+
_switch_input(null)
143+
elif option:
144+
_switch_input(_option_input)
145+
else:
146+
match variant_type:
147+
TYPE_COLOR:
148+
_switch_input(_color_input)
149+
TYPE_VECTOR2:
150+
_switch_input(_vector2_input)
151+
TYPE_BOOL:
152+
_switch_input(_bool_input)
153+
_:
154+
_switch_input(_text_input)
155+
156+
157+
func _switch_input(node: Node):
152158
for c in _input_switcher.get_children():
153159
c.visible = false
154160

155-
node.visible = true
161+
if node:
162+
node.visible = true
156163

157164

158165
func _on_color_input_color_changed(color):
@@ -169,3 +176,7 @@ func _update_panel_bg_color(new_color):
169176

170177
func _on_option_input_item_selected(index):
171178
modified.emit()
179+
180+
181+
func _on_snap_point_snapped_block_changed(block):
182+
_update_visible_input()

addons/block_code/ui/blocks/utilities/parameter_input/parameter_input.tscn

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ size_flags_horizontal = 3
156156

157157
[node name="BoolInput" type="MarginContainer" parent="InputSwitcher"]
158158
unique_name_in_owner = true
159+
visible = false
159160
layout_mode = 2
160161
theme_override_constants/margin_left = 8
161162

@@ -187,3 +188,4 @@ variant_type = 4
187188
[connection signal="text_changed" from="InputSwitcher/Vector2Input/HBoxContainer/XLineEdit" to="." method="_on_line_edit_text_changed"]
188189
[connection signal="text_changed" from="InputSwitcher/Vector2Input/HBoxContainer/YLineEdit" to="." method="_on_line_edit_text_changed"]
189190
[connection signal="item_selected" from="InputSwitcher/BoolInput/BoolInputOption" to="." method="_on_option_input_item_selected"]
191+
[connection signal="snapped_block_changed" from="SnapPoint" to="." method="_on_snap_point_snapped_block_changed"]

0 commit comments

Comments
 (0)