Skip to content

Improve ControlBlock background drawing #177

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

Merged
merged 2 commits into from
Jul 31, 2024

Conversation

dylanmccall
Copy link
Contributor

Instead of reusing the background.gd script to draw a gutter in ControlBlock, define a new script (gutter.gd) specifically for that purpose. In the existing background.gd script, draw a left border which is expected to flow into the gutter if shift_top or shift_bottom is set.

https://phabricator.endlessm.com/T35538

@dylanmccall dylanmccall force-pushed the T35538-control-block-borders branch from 1265925 to 38ab701 Compare July 31, 2024 01:05

var snap_gutter := Control.new()
snap_gutter.name = "Background"
snap_gutter.set_script(preload("res://addons/block_code/ui/blocks/utilities/background/gutter.gd"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've seen this in a couple places in here. Why not just instantiate the class directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why we don't do that, indeed. I'll fix that :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, set_script() only makes sense in the BlockCode node when it replaces the parent script. All others should be fixed.

Copy link
Contributor

@manuq manuq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks very nice! The set_script that was there before for other backgrounds and should be changed. Besides that, please leave the Pong scene out of this PR.


var snap_gutter := Control.new()
snap_gutter.name = "Background"
snap_gutter.set_script(preload("res://addons/block_code/ui/blocks/utilities/background/gutter.gd"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, set_script() only makes sense in the BlockCode node when it replaces the parent script. All others should be fixed.

Instead of reusing the background.gd script to draw a gutter in
ControlBlock, define a new script (gutter.gd) specifically for that
purpose. In the existing background.gd script, draw a left border which
is expected to flow into the gutter if shift_top or shift_bottom is set.

https://phabricator.endlessm.com/T35538
@dylanmccall dylanmccall force-pushed the T35538-control-block-borders branch from 38ab701 to b20005e Compare July 31, 2024 16:56
@dylanmccall
Copy link
Contributor Author

In the newest set of commits, I removed the unnecessary change to pong_game.tscn and I replaced that set_script() scheme with instantiating BlockBackground and BlockGutter classes directly.

@dylanmccall dylanmccall requested a review from manuq July 31, 2024 16:59
Copy link
Member

@dbnicholson dbnicholson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't say that I really followed the polygon changes, but I trust their right. I just had one small suggestion on class names.

@@ -144,9 +143,8 @@ func format():
snap_container.custom_minimum_size.y = 30
snap_container.size_flags_horizontal = Control.SIZE_SHRINK_BEGIN

var snap_gutter := Control.new()
var snap_gutter := BlockGutter.new()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we've been trying to move away from global classes unless their really needed since it reduces the chance for startup issues with the global class cache. Instead, I think you should just preload them at the top:

const BlockBackground = preload("res://addons/block_code/ui/blocks/utilities/background/background.gd")
const BlockGutter = preload("res://addons/block_code/ui/blocks/utilities/background/gutter.gd")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, exactly. Can you make this last change @dylanmccall ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I missed that happening! Makes sense :) That's fixed in the newest commit.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Manuel started it near the beginning of GUADEC in the context of import errors and I happened to notice it since I was trying to wrap up some of my own work that Thursday and Friday.

@@ -144,9 +143,8 @@ func format():
snap_container.custom_minimum_size.y = 30
snap_container.size_flags_horizontal = Control.SIZE_SHRINK_BEGIN

var snap_gutter := Control.new()
var snap_gutter := BlockGutter.new()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, exactly. Can you make this last change @dylanmccall ?

@@ -1,4 +1,5 @@
@tool
class_name BlockBackground
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As Dan pointed, please remove class_name and use preload instead.

@dylanmccall dylanmccall force-pushed the T35538-control-block-borders branch from b20005e to d2495b0 Compare July 31, 2024 19:12
@dylanmccall dylanmccall requested review from dbnicholson and manuq July 31, 2024 19:30
Copy link
Member

@dbnicholson dbnicholson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lovely, thanks!

@dbnicholson dbnicholson merged commit 8b85fa3 into main Jul 31, 2024
2 checks passed
@dbnicholson dbnicholson deleted the T35538-control-block-borders branch July 31, 2024 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants