Added a new settings resource class to the data manager addon, and made the plugin load and save it to a central folder.

This commit is contained in:
Relintai 2022-01-26 18:17:09 +01:00
parent 3db96fec68
commit 965ecd5f18
4 changed files with 29 additions and 1 deletions

Binary file not shown.

View File

@ -1,12 +1,18 @@
tool tool
extends EditorPlugin extends EditorPlugin
const DataManagerAddonSettings = preload("res://addons/data_manager/resources/data_manager_addon_settings.gd")
const _main_panel : PackedScene = preload("res://addons/data_manager/panels/MainPanel.tscn") 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") const _script_icon : Texture = preload("res://addons/data_manager/icons/icon_multi_line.png")
var settings : DataManagerAddonSettings = null
var _main_panel_instance : Control var _main_panel_instance : Control
func _enter_tree(): func _enter_tree():
load_settings()
_main_panel_instance = _main_panel.instance() as Control _main_panel_instance = _main_panel.instance() as Control
_main_panel_instance.connect("inspect_data", self, "inspect_data") _main_panel_instance.connect("inspect_data", self, "inspect_data")
@ -34,3 +40,21 @@ func get_plugin_name():
func inspect_data(var data : Resource) -> void: func inspect_data(var data : Resource) -> void:
get_editor_interface().inspect_object(data) get_editor_interface().inspect_object(data)
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()
if !dir.file_exists("res://addons/data_manager/_data/settings.res"):
settings = DataManagerAddonSettings.new()
ResourceSaver.save("res://addons/data_manager/_data/settings.res", settings)
else:
settings = ResourceLoader.load("res://addons/data_manager/_data/settings.res")

View File

@ -0,0 +1,4 @@
tool
extends Resource

View File

@ -8,6 +8,7 @@
config_version=4 config_version=4
Node="input/actionbar_5_11"
_global_script_classes=[ { _global_script_classes=[ {
"base": "Reference", "base": "Reference",
"class": "BrushPrefabs", "class": "BrushPrefabs",
@ -311,7 +312,6 @@ _global_script_class_icons={
"WorldGeneratorSettings": "", "WorldGeneratorSettings": "",
"Zone": "" "Zone": ""
} }
Node="input/actionbar_5_11"
[application] [application]