make inline rename work

This commit is contained in:
Lera Elvoé 2023-05-27 03:46:46 +03:00
parent ba3e2751dd
commit fee4edce61
Signed by: yagich
SSH Key Fingerprint: SHA256:6xjGb6uA7lAVcULa7byPEN//rQ0wPoG+UzYVMfZnbvc
9 changed files with 44 additions and 21 deletions

View File

@ -1,5 +1,4 @@
extends Resource
class_name GroupListMetadata
@export var order: Array[String]
@export var uncollapsed_groups: Array[String]
@export var groups: Array[GroupMetadata]

View File

@ -1,6 +1,7 @@
extends Resource
class_name GroupMetadata
@export var name: String
@export var icon_path: String
@export var description: String
@export var installs: Array[InstallMetadata]

View File

@ -322,7 +322,7 @@ func get_version_metadata(version: String) -> ReleaseMetadata:
func get_installed_versions() -> Dictionary:
var res: Dictionary
var res: Dictionary = {}
for version in releases.releases:
if is_version_installed(version):
res[version] = releases.releases[version]

View File

@ -26,7 +26,6 @@ signal add_install_button_pressed
signal edit_group_button_pressed
signal delete_button_pressed
signal header_text_changed(new_text: String, old_text: String)
func _ready() -> void:
@ -54,9 +53,9 @@ func add_new_install() -> void:
var im := install_edit_dialog.get_install_metadata()
var install_item: InstallItem = ITEM_SCENE.instantiate()
child_container.add_child(install_item)
install_item.setup_from_metadata(install_edit_dialog.get_install_metadata())
install_item.setup_from_metadata(im)
install_item.edit_item_button_pressed.connect(edit_install.bind(install_item))
group_metadata.installs.append(install_edit_dialog.get_install_metadata())
group_metadata.installs.append(im)
, CONNECT_ONE_SHOT)
install_edit_dialog.show()
@ -116,8 +115,8 @@ func set_children_visible(p_visible: bool) -> void:
child_container.visible = p_visible
add_install_button_container.visible = p_visible
inner_separator.visible = p_visible
description_label.visible = p_visible && !description_label.text.is_empty()
group_metadata.set_meta("collapsed", p_visible)
func add_custom(control: Control) -> void:
@ -143,9 +142,8 @@ 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, old_text)
group_metadata.name = new_text
reenable.call()
)
@ -153,9 +151,9 @@ func setup_rename() -> void:
l.grab_focus()
func setup_from_metadata(header_text: String, p_group_metadata: GroupMetadata) -> void:
func setup_from_metadata(p_group_metadata: GroupMetadata) -> void:
group_metadata = p_group_metadata
set_text(header_text)
set_text(p_group_metadata.name)
set_description(group_metadata.description)
# TODO: add installs
# TODO: add icon

View File

@ -51,6 +51,7 @@ func setup_rename() -> void:
func(new_text: String):
name_label.text = new_text
name_changed.emit(new_text)
install_metadata.name = new_text
name_label.visible = true
)

View File

@ -21,12 +21,13 @@ 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()
group_metadata.name = name_line_edit.text
return group_metadata
func fill_from_group_metadata(p_name: String) -> void:
name_line_edit.text = p_name
func fill_from_group_metadata() -> void:
name_line_edit.text = group_metadata.name
icon_path_line_edit.text = group_metadata.icon_path
description_text_edit.text = group_metadata.description
override_editor_settings_menu.fill_from_dictionary(group_metadata.settings_overrides)

View File

@ -25,12 +25,9 @@ func add_new_group() -> void:
func():
var gm := group_edit_dialog.get_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_menu.setup_from_metadata(gm)
group_menu.edit_group_button_pressed.connect(edit_group.bind(group_menu))
@ -43,13 +40,12 @@ func edit_group(group_menu: GroupMenu) -> void:
group_edit_dialog.clear()
group_edit_dialog.ok_button_text = "OK"
var group_name := group_menu.get_text()
group_edit_dialog.group_metadata = group_menu.group_metadata
group_edit_dialog.fill_from_group_metadata(group_name)
group_edit_dialog.fill_from_group_metadata()
group_edit_dialog.confirmed.connect(
func():
group_menu.setup_from_metadata(group_name, group_edit_dialog.get_group_metadata())
group_menu.setup_from_metadata(group_edit_dialog.get_group_metadata())
, CONNECT_ONE_SHOT)
group_edit_dialog.show()

27
UI/Main/Main.tscn Normal file
View File

@ -0,0 +1,27 @@
[gd_scene load_steps=3 format=3 uid="uid://0wv6qt367nml"]
[ext_resource type="PackedScene" uid="uid://bf464y0q4l67h" path="res://UI/Main/GroupsView.tscn" id="1_qdj8e"]
[ext_resource type="PackedScene" uid="uid://irfav51b5hf6" path="res://UI/Main/ReleasesView.tscn" id="2_sif55"]
[node name="Main" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="HSplitContainer" type="HSplitContainer" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
split_offset = 400
[node name="ReleasesView" parent="HSplitContainer" instance=ExtResource("2_sif55")]
layout_mode = 2
[node name="GroupsView" parent="HSplitContainer" instance=ExtResource("1_qdj8e")]
layout_mode = 2

View File

@ -11,7 +11,7 @@ config_version=5
[application]
config/name="yagvm"
run/main_scene="res://UI/Main/GroupsView.tscn"
run/main_scene="res://UI/Main/Main.tscn"
config/use_custom_user_dir=true
config/custom_user_dir_name="yagvm"
config/features=PackedStringArray("4.0", "Forward Plus")