-
Notifications
You must be signed in to change notification settings - Fork 28
T35536 decouple mid-term option #164
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
9d62ccd
410fd7d
87ed823
690136c
edb88a6
5a772b7
6e17904
97cd48f
13e5700
46f1db2
ca1c8eb
56c2031
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
extends Resource | ||
|
||
const Types = preload("res://addons/block_code/types/types.gd") | ||
|
||
var name: StringName | ||
var type: Types.BlockType | ||
var description: String | ||
var category: String | ||
|
||
var label_template: String | ||
var code_template: String | ||
var defaults: Dictionary = {} | ||
|
||
## Only for blocks of type Types.ENTRY. If non-empty, this block defines a | ||
## callback that will be connected to the signal with this name. | ||
var signal_name: String = "" | ||
|
||
|
||
func _init(p_name: StringName, p_type: Types.BlockType): | ||
name = p_name | ||
type = p_type |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
extends Object | ||
|
||
const BlockDefinition = preload("res://addons/block_code/block_definition.gd") | ||
const Types = preload("res://addons/block_code/types/types.gd") | ||
|
||
static var _catalog: Dictionary | ||
|
||
|
||
static func setup(): | ||
if _catalog: | ||
return | ||
|
||
_catalog = {} | ||
var block_definition: BlockDefinition = BlockDefinition.new(&"ready_block", Types.BlockType.ENTRY) | ||
block_definition.label_template = "On Ready" | ||
block_definition.code_template = "func _ready():" | ||
block_definition.description = 'Attached blocks will be executed once when the node is "ready"' | ||
block_definition.category = "Lifecycle" | ||
_catalog[&"ready_block"] = block_definition | ||
|
||
block_definition = BlockDefinition.new(&"print", Types.BlockType.EXECUTE) | ||
block_definition.label_template = "print {text: STRING}" | ||
block_definition.code_template = "print({text})" | ||
block_definition.defaults = {"text": "Hello"} | ||
block_definition.description = "Print the text to output" | ||
block_definition.category = "Log" | ||
_catalog[&"print"] = block_definition | ||
|
||
|
||
static func get_block(block_name: StringName): | ||
return _catalog.get(block_name) | ||
|
||
|
||
static func has_block(block_name: StringName): | ||
return block_name in _catalog |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
class_name SerializedBlockTreeNode | ||
extends Resource | ||
|
||
@export var serialized_block: SerializedBlock | ||
@export var name: StringName | ||
@export var position: Vector2 | ||
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. Another thing here: Why does every 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.
Yes, I thought about this. For a snapped/attached block, as soon as the user detaches it by dragging it to the canvas, it will need a position. So I thought that it is better to keep the position as property to all the saved blocks, and just ignore it if they are attached. What do you think? 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. Yep, that's totally fine. It makes the code a little simpler in this case! |
||
@export var path_child_pairs: Array | ||
|
||
# TODO: Remove once the data/UI decouple is done. | ||
@export var serialized_block: SerializedBlock | ||
|
||
|
||
func _init(p_serialized_block: SerializedBlock = null, p_path_child_pairs: Array = []): | ||
func _init(p_name: StringName, p_position: Vector2 = Vector2.ZERO, p_serialized_block: SerializedBlock = null, p_path_child_pairs: Array = []): | ||
name = p_name | ||
position = p_position | ||
serialized_block = p_serialized_block | ||
path_child_pairs = p_path_child_pairs |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,30 @@ | ||
[gd_resource type="Resource" script_class="BlockScriptData" load_steps=3 format=3 uid="uid://dit7fykhl3h48"] | ||
[gd_resource type="Resource" script_class="BlockScriptData" load_steps=8 format=3 uid="uid://dit7fykhl3h48"] | ||
|
||
[ext_resource type="Script" path="res://addons/block_code/block_script_data/block_script_data.gd" id="1_h8ggn"] | ||
[ext_resource type="Resource" uid="uid://djn5nejdsfu2a" path="res://addons/block_code/ui/bsd_templates/default_blocktrees.tres" id="1_y70fv"] | ||
[ext_resource type="Script" path="res://addons/block_code/ui/block_canvas/serialized_block_tree_node.gd" id="1_barc5"] | ||
[ext_resource type="Script" path="res://addons/block_code/ui/block_canvas/serialized_block.gd" id="2_cgfpx"] | ||
[ext_resource type="Script" path="res://addons/block_code/ui/block_canvas/serialized_block_tree_node_array.gd" id="3_gx4d7"] | ||
[ext_resource type="Script" path="res://addons/block_code/block_script_data/block_script_data.gd" id="4_cqq7x"] | ||
|
||
[sub_resource type="Resource" id="Resource_b0aen"] | ||
script = ExtResource("2_cgfpx") | ||
block_class = &"EntryBlock" | ||
serialized_props = [["color", Color(0.92549, 0.231373, 0.34902, 1)], ["scope", ""], ["param_input_strings", {}]] | ||
|
||
[sub_resource type="Resource" id="Resource_1h6wi"] | ||
script = ExtResource("1_barc5") | ||
name = &"ready_block" | ||
position = Vector2(54, 47) | ||
path_child_pairs = [] | ||
serialized_block = SubResource("Resource_b0aen") | ||
|
||
[sub_resource type="Resource" id="Resource_nkub8"] | ||
script = ExtResource("3_gx4d7") | ||
array = Array[ExtResource("1_barc5")]([SubResource("Resource_1h6wi")]) | ||
|
||
[resource] | ||
script = ExtResource("1_h8ggn") | ||
script = ExtResource("4_cqq7x") | ||
script_inherits = "INHERIT_DEFAULT" | ||
block_trees = ExtResource("1_y70fv") | ||
block_trees = SubResource("Resource_nkub8") | ||
variables = Array[Resource("res://addons/block_code/ui/block_canvas/variable_resource.gd")]([]) | ||
generated_script = "extends INHERIT_DEFAULT" | ||
version = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think since the dictionary defaults to empty, the
_created
boolean is not needed. You can just checkif _catalog: return
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed! Thanks.