Skip to content

Commit 92314bd

Browse files
committed
Block scenes: Remove most serialized properties
For Block, StatementBlock and EntryBlock classes. Only if the block is in the model catalog. Otherwise keep the previous behavior. The exceptions are: - Color: it should be derived from the category, but needs refactoring - Scope: may be handled in a different way
1 parent 1fe0892 commit 92314bd

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

addons/block_code/ui/blocks/block/block.gd

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
class_name Block
33
extends MarginContainer
44

5+
const BlocksCatalog = preload("res://addons/block_code/model/blocks_catalog.gd")
56
const InstructionTree = preload("res://addons/block_code/instruction_tree/instruction_tree.gd")
67
const Types = preload("res://addons/block_code/types/types.gd")
78

@@ -92,7 +93,13 @@ func update_resources(undo_redo: EditorUndoRedoManager):
9293

9394
# Override this method to add more serialized properties
9495
func get_serialized_props() -> Array:
95-
return serialize_props(["block_name", "label", "color", "block_type", "position", "scope"])
96+
if not BlocksCatalog.has_block(block_name):
97+
return serialize_props(["block_name", "label", "color", "block_type", "position", "scope"])
98+
99+
# TODO: Remove remaining serialization:
100+
# - Derive color from category.
101+
# - Handle scope in a different way?
102+
return serialize_props(["color", "scope"])
96103

97104

98105
func _to_string():

addons/block_code/ui/blocks/entry_block/entry_block.gd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@ func get_entry_statement() -> String:
3030

3131
func get_serialized_props() -> Array:
3232
var props := super()
33-
props.append_array(serialize_props(["signal_name"]))
33+
if not BlocksCatalog.has_block(block_name):
34+
props.append_array(serialize_props(["signal_name"]))
3435
return props

addons/block_code/ui/blocks/statement_block/statement_block.gd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ func _on_drag_drop_area_mouse_down():
3636

3737
func get_serialized_props() -> Array:
3838
var props := super()
39-
props.append_array(serialize_props(["block_format", "statement", "defaults"]))
39+
if not BlocksCatalog.has_block(block_name):
40+
props.append_array(serialize_props(["block_format", "statement", "defaults"]))
4041

4142
var _param_input_strings: Dictionary = {}
4243
for pair in param_name_input_pairs:

0 commit comments

Comments
 (0)