Skip to content

Commit cfb02d7

Browse files
committed
Vector2 input
1 parent c9fc020 commit cfb02d7

File tree

2 files changed

+88
-5
lines changed

2 files changed

+88
-5
lines changed

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

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,21 @@ var option: bool = false
1616
var block: Block
1717

1818
@onready var _panel := %Panel
19-
@onready var _line_edit := %LineEdit
2019
@onready var snap_point := %SnapPoint
2120
@onready var _input_switcher := %InputSwitcher
22-
# Inputs
21+
22+
## Inputs
23+
# Text
2324
@onready var _text_input := %TextInput
25+
@onready var _line_edit := %LineEdit
26+
# Color
2427
@onready var _color_input := %ColorInput
28+
# Option Dropdown
2529
@onready var _option_input := %OptionInput
30+
# Vector2
31+
@onready var _vector2_input := %Vector2Input
32+
@onready var _x_line_edit := %XLineEdit
33+
@onready var _y_line_edit := %YLineEdit
2634

2735

2836
func set_raw_input(raw_input):
@@ -40,7 +48,10 @@ func set_raw_input(raw_input):
4048
TYPE_COLOR:
4149
_color_input.color = raw_input
4250
_update_panel_bg_color(raw_input)
43-
51+
TYPE_VECTOR2:
52+
var split = raw_input.split(",")
53+
_x_line_edit.text = split[0]
54+
_y_line_edit.text = split[1]
4455
_:
4556
_line_edit.text = raw_input
4657

@@ -55,7 +66,8 @@ func get_raw_input():
5566
match variant_type:
5667
TYPE_COLOR:
5768
return _color_input.color
58-
69+
TYPE_VECTOR2:
70+
return _x_line_edit.text + "," + _y_line_edit.text
5971
_:
6072
return _line_edit.text
6173

@@ -84,7 +96,8 @@ func _ready():
8496
match variant_type:
8597
TYPE_COLOR:
8698
switch_input(_color_input)
87-
99+
TYPE_VECTOR2:
100+
switch_input(_vector2_input)
88101
_:
89102
switch_input(_text_input)
90103

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

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,74 @@ custom_minimum_size = Vector2(40, 0)
8484
layout_mode = 2
8585
theme_override_styles/normal = SubResource("StyleBoxEmpty_fjquj")
8686

87+
[node name="Vector2Input" type="MarginContainer" parent="InputSwitcher"]
88+
unique_name_in_owner = true
89+
visible = false
90+
layout_mode = 2
91+
theme_override_constants/margin_left = 8
92+
theme_override_constants/margin_top = 4
93+
theme_override_constants/margin_right = 8
94+
theme_override_constants/margin_bottom = 4
95+
96+
[node name="HBoxContainer" type="HBoxContainer" parent="InputSwitcher/Vector2Input"]
97+
layout_mode = 2
98+
99+
[node name="Control" type="Control" parent="InputSwitcher/Vector2Input/HBoxContainer"]
100+
layout_mode = 2
101+
size_flags_horizontal = 3
102+
103+
[node name="XLineEdit" type="LineEdit" parent="InputSwitcher/Vector2Input/HBoxContainer"]
104+
unique_name_in_owner = true
105+
layout_mode = 2
106+
mouse_filter = 1
107+
theme_override_colors/font_color = Color(0.118581, 0.118581, 0.118581, 1)
108+
theme_override_colors/font_uneditable_color = Color(0.117647, 0.117647, 0.117647, 1)
109+
theme_override_colors/font_placeholder_color = Color(0.76662, 0.76662, 0.76662, 1)
110+
theme_override_constants/minimum_character_width = 0
111+
theme_override_styles/normal = SubResource("StyleBoxEmpty_6oowp")
112+
theme_override_styles/focus = SubResource("StyleBoxEmpty_afyv2")
113+
theme_override_styles/read_only = SubResource("StyleBoxEmpty_3r4mt")
114+
placeholder_text = "x"
115+
alignment = 1
116+
expand_to_text_length = true
117+
118+
[node name="Control3" type="Control" parent="InputSwitcher/Vector2Input/HBoxContainer"]
119+
layout_mode = 2
120+
size_flags_horizontal = 3
121+
122+
[node name="CenterContainer" type="MarginContainer" parent="InputSwitcher/Vector2Input/HBoxContainer"]
123+
layout_mode = 2
124+
size_flags_horizontal = 3
125+
126+
[node name="ColorRect" type="ColorRect" parent="InputSwitcher/Vector2Input/HBoxContainer/CenterContainer"]
127+
custom_minimum_size = Vector2(2, 0)
128+
layout_mode = 2
129+
size_flags_horizontal = 4
130+
color = Color(0.804743, 0.804743, 0.804743, 1)
131+
132+
[node name="Control4" type="Control" parent="InputSwitcher/Vector2Input/HBoxContainer"]
133+
layout_mode = 2
134+
size_flags_horizontal = 3
135+
136+
[node name="YLineEdit" type="LineEdit" parent="InputSwitcher/Vector2Input/HBoxContainer"]
137+
unique_name_in_owner = true
138+
layout_mode = 2
139+
mouse_filter = 1
140+
theme_override_colors/font_color = Color(0.118581, 0.118581, 0.118581, 1)
141+
theme_override_colors/font_uneditable_color = Color(0.117647, 0.117647, 0.117647, 1)
142+
theme_override_colors/font_placeholder_color = Color(0.76662, 0.76662, 0.76662, 1)
143+
theme_override_constants/minimum_character_width = 0
144+
theme_override_styles/normal = SubResource("StyleBoxEmpty_6oowp")
145+
theme_override_styles/focus = SubResource("StyleBoxEmpty_afyv2")
146+
theme_override_styles/read_only = SubResource("StyleBoxEmpty_3r4mt")
147+
placeholder_text = "y"
148+
alignment = 1
149+
expand_to_text_length = true
150+
151+
[node name="Control2" type="Control" parent="InputSwitcher/Vector2Input/HBoxContainer"]
152+
layout_mode = 2
153+
size_flags_horizontal = 3
154+
87155
[node name="SnapPoint" parent="." instance=ExtResource("2_6esp3")]
88156
unique_name_in_owner = true
89157
layout_mode = 2
@@ -94,3 +162,5 @@ variant_type = 4
94162
[connection signal="text_changed" from="InputSwitcher/TextInput/LineEdit" to="." method="_on_line_edit_text_changed"]
95163
[connection signal="color_changed" from="InputSwitcher/ColorInput" to="." method="_on_color_input_color_changed"]
96164
[connection signal="item_selected" from="InputSwitcher/OptionInput" to="." method="_on_option_input_item_selected"]
165+
[connection signal="text_changed" from="InputSwitcher/Vector2Input/HBoxContainer/XLineEdit" to="." method="_on_line_edit_text_changed"]
166+
[connection signal="text_changed" from="InputSwitcher/Vector2Input/HBoxContainer/YLineEdit" to="." method="_on_line_edit_text_changed"]

0 commit comments

Comments
 (0)