Skip to content

Commit c8b7692

Browse files
committed
blocks_catalog: Introduce get_resource_block_definition()
Have get_resource_block_definition() providing resource block's definition. It uses constant parameter value with key "file_path" to hold the resource file's path information. https://phabricator.endlessm.com/T35712
1 parent f30e4a1 commit c8b7692

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

addons/block_code/code_generation/blocks_catalog.gd

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,3 +302,20 @@ static func get_property_setter_block_definition(variable: VariableDefinition) -
302302
var block_def := get_variable_setter_block_definition(variable)
303303
block_def.description = "Set the %s property" % variable.var_name
304304
return block_def
305+
306+
307+
static func get_resource_block_definition(file_path: String) -> BlockDefinition:
308+
var block_def := BlockDefinition.new()
309+
var file_name = file_path.get_file()
310+
311+
# Block Definition's name cannot work with '.'
312+
block_def.name = &"get_resource_file_path"
313+
block_def.description = "The full resource path of '%s'" % file_name
314+
block_def.category = "Variables"
315+
block_def.type = Types.BlockType.VALUE
316+
block_def.variant_type = TYPE_STRING
317+
block_def.display_template = "%s {const file_path: STRING}" % file_name
318+
block_def.code_template = "{file_path}"
319+
block_def.defaults = {"file_path": file_path}
320+
321+
return block_def

0 commit comments

Comments
 (0)