Skip to content

Commit 1470758

Browse files
committed
Bool inputs
1 parent cfb02d7 commit 1470758

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ var block: Block
3131
@onready var _vector2_input := %Vector2Input
3232
@onready var _x_line_edit := %XLineEdit
3333
@onready var _y_line_edit := %YLineEdit
34+
# Bool
35+
@onready var _bool_input := %BoolInput
36+
@onready var _bool_input_option := %BoolInputOption
3437

3538

3639
func set_raw_input(raw_input):
@@ -52,6 +55,8 @@ func set_raw_input(raw_input):
5255
var split = raw_input.split(",")
5356
_x_line_edit.text = split[0]
5457
_y_line_edit.text = split[1]
58+
TYPE_BOOL:
59+
_bool_input_option.select(raw_input)
5560
_:
5661
_line_edit.text = raw_input
5762

@@ -68,6 +73,8 @@ func get_raw_input():
6873
return _color_input.color
6974
TYPE_VECTOR2:
7075
return _x_line_edit.text + "," + _y_line_edit.text
76+
TYPE_BOOL:
77+
return bool(_bool_input_option.selected)
7178
_:
7279
return _line_edit.text
7380

@@ -98,6 +105,8 @@ func _ready():
98105
switch_input(_color_input)
99106
TYPE_VECTOR2:
100107
switch_input(_vector2_input)
108+
TYPE_BOOL:
109+
switch_input(_bool_input)
101110
_:
102111
switch_input(_text_input)
103112

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

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[gd_scene load_steps=9 format=3 uid="uid://cjvxs6euc6xbm"]
1+
[gd_scene load_steps=10 format=3 uid="uid://cjvxs6euc6xbm"]
22

33
[ext_resource type="Script" path="res://addons/block_code/ui/blocks/utilities/parameter_input/parameter_input.gd" id="1_rgmxn"]
44
[ext_resource type="PackedScene" uid="uid://b1oge52xhjqnu" path="res://addons/block_code/ui/blocks/utilities/snap_point/snap_point.tscn" id="2_6esp3"]
@@ -20,6 +20,8 @@ corner_radius_bottom_left = 40
2020

2121
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_fjquj"]
2222

23+
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_e7f0k"]
24+
2325
[node name="ParameterInput" type="MarginContainer"]
2426
anchors_preset = 15
2527
anchor_right = 1.0
@@ -152,6 +154,26 @@ expand_to_text_length = true
152154
layout_mode = 2
153155
size_flags_horizontal = 3
154156

157+
[node name="BoolInput" type="MarginContainer" parent="InputSwitcher"]
158+
unique_name_in_owner = true
159+
layout_mode = 2
160+
theme_override_constants/margin_left = 8
161+
162+
[node name="BoolInputOption" type="OptionButton" parent="InputSwitcher/BoolInput"]
163+
unique_name_in_owner = true
164+
custom_minimum_size = Vector2(60, 0)
165+
layout_mode = 2
166+
theme_override_colors/font_color = Color(0, 0, 0, 1)
167+
theme_override_colors/font_focus_color = Color(0, 0, 0, 1)
168+
theme_override_styles/focus = SubResource("StyleBoxEmpty_e7f0k")
169+
theme_override_styles/normal = SubResource("StyleBoxEmpty_fjquj")
170+
item_count = 2
171+
selected = 0
172+
popup/item_0/text = "False"
173+
popup/item_0/id = 0
174+
popup/item_1/text = "True"
175+
popup/item_1/id = 1
176+
155177
[node name="SnapPoint" parent="." instance=ExtResource("2_6esp3")]
156178
unique_name_in_owner = true
157179
layout_mode = 2
@@ -164,3 +186,4 @@ variant_type = 4
164186
[connection signal="item_selected" from="InputSwitcher/OptionInput" to="." method="_on_option_input_item_selected"]
165187
[connection signal="text_changed" from="InputSwitcher/Vector2Input/HBoxContainer/XLineEdit" to="." method="_on_line_edit_text_changed"]
166188
[connection signal="text_changed" from="InputSwitcher/Vector2Input/HBoxContainer/YLineEdit" to="." method="_on_line_edit_text_changed"]
189+
[connection signal="item_selected" from="InputSwitcher/BoolInput/BoolInputOption" to="." method="_on_option_input_item_selected"]

addons/block_code/ui/picker/categories/category_factory.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ static func get_built_in_categories(_class_name: String) -> Array[BlockCategory]
350350
props = ["position", "rotation", "scale"]
351351

352352
"CanvasItem":
353-
props = ["modulate"]
353+
props = ["modulate", "visible"]
354354

355355
"RigidBody2D":
356356
for verb in ["entered", "exited"]:

0 commit comments

Comments
 (0)