diff --git a/game/addons/data_manager/panels/AddFolderDialog.gd b/game/addons/data_manager/panels/AddFolderDialog.gd new file mode 100644 index 00000000..ecb78f28 --- /dev/null +++ b/game/addons/data_manager/panels/AddFolderDialog.gd @@ -0,0 +1,73 @@ +tool +extends ConfirmationDialog + +const DataManagerAddonSettings = preload("res://addons/data_manager/resources/data_manager_addon_settings.gd") + +var _settings : DataManagerAddonSettings = null +var _module = null + +signal folders_created + +func _enter_tree(): + connect("confirmed", self, "on_confirmed") + +func setup() -> void: + var entry_container : Control = $ScrollContainer/VBoxContainer + + for ch in entry_container.get_children(): + ch.queue_free() + + var dir : Directory = Directory.new() + + var label_str : String = "= " + get_module_label_text(_module) + " =" + window_title = "Add folder(s) for " + label_str + + var module_dir_base : String = _module.resource_path.get_base_dir() + + for f in _settings.folders: + if dir.dir_exists(module_dir_base + "/" + f.folder): + continue + + var ecb : CheckBox = CheckBox.new() + ecb.text = f.folder + " (" + f.type + ")" + ecb.set_meta("folder", f.folder) + entry_container.add_child(ecb) + +func on_confirmed() -> void: + var entry_container : Control = $ScrollContainer/VBoxContainer + + var dir : Directory = Directory.new() + var module_dir_base : String = _module.resource_path.get_base_dir() + + for c in entry_container.get_children(): + if !(c is CheckBox): + continue + + if !c.pressed: + continue + + var folder : String = c.get_meta("folder") + var d : String = module_dir_base + "/" + folder + if !dir.dir_exists(d): + dir.make_dir(d) + + emit_signal("folders_created") + +func set_module(module, settings : DataManagerAddonSettings) -> void: + _module = module + _settings = settings + setup() + #popup_centered() + + popup_centered() + +func get_module_label_text(module) -> String: + var label_str : String = module.resource_name + + if label_str == "": + label_str = module.resource_path + label_str = label_str.replace("res://", "") + label_str = label_str.replace("/game_module.tres", "") + label_str = label_str.replace("game_module.tres", "") + + return label_str diff --git a/game/addons/data_manager/panels/MainPanel.gd b/game/addons/data_manager/panels/MainPanel.gd index 4f4e7066..b2d5cbd3 100644 --- a/game/addons/data_manager/panels/MainPanel.gd +++ b/game/addons/data_manager/panels/MainPanel.gd @@ -2,6 +2,8 @@ tool extends Control const DataManagerAddonSettings = preload("res://addons/data_manager/resources/data_manager_addon_settings.gd") +const add_icon = preload("res://addons/data_manager/icons/icon_add.png") + signal inspect_data @@ -27,6 +29,9 @@ var _plugin : EditorPlugin = null func _enter_tree(): if !is_connected("visibility_changed", self, "on_visibility_changed"): connect("visibility_changed", self, "on_visibility_changed") + + if !$Popups/AddFolderDialog.is_connected("folders_created", self, "on_folders_created"): + $Popups/AddFolderDialog.connect("folders_created", self, "on_folders_created") func on_visibility_changed(): if _plugin && is_visible_in_tree() && !_initialized: @@ -72,7 +77,12 @@ func generate_folder_entry_list() -> void: var dir : Directory = Directory.new() - for module in _active_modules: + for i in range(_active_modules.size()): + var module = _active_modules[i] + + if i > 0: + _folder_entry_container.add_child(HSeparator.new()) + var label_str : String = "= " + get_module_label_text(module) + " =" var mlabel : Label = Label.new() mlabel.text = label_str @@ -102,6 +112,16 @@ func generate_folder_entry_list() -> void: fe.set_main_panel(self) index += 1 + + var bsep : Label = Label.new() + bsep.text = "Actions" + _folder_entry_container.add_child(bsep) + + var add_folder_button : Button = Button.new() + add_folder_button.text = "Add Folder" + add_folder_button.icon = add_icon + _folder_entry_container.add_child(add_folder_button) + add_folder_button.connect("pressed", self, "on_add_folder_button_pressed", [ module ]) set_tab(0) @@ -120,6 +140,9 @@ func on_module_entry_button_toggled(on : bool, module) -> void: generate_folder_entry_list() return +func on_add_folder_button_pressed(module) -> void: + $Popups/AddFolderDialog.set_module(module, _settings) + func load_modules() -> void: _modules.clear() load_modules_at("res://") @@ -161,8 +184,7 @@ class ModulePathSorter: if a.resource_path < b.resource_path: return true return false - - + func set_tab(tab_index : int) -> void: hide_all() @@ -188,3 +210,6 @@ func get_module_label_text(module) -> String: label_str = label_str.replace("game_module.tres", "") return label_str + +func on_folders_created() -> void: + generate_folder_entry_list() diff --git a/game/addons/data_manager/panels/MainPanel.tscn b/game/addons/data_manager/panels/MainPanel.tscn index d14f9243..8fcd5321 100644 --- a/game/addons/data_manager/panels/MainPanel.tscn +++ b/game/addons/data_manager/panels/MainPanel.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=4 format=2] +[gd_scene load_steps=5 format=2] [ext_resource path="res://addons/data_manager/panels/MainPanel.gd" type="Script" id=1] [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] +[ext_resource path="res://addons/data_manager/panels/AddFolderDialog.gd" type="Script" id=4] [node name="Panel" type="MarginContainer"] anchor_right = 1.0 @@ -67,3 +68,36 @@ size_flags_horizontal = 3 margin_left = 230.0 margin_right = 1024.0 margin_bottom = 600.0 + +[node name="Popups" type="Control" parent="."] +margin_right = 1024.0 +margin_bottom = 600.0 +mouse_filter = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 +__meta__ = { +"_edit_lock_": true +} + +[node name="AddFolderDialog" type="ConfirmationDialog" parent="Popups"] +margin_left = 287.0 +margin_top = 100.0 +margin_right = 751.0 +margin_bottom = 447.0 +window_title = "Add folder(s)" +resizable = true +script = ExtResource( 4 ) + +[node name="ScrollContainer" type="ScrollContainer" parent="Popups/AddFolderDialog"] +margin_left = 8.0 +margin_top = 8.0 +margin_right = 456.0 +margin_bottom = 311.0 +scroll_horizontal_enabled = false +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="VBoxContainer" type="VBoxContainer" parent="Popups/AddFolderDialog/ScrollContainer"] +margin_right = 448.0 +size_flags_horizontal = 3 diff --git a/game/addons/data_manager/panels/ResourcePanel.tscn b/game/addons/data_manager/panels/ResourcePanel.tscn index 7d457577..45fea9af 100644 --- a/game/addons/data_manager/panels/ResourcePanel.tscn +++ b/game/addons/data_manager/panels/ResourcePanel.tscn @@ -8,7 +8,6 @@ [ext_resource path="res://addons/data_manager/icons/icon_empty.png" type="Texture" id=6] [ext_resource path="res://addons/data_manager/icons/icon_reload_small.png" type="Texture" id=7] - [node name="Panel" type="Control"] anchor_right = 1.0 anchor_bottom = 1.0 @@ -33,71 +32,71 @@ __meta__ = { } [node name="VBoxContainer2" type="VBoxContainer" parent="ResourcePanel"] -margin_right = 664.0 +margin_right = 600.0 margin_bottom = 600.0 [node name="LineEdit" type="LineEdit" parent="ResourcePanel/VBoxContainer2"] -margin_right = 664.0 -margin_bottom = 45.0 +margin_right = 600.0 +margin_bottom = 26.0 right_icon = ExtResource( 6 ) placeholder_text = "Filter" caret_blink = true [node name="CreateButton" type="Button" parent="ResourcePanel/VBoxContainer2"] -margin_top = 53.0 -margin_right = 664.0 -margin_bottom = 90.0 +margin_top = 30.0 +margin_right = 600.0 +margin_bottom = 50.0 rect_min_size = Vector2( 100, 0 ) text = "Create" icon = ExtResource( 4 ) expand_icon = true [node name="HSeparator" type="HSeparator" parent="ResourcePanel/VBoxContainer2"] -margin_top = 98.0 -margin_right = 664.0 -margin_bottom = 106.0 +margin_top = 54.0 +margin_right = 600.0 +margin_bottom = 58.0 size_flags_horizontal = 3 __meta__ = { "_edit_use_anchors_": false } [node name="ScrollContainer2" type="ScrollContainer" parent="ResourcePanel/VBoxContainer2"] -margin_top = 114.0 -margin_right = 664.0 +margin_top = 62.0 +margin_right = 600.0 margin_bottom = 600.0 size_flags_vertical = 3 [node name="VBoxContainer" type="VBoxContainer" parent="ResourcePanel/VBoxContainer2/ScrollContainer2"] -margin_right = 664.0 +margin_right = 600.0 size_flags_horizontal = 3 [node name="VBoxContainer" type="VBoxContainer" parent="ResourcePanel"] -margin_left = 688.0 +margin_left = 612.0 margin_right = 1024.0 margin_bottom = 600.0 [node name="Button" type="Button" parent="ResourcePanel/VBoxContainer"] -margin_right = 336.0 -margin_bottom = 37.0 +margin_right = 412.0 +margin_bottom = 20.0 size_flags_horizontal = 3 text = "Clear History" icon = ExtResource( 7 ) [node name="HSeparator" type="HSeparator" parent="ResourcePanel/VBoxContainer"] -margin_top = 45.0 -margin_right = 336.0 -margin_bottom = 53.0 +margin_top = 24.0 +margin_right = 412.0 +margin_bottom = 28.0 size_flags_horizontal = 3 [node name="ScrollContainer" type="ScrollContainer" parent="ResourcePanel/VBoxContainer"] -margin_top = 61.0 -margin_right = 336.0 +margin_top = 32.0 +margin_right = 412.0 margin_bottom = 600.0 size_flags_horizontal = 3 size_flags_vertical = 3 [node name="VBoxContainer" type="VBoxContainer" parent="ResourcePanel/VBoxContainer/ScrollContainer"] -margin_right = 336.0 +margin_right = 412.0 size_flags_horizontal = 3 [node name="CreateNamePopup" parent="." instance=ExtResource( 1 )] @@ -112,6 +111,7 @@ margin_top = -55.0 margin_right = 139.0 margin_bottom = 55.0 dialog_text = "Delete?" + [connection signal="text_entered" from="ResourcePanel/VBoxContainer2/LineEdit" to="." method="search"] [connection signal="pressed" from="ResourcePanel/VBoxContainer2/CreateButton" to="CreateNamePopup" method="popup"] [connection signal="pressed" from="ResourcePanel/VBoxContainer/Button" to="." method="clear_history"]