|
@@ -1,18 +1,23 @@
|
|
@tool
|
|
@tool
|
|
extends EditorPlugin
|
|
extends EditorPlugin
|
|
|
|
|
|
|
|
+const _tool_json_root_path := "res://.tbl"
|
|
|
|
+
|
|
func _enter_tree() -> void:
|
|
func _enter_tree() -> void:
|
|
var helper := preload('tblext.gd')
|
|
var helper := preload('tblext.gd')
|
|
var base_dir: String = helper.resource_path.get_base_dir()
|
|
var base_dir: String = helper.resource_path.get_base_dir()
|
|
var tools_dir := base_dir.path_join('editor/tools')
|
|
var tools_dir := base_dir.path_join('editor/tools')
|
|
var dir := DirAccess.open(tools_dir)
|
|
var dir := DirAccess.open(tools_dir)
|
|
for file in dir.get_files():
|
|
for file in dir.get_files():
|
|
- if file.get_extension() == 'tres':
|
|
|
|
- make_panel(load(tools_dir.path_join(file)))
|
|
|
|
|
|
+ if file.get_extension() == 'rb':
|
|
|
|
+ var json_path := _tool_json_root_path.path_join(file.get_basename()) + '.json'
|
|
|
|
+ if FileAccess.file_exists(json_path):
|
|
|
|
+ make_panel(ProjectSettings.globalize_path(json_path), ProjectSettings.globalize_path(file))
|
|
|
|
|
|
-func make_panel(dev_tool:DevTool) -> VBoxContainer:
|
|
|
|
|
|
+func make_panel(tool_json_path:String, tool_script_path:String) -> VBoxContainer:
|
|
var panel := VBoxContainer.new()
|
|
var panel := VBoxContainer.new()
|
|
- var options := JSON.parse_string(FileAccess.get_file_as_string(dev_tool.tool_config))
|
|
|
|
|
|
+ var tool_json = JSON.parse_string(FileAccess.get_file_as_string(tool_json_path))
|
|
|
|
+ var options = tool_json.options
|
|
for option in options:
|
|
for option in options:
|
|
if option.value is String:
|
|
if option.value is String:
|
|
var comment := Label.new()
|
|
var comment := Label.new()
|
|
@@ -58,16 +63,16 @@ func make_panel(dev_tool:DevTool) -> VBoxContainer:
|
|
else:
|
|
else:
|
|
print("unsupported option value({0}): {1}".format([option.name, typeof(option.value)]))
|
|
print("unsupported option value({0}): {1}".format([option.name, typeof(option.value)]))
|
|
var command := Button.new()
|
|
var command := Button.new()
|
|
- command.text = dev_tool.tool_command_name
|
|
|
|
|
|
+ command.text = tool_json.command_name
|
|
command.button_up.connect(func():
|
|
command.button_up.connect(func():
|
|
- OS.execute('ruby', [ProjectSettings.globalize_path(dev_tool.tool_script)])
|
|
|
|
|
|
+ OS.execute('ruby', [tool_script_path])
|
|
)
|
|
)
|
|
panel.add_child(command)
|
|
panel.add_child(command)
|
|
- panel.name = dev_tool.tool_name
|
|
|
|
- add_control_to_dock(dev_tool.tool_dock, panel)
|
|
|
|
|
|
+ panel.name = tool_json.title
|
|
|
|
+ add_control_to_dock(DOCK_SLOT_LEFT_BR, panel)
|
|
panel.tree_exited.connect(func():
|
|
panel.tree_exited.connect(func():
|
|
- var json := FileAccess.open(dev_tool.tool_config, FileAccess.WRITE)
|
|
|
|
- json.store_string(JSON.stringify(options, "\t"))
|
|
|
|
|
|
+ var json := FileAccess.open(tool_json_path, FileAccess.WRITE)
|
|
|
|
+ json.store_string(JSON.stringify(tool_json, "\t"))
|
|
)
|
|
)
|
|
tree_exiting.connect(func():
|
|
tree_exiting.connect(func():
|
|
remove_control_from_docks(panel)
|
|
remove_control_from_docks(panel)
|