Skip to content

Commit

Permalink
Add parameters list to block tooltips
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanmccall committed Oct 25, 2024
1 parent f299c72 commit e5d2cef
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
9 changes: 9 additions & 0 deletions addons/block_code/code_generation/block_definition.gd
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ func _to_string():
return "%s - %s" % [name, target_node_class]


func get_input_parameters() -> Dictionary:
var result: Dictionary
for item in parse_display_template(display_template):
if item.has("in_parameter"):
var parameter = item.get("in_parameter")
result[parameter["name"]] = parameter["type"]
return result


func get_output_parameters() -> Dictionary:
var result: Dictionary
for item in parse_display_template(display_template):
Expand Down
14 changes: 14 additions & 0 deletions addons/block_code/ui/blocks/block/block.gd
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,20 @@ func _get_tooltip(at_position: Vector2) -> String:
lines.append("")
lines.append("[code]{0}[/code]".format([definition.code_template.strip_edges()]))

var input_parameters := definition.get_input_parameters()
var output_parameters := definition.get_output_parameters()

if input_parameters or output_parameters:
lines.append("")

for parameter_name in input_parameters:
var parameter_type = input_parameters[parameter_name]
lines.append("{0}: [b]{1}[/b]".format([parameter_name, type_string(parameter_type)]))

for parameter_name in output_parameters:
var parameter_type = output_parameters[parameter_name]
lines.append("{0}: [b]{1}[/b]".format([parameter_name, type_string(parameter_type)]))

if definition.variant_type != Variant.Type.TYPE_NIL:
lines.append("")
lines.append("Type: [b]{0}[/b]".format([type_string(definition.variant_type)]))
Expand Down

0 comments on commit e5d2cef

Please sign in to comment.