-
Notifications
You must be signed in to change notification settings - Fork 27
tooltip: Don't save style overrides to tooltip.tscn #138
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
Conversation
I pushed a couple more changes to apply the same fix to the scenes discussed on Slack. |
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.
Wow, nice find. I have often wondered why so much stuff is getting serialized into the scenes.
@@ -45,7 +47,7 @@ signal replace_block_code | |||
|
|||
|
|||
func _ready(): | |||
if not _open_scene_button.icon: | |||
if not Util.node_is_part_of_edited_scene(self) and not _open_scene_button.icon: |
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.
Nitpick - optimize the logic by moving the simple null
check first.
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 the null check is now redundant: it will always be null when _ready runs.
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 left the null check in, but swapped the condition around.
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 to me once you fix Dan's changes! This is a much more elegant solution than restoring the file every time :)
Godot 4.3+ exposes `Node.is_part_of_edited_scene()` to GDScript, which is analogous to `Engine.is_editor_hint()` but determines whether the `@tool` script's node is itself being edited, as opposed to instantiated elsewhere in the editor. Reimplement this function in GDScript. https://phabricator.endlessm.com/T35540 Move node_is_part_of_edited_scene to new Util module This will allow it to be reused in other scenes which have the same problem as tooltip did.
Previously, if you opened tooltip.tscn in the editor and hit Save, its `_ready()` method would persist the style overrides we use to apply the editor theme's fonts to the label. This isn't necessary, or desirable. Don't apply the style overrides if the tooltip scene itself is being edited. https://phabricator.endlessm.com/T35540
Previously, opening and saving parameter_block.tscn (for example) in the editor would cause its StyleBoxFlat resource to be replaced by an identical sub_resource with a new unique identifier. This is because its _ready() function runs when the scene is being edited, and previously would unconditionally re-set the stylebox. This either causes needless diff churn, or requires extra work by the developer to discard that hunk. In each case, guard the change with `node_is_part_of_edited_scene`, and remove it from the saved scene.
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.
Sweet
I'm late to the party, this is a fantastic improvement! |
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.
@wjt Did you remove the style boxes manually? Or did the scene resave without them? Because all of the parameter blocks and category color icons are now squares xD. My bad for not catching.
|
||
[ext_resource type="Script" path="res://addons/block_code/ui/blocks/parameter_block/parameter_block.gd" id="1_0hajy"] | ||
[ext_resource type="PackedScene" uid="uid://c7puyxpqcq6xo" path="res://addons/block_code/ui/blocks/utilities/drag_drop_area/drag_drop_area.tscn" id="2_gy5co"] | ||
|
||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_dbera"] | ||
bg_color = Color(1, 1, 1, 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.
Wait were these StyleBoxes removed manually? They are meant to be saved to the scene, somehow I missed this.
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.
Hmm I think I reset them to defaults in the editor on the basis that they will be instantiated every time the scene is actually used. I didn't see the square-icon issue... I can investigate tomorrow
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.
Yeah, the default stylebox value is actually used as a template, only the color is set on it. Which is kind of weird, maybe we should just create a totally new stylebox at runtime.
|
||
[ext_resource type="Script" path="res://addons/block_code/ui/picker/categories/block_category_button.gd" id="1_pxxnl"] | ||
|
||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_eogpc"] | ||
bg_color = Color(1, 0, 0, 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.
Here too.
This partially reverts commit 1b6d64b (“Don't recreate resources when editing plugin scenes”). I incorrectly believed that these were being fully recreated every time the scene is instantiated based on another element's stylebox, but in fact they are being used as a template and it is only the colour that is being adjusted. See discussion at #138 (comment).
This partially reverts commit 1b6d64b (“Don't recreate resources when editing plugin scenes”). I incorrectly believed that these were being fully recreated every time the scene is instantiated based on another element's stylebox, but in fact they are being used as a template and it is only the colour that is being adjusted. See discussion at #138 (comment).
Previously, if you opened tooltip.tscn in the editor and hit Save, its
_ready()
method would persist the style overrides we use to apply the editor theme's fonts to the label. This isn't necessary, or desirable.Godot 4.3+ exposes
Node.is_part_of_edited_scene()
to GDScript, which is analogous toEngine.is_editor_hint()
but determines whether the@tool
script's node is itself being edited, as opposed to instantiated elsewhere in the editor.Reimplement this function in GDScript and only apply the style overrides to the tooltip if it returns false.
https://phabricator.endlessm.com/T35540