2020-04-26 15:47:21 +02:00
|
|
|
tool
|
|
|
|
extends EditorPlugin
|
|
|
|
|
2022-01-26 18:17:09 +01:00
|
|
|
const DataManagerAddonSettings = preload("res://addons/data_manager/resources/data_manager_addon_settings.gd")
|
|
|
|
|
2022-01-26 17:23:27 +01:00
|
|
|
const _main_panel : PackedScene = preload("res://addons/data_manager/panels/MainPanel.tscn")
|
|
|
|
const _script_icon : Texture = preload("res://addons/data_manager/icons/icon_multi_line.png")
|
2020-04-26 15:47:21 +02:00
|
|
|
|
2022-01-26 18:17:09 +01:00
|
|
|
var settings : DataManagerAddonSettings = null
|
|
|
|
|
2020-04-26 15:47:21 +02:00
|
|
|
var _main_panel_instance : Control
|
|
|
|
|
|
|
|
func _enter_tree():
|
2022-01-26 18:17:09 +01:00
|
|
|
load_settings()
|
|
|
|
|
2020-04-26 15:47:21 +02:00
|
|
|
_main_panel_instance = _main_panel.instance() as Control
|
|
|
|
_main_panel_instance.connect("inspect_data", self, "inspect_data")
|
|
|
|
|
|
|
|
get_editor_interface().get_editor_viewport().add_child(_main_panel_instance)
|
|
|
|
|
|
|
|
make_visible(false)
|
|
|
|
|
|
|
|
func _exit_tree():
|
|
|
|
_main_panel_instance.queue_free()
|
|
|
|
|
|
|
|
func has_main_screen():
|
|
|
|
return true
|
|
|
|
|
|
|
|
func make_visible(visible):
|
|
|
|
if visible:
|
|
|
|
_main_panel_instance.show()
|
|
|
|
else:
|
|
|
|
_main_panel_instance.hide()
|
|
|
|
|
|
|
|
func get_plugin_icon():
|
|
|
|
return _script_icon
|
|
|
|
|
|
|
|
func get_plugin_name():
|
2022-01-26 17:29:17 +01:00
|
|
|
return "Data"
|
2020-04-26 15:47:21 +02:00
|
|
|
|
|
|
|
func inspect_data(var data : Resource) -> void:
|
|
|
|
get_editor_interface().inspect_object(data)
|
2022-01-26 18:17:09 +01:00
|
|
|
|
|
|
|
func ensure_data_dir_exists() -> void:
|
|
|
|
var dir : Directory = Directory.new()
|
|
|
|
|
|
|
|
if !dir.dir_exists("res://addons/data_manager/_data/"):
|
|
|
|
dir.make_dir("res://addons/data_manager/_data/")
|
|
|
|
|
|
|
|
func load_settings() -> void:
|
|
|
|
ensure_data_dir_exists()
|
|
|
|
|
|
|
|
var dir : Directory = Directory.new()
|
|
|
|
|
2022-01-26 18:57:16 +01:00
|
|
|
if !dir.file_exists("res://addons/data_manager/_data/settings.tres"):
|
2022-01-26 18:17:09 +01:00
|
|
|
settings = DataManagerAddonSettings.new()
|
|
|
|
|
2022-01-26 18:57:16 +01:00
|
|
|
ResourceSaver.save("res://addons/data_manager/_data/settings.tres", settings)
|
2022-01-26 18:17:09 +01:00
|
|
|
else:
|
2022-01-26 18:57:16 +01:00
|
|
|
settings = ResourceLoader.load("res://addons/data_manager/_data/settings.tres")
|