diff --git a/game/addons/data_manager/panels/MainPanel.gd b/game/addons/data_manager/panels/MainPanel.gd index 66b58447..f7d0fb01 100644 --- a/game/addons/data_manager/panels/MainPanel.gd +++ b/game/addons/data_manager/panels/MainPanel.gd @@ -9,10 +9,12 @@ export(PackedScene) var resource_scene : PackedScene export(PackedScene) var folder_entry_button_scene : PackedScene export(String) var base_folder : String = "res://" export(NodePath) var main_container : NodePath +export(NodePath) var module_entry_container_path : NodePath export(NodePath) var folder_entry_container_path : NodePath var _main_container : Node var _resource_scene : Node +var _module_entry_container : Node var _folder_entry_container : Node var _modules : Array = Array() @@ -42,6 +44,25 @@ func load_data(): _resource_scene.owner = _main_container _resource_scene.connect("inspect_data", self, "inspect_data") + _module_entry_container = get_node(module_entry_container_path) + load_modules() + + for m in _modules: + var label_str : String = m.resource_name + + if label_str == "": + label_str = m.resource_path + label_str = label_str.replace("res://", "") + label_str = label_str.replace("/game_module.tres", "") + label_str = label_str.replace("game_module.tres", "") + + var b : Button = Button.new() + b.toggle_mode = true + b.text = label_str + b.set_h_size_flags(SIZE_EXPAND_FILL) + b.connect("toggled", self, "on_module_entry_button_toggled", [ m ]) + _module_entry_container.add_child(b) + _folder_entry_container = get_node(folder_entry_container_path) for ch in _folder_entry_container.get_children(): @@ -71,18 +92,14 @@ func load_data(): set_tab(0) +func on_module_entry_button_toggled(on : bool, module) -> void: + pass -func initialize_modules() -> void: +func load_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: @@ -114,7 +131,6 @@ func load_modules_at(path : String) -> void: 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: diff --git a/game/addons/data_manager/panels/MainPanel.tscn b/game/addons/data_manager/panels/MainPanel.tscn index 072bd406..d14f9243 100644 --- a/game/addons/data_manager/panels/MainPanel.tscn +++ b/game/addons/data_manager/panels/MainPanel.tscn @@ -17,7 +17,8 @@ resource_scene = ExtResource( 3 ) folder_entry_button_scene = ExtResource( 2 ) base_folder = "res://data/" main_container = NodePath("HSplitContainer/MarginContainer") -folder_entry_container_path = NodePath("HSplitContainer/ScrollContainer/VBoxContainer") +module_entry_container_path = NodePath("HSplitContainer/TabContainer/Modules/VBoxContainer") +folder_entry_container_path = NodePath("HSplitContainer/TabContainer/Folders/VBoxContainer") [node name="HSplitContainer" type="HSplitContainer" parent="."] margin_right = 1024.0 @@ -29,16 +30,40 @@ __meta__ = { "_edit_use_anchors_": false } -[node name="ScrollContainer" type="ScrollContainer" parent="HSplitContainer"] -margin_right = 210.0 +[node name="TabContainer" type="TabContainer" parent="HSplitContainer"] +margin_right = 218.0 margin_bottom = 600.0 -size_flags_vertical = 3 -[node name="VBoxContainer" type="VBoxContainer" parent="HSplitContainer/ScrollContainer"] +[node name="Modules" type="ScrollContainer" parent="HSplitContainer/TabContainer"] +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_left = 4.0 +margin_top = 32.0 +margin_right = -4.0 +margin_bottom = -4.0 +size_flags_vertical = 3 +scroll_horizontal_enabled = false + +[node name="VBoxContainer" type="VBoxContainer" parent="HSplitContainer/TabContainer/Modules"] +margin_right = 210.0 +size_flags_horizontal = 3 + +[node name="Folders" type="ScrollContainer" parent="HSplitContainer/TabContainer"] +visible = false +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_left = 4.0 +margin_top = 32.0 +margin_right = -4.0 +margin_bottom = -4.0 +size_flags_vertical = 3 +scroll_horizontal_enabled = false + +[node name="VBoxContainer" type="VBoxContainer" parent="HSplitContainer/TabContainer/Folders"] margin_right = 210.0 size_flags_horizontal = 3 [node name="MarginContainer" type="MarginContainer" parent="HSplitContainer"] -margin_left = 222.0 +margin_left = 230.0 margin_right = 1024.0 margin_bottom = 600.0