mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-11-13 20:47:19 +01:00
Brought in code from the DataManager singleton (which maybe should be renamed) to the data manager addon. Also disabled the addon's panel's _ready() for now, and enabled it.
This commit is contained in:
parent
1a509a9751
commit
3db96fec68
@ -5,23 +5,20 @@ signal inspect_data
|
||||
|
||||
export(PackedScene) var resource_scene : PackedScene
|
||||
export(PackedScene) var folder_entry_button_scene : PackedScene
|
||||
export(String) var base_folder : String = "res://modules/"
|
||||
export(String) var base_folder : String = "res://"
|
||||
export(NodePath) var main_container : NodePath
|
||||
export(NodePath) var folder_entry_container_path : NodePath
|
||||
|
||||
|
||||
var _main_container : Node
|
||||
var _resource_scene : Node
|
||||
var _folder_entry_container : Node
|
||||
|
||||
var _modules : Array = Array()
|
||||
var _folders : Array = Array()
|
||||
|
||||
var _folders : Array = [
|
||||
]
|
||||
|
||||
func _ready():
|
||||
func _old_ready():
|
||||
var dir : Directory = Directory.new()
|
||||
|
||||
|
||||
if dir.file_exists("res://ess_data.json"):
|
||||
var file : File = File.new()
|
||||
|
||||
@ -31,14 +28,7 @@ func _ready():
|
||||
_folders = parse_json(s)
|
||||
|
||||
file.close()
|
||||
# else:
|
||||
# var file : File = File.new()
|
||||
#
|
||||
# if file.open("res://ess_data.json", File.WRITE) == OK:
|
||||
# file.store_string(to_json(_folders))
|
||||
#
|
||||
# file.close()
|
||||
|
||||
|
||||
_main_container = get_node(main_container)
|
||||
|
||||
_resource_scene = resource_scene.instance()
|
||||
@ -76,6 +66,57 @@ func _ready():
|
||||
set_tab(0)
|
||||
# set_tab("test")
|
||||
|
||||
|
||||
func initialize_modules() -> void:
|
||||
_modules.clear()
|
||||
|
||||
load_modules_at("res://")
|
||||
|
||||
_modules.sort_custom(ModulePathSorter, "sort_ascending")
|
||||
|
||||
for module in _modules:
|
||||
if module.has_method("load_module"):
|
||||
module.load_module()
|
||||
|
||||
func load_modules_at(path : String) -> void:
|
||||
var dir = Directory.new()
|
||||
if dir.open(path) == OK:
|
||||
dir.list_dir_begin()
|
||||
var file_name = dir.get_next()
|
||||
while file_name != "":
|
||||
if file_name == "." or file_name == "..":
|
||||
file_name = dir.get_next()
|
||||
continue
|
||||
|
||||
if dir.current_is_dir():
|
||||
if path == "res://":
|
||||
load_modules_at(path + file_name)
|
||||
else:
|
||||
load_modules_at(path + "/" + file_name)
|
||||
else:
|
||||
if file_name == "game_module.tres":
|
||||
var res : Resource = null
|
||||
|
||||
if path == "res://":
|
||||
res = ResourceLoader.load(path + file_name)
|
||||
else:
|
||||
res = ResourceLoader.load(path + "/" + file_name)
|
||||
|
||||
if res.enabled:
|
||||
_modules.append(res)
|
||||
|
||||
file_name = dir.get_next()
|
||||
else:
|
||||
print("An error occurred when trying to access the path: " + path)
|
||||
|
||||
|
||||
class ModulePathSorter:
|
||||
static func sort_ascending(a, b):
|
||||
if a.resource_path < b.resource_path:
|
||||
return true
|
||||
return false
|
||||
|
||||
|
||||
func set_tab(tab_index : int) -> void:
|
||||
hide_all()
|
||||
|
||||
|
@ -4,7 +4,6 @@
|
||||
[ext_resource path="res://addons/data_manager/panels/FolderEntryButton.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://addons/data_manager/panels/ResourcePanel.tscn" type="PackedScene" id=3]
|
||||
|
||||
|
||||
[node name="Panel" type="MarginContainer"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
|
@ -358,7 +358,7 @@ window/size/ui_scale_touch=1.0
|
||||
|
||||
[editor_plugins]
|
||||
|
||||
enabled=PoolStringArray( "res://addons/Godoxel/plugin.cfg", "res://addons/color-palette/plugin.cfg", "res://addons/godot-plugin-refresher/plugin.cfg", "res://addons/mat_maker_gd/plugin.cfg", "res://addons/mesh_data_resource_editor/plugin.cfg", "res://addons/world_generator/plugin.cfg" )
|
||||
enabled=PoolStringArray( "res://addons/Godoxel/plugin.cfg", "res://addons/color-palette/plugin.cfg", "res://addons/data_manager/plugin.cfg", "res://addons/godot-plugin-refresher/plugin.cfg", "res://addons/mat_maker_gd/plugin.cfg", "res://addons/mesh_data_resource_editor/plugin.cfg", "res://addons/world_generator/plugin.cfg" )
|
||||
|
||||
[ess]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user