Skip to content

Commit c5290bb

Browse files
committed
Remove class_name from all other internal scripts
Except for the resources, the blocks and the snap point. With this, the class is not registered by name in ClassDB and it can't be referenced directly in other scripts, it must be preloaded. Also, if the script extends Node or a subclass of Node, it won't appear in the UI to the end user when adding a node. Another advantage: it won't collide with classes defined by the end user in the project. Our current Types class has a good chance to conflict given the generic name. Also: delete PackedSceneTreeNode and PackedScene abandoned resources.
1 parent 3267242 commit c5290bb

File tree

27 files changed

+61
-45
lines changed

27 files changed

+61
-45
lines changed

addons/block_code/block_code_plugin.gd

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
@tool
2-
class_name BlockCodePlugin
32
extends EditorPlugin
3+
const MainPanelScene := preload("res://addons/block_code/ui/main_panel.tscn")
4+
const MainPanel = preload("res://addons/block_code/ui/main_panel.gd")
5+
const Types = preload("res://addons/block_code/types/types.gd")
46

5-
const MainPanel := preload("res://addons/block_code/ui/main_panel.tscn")
67
static var main_panel: MainPanel
78
static var block_code_button: Button
89

@@ -18,8 +19,6 @@ var old_feature_profile: String = ""
1819

1920
const DISABLED_CLASSES := [
2021
"BlockScriptData",
21-
"InstructionTree",
22-
"Types",
2322
"Block",
2423
"ControlBlock",
2524
"ParameterBlock",
@@ -28,19 +27,6 @@ const DISABLED_CLASSES := [
2827
"SerializedBlockTreeNodeArray",
2928
"SerializedBlockTreeNode",
3029
"SerializedBlock",
31-
"PackedSceneTreeNodeArray",
32-
"PackedSceneTreeNode",
33-
"BlockCanvas",
34-
"CategoryFactory",
35-
"BlockCategoryDisplay",
36-
"BlockCategory",
37-
"Picker",
38-
"TitleBar",
39-
"MainPanel",
40-
"BlockCodePlugin",
41-
"BlockCategoryButton",
42-
"CreateVariableButton",
43-
"VariableCategoryDisplay"
4430
]
4531

4632

@@ -50,7 +36,7 @@ func _enter_tree():
5036
editor_inspector = EditorInterface.get_inspector()
5137
editor_selection = EditorInterface.get_selection()
5238

53-
main_panel = MainPanel.instantiate()
39+
main_panel = MainPanelScene.instantiate()
5440
main_panel.undo_redo = get_undo_redo()
5541
block_code_button = add_control_to_bottom_panel(main_panel, _get_plugin_name())
5642
block_inspector_plugin = BlockInspectorPlugin.new()

addons/block_code/drag_manager/drag.gd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
@tool
22
extends Control
33

4+
const BlockCanvas = preload("res://addons/block_code/ui/block_canvas/block_canvas.gd")
45
const Constants = preload("res://addons/block_code/ui/constants.gd")
56
const DragManager = preload("res://addons/block_code/drag_manager/drag_manager.gd")
7+
const Types = preload("res://addons/block_code/types/types.gd")
68

79
enum DragAction { NONE, PLACE, REMOVE }
810

addons/block_code/drag_manager/drag_manager.gd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ extends Control
44
signal block_dropped
55
signal block_modified
66

7+
const BlockCanvas = preload("res://addons/block_code/ui/block_canvas/block_canvas.gd")
78
const Drag = preload("res://addons/block_code/drag_manager/drag.gd")
9+
const Picker = preload("res://addons/block_code/ui/picker/picker.gd")
810

911
@export var picker_path: NodePath
1012
@export var block_canvas_path: NodePath

addons/block_code/inspector_plugin/block_script_inspector.gd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
extends EditorInspectorPlugin
22

3+
const BlockCodePlugin = preload("res://addons/block_code/block_code_plugin.gd")
4+
35

46
func _can_handle(object):
57
return object is BlockCode

addons/block_code/instruction_tree/instruction_tree.gd

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
class_name InstructionTree
21
extends Object
32

43

@@ -99,7 +98,7 @@ static func _generate_script_from_entry_blocks(entry_statement: String, entry_bl
9998
var signal_node: TreeNode
10099
var is_empty = true
101100

102-
InstructionTree.IDHandler.reset()
101+
IDHandler.reset()
103102

104103
for entry_block in entry_blocks:
105104
var next_block := entry_block.bottom_snap.get_snapped_block()

addons/block_code/simple_nodes/simple_character/simple_character.gd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
class_name SimpleCharacter
33
extends CharacterBody2D
44

5+
const CategoryFactory = preload("res://addons/block_code/ui/picker/categories/category_factory.gd")
6+
const Types = preload("res://addons/block_code/types/types.gd")
7+
58
@export var texture: Texture2D:
69
set = _set_texture
710

addons/block_code/simple_nodes/simple_scoring/simple_scoring.gd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
class_name SimpleScoring
33
extends CanvasLayer
44

5+
const CategoryFactory = preload("res://addons/block_code/ui/picker/categories/category_factory.gd")
6+
const Types = preload("res://addons/block_code/types/types.gd")
7+
58
@export var score_left: int:
69
set = _set_score_left
710

addons/block_code/types/types.gd

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
class_name Types
21
extends Node
32

43
enum BlockType {

addons/block_code/ui/block_canvas/block_canvas.gd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
@tool
2-
class_name BlockCanvas
32
extends MarginContainer
43

4+
const BlockCodePlugin = preload("res://addons/block_code/block_code_plugin.gd")
55
const DragManager = preload("res://addons/block_code/drag_manager/drag_manager.gd")
6+
const InstructionTree = preload("res://addons/block_code/instruction_tree/instruction_tree.gd")
67
const Util = preload("res://addons/block_code/ui/util.gd")
78

89
const EXTEND_MARGIN: float = 800

addons/block_code/ui/block_canvas/packed_scene_tree_node.gd

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

0 commit comments

Comments
 (0)