Skip to content

Commit 8b41b8d

Browse files
committed
Remove NodeBlockCanvas
NodeBlockCanvas extends BlockCanvas, but the only thing it was providing was the method to generate the script from the current window. Might as will just put that in BlockCanvas and drop the extension.
1 parent 4338632 commit 8b41b8d

File tree

8 files changed

+53
-38
lines changed

8 files changed

+53
-38
lines changed

addons/block_code/block_code_plugin.gd

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ const DISABLED_CLASSES := [
2424
"StatementBlock",
2525
"DragDropArea",
2626
"SnapPoint",
27-
"NodeBlockCanvas",
2827
"SerializedBlockTreeNodeArray",
2928
"SerializedBlockTreeNode",
3029
"SerializedBlock",

addons/block_code/ui/block_canvas/block_canvas.gd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,3 +306,8 @@ func set_mouse_override(override: bool):
306306
else:
307307
_mouse_override.mouse_filter = Control.MOUSE_FILTER_IGNORE
308308
_mouse_override.mouse_default_cursor_shape = Control.CURSOR_ARROW
309+
310+
311+
func generate_script_from_current_window(bsd: BlockScriptData) -> String:
312+
# TODO: implement multiple windows
313+
return InstructionTree.generate_script_from_nodes(_window.get_children(), bsd)

addons/block_code/ui/block_canvas/block_canvas.tscn

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[ext_resource type="Script" path="res://addons/block_code/ui/block_canvas/block_canvas.gd" id="1_tk8h2"]
44
[ext_resource type="Texture2D" uid="uid://cmusxj1ppspnp" path="res://addons/block_code/block_code_node/block_code_node.svg" id="2_710vn"]
55

6-
[sub_resource type="Image" id="Image_0aray"]
6+
[sub_resource type="Image" id="Image_1nubg"]
77
data = {
88
"data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 93, 93, 41, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0),
99
"format": "RGBA8",
@@ -13,7 +13,7 @@ data = {
1313
}
1414

1515
[sub_resource type="ImageTexture" id="ImageTexture_jgo72"]
16-
image = SubResource("Image_0aray")
16+
image = SubResource("Image_1nubg")
1717

1818
[node name="BlockCanvas" type="MarginContainer"]
1919
anchors_preset = 15

addons/block_code/ui/block_canvas/node_block_canvas/node_block_canvas.gd

Lines changed: 0 additions & 8 deletions
This file was deleted.

addons/block_code/ui/block_canvas/node_block_canvas/node_block_canvas.tscn

Lines changed: 0 additions & 7 deletions
This file was deleted.

addons/block_code/ui/main_panel.gd

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class_name MainPanel
33
extends Control
44

55
@onready var _picker: Picker = %Picker
6-
@onready var _block_canvas: BlockCanvas = %NodeBlockCanvas
6+
@onready var _block_canvas: BlockCanvas = %BlockCanvas
77
@onready var _drag_manager: DragManager = %DragManager
88
@onready var _title_bar: TitleBar = %TitleBar
99
@onready var _delete_node_button: Button = %DeleteNodeButton
@@ -192,7 +192,7 @@ func _on_collapse_button_pressed():
192192
toggle_collapse()
193193

194194

195-
func _on_node_block_canvas_add_block_code():
195+
func _on_block_canvas_add_block_code():
196196
var edited_node: Node = EditorInterface.get_inspector().get_edited_object() as Node
197197
var scene_root: Node = EditorInterface.get_edited_scene_root()
198198

@@ -214,7 +214,7 @@ func _on_node_block_canvas_add_block_code():
214214
undo_redo.commit_action()
215215

216216

217-
func _on_node_block_canvas_open_scene():
217+
func _on_block_canvas_open_scene():
218218
var edited_node: Node = EditorInterface.get_inspector().get_edited_object() as Node
219219

220220
if edited_node == null or edited_node.owner == null:
@@ -223,7 +223,7 @@ func _on_node_block_canvas_open_scene():
223223
EditorInterface.open_scene_from_path(edited_node.scene_file_path)
224224

225225

226-
func _on_node_block_canvas_replace_block_code():
226+
func _on_block_canvas_replace_block_code():
227227
var edited_node: Node = EditorInterface.get_inspector().get_edited_object() as Node
228228
var scene_root: Node = EditorInterface.get_edited_scene_root()
229229

addons/block_code/ui/main_panel.tscn

Lines changed: 33 additions & 7 deletions
Large diffs are not rendered by default.

docs/OVERVIEW.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33
## Data flow/Hierarchy
44

55
1. The plugin enters at `block_code_plugin.gd` (`BlockCodePlugin`) where the `MainPanel` is initialized and added as a main screen tab labeled "Block Code".
6-
* The `MainPanel` contains a block `Picker`, a `NodeBlockCanvas`, a `TitleBar`, and a `DragManager`.
6+
* The `MainPanel` contains a block `Picker`, a `BlockCanvas`, a `TitleBar`, and a `DragManager`.
77
* The `Picker` contains a combined list of categories of blocks from the global blocks generated in `CategoryFactory`, and custom blocks defined in the class the script is attached to.
8-
* The `NodeBlockCanvas` is where placed blocks live, and generates the code from the scene tree of blocks.
8+
* The `BlockCanvas` is where placed blocks live, and generates the code from the scene tree of blocks.
99
* The `TitleBar` displays some information about the block script.
10-
* The `DragManager` determines how blocks are snapped, and what happens when you drag a block from either the `Picker` or the `NodeBlockCanvas`
10+
* The `DragManager` determines how blocks are snapped, and what happens when you drag a block from either the `Picker` or the `BlockCanvas`
1111

12-
2. When a `BlockCode` node is selected, the `MainPanel` supplies the `Picker`, `NodeBlockCanvas`, and `TitleBar` with the `BlockScriptData` (BSD) attached to the `BlockCode` node you clicked.
12+
2. When a `BlockCode` node is selected, the `MainPanel` supplies the `Picker`, `BlockCanvas`, and `TitleBar` with the `BlockScriptData` (BSD) attached to the `BlockCode` node you clicked.
1313
* The `Picker` will be loaded with blocks, and any custom blocks supplied by the parent of the `BlockCode` node you clicked.
14-
* The `NodeBlockCanvas` will be populated with the block scene tree deserialized from the BSD (`BlockScriptData.block_trees`).
14+
* The `BlockCanvas` will be populated with the block scene tree deserialized from the BSD (`BlockScriptData.block_trees`).
1515
* The `TitleBar` will be populated with the name of class the script inherits.
1616
* If the BSD is `null`, it will copy and load the default one.
1717

18-
3. When you click and drag a block from the `Picker`, the `DragManager` is signaled to copy the block and enables you to drag it to the `NodeBlockCanvas`.
18+
3. When you click and drag a block from the `Picker`, the `DragManager` is signaled to copy the block and enables you to drag it to the `BlockCanvas`.
1919

2020
4. The `DragManager` looks for the closest compatible snap point within a certain range, and if it exists, will show a preview where your `Block` will go if you drop it.
2121
* Each `Block` has a `block_type` property, and so does each snap point. They must match to snap.
@@ -25,7 +25,7 @@
2525

2626
5. When the block script is modified, it will regenerate the BSD, and save it as an exported property of the `BlockCode` node you are working on. This way it gets saved to the scene.
2727
* The block script is modified when a block is moved, or a `ParameterInput`'s raw input has been changed.
28-
* Code is generated whenever you modify the block in `NodeBlockCanvas`.
28+
* Code is generated whenever you modify the block in `BlockCanvas`.
2929

3030
6. When you play the scene, each `BlockCode` node will attach a generated script from it's BSD to it's parent node. The `_ready` and `_process` methods will start normally.
3131

@@ -78,7 +78,7 @@ b.block_format = "On Process [delta: FLOAT]"
7878
* `/block_script_data/`: Contains the custom resource that persists each block script. Each resource saves the class it inherits from, the generated script, and the tree of `Block`s to load.
7979
* `/drag_manager/`: Should be in the `ui` folder, let's fix that. Handles dragging blocks across the canvas and picker.
8080
* `/inspector_plugin/`: An inspector plugin that adds a button to the inspector on `BlockCode` nodes to open the script.
81-
* `/instruction_tree/`: A utility script that generates code from a tree of `TreeNode`s. This tree is created by `NodeBlockCanvas` and also recursively by the `Block`s themselves.
81+
* `/instruction_tree/`: A utility script that generates code from a tree of `TreeNode`s. This tree is created by `BlockCanvas` and also recursively by the `Block`s themselves.
8282
* `/lib/`: Some scripts from GodotTours that label and expose some of the editor Control nodes so they can be interfaced with.
8383
* `/simple_nodes/`: Contains scenes for simple nodes that can be used in a simple game. E.g. `SimpleCharacter` comes with a sprite and collision, and exposes custom movement blocks.
8484
* `/types/`: Contains all things related to types in the addon. Types of blocks, casting, and variant to string type conversion.
@@ -96,7 +96,7 @@ b.block_format = "On Process [delta: FLOAT]"
9696
* `/drag_drop_area/`: A simple node that signals on mouse down and up
9797
* `/parameter_input/`: An input for nodes to receive data from raw text, or from a snapped `ParameterBlock`.
9898
* `/snap_point/`: Node that the `DragManager` looks for when trying to snap new blocks.
99-
* `/block_canvas/`: Contains the code for the `BlockCanvas` which loads and holds blocks on a canvas. Inherited by `NodeBlockCanvas` which can generate scripts for block scripts made for Godot `Node`s (which is all of the scripts ATM). Also contains resources for serializing blocks.
99+
* `/block_canvas/`: Contains the code for the `BlockCanvas` which loads and holds blocks on a canvas. This can generate scripts for block scripts made for Godot `Node`s (which is all of the scripts ATM). Also contains resources for serializing blocks.
100100
* `/bsd_templates/`: Template block script data files for loading a default script. E.g. `_ready` and `_process` entry blocks already on canvas.
101101
* `/node_canvas/`: Deprecated
102102
* `/node_list/`: Deprecated

0 commit comments

Comments
 (0)