diff --git a/UI/Components/GroupMenu.gd b/UI/Components/GroupMenu.gd index e254feb..01eaba3 100644 --- a/UI/Components/GroupMenu.gd +++ b/UI/Components/GroupMenu.gd @@ -9,17 +9,20 @@ class_name GroupMenu @onready var add_install_button_container: CenterContainer = %AddInstallButtonContainer @onready var add_install_button: Button = %AddInstallButton @onready var description_label: Label = %DescriptionLabel +@onready var inner_separator: HSeparator = %InnerSeparator @onready var edit_group_button: Button = %EditGroupButton @onready var delete_group_button: Button = %DeleteGroupButton @onready var header_container: HBoxContainer = %HeaderContainer +var group_metadata: GroupMetadata + signal add_install_button_pressed signal edit_group_button_pressed signal delete_button_pressed -signal header_text_changed(new_text: String) +signal header_text_changed(new_text: String, old_text: String) func _ready() -> void: @@ -79,6 +82,7 @@ func set_children_visible(p_visible: bool) -> void: collapse_button.text = "v" if p_visible else ">" child_container.visible = p_visible add_install_button_container.visible = p_visible + inner_separator.visible = p_visible func add_custom(control: Control) -> void: @@ -104,8 +108,9 @@ func setup_rename() -> void: l.text_submitted.connect( func(new_text: String): + var old_text: = header_text_label.text header_text_label.text = new_text - header_text_changed.emit(new_text) + header_text_changed.emit(new_text, old_text) reenable.call() ) @@ -113,6 +118,14 @@ func setup_rename() -> void: l.grab_focus() +func setup_from_metadata(header_text: String, p_group_metadata: GroupMetadata) -> void: + group_metadata = p_group_metadata + set_text(header_text) + set_description(group_metadata.description) + # TODO: add installs + # TODO: add icon + + func _on_header_text_label_gui_input(event: InputEvent) -> void: if event is InputEventMouseButton && \ (event as InputEventMouseButton).double_click && \ diff --git a/UI/Components/GroupMenu.tscn b/UI/Components/GroupMenu.tscn index 14098e6..94635bb 100644 --- a/UI/Components/GroupMenu.tscn +++ b/UI/Components/GroupMenu.tscn @@ -62,7 +62,8 @@ layout_mode = 2 unique_name_in_owner = true layout_mode = 2 -[node name="HSeparator2" type="HSeparator" parent="."] +[node name="InnerSeparator" type="HSeparator" parent="."] +unique_name_in_owner = true layout_mode = 2 [node name="AddInstallButtonContainer" type="CenterContainer" parent="."] @@ -73,3 +74,7 @@ layout_mode = 2 unique_name_in_owner = true layout_mode = 2 text = "New Install" + +[node name="HSeparator3" type="HSeparator" parent="."] +layout_mode = 2 +theme_override_constants/separation = 16 diff --git a/UI/Components/InstallItem.gd b/UI/Components/InstallItem.gd index 148bdb9..b158e02 100644 --- a/UI/Components/InstallItem.gd +++ b/UI/Components/InstallItem.gd @@ -7,6 +7,8 @@ class_name InstallItem @onready var delete_item_button: Button = %DeleteItemButton @onready var launch_item_button: Button = %LaunchItemButton +var install_metadata: InstallMetadata + signal edit_item_button_pressed signal delete_item_button_pressed signal launch_item_button_pressed diff --git a/UI/Components/OverrideEditorSettingsMenu/OverrideEditorSettingsMenu.gd b/UI/Components/OverrideEditorSettingsMenu/OverrideEditorSettingsMenu.gd index eed5cee..1c3d442 100644 --- a/UI/Components/OverrideEditorSettingsMenu/OverrideEditorSettingsMenu.gd +++ b/UI/Components/OverrideEditorSettingsMenu/OverrideEditorSettingsMenu.gd @@ -26,3 +26,10 @@ func get_overrides() -> Dictionary: res.merge(item.get_property()) return res + + +func clear() -> void: + override_item_container.get_children().map( + func(c: OverrideEditorSettingsMenuItem): + c.queue_free() + ) diff --git a/UI/Dialogs/GroupEditDialog.gd b/UI/Dialogs/GroupEditDialog.gd new file mode 100644 index 0000000..232a15c --- /dev/null +++ b/UI/Dialogs/GroupEditDialog.gd @@ -0,0 +1,25 @@ +extends ConfirmationDialog +class_name GroupEditDialog + +@onready var name_line_edit: LineEdit = %NameLineEdit +@onready var icon_path_line_edit: LineEdit = %IconPathLineEdit +@onready var description_text_edit: TextEdit = %DescriptionTextEdit +@onready var override_editor_settings_menu: OverrideEditorSettingsMenu = %OverrideEditorSettingsMenu + +var group_metadata: GroupMetadata + + +func clear() -> void: + name_line_edit.clear() + icon_path_line_edit.clear() + description_text_edit.clear() + override_editor_settings_menu.clear() + group_metadata = GroupMetadata.new() + + +func get_group_metadata() -> GroupMetadata: + group_metadata.icon_path = icon_path_line_edit.text + group_metadata.description = description_text_edit.text + group_metadata.settings_overrides = override_editor_settings_menu.get_overrides() + + return group_metadata diff --git a/UI/Dialogs/GroupEditDialog.tscn b/UI/Dialogs/GroupEditDialog.tscn index 2fa88dc..5fe2027 100644 --- a/UI/Dialogs/GroupEditDialog.tscn +++ b/UI/Dialogs/GroupEditDialog.tscn @@ -1,12 +1,13 @@ -[gd_scene load_steps=2 format=3 uid="uid://du25gr7aoh34m"] +[gd_scene load_steps=3 format=3 uid="uid://du25gr7aoh34m"] +[ext_resource type="Script" path="res://UI/Dialogs/GroupEditDialog.gd" id="1_ic3yh"] [ext_resource type="PackedScene" uid="uid://ig4wkr1lxvbv" path="res://UI/Components/OverrideEditorSettingsMenu/OverrideEditorSettingsMenu.tscn" id="1_yeeya"] [node name="GroupEditDialog" type="ConfirmationDialog"] initial_position = 1 title = "Edit Group" size = Vector2i(678, 411) -visible = true +script = ExtResource("1_ic3yh") [node name="VBoxContainer" type="VBoxContainer" parent="."] offset_left = 8.0 @@ -22,6 +23,7 @@ layout_mode = 2 text = "Name" [node name="NameLineEdit" type="LineEdit" parent="VBoxContainer/HBoxContainer"] +unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 3 @@ -33,11 +35,13 @@ layout_mode = 2 text = "Icon" [node name="IconPathLineEdit" type="LineEdit" parent="VBoxContainer/HBoxContainer2"] +unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 3 placeholder_text = "Optional" [node name="OpenIconFileDialogButton" type="Button" parent="VBoxContainer/HBoxContainer2"] +unique_name_in_owner = true layout_mode = 2 text = "F" @@ -48,7 +52,8 @@ layout_mode = 2 layout_mode = 2 text = "Description" -[node name="TextEdit" type="TextEdit" parent="VBoxContainer/VBoxContainer"] +[node name="DescriptionTextEdit" type="TextEdit" parent="VBoxContainer/VBoxContainer"] +unique_name_in_owner = true custom_minimum_size = Vector2(0, 100) layout_mode = 2 placeholder_text = "Optional" @@ -60,5 +65,6 @@ size_flags_vertical = 3 horizontal_scroll_mode = 0 [node name="OverrideEditorSettingsMenu" parent="VBoxContainer/ScrollContainer" instance=ExtResource("1_yeeya")] +unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 3 diff --git a/UI/Main/GroupsView.gd b/UI/Main/GroupsView.gd new file mode 100644 index 0000000..d51ce57 --- /dev/null +++ b/UI/Main/GroupsView.gd @@ -0,0 +1,35 @@ +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) + + +func add_new_group(): + group_edit_dialog.clear() + group_edit_dialog.ok_button_text = "Create" + + group_edit_dialog.confirmed.connect( + func(): + var gm := group_edit_dialog.group_metadata + + # TODO: hack, redo later + var group_name := group_edit_dialog.name_line_edit.text + + var group_menu: GroupMenu = GROUP_MENU_SCENE.instantiate() + group_menus_container.add_child(group_menu) + group_menu.setup_from_metadata(group_name, gm) + + ) + + group_edit_dialog.show() diff --git a/UI/Main/GroupsView.tscn b/UI/Main/GroupsView.tscn index 1190007..bdaf10c 100644 --- a/UI/Main/GroupsView.tscn +++ b/UI/Main/GroupsView.tscn @@ -1,4 +1,7 @@ -[gd_scene format=3 uid="uid://bf464y0q4l67h"] +[gd_scene load_steps=3 format=3 uid="uid://bf464y0q4l67h"] + +[ext_resource type="Script" path="res://UI/Main/GroupsView.gd" id="1_15bdc"] +[ext_resource type="PackedScene" uid="uid://du25gr7aoh34m" path="res://UI/Dialogs/GroupEditDialog.tscn" id="1_fqa62"] [node name="GroupsView" type="VBoxContainer"] anchors_preset = 15 @@ -6,6 +9,7 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 +script = ExtResource("1_15bdc") metadata/_edit_use_anchors_ = true [node name="Label" type="Label" parent="."] @@ -22,6 +26,7 @@ layout_mode = 2 size_flags_vertical = 3 [node name="GroupMenusContainer" type="VBoxContainer" parent="PanelContainer/ScrollContainer"] +unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 3 @@ -29,5 +34,9 @@ size_flags_horizontal = 3 layout_mode = 2 [node name="NewGroupButton" type="Button" parent="CenterContainer"] +unique_name_in_owner = true layout_mode = 2 text = "New Group" + +[node name="GroupEditDialog" parent="." instance=ExtResource("1_fqa62")] +unique_name_in_owner = true