From 965ecd5f181263aa41d3664cbfbac8442e5926aa Mon Sep 17 00:00:00 2001 From: Relintai Date: Wed, 26 Jan 2022 18:17:09 +0100 Subject: [PATCH] Added a new settings resource class to the data manager addon, and made the plugin load and save it to a central folder. --- game/addons/data_manager/_data/settings.res | Bin 0 -> 311 bytes game/addons/data_manager/plugin.gd | 24 ++++++++++++++++++ .../resources/data_manager_addon_settings.gd | 4 +++ game/project.godot | 2 +- 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 game/addons/data_manager/_data/settings.res create mode 100644 game/addons/data_manager/resources/data_manager_addon_settings.gd diff --git a/game/addons/data_manager/_data/settings.res b/game/addons/data_manager/_data/settings.res new file mode 100644 index 0000000000000000000000000000000000000000..b361966420442dc5cc16927f463a649138e9b83d GIT binary patch literal 311 zcmbtQ%L>9U5R8h59z1yRD-2$}_7Bnz2ure*LYqi7{=c)af;~Gh>?6zUY+Ua;vtWm~ z2Q?l+$C6(qFw*~^f>*FCf_}<@CSS9cz=_TI_bt)P=75fbGCr%>Al0(}l$Y#BUbxmV4RRY|Q$0bdIf2;STyznzx?Fo(P~Gbl3WqOy1F2&= AIRF3v literal 0 HcmV?d00001 diff --git a/game/addons/data_manager/plugin.gd b/game/addons/data_manager/plugin.gd index a457513b..78e825cc 100644 --- a/game/addons/data_manager/plugin.gd +++ b/game/addons/data_manager/plugin.gd @@ -1,12 +1,18 @@ tool 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 _script_icon : Texture = preload("res://addons/data_manager/icons/icon_multi_line.png") +var settings : DataManagerAddonSettings = null + var _main_panel_instance : Control func _enter_tree(): + load_settings() + _main_panel_instance = _main_panel.instance() as Control _main_panel_instance.connect("inspect_data", self, "inspect_data") @@ -34,3 +40,21 @@ func get_plugin_name(): func inspect_data(var data : Resource) -> void: 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") diff --git a/game/addons/data_manager/resources/data_manager_addon_settings.gd b/game/addons/data_manager/resources/data_manager_addon_settings.gd new file mode 100644 index 00000000..2ec21290 --- /dev/null +++ b/game/addons/data_manager/resources/data_manager_addon_settings.gd @@ -0,0 +1,4 @@ +tool +extends Resource + + diff --git a/game/project.godot b/game/project.godot index 1c5fc74c..b2987613 100644 --- a/game/project.godot +++ b/game/project.godot @@ -8,6 +8,7 @@ config_version=4 +Node="input/actionbar_5_11" _global_script_classes=[ { "base": "Reference", "class": "BrushPrefabs", @@ -311,7 +312,6 @@ _global_script_class_icons={ "WorldGeneratorSettings": "", "Zone": "" } -Node="input/actionbar_5_11" [application]