diff --git a/UI/Components/GroupMenu.gd b/UI/Components/GroupMenu.gd index 01eaba3..bd320be 100644 --- a/UI/Components/GroupMenu.gd +++ b/UI/Components/GroupMenu.gd @@ -61,6 +61,10 @@ func set_text(text: String) -> void: header_text_label.text = text +func get_text() -> String: + return header_text_label.text + + func set_description(text: String) -> void: if text == "": description_label.visible = false @@ -84,6 +88,8 @@ func set_children_visible(p_visible: bool) -> void: add_install_button_container.visible = p_visible inner_separator.visible = p_visible + description_label.visible = p_visible && !description_label.text.is_empty() + func add_custom(control: Control) -> void: header_custom_control_container.add_child(control) diff --git a/UI/Components/OverrideEditorSettingsMenu/OverrideEditorSettingsMenu.gd b/UI/Components/OverrideEditorSettingsMenu/OverrideEditorSettingsMenu.gd index 1c3d442..efef317 100644 --- a/UI/Components/OverrideEditorSettingsMenu/OverrideEditorSettingsMenu.gd +++ b/UI/Components/OverrideEditorSettingsMenu/OverrideEditorSettingsMenu.gd @@ -33,3 +33,10 @@ func clear() -> void: func(c: OverrideEditorSettingsMenuItem): c.queue_free() ) + + +func fill_from_dictionary(overrides: Dictionary) -> void: + for override in overrides: + var item: OverrideEditorSettingsMenuItem = ITEM_SCENE.instantiate() + add_item(item) + item.fill(override, overrides[override]) diff --git a/UI/Components/OverrideEditorSettingsMenu/OverrideEditorSettingsMenuItem.gd b/UI/Components/OverrideEditorSettingsMenu/OverrideEditorSettingsMenuItem.gd index a130ca5..1ba9781 100644 --- a/UI/Components/OverrideEditorSettingsMenu/OverrideEditorSettingsMenuItem.gd +++ b/UI/Components/OverrideEditorSettingsMenu/OverrideEditorSettingsMenuItem.gd @@ -19,6 +19,11 @@ func _ready() -> void: func get_property() -> Dictionary: var prop_name = property_name_line_edit.text - var value = str_to_var(prop_name) + var value = str_to_var(property_value_line_edit.text) return {prop_name: value} + + +func fill(key: String, value: Variant) -> void: + property_name_line_edit.text = key + property_value_line_edit.text = var_to_str(value) diff --git a/UI/Dialogs/GroupEditDialog.gd b/UI/Dialogs/GroupEditDialog.gd index 232a15c..c87faad 100644 --- a/UI/Dialogs/GroupEditDialog.gd +++ b/UI/Dialogs/GroupEditDialog.gd @@ -23,3 +23,18 @@ func get_group_metadata() -> GroupMetadata: group_metadata.settings_overrides = override_editor_settings_menu.get_overrides() return group_metadata + + +func fill_from_group_metadata(p_name: String) -> void: + name_line_edit.text = p_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) + + +func clear_ok_button_connections() -> void: + for connection in get_signal_connection_list("confirmed"): + var callable := connection["callable"] as Callable + var _signal := connection["signal"] as Signal + + _signal.disconnect(callable) diff --git a/UI/Dialogs/GroupEditDialog.tscn b/UI/Dialogs/GroupEditDialog.tscn index 5fe2027..6f815e7 100644 --- a/UI/Dialogs/GroupEditDialog.tscn +++ b/UI/Dialogs/GroupEditDialog.tscn @@ -6,14 +6,14 @@ [node name="GroupEditDialog" type="ConfirmationDialog"] initial_position = 1 title = "Edit Group" -size = Vector2i(678, 411) +size = Vector2i(678, 419) script = ExtResource("1_ic3yh") [node name="VBoxContainer" type="VBoxContainer" parent="."] -offset_left = 8.0 -offset_top = 8.0 -offset_right = 670.0 -offset_bottom = 362.0 +offset_left = 12.0 +offset_top = 12.0 +offset_right = 666.0 +offset_bottom = 366.0 [node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"] layout_mode = 2 diff --git a/UI/Main/GroupsView.gd b/UI/Main/GroupsView.gd index d51ce57..a3c4df7 100644 --- a/UI/Main/GroupsView.gd +++ b/UI/Main/GroupsView.gd @@ -14,14 +14,16 @@ func _ready() -> void: new_group_button.pressed.connect(add_new_group) + group_edit_dialog.canceled.connect(group_edit_dialog.clear_ok_button_connections) -func add_new_group(): + +func add_new_group() -> void: group_edit_dialog.clear() group_edit_dialog.ok_button_text = "Create" group_edit_dialog.confirmed.connect( func(): - var gm := group_edit_dialog.group_metadata + var gm := group_edit_dialog.get_group_metadata() # TODO: hack, redo later var group_name := group_edit_dialog.name_line_edit.text @@ -30,6 +32,24 @@ func add_new_group(): group_menus_container.add_child(group_menu) group_menu.setup_from_metadata(group_name, gm) - ) + group_menu.edit_group_button_pressed.connect(edit_group.bind(group_menu)) + + , 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" + + 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.confirmed.connect( + func(): + group_menu.setup_from_metadata(group_name, group_edit_dialog.get_group_metadata()) + , CONNECT_ONE_SHOT) group_edit_dialog.show()