removing tests, datapacks now auto-load on start
This commit is contained in:
parent
06c8817996
commit
abd1505d25
@ -1,6 +1,4 @@
|
|||||||
[gd_scene load_steps=2 format=3 uid="uid://fy5iji5t58jk"]
|
[gd_scene format=3 uid="uid://fy5iji5t58jk"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://b6xurr0segcug" path="res://scripts/datapacks/datapack_tests.gd" id="1_ffwby"]
|
|
||||||
|
|
||||||
[node name="MainUI" type="CanvasLayer"]
|
[node name="MainUI" type="CanvasLayer"]
|
||||||
|
|
||||||
@ -11,6 +9,3 @@ anchor_bottom = 1.0
|
|||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
theme_type_variation = &"Background_Panel"
|
theme_type_variation = &"Background_Panel"
|
||||||
|
|
||||||
[node name="DatapackTests" type="Node" parent="."]
|
|
||||||
script = ExtResource("1_ffwby")
|
|
||||||
|
|||||||
@ -1,9 +1,58 @@
|
|||||||
# datapack_manager.gd
|
# datapack_manager.gd
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
|
# --- CONFIGURATION ---
|
||||||
|
const DATAPACKS_DIR = "user://datapacks/"
|
||||||
|
|
||||||
|
# --- STATE ---
|
||||||
var loaded_packs: Dictionary[String, DatapackModel] = {}
|
var loaded_packs: Dictionary[String, DatapackModel] = {}
|
||||||
|
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
var dir = DirAccess.open("user://")
|
||||||
|
if dir:
|
||||||
|
if not dir.dir_exists("datapacks"):
|
||||||
|
dir.make_dir("datapacks")
|
||||||
|
|
||||||
|
load_all_local_packs()
|
||||||
|
|
||||||
|
|
||||||
|
## Scans the local DATAPACKS_DIR, loads all valid datapack subdirectories,
|
||||||
|
## and registers them with the manager. This serves as the initial load and the refresh option.
|
||||||
|
func load_all_local_packs():
|
||||||
|
print("DatapackManager: Starting scan for local datapacks in '%s'" % DATAPACKS_DIR)
|
||||||
|
|
||||||
|
var loader = DatapackLoader.new()
|
||||||
|
var dir = DirAccess.open(DATAPACKS_DIR)
|
||||||
|
|
||||||
|
if dir == null:
|
||||||
|
push_error("DatapackManager: Failed to open datapacks directory: %s" % DATAPACKS_DIR)
|
||||||
|
return
|
||||||
|
|
||||||
|
dir.list_dir_begin()
|
||||||
|
var dir_name = dir.get_next()
|
||||||
|
|
||||||
|
while dir_name != "":
|
||||||
|
if dir_name == "." or dir_name == "..":
|
||||||
|
dir_name = dir.get_next()
|
||||||
|
continue
|
||||||
|
|
||||||
|
if dir.current_is_dir():
|
||||||
|
print("DatapackManager: Found pack directory: %s" % dir_name)
|
||||||
|
|
||||||
|
var datapack: DatapackModel = loader.load_datapack(dir_name)
|
||||||
|
|
||||||
|
if datapack:
|
||||||
|
register_pack(datapack)
|
||||||
|
else:
|
||||||
|
push_warning("DatapackManager: Failed to load pack in directory: %s. Skipping." % dir_name)
|
||||||
|
|
||||||
|
dir_name = dir.get_next()
|
||||||
|
|
||||||
|
dir.list_dir_end()
|
||||||
|
print("DatapackManager: Finished scanning local datapacks.")
|
||||||
|
|
||||||
|
|
||||||
func clear_loaded_packs():
|
func clear_loaded_packs():
|
||||||
loaded_packs.clear()
|
loaded_packs.clear()
|
||||||
|
|
||||||
@ -22,7 +71,9 @@ func unregister_pack(pack_guid: String):
|
|||||||
loaded_packs.erase(pack_guid)
|
loaded_packs.erase(pack_guid)
|
||||||
print("DatapackManager: Unregistered pack with GUID %s." % pack_guid)
|
print("DatapackManager: Unregistered pack with GUID %s." % pack_guid)
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
# --- DEPENDENCY RESOLUTION ---
|
# --- DEPENDENCY RESOLUTION ---
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
|
|
||||||
## Resolves a single SzObject ID across all loaded packs.
|
## Resolves a single SzObject ID across all loaded packs.
|
||||||
## Used by SPECIFIC_DATASET mode when the pack GUID is unknown (or referencing local content).
|
## Used by SPECIFIC_DATASET mode when the pack GUID is unknown (or referencing local content).
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user