Skip to content

Commit

Permalink
Remove polyfill for Node.is_part_of_edited_scene()
Browse files Browse the repository at this point in the history
We now require Godot 4.3, which introduces this method.
  • Loading branch information
wjt committed Dec 18, 2024
1 parent 2684d95 commit 0525fbe
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 17 deletions.
4 changes: 2 additions & 2 deletions addons/block_code/ui/block_canvas/block_canvas.gd
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ signal replace_block_code
func _ready():
_context.changed.connect(_on_context_changed)

if not _open_scene_button.icon and not Util.node_is_part_of_edited_scene(self):
if not _open_scene_button.icon and not self.is_part_of_edited_scene():
_open_scene_button.icon = _open_scene_icon
if not _zoom_out_button.icon:
_zoom_out_button.icon = _icon_zoom_out
Expand Down Expand Up @@ -99,7 +99,7 @@ func _can_drop_data(at_position: Vector2, data: Variant) -> bool:
# Don't allow dropping BlockCode nodes or nodes that aren't part of the
# edited scene.
var node := get_tree().root.get_node(abs_path)
if node is BlockCode or not Util.node_is_part_of_edited_scene(node):
if node is BlockCode or not node.is_part_of_edited_scene():
return false

# Don't allow dropping the BlockCode node's parent as that's already self.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func _ready():
if not category:
category = BlockCategory.new("Example", Color.RED)

if not Util.node_is_part_of_edited_scene(self):
if not self.is_part_of_edited_scene():
var new_stylebox: StyleBoxFlat = _panel.get_theme_stylebox("panel").duplicate()
new_stylebox.bg_color = category.color
_panel.add_theme_stylebox_override("panel", new_stylebox)
Expand Down
2 changes: 1 addition & 1 deletion addons/block_code/ui/tooltip/tooltip.gd
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ func override_fonts():


func _ready():
if not Util.node_is_part_of_edited_scene(self):
if not self.is_part_of_edited_scene():
override_fonts()
13 changes: 0 additions & 13 deletions addons/block_code/ui/util.gd
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
extends Object


## Polyfill of Node.is_part_of_edited_scene(), available to GDScript in Godot 4.3+.
static func node_is_part_of_edited_scene(node: Node) -> bool:
if not Engine.is_editor_hint():
return false

var tree := node.get_tree()
if not tree or not tree.edited_scene_root:
return false

var edited_scene_parent := tree.edited_scene_root.get_parent()
return edited_scene_parent and edited_scene_parent.is_ancestor_of(node)


## Get the path from [param reference] to [param node] within a scene.
##
## Returns the path from [param reference] to [param node] without referencing
Expand Down

0 comments on commit 0525fbe

Please sign in to comment.