add basic functionality for adding group items
This commit is contained in:
parent
8fdec75ec9
commit
f0ce658518
@ -9,17 +9,20 @@ class_name GroupMenu
|
|||||||
@onready var add_install_button_container: CenterContainer = %AddInstallButtonContainer
|
@onready var add_install_button_container: CenterContainer = %AddInstallButtonContainer
|
||||||
@onready var add_install_button: Button = %AddInstallButton
|
@onready var add_install_button: Button = %AddInstallButton
|
||||||
@onready var description_label: Label = %DescriptionLabel
|
@onready var description_label: Label = %DescriptionLabel
|
||||||
|
@onready var inner_separator: HSeparator = %InnerSeparator
|
||||||
|
|
||||||
@onready var edit_group_button: Button = %EditGroupButton
|
@onready var edit_group_button: Button = %EditGroupButton
|
||||||
@onready var delete_group_button: Button = %DeleteGroupButton
|
@onready var delete_group_button: Button = %DeleteGroupButton
|
||||||
|
|
||||||
@onready var header_container: HBoxContainer = %HeaderContainer
|
@onready var header_container: HBoxContainer = %HeaderContainer
|
||||||
|
|
||||||
|
var group_metadata: GroupMetadata
|
||||||
|
|
||||||
signal add_install_button_pressed
|
signal add_install_button_pressed
|
||||||
|
|
||||||
signal edit_group_button_pressed
|
signal edit_group_button_pressed
|
||||||
signal delete_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:
|
func _ready() -> void:
|
||||||
@ -79,6 +82,7 @@ func set_children_visible(p_visible: bool) -> void:
|
|||||||
collapse_button.text = "v" if p_visible else ">"
|
collapse_button.text = "v" if p_visible else ">"
|
||||||
child_container.visible = p_visible
|
child_container.visible = p_visible
|
||||||
add_install_button_container.visible = p_visible
|
add_install_button_container.visible = p_visible
|
||||||
|
inner_separator.visible = p_visible
|
||||||
|
|
||||||
|
|
||||||
func add_custom(control: Control) -> void:
|
func add_custom(control: Control) -> void:
|
||||||
@ -104,8 +108,9 @@ func setup_rename() -> void:
|
|||||||
|
|
||||||
l.text_submitted.connect(
|
l.text_submitted.connect(
|
||||||
func(new_text: String):
|
func(new_text: String):
|
||||||
|
var old_text: = header_text_label.text
|
||||||
header_text_label.text = new_text
|
header_text_label.text = new_text
|
||||||
header_text_changed.emit(new_text)
|
header_text_changed.emit(new_text, old_text)
|
||||||
|
|
||||||
reenable.call()
|
reenable.call()
|
||||||
)
|
)
|
||||||
@ -113,6 +118,14 @@ func setup_rename() -> void:
|
|||||||
l.grab_focus()
|
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:
|
func _on_header_text_label_gui_input(event: InputEvent) -> void:
|
||||||
if event is InputEventMouseButton && \
|
if event is InputEventMouseButton && \
|
||||||
(event as InputEventMouseButton).double_click && \
|
(event as InputEventMouseButton).double_click && \
|
||||||
|
@ -62,7 +62,8 @@ layout_mode = 2
|
|||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
||||||
[node name="HSeparator2" type="HSeparator" parent="."]
|
[node name="InnerSeparator" type="HSeparator" parent="."]
|
||||||
|
unique_name_in_owner = true
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
||||||
[node name="AddInstallButtonContainer" type="CenterContainer" parent="."]
|
[node name="AddInstallButtonContainer" type="CenterContainer" parent="."]
|
||||||
@ -73,3 +74,7 @@ layout_mode = 2
|
|||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
text = "New Install"
|
text = "New Install"
|
||||||
|
|
||||||
|
[node name="HSeparator3" type="HSeparator" parent="."]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_constants/separation = 16
|
||||||
|
@ -7,6 +7,8 @@ class_name InstallItem
|
|||||||
@onready var delete_item_button: Button = %DeleteItemButton
|
@onready var delete_item_button: Button = %DeleteItemButton
|
||||||
@onready var launch_item_button: Button = %LaunchItemButton
|
@onready var launch_item_button: Button = %LaunchItemButton
|
||||||
|
|
||||||
|
var install_metadata: InstallMetadata
|
||||||
|
|
||||||
signal edit_item_button_pressed
|
signal edit_item_button_pressed
|
||||||
signal delete_item_button_pressed
|
signal delete_item_button_pressed
|
||||||
signal launch_item_button_pressed
|
signal launch_item_button_pressed
|
||||||
|
@ -26,3 +26,10 @@ func get_overrides() -> Dictionary:
|
|||||||
res.merge(item.get_property())
|
res.merge(item.get_property())
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
|
func clear() -> void:
|
||||||
|
override_item_container.get_children().map(
|
||||||
|
func(c: OverrideEditorSettingsMenuItem):
|
||||||
|
c.queue_free()
|
||||||
|
)
|
||||||
|
25
UI/Dialogs/GroupEditDialog.gd
Normal file
25
UI/Dialogs/GroupEditDialog.gd
Normal file
@ -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
|
@ -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"]
|
[ext_resource type="PackedScene" uid="uid://ig4wkr1lxvbv" path="res://UI/Components/OverrideEditorSettingsMenu/OverrideEditorSettingsMenu.tscn" id="1_yeeya"]
|
||||||
|
|
||||||
[node name="GroupEditDialog" type="ConfirmationDialog"]
|
[node name="GroupEditDialog" type="ConfirmationDialog"]
|
||||||
initial_position = 1
|
initial_position = 1
|
||||||
title = "Edit Group"
|
title = "Edit Group"
|
||||||
size = Vector2i(678, 411)
|
size = Vector2i(678, 411)
|
||||||
visible = true
|
script = ExtResource("1_ic3yh")
|
||||||
|
|
||||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||||
offset_left = 8.0
|
offset_left = 8.0
|
||||||
@ -22,6 +23,7 @@ layout_mode = 2
|
|||||||
text = "Name"
|
text = "Name"
|
||||||
|
|
||||||
[node name="NameLineEdit" type="LineEdit" parent="VBoxContainer/HBoxContainer"]
|
[node name="NameLineEdit" type="LineEdit" parent="VBoxContainer/HBoxContainer"]
|
||||||
|
unique_name_in_owner = true
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
@ -33,11 +35,13 @@ layout_mode = 2
|
|||||||
text = "Icon"
|
text = "Icon"
|
||||||
|
|
||||||
[node name="IconPathLineEdit" type="LineEdit" parent="VBoxContainer/HBoxContainer2"]
|
[node name="IconPathLineEdit" type="LineEdit" parent="VBoxContainer/HBoxContainer2"]
|
||||||
|
unique_name_in_owner = true
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
placeholder_text = "Optional"
|
placeholder_text = "Optional"
|
||||||
|
|
||||||
[node name="OpenIconFileDialogButton" type="Button" parent="VBoxContainer/HBoxContainer2"]
|
[node name="OpenIconFileDialogButton" type="Button" parent="VBoxContainer/HBoxContainer2"]
|
||||||
|
unique_name_in_owner = true
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
text = "F"
|
text = "F"
|
||||||
|
|
||||||
@ -48,7 +52,8 @@ layout_mode = 2
|
|||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
text = "Description"
|
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)
|
custom_minimum_size = Vector2(0, 100)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
placeholder_text = "Optional"
|
placeholder_text = "Optional"
|
||||||
@ -60,5 +65,6 @@ size_flags_vertical = 3
|
|||||||
horizontal_scroll_mode = 0
|
horizontal_scroll_mode = 0
|
||||||
|
|
||||||
[node name="OverrideEditorSettingsMenu" parent="VBoxContainer/ScrollContainer" instance=ExtResource("1_yeeya")]
|
[node name="OverrideEditorSettingsMenu" parent="VBoxContainer/ScrollContainer" instance=ExtResource("1_yeeya")]
|
||||||
|
unique_name_in_owner = true
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
|
35
UI/Main/GroupsView.gd
Normal file
35
UI/Main/GroupsView.gd
Normal file
@ -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()
|
@ -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"]
|
[node name="GroupsView" type="VBoxContainer"]
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
@ -6,6 +9,7 @@ anchor_right = 1.0
|
|||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
|
script = ExtResource("1_15bdc")
|
||||||
metadata/_edit_use_anchors_ = true
|
metadata/_edit_use_anchors_ = true
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="."]
|
[node name="Label" type="Label" parent="."]
|
||||||
@ -22,6 +26,7 @@ layout_mode = 2
|
|||||||
size_flags_vertical = 3
|
size_flags_vertical = 3
|
||||||
|
|
||||||
[node name="GroupMenusContainer" type="VBoxContainer" parent="PanelContainer/ScrollContainer"]
|
[node name="GroupMenusContainer" type="VBoxContainer" parent="PanelContainer/ScrollContainer"]
|
||||||
|
unique_name_in_owner = true
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
@ -29,5 +34,9 @@ size_flags_horizontal = 3
|
|||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
||||||
[node name="NewGroupButton" type="Button" parent="CenterContainer"]
|
[node name="NewGroupButton" type="Button" parent="CenterContainer"]
|
||||||
|
unique_name_in_owner = true
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
text = "New Group"
|
text = "New Group"
|
||||||
|
|
||||||
|
[node name="GroupEditDialog" parent="." instance=ExtResource("1_fqa62")]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
Loading…
Reference in New Issue
Block a user