Added a modules tab to the data manager's main panel. Also made it collect all the modules in the project.

This commit is contained in:
Relintai 2022-01-26 20:21:35 +01:00
parent 58d707c695
commit 33ea23e3c3
2 changed files with 55 additions and 14 deletions

View File

@ -9,10 +9,12 @@ export(PackedScene) var resource_scene : PackedScene
export(PackedScene) var folder_entry_button_scene : PackedScene export(PackedScene) var folder_entry_button_scene : PackedScene
export(String) var base_folder : String = "res://" export(String) var base_folder : String = "res://"
export(NodePath) var main_container : NodePath export(NodePath) var main_container : NodePath
export(NodePath) var module_entry_container_path : NodePath
export(NodePath) var folder_entry_container_path : NodePath export(NodePath) var folder_entry_container_path : NodePath
var _main_container : Node var _main_container : Node
var _resource_scene : Node var _resource_scene : Node
var _module_entry_container : Node
var _folder_entry_container : Node var _folder_entry_container : Node
var _modules : Array = Array() var _modules : Array = Array()
@ -42,6 +44,25 @@ func load_data():
_resource_scene.owner = _main_container _resource_scene.owner = _main_container
_resource_scene.connect("inspect_data", self, "inspect_data") _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) _folder_entry_container = get_node(folder_entry_container_path)
for ch in _folder_entry_container.get_children(): for ch in _folder_entry_container.get_children():
@ -71,18 +92,14 @@ func load_data():
set_tab(0) set_tab(0)
func on_module_entry_button_toggled(on : bool, module) -> void:
pass
func initialize_modules() -> void: func load_modules() -> void:
_modules.clear() _modules.clear()
load_modules_at("res://") load_modules_at("res://")
_modules.sort_custom(ModulePathSorter, "sort_ascending") _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: func load_modules_at(path : String) -> void:
var dir = Directory.new() var dir = Directory.new()
if dir.open(path) == OK: if dir.open(path) == OK:
@ -114,7 +131,6 @@ func load_modules_at(path : String) -> void:
else: else:
print("An error occurred when trying to access the path: " + path) print("An error occurred when trying to access the path: " + path)
class ModulePathSorter: class ModulePathSorter:
static func sort_ascending(a, b): static func sort_ascending(a, b):
if a.resource_path < b.resource_path: if a.resource_path < b.resource_path:

View File

@ -17,7 +17,8 @@ resource_scene = ExtResource( 3 )
folder_entry_button_scene = ExtResource( 2 ) folder_entry_button_scene = ExtResource( 2 )
base_folder = "res://data/" base_folder = "res://data/"
main_container = NodePath("HSplitContainer/MarginContainer") 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="."] [node name="HSplitContainer" type="HSplitContainer" parent="."]
margin_right = 1024.0 margin_right = 1024.0
@ -29,16 +30,40 @@ __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="ScrollContainer" type="ScrollContainer" parent="HSplitContainer"] [node name="TabContainer" type="TabContainer" parent="HSplitContainer"]
margin_right = 210.0 margin_right = 218.0
margin_bottom = 600.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 margin_right = 210.0
size_flags_horizontal = 3 size_flags_horizontal = 3
[node name="MarginContainer" type="MarginContainer" parent="HSplitContainer"] [node name="MarginContainer" type="MarginContainer" parent="HSplitContainer"]
margin_left = 222.0 margin_left = 230.0
margin_right = 1024.0 margin_right = 1024.0
margin_bottom = 600.0 margin_bottom = 600.0