Skip to content

Commit

Permalink
Update ParameterInput visibility when blocks are attached
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanmccall committed Jun 21, 2024
1 parent eeb2d75 commit 8354a46
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,7 @@ func _ready():
snap_point.block_type = block_type
snap_point.variant_type = variant_type

match variant_type:
TYPE_COLOR:
switch_input(_color_input)
TYPE_VECTOR2:
switch_input(_vector2_input)
TYPE_BOOL:
switch_input(_bool_input)
_:
switch_input(_text_input)

if option:
switch_input(_option_input)
_update_visible_input()


func get_snapped_block() -> Block:
Expand Down Expand Up @@ -148,11 +137,29 @@ func _on_line_edit_text_changed(new_text):
modified.emit()


func switch_input(node: Node):
func _update_visible_input():
if snap_point.has_snapped_block():
_switch_input(null)
elif option:
_switch_input(_option_input)
else:
match variant_type:
TYPE_COLOR:
_switch_input(_color_input)
TYPE_VECTOR2:
_switch_input(_vector2_input)
TYPE_BOOL:
_switch_input(_bool_input)
_:
_switch_input(_text_input)


func _switch_input(node: Node):
for c in _input_switcher.get_children():
c.visible = false

node.visible = true
if node:
node.visible = true


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

func _on_option_input_item_selected(index):
modified.emit()


func _on_snap_point_snapped_block_changed(block):
_update_visible_input()
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ size_flags_horizontal = 3

[node name="BoolInput" type="MarginContainer" parent="InputSwitcher"]
unique_name_in_owner = true
visible = false
layout_mode = 2
theme_override_constants/margin_left = 8

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

0 comments on commit 8354a46

Please sign in to comment.