Skip to content

Commit 98dd81c

Browse files
committed
TemplateEditor: Remove the OPTION parameter type
Instead, we infer that a parameter has a set of options by the existence of an OptionData as its default value. https://phabricator.endlessm.com/T35564
1 parent 0ba7a97 commit 98dd81c

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

addons/block_code/blocks/graphics/animationplayer_play.tres

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[gd_resource type="Resource" load_steps=5 format=3 uid="uid://c5e1byehtxwc0"]
1+
[gd_resource type="Resource" load_steps=6 format=3 uid="uid://c5e1byehtxwc0"]
22

33
[ext_resource type="Script" path="res://addons/block_code/code_generation/block_definition.gd" id="1_emeuv"]
44
[ext_resource type="Script" path="res://addons/block_code/code_generation/option_data.gd" id="1_xu43h"]
@@ -9,6 +9,11 @@ script = ExtResource("1_xu43h")
99
selected = 0
1010
items = ["ahead", "backwards"]
1111

12+
[sub_resource type="Resource" id="Resource_qpxn2"]
13+
script = ExtResource("1_xu43h")
14+
selected = 0
15+
items = []
16+
1217
[resource]
1318
script = ExtResource("1_emeuv")
1419
name = &"animationplayer_play"
@@ -17,13 +22,14 @@ description = "Play the animation."
1722
category = "Graphics | Animation"
1823
type = 2
1924
variant_type = 0
20-
display_template = "Play {animation: OPTION} {direction: OPTION}"
25+
display_template = "Play {animation: NIL} {direction: NIL}"
2126
code_template = "if \"{direction}\" == \"ahead\":
2227
play(\"{animation}\")
2328
else:
2429
play_backwards(\"{animation}\")
2530
"
2631
defaults = {
32+
"animation": SubResource("Resource_qpxn2"),
2733
"direction": SubResource("Resource_vnp2w")
2834
}
2935
signal_name = ""

addons/block_code/blocks/logic/compare.tres

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ description = ""
1616
category = "Logic | Comparison"
1717
type = 3
1818
variant_type = 1
19-
display_template = "{float1: FLOAT} {op: OPTION} {float2: FLOAT}"
19+
display_template = "{float1: FLOAT} {op: NIL} {float2: FLOAT}"
2020
code_template = "{float1} {op} {float2}"
2121
defaults = {
2222
"float1": 1.0,

addons/block_code/blocks/sounds/pause_continue_sound.tres

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[sub_resource type="Resource" id="Resource_lalgp"]
77
script = ExtResource("1_ilhdq")
88
selected = 0
9-
items = ["Pause", "Continue"]
9+
items = ["pause", "continue"]
1010

1111
[resource]
1212
script = ExtResource("1_q04gm")
@@ -16,7 +16,7 @@ description = "Pause/Continue the audio stream"
1616
category = "Sounds"
1717
type = 2
1818
variant_type = 0
19-
display_template = "{pause: OPTION} the sound {name: STRING}"
19+
display_template = "{pause: NIL} the sound {name: STRING}"
2020
code_template = "var __sound_node = get_node({name})
2121
if \"{pause}\" == \"pause\":
2222
__sound_node.stream_paused = true

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

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,11 @@ func _append_input_parameter(parameter_format: String, id: int):
117117
parameter_input.placeholder = parameter["name"]
118118
parameter_input.variant_type = parameter["type"]
119119

120-
if parameter["is_option"] and default_value is OptionData:
120+
if default_value is OptionData:
121121
var option_data := default_value as OptionData
122122
parameter_input.option_data = option_data
123123
if option_data.selected < option_data.items.size():
124124
parameter_input.default_value = option_data.items[option_data.selected]
125-
elif parameter["is_option"]:
126-
push_warning("The block parameter %s in %s appears to be an option, but no option data is provided" % [parameter_format, parent_block])
127125
else:
128126
parameter_input.default_value = default_value
129127

@@ -152,7 +150,6 @@ func _parse_parameter_format(parameter_format: String) -> Dictionary:
152150
var parameter_name: String
153151
var parameter_type_str: String
154152
var parameter_type: Variant.Type
155-
var is_option: bool
156153
var split := parameter_format.split(":", true, 1)
157154

158155
if len(split) == 0:
@@ -164,9 +161,7 @@ func _parse_parameter_format(parameter_format: String) -> Dictionary:
164161
if len(split) > 1:
165162
parameter_type_str = split[1].strip_edges()
166163

167-
if parameter_type_str and parameter_type_str == "OPTION":
168-
is_option = true
169-
elif parameter_type_str:
164+
if parameter_type_str:
170165
parameter_type = Types.STRING_TO_VARIANT_TYPE[parameter_type_str]
171166

172-
return {"name": parameter_name, "type": parameter_type, "is_option": is_option}
167+
return {"name": parameter_name, "type": parameter_type}

0 commit comments

Comments
 (0)