2023-03-06 13:33:46 +00:00
|
|
|
extends VBoxContainer
|
|
|
|
|
|
|
|
@onready var group_menus_container: VBoxContainer = %GroupMenusContainer
|
|
|
|
@onready var new_group_button: Button = %NewGroupButton
|
|
|
|
@onready var group_edit_dialog: GroupEditDialog = %GroupEditDialog
|
|
|
|
|
|
|
|
const GROUP_MENU_SCENE := preload("res://UI/Components/GroupMenu.tscn")
|
|
|
|
|
|
|
|
var group_list_metadata: GroupListMetadata
|
|
|
|
|
|
|
|
|
|
|
|
func _ready() -> void:
|
|
|
|
group_list_metadata = GroupListMetadata.new()
|
|
|
|
|
|
|
|
new_group_button.pressed.connect(add_new_group)
|
|
|
|
|
2023-03-08 07:24:34 +00:00
|
|
|
group_edit_dialog.canceled.connect(group_edit_dialog.clear_ok_button_connections)
|
2023-03-06 13:33:46 +00:00
|
|
|
|
2023-03-08 07:24:34 +00:00
|
|
|
|
|
|
|
func add_new_group() -> void:
|
2023-03-06 13:33:46 +00:00
|
|
|
group_edit_dialog.clear()
|
|
|
|
group_edit_dialog.ok_button_text = "Create"
|
|
|
|
|
|
|
|
group_edit_dialog.confirmed.connect(
|
|
|
|
func():
|
2023-03-08 07:24:34 +00:00
|
|
|
var gm := group_edit_dialog.get_group_metadata()
|
2023-03-06 13:33:46 +00:00
|
|
|
|
|
|
|
var group_menu: GroupMenu = GROUP_MENU_SCENE.instantiate()
|
|
|
|
group_menus_container.add_child(group_menu)
|
2023-05-27 00:46:46 +00:00
|
|
|
group_menu.setup_from_metadata(gm)
|
2023-03-06 13:33:46 +00:00
|
|
|
|
2023-03-08 07:24:34 +00:00
|
|
|
group_menu.edit_group_button_pressed.connect(edit_group.bind(group_menu))
|
2023-05-27 02:54:11 +00:00
|
|
|
GroupsInstallsManager.create_group_folder(gm)
|
|
|
|
GroupsInstallsManager.group_metadata_should_save(gm)
|
2023-03-08 07:24:34 +00:00
|
|
|
|
|
|
|
, CONNECT_ONE_SHOT)
|
|
|
|
|
|
|
|
group_edit_dialog.show()
|
|
|
|
|
|
|
|
|
|
|
|
func edit_group(group_menu: GroupMenu) -> void:
|
|
|
|
group_edit_dialog.clear()
|
|
|
|
group_edit_dialog.ok_button_text = "OK"
|
|
|
|
|
|
|
|
group_edit_dialog.group_metadata = group_menu.group_metadata
|
2023-05-27 00:46:46 +00:00
|
|
|
group_edit_dialog.fill_from_group_metadata()
|
2023-03-08 07:24:34 +00:00
|
|
|
|
|
|
|
group_edit_dialog.confirmed.connect(
|
|
|
|
func():
|
2023-05-27 00:46:46 +00:00
|
|
|
group_menu.setup_from_metadata(group_edit_dialog.get_group_metadata())
|
2023-03-08 07:24:34 +00:00
|
|
|
, CONNECT_ONE_SHOT)
|
2023-03-06 13:33:46 +00:00
|
|
|
|
|
|
|
group_edit_dialog.show()
|