From fee4edce61419cbcee5bbde7a239b2b94085d32b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lera=20Elvo=C3=A9?= Date: Sat, 27 May 2023 03:46:46 +0300 Subject: [PATCH] make inline rename work --- Classes/GroupListMetadata.gd | 3 +-- Classes/GroupMetadata.gd | 1 + Classes/ReleasesManager.gd | 2 +- UI/Components/GroupMenu.gd | 14 ++++++-------- UI/Components/InstallItem.gd | 1 + UI/Dialogs/GroupEditDialog.gd | 5 +++-- UI/Main/GroupsView.gd | 10 +++------- UI/Main/Main.tscn | 27 +++++++++++++++++++++++++++ project.godot | 2 +- 9 files changed, 44 insertions(+), 21 deletions(-) create mode 100644 UI/Main/Main.tscn diff --git a/Classes/GroupListMetadata.gd b/Classes/GroupListMetadata.gd index 2d43896..0a0e254 100644 --- a/Classes/GroupListMetadata.gd +++ b/Classes/GroupListMetadata.gd @@ -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] diff --git a/Classes/GroupMetadata.gd b/Classes/GroupMetadata.gd index 6fded73..3b85058 100644 --- a/Classes/GroupMetadata.gd +++ b/Classes/GroupMetadata.gd @@ -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] diff --git a/Classes/ReleasesManager.gd b/Classes/ReleasesManager.gd index b463f37..cf39c8d 100644 --- a/Classes/ReleasesManager.gd +++ b/Classes/ReleasesManager.gd @@ -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] diff --git a/UI/Components/GroupMenu.gd b/UI/Components/GroupMenu.gd index d216e9f..8208d08 100644 --- a/UI/Components/GroupMenu.gd +++ b/UI/Components/GroupMenu.gd @@ -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 diff --git a/UI/Components/InstallItem.gd b/UI/Components/InstallItem.gd index 321f4cd..ed77dc1 100644 --- a/UI/Components/InstallItem.gd +++ b/UI/Components/InstallItem.gd @@ -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 ) diff --git a/UI/Dialogs/GroupEditDialog.gd b/UI/Dialogs/GroupEditDialog.gd index c87faad..286b0fa 100644 --- a/UI/Dialogs/GroupEditDialog.gd +++ b/UI/Dialogs/GroupEditDialog.gd @@ -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) diff --git a/UI/Main/GroupsView.gd b/UI/Main/GroupsView.gd index a3c4df7..14d24f9 100644 --- a/UI/Main/GroupsView.gd +++ b/UI/Main/GroupsView.gd @@ -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() diff --git a/UI/Main/Main.tscn b/UI/Main/Main.tscn new file mode 100644 index 0000000..70dda16 --- /dev/null +++ b/UI/Main/Main.tscn @@ -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 diff --git a/project.godot b/project.godot index d2209b9..ad6a782 100644 --- a/project.godot +++ b/project.godot @@ -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")