From 26f39de20f1c6a1eb572c3c482cb2e6794917a5e Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Mon, 4 Nov 2024 10:26:15 +0000 Subject: [PATCH 1/5] ci: List Godot versions to test one per line This will make future diffs that add and remove engine versions more legible. --- .github/workflows/checks.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index 12cd71c5..06a2dcdc 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -32,7 +32,9 @@ jobs: name: Tests strategy: matrix: - godot-version: [4.2.2, 4.3.0] + godot-version: + - 4.2.2 + - 4.3.0 runs-on: ubuntu-latest steps: - name: Checkout From 6f4335cbd0344ffa84667646e2d83a1b37f6ce36 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Wed, 18 Dec 2024 11:43:46 +0000 Subject: [PATCH 2/5] Set Godot 4.3 as minimum supported version Godot 4.3 has been available for 4 months and it seems unlikely that anyone will have a pressing need to add blocks to a Godot 4.2 project. Although we have been running unit tests against 4.2 in CI, those do not cover the full functionality of the plugin. To the best of my knowledge, no-one is regularly testing the plugin interactively against Godot 4.2. Set the minimum version in the asset library template. Drop 4.2 from the CI test matrix. --- .github/workflows/checks.yaml | 1 - asset-template.json.hb | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index 06a2dcdc..1d4e315c 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -33,7 +33,6 @@ jobs: strategy: matrix: godot-version: - - 4.2.2 - 4.3.0 runs-on: ubuntu-latest steps: diff --git a/asset-template.json.hb b/asset-template.json.hb index d9539075..a0093ae6 100644 --- a/asset-template.json.hb +++ b/asset-template.json.hb @@ -2,7 +2,7 @@ "title": "Block Coding", "description": "Create games using a high-level, block-based visual programming language.\r\n\r\nIntended as an educational tool for learners in the earlier stages of their journey towards becoming game developers. This plugin lets you create your first games with high-level blocks, avoiding the immediate need to learn to code in GDScript. Building games in this way provides a gentle introduction to programming concepts and allows you to focus your efforts on becoming familiar with the rest of the Godot Editor UI.", "category_id": "5", - "godot_version": "4.2", + "godot_version": "4.3", "version_string": "{{ context.release.name }}", "cost": "MIT", "support_level": "community", From c59c6a1fe606e327a4c378a9617190089a87e29b Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Wed, 18 Dec 2024 11:50:04 +0000 Subject: [PATCH 3/5] block: Use Dictionary.merged() Now that Godot 4.3 is the minimum supported version, we can use this new method to merge two dictionaries a little more tersely. --- addons/block_code/ui/blocks/block/block.gd | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/addons/block_code/ui/blocks/block/block.gd b/addons/block_code/ui/blocks/block/block.gd index fea24b3c..6a6f851e 100644 --- a/addons/block_code/ui/blocks/block/block.gd +++ b/addons/block_code/ui/blocks/block/block.gd @@ -132,10 +132,7 @@ func _get_parameter_defaults() -> Dictionary: if not block_extension: return definition.defaults - # Use Dictionary.merge instead of Dictionary.merged for Godot 4.2 compatibility - var new_defaults := block_extension.get_defaults() - new_defaults.merge(definition.defaults) - return new_defaults + return block_extension.get_defaults().merged(definition.defaults) func _get_or_create_block_extension() -> BlockExtension: From 2684d95088a641b9414c2e0fa7a15bb67895ddf8 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Wed, 18 Dec 2024 11:52:34 +0000 Subject: [PATCH 4/5] Back out "Fix error in simple_spawner.gd with Godot 4.2.2" This backs out commit 99e2dc15adad1add1a568ff12ccce7b8441d388f. We now require Godot 4.3. --- addons/block_code/simple_spawner/simple_spawner.gd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/block_code/simple_spawner/simple_spawner.gd b/addons/block_code/simple_spawner/simple_spawner.gd index acae8032..89e3f3d3 100644 --- a/addons/block_code/simple_spawner/simple_spawner.gd +++ b/addons/block_code/simple_spawner/simple_spawner.gd @@ -89,7 +89,7 @@ func spawn_once(): if scenes.size() == 0: return - _spawned_scenes = _spawned_scenes.filter(func(instance): return is_instance_valid(instance)) + _spawned_scenes = _spawned_scenes.filter(is_instance_valid) if spawn_limit != 0 and _spawned_scenes.size() >= spawn_limit: if limit_behavior == LimitBehavior.NO_SPAWN: From 0525fbe0cfcce133ed52aa0b34de0e70deb38c38 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Wed, 18 Dec 2024 18:38:40 +0000 Subject: [PATCH 5/5] Remove polyfill for Node.is_part_of_edited_scene() We now require Godot 4.3, which introduces this method. --- addons/block_code/ui/block_canvas/block_canvas.gd | 4 ++-- .../ui/picker/categories/block_category_button.gd | 2 +- addons/block_code/ui/tooltip/tooltip.gd | 2 +- addons/block_code/ui/util.gd | 13 ------------- 4 files changed, 4 insertions(+), 17 deletions(-) diff --git a/addons/block_code/ui/block_canvas/block_canvas.gd b/addons/block_code/ui/block_canvas/block_canvas.gd index ef07844b..a9b385f4 100644 --- a/addons/block_code/ui/block_canvas/block_canvas.gd +++ b/addons/block_code/ui/block_canvas/block_canvas.gd @@ -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 @@ -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. diff --git a/addons/block_code/ui/picker/categories/block_category_button.gd b/addons/block_code/ui/picker/categories/block_category_button.gd index 4edb3123..06fa7fb0 100644 --- a/addons/block_code/ui/picker/categories/block_category_button.gd +++ b/addons/block_code/ui/picker/categories/block_category_button.gd @@ -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) diff --git a/addons/block_code/ui/tooltip/tooltip.gd b/addons/block_code/ui/tooltip/tooltip.gd index 5f165021..76306b11 100644 --- a/addons/block_code/ui/tooltip/tooltip.gd +++ b/addons/block_code/ui/tooltip/tooltip.gd @@ -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() diff --git a/addons/block_code/ui/util.gd b/addons/block_code/ui/util.gd index 70c84781..2a856de1 100644 --- a/addons/block_code/ui/util.gd +++ b/addons/block_code/ui/util.gd @@ -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