-
Notifications
You must be signed in to change notification settings - Fork 27
Serialization: Reuse SerializedBlock resources #137
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 1 commit
01ab76c
0f5722b
b786cad
53d5a4a
2ece94f
22ef121
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Add a resource property to blocks. The resource will be updated before building the tree. This mitigates having a huge diff in scenes with blocks for minimum changes like moving a block in the canvas.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -139,17 +139,14 @@ func save_script(): | |||||||||||||||
_current_block_code_node.block_script = block_script | ||||||||||||||||
undo_redo.add_do_property(_current_block_code_node, "block_script", _current_block_code_node.block_script) | ||||||||||||||||
|
||||||||||||||||
undo_redo.add_undo_property(_current_block_code_node.block_script, "block_trees", _current_block_code_node.block_script.block_trees) | ||||||||||||||||
undo_redo.add_undo_property(_current_block_code_node.block_script, "generated_script", _current_block_code_node.block_script.generated_script) | ||||||||||||||||
|
||||||||||||||||
var block_trees := _block_canvas.get_canvas_block_trees() | ||||||||||||||||
_block_canvas.rebuild_block_trees(undo_redo) | ||||||||||||||||
var generated_script = _block_canvas.generate_script_from_current_window(block_script) | ||||||||||||||||
block_script.block_trees = block_trees | ||||||||||||||||
block_script.generated_script = generated_script | ||||||||||||||||
if generated_script != block_script.generated_script: | ||||||||||||||||
undo_redo.add_undo_property(_current_block_code_node.block_script, "generated_script", _current_block_code_node.block_script.generated_script) | ||||||||||||||||
block_script.generated_script = generated_script | ||||||||||||||||
undo_redo.add_do_property(_current_block_code_node.block_script, "generated_script", _current_block_code_node.block_script.generated_script) | ||||||||||||||||
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. We shouldn't be changing the generated_script property on our own here, and we should consistently use the
Suggested change
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. Turns out we're doing this in a lot of places. I included this and a bunch of similar fixes in #140. |
||||||||||||||||
block_script.version = Constants.CURRENT_DATA_VERSION | ||||||||||||||||
|
||||||||||||||||
undo_redo.add_do_property(_current_block_code_node.block_script, "block_trees", block_trees) | ||||||||||||||||
undo_redo.add_do_property(_current_block_code_node.block_script, "generated_script", generated_script) | ||||||||||||||||
undo_redo.commit_action() | ||||||||||||||||
|
||||||||||||||||
|
||||||||||||||||
|
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.
Personally I would just pass this down in to
build_tree
rather than stashing it in the object. It's only called internally to this object, so there's no danger of it breaking another user.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.
Yes I though about that, I did it like this because is also used in the
build_tree()
method that's called recursively. But yes it can be passed around tobuild_tree()
as parameter.