-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathblockflow.gd
More file actions
90 lines (74 loc) · 3.27 KB
/
Copy pathblockflow.gd
File metadata and controls
90 lines (74 loc) · 3.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
## Blockflow plugin-wide constants.
# Modifying values here requires a plugin reload after save.
const PluginConstants = preload("res://addons/blockflow/core/constants.gd")
## Blockflow debugger constants messages
const Debugger = preload("res://addons/blockflow/debugger/debugger_messages.gd")
## Blockflow util scripts. Utility functions that didn't have place here.
const Utils = preload("res://addons/blockflow/core/utils.gd")
## Blockflow CommandRecord class. Used to manage registered commands in editor.
const CommandRecord = preload("res://addons/blockflow/core/command_record.gd")
# Made to ensure that classes are loaded before class_name populates editor
## [Collection] class.
const CollectionClass = preload("res://addons/blockflow/collection.gd")
## [CommandCollection] class.
const CommandCollectionClass = preload("res://addons/blockflow/command_collection.gd")
## [Command] class.
const CommandClass = preload("res://addons/blockflow/commands/command.gd")
## [CommandProcessor] class.
const CommandProcessorClass = preload("res://addons/blockflow/processors/command_processor.gd")
static func get_default_command_scripts() -> Array:
var commands := []
for command_path in PluginConstants.DEFAULT_COMMAND_PATHS:
if not ResourceLoader.exists(command_path, "Script"):
push_warning("!ResourceLoader.exists(%s) == true, continuing"%command_path)
continue
var command_script: Script = load(command_path) as Script
if not command_script:
push_warning("CommandList: Resource at '%s' is not an Script."%command_path)
continue
commands.append(command_script)
return commands
# TODO: Custom commands made by the user that are not a script/resource file
# and will live under a special folder.
## Commands defined in
## ProjectSettings [constant PROJECT_SETTING_CUSTOM_COMMANDS]
static func get_custom_commands() -> Array:
var commands := []
for command_path in ProjectSettings.get_setting(PluginConstants.PROJECT_SETTING_CUSTOM_COMMANDS, []):
if not ResourceLoader.exists(command_path):
push_warning("!ResourceLoader.exists(%s) == true, continuing"%command_path)
continue
# We can't guess the type, so let's load it as generic
# and let the caller handle it.
var command: Resource = ResourceLoader.load(command_path)
if not command:
# HOW?
push_warning("CommandList: Resource at '%s' is not valid."%command_path)
continue
commands.append(command)
return commands
static func get_plugin() -> Node:
if not Engine.has_meta(PluginConstants.PLUGIN_NAME):
return null
return Engine.get_meta(PluginConstants.PLUGIN_NAME)
static func get_editor_interface() -> EditorInterface:
return null
enum Toast {
SEVERITY_INFO,
SEVERITY_WARNING,
SEVERITY_ERROR
}
static func _recursive_add(command, to) -> void:
to.append(command)
for subcommand in command:
_recursive_add(subcommand, to)
static func move_to_collection(command, to_collection, to_position = 0) -> void:
var owner_collection = command.get_command_owner()
owner_collection.erase(command)
to_collection.insert(command, to_position)
# var idx = to_position if to_position > -1 else to_collection.collection.size()
# to_collection.collection.insert(idx, command)
# owner_collection.emit_changed()
# to_collection.emit_changed()
# owner_collection._notify_changed()
# to_collection._notify_changed()