Skip to content

Commit ba0c90b

Browse files
authored
Merge pull request #28 from endlessm/plugin-cleanup
Plugin cleanup
2 parents 62e90bf + 4db65bd commit ba0c90b

File tree

2 files changed

+44
-57
lines changed

2 files changed

+44
-57
lines changed

addons/block_code/block_code_plugin.gd

Lines changed: 37 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,44 @@ extends EditorPlugin
55
const MainPanel := preload("res://addons/block_code/ui/main_panel.tscn")
66
static var main_panel
77

8-
var script_ok_button: Button
9-
var script_ok_prev_connection: Dictionary
10-
var prev_opened_script_idx: int
11-
128
var old_feature_profile: String = ""
139

10+
const DISABLED_CLASSES := [
11+
"BlockScriptData",
12+
"DragManager",
13+
"InstructionTree",
14+
"EditorInterfaceAccess",
15+
"SimpleCharacter",
16+
"Types",
17+
"BasicBlock",
18+
"Block",
19+
"ControlBlock",
20+
"ParameterBlock",
21+
"StatementBlock",
22+
"DragDropArea",
23+
"SnapPoint",
24+
"NodeBlockCanvas",
25+
"SerializedBlockTreeNodeArray",
26+
"SerializedBlockTreeNode",
27+
"SerializedBlock",
28+
"PackedSceneTreeNodeArray",
29+
"PackedSceneTreeNode",
30+
"BlockCanvas",
31+
"NodeCanvas",
32+
"NodeClass",
33+
"NodeClassList",
34+
"NodeData",
35+
"NodePreview",
36+
"NodeList",
37+
"CategoryFactory",
38+
"BlockCategoryDisplay",
39+
"BlockCategory",
40+
"Picker",
41+
"TitleBar",
42+
"MainPanel",
43+
"BlockCodePlugin"
44+
]
45+
1446

1547
func _enter_tree():
1648
main_panel = MainPanel.instantiate()
@@ -25,50 +57,14 @@ func _enter_tree():
2557
add_autoload_singleton("SignalManager", "res://addons/block_code/block_code_node/utilities/signal_manager.gd")
2658

2759
# Remove unwanted class nodes from create node
28-
var remove_list := [
29-
"BlockScriptData",
30-
"DragManager",
31-
"InstructionTree",
32-
"EditorInterfaceAccess",
33-
"SimpleCharacter",
34-
"Types",
35-
"BasicBlock",
36-
"Block",
37-
"ControlBlock",
38-
"ParameterBlock",
39-
"StatementBlock",
40-
"DragDropArea",
41-
"SnapPoint",
42-
"NodeBlockCanvas",
43-
"SerializedBlockTreeNodeArray",
44-
"SerializedBlockTreeNode",
45-
"SerializedBlock",
46-
"PackedSceneTreeNodeArray",
47-
"PackedSceneTreeNode",
48-
"BlockCanvas",
49-
"NodeCanvas",
50-
"NodeClass",
51-
"NodeClassList",
52-
"NodeData",
53-
"NodePreview",
54-
"NodeList",
55-
"CategoryFactory",
56-
"BlockCategoryDisplay",
57-
"BlockCategory",
58-
"Picker",
59-
"TitleBar",
60-
"MainPanel",
61-
"BlockCodePlugin"
62-
]
63-
6460
old_feature_profile = EditorInterface.get_current_feature_profile()
6561

6662
var editor_paths: EditorPaths = EditorInterface.get_editor_paths()
6763
if editor_paths:
6864
var config_dir := editor_paths.get_config_dir()
6965
var new_profile := EditorFeatureProfile.new()
7066
new_profile.load_from_file(config_dir + "/feature_profiles/" + old_feature_profile + ".profile")
71-
for _class_name in remove_list:
67+
for _class_name in DISABLED_CLASSES:
7268
new_profile.set_disable_class(_class_name, true)
7369

7470
var dir = config_dir + "/feature_profiles/block_code.profile"
@@ -93,10 +89,6 @@ func _exit_tree():
9389
EditorInterface.set_current_feature_profile("")
9490

9591

96-
func _reconnect_signal(_signal: Signal, _data: Dictionary):
97-
_signal.connect(_data.callable, _data.flags)
98-
99-
10092
func _has_main_screen():
10193
return true
10294

addons/block_code/ui/main_panel.gd

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ var eia: EditorInterfaceAccess
77
@onready var _picker: Picker = %Picker
88
@onready var _block_canvas: BlockCanvas = %NodeBlockCanvas
99
@onready var _drag_manager: DragManager = %DragManager
10-
#@onready var _node_canvas := %NodeCanvas
11-
#@onready var _node_list: NodeList = %NodeList
1210
@onready var _title_bar: TitleBar = %TitleBar
1311

1412
var block_code_tab: Button
@@ -23,8 +21,6 @@ func _ready():
2321
_block_canvas.reconnect_block.connect(_drag_manager.connect_block_canvas_signals)
2422
_drag_manager.block_dropped.connect(save_script)
2523
_drag_manager.block_modified.connect(save_script)
26-
#_node_list.node_selected.connect(_title_bar.node_selected)
27-
#_title_bar.node_name_changed.connect(_node_list.on_node_name_changed)
2824

2925
eia = EditorInterfaceAccess.new()
3026

@@ -33,7 +29,7 @@ func _ready():
3329

3430

3531
func _on_button_pressed():
36-
pass
32+
_print_generated_script()
3733

3834

3935
func switch_script(block_code_node: BlockCode):
@@ -78,11 +74,10 @@ func _input(event):
7874
else:
7975
_drag_manager.drag_ended()
8076

81-
# HACK: play the topmost block
82-
if event is InputEventKey:
83-
if event.keycode == KEY_F and event.pressed:
84-
if _current_bsd:
85-
var script: String = _block_canvas.generate_script_from_current_window(_current_bsd.script_inherits)
8677

87-
print(script)
88-
print("Debug script! (not saved)")
78+
func _print_generated_script():
79+
if _current_bsd == null:
80+
return
81+
var script: String = _block_canvas.generate_script_from_current_window(_current_bsd.script_inherits)
82+
print(script)
83+
print("Debug script! (not saved)")

0 commit comments

Comments
 (0)