-
Notifications
You must be signed in to change notification settings - Fork 25
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
Add scope to blocks #79
Conversation
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.
Looks good! Can you transfer the information in the PR description to each commit message body?
Yes! I'll be better at doing that in the future ;) |
Ok, should be better now @manuq I just realized however that we shouldn't just check the scope of the dragged block, but also the scope of the dragged block's child blocks. That way you couldn't drag a child block out of it's scope. Should I add that to this PR? |
func set_scope(scope: String): | ||
for block in _window.get_children(): | ||
if block is EntryBlock: | ||
var entry_block = block as EntryBlock | ||
|
||
if scope != entry_block.get_entry_statement(): | ||
entry_block.modulate = Color(0.5, 0.5, 0.5, 1) |
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.
As a general advice, at least in languages that have semantic indentation (Python, GDScript) it is better to return early to avoid nesting and thus very indented code. In a for loop you can do that with break/continue. In a function you can do that with return. Example:
func set_scope(scope: String):
for block in _window.get_children():
if block is not EntryBlock:
continue
var entry_block = block as EntryBlock
(...)
I think it's fine to merge now after fixing conflicts and my request above. But if you think it's better to do the children blocks scoping now, that's fine with me too. |
Made it so that parameter blocks copy-dragged from an EntryBlock can only be placed below entry blocks with the same method signature.
Darken the block trees that cannot be snapped to by the currently dragged block.
Alright, I actually decided to just implement checking the child block scope as well. There should be no case where block trees will have blocks from different scopes. Definitely gained some solid merging experience from rebasing with all of Dylan's new dragging/snapping code 💪 |
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.
Almost there!
if copy_block: | ||
if copy_block.drag_started.get_connections().size() == 0: | ||
copy_block.drag_started.connect(func(b: Block): drag_copy_parameter(b, block)) |
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.
if copy_block: | |
if copy_block.drag_started.get_connections().size() == 0: | |
copy_block.drag_started.connect(func(b: Block): drag_copy_parameter(b, block)) | |
if copy_block == null: | |
continue | |
if copy_block.drag_started.get_connections().size() == 0: | |
copy_block.drag_started.connect(func(b: Block): drag_copy_parameter(b, block)) |
if tree_scope == "" or scope == tree_scope: | ||
valid = true | ||
|
||
if !valid: |
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.
The !
negation is deprecated in GDScript. Use not
:
if !valid: | |
if not valid: |
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.
@wnbaum looks good now! Feel free to squash the last commit and merge.
When dragging a block, we need to see if its child blocks are out of scope as well. Also check if child blocks of orphaned blocks are in a different scope. Small code cleanup
Made it so that parameter blocks copy-dragged from an
EntryBlock
can only be placed below entry blocks with the same method signature.Also darken the block trees that cannot be snapped to by the current dragged block.
https://phabricator.endlessm.com/T35521