-
Notifications
You must be signed in to change notification settings - Fork 32
BlockCanvas: Implement drag & drop the file from resource FileSystem #305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8be79dc
f30e4a1
c8b7692
6b7c9d2
96a7da3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,8 +13,6 @@ const ParameterInputScene = preload("res://addons/block_code/ui/blocks/utilities | |
| const ParameterOutput = preload("res://addons/block_code/ui/blocks/utilities/parameter_output/parameter_output.gd") | ||
| const ParameterOutputScene = preload("res://addons/block_code/ui/blocks/utilities/parameter_output/parameter_output.tscn") | ||
|
|
||
| const FORMAT_STRING_PATTERN = "\\[(?<out_parameter>[^\\]]+)\\]|\\{(?<in_parameter>[^}]+)\\}|(?<label>[^\\{\\[]+)" | ||
|
|
||
| ## A string describing a block's display format. For example: | ||
| ## [br] | ||
| ## [code] | ||
|
|
@@ -41,7 +39,6 @@ var parent_block: Block | |
| var _parameter_inputs_by_name: Dictionary | ||
|
|
||
| @onready var _container := %Container | ||
| @onready var _regex := RegEx.create_from_string(FORMAT_STRING_PATTERN) | ||
|
|
||
|
|
||
| func _ready() -> void: | ||
|
|
@@ -97,6 +94,8 @@ func _update_from_format_string(): | |
| _append_input_parameter(item.get("in_parameter"), match_id) | ||
| elif item.has("out_parameter"): | ||
| _append_output_parameter(item.get("out_parameter"), match_id) | ||
| elif item.has("const_parameter"): | ||
| _append_const_parameter(item.get("const_parameter"), match_id) | ||
| match_id += 1 | ||
|
|
||
|
|
||
|
|
@@ -107,7 +106,7 @@ func _append_label(label_format: String): | |
| _container.add_child(label) | ||
|
|
||
|
|
||
| func _append_input_parameter(parameter: Dictionary, id: int): | ||
| func _append_input_parameter(parameter: Dictionary, id: int) -> ParameterInput: | ||
| var default_value = parameter_defaults.get(parameter["name"]) | ||
|
|
||
| var parameter_input: ParameterInput = ParameterInputScene.instantiate() | ||
|
|
@@ -129,6 +128,8 @@ func _append_input_parameter(parameter: Dictionary, id: int): | |
| _container.add_child(parameter_input) | ||
| _parameter_inputs_by_name[parameter["name"]] = parameter_input | ||
|
|
||
| return parameter_input | ||
|
|
||
|
|
||
| func _append_output_parameter(parameter: Dictionary, id: int): | ||
| var parameter_output: ParameterOutput | ||
|
|
@@ -140,5 +141,12 @@ func _append_output_parameter(parameter: Dictionary, id: int): | |
| _container.add_child(parameter_output) | ||
|
|
||
|
|
||
| func _append_const_parameter(parameter: Dictionary, id: int): | ||
| # const_parameter is a kind of in_parameter with default value, but never | ||
| # changes value. | ||
| var parameter_const := _append_input_parameter(parameter, id) | ||
| parameter_const.visible = false | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does this do exactly? I want to make sure the extra syntax is really worth it since it seems like the regular input parameter would work fine.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This clears the in parameter's "visible" to avoid modify the value from users.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, if the in parameter shows up, it displays the full file path as a long text.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
|
|
||
| func _on_parameter_input_drag_started(offset: Vector2): | ||
| drag_started.emit(offset) | ||


Uh oh!
There was an error while loading. Please reload this page.