From 0c03a5b46c275fcdb46c3a11e91e59a6dfb0791c Mon Sep 17 00:00:00 2001 From: BasilYes Date: Tue, 20 Feb 2024 23:32:24 +0300 Subject: [PATCH] add rename feature to Duplicate --- .../install_project_dialog/install_project_dialog.gd | 2 ++ .../install_project_dialog.tscn | 12 ++++++++++++ src/components/projects/projects.gd | 8 ++++++++ 3 files changed, 22 insertions(+) diff --git a/src/components/projects/install_project_dialog/install_project_dialog.gd b/src/components/projects/install_project_dialog/install_project_dialog.gd index ca283f6e..838559aa 100644 --- a/src/components/projects/install_project_dialog/install_project_dialog.gd +++ b/src/components/projects/install_project_dialog/install_project_dialog.gd @@ -10,6 +10,8 @@ extends ConfirmationDialog @onready var _create_folder_failed_dialog = $CreateFolderFailedDialog @onready var _file_dialog = $FileDialog @onready var _randomize_name_button = %RandomizeNameButton +@onready var _rename_container: HBoxContainer = $VBoxContainer/HBoxContainer3 +@onready var _rename_check_box: CheckBox = %RenameCheckBox var _create_folder_failed_label: Label diff --git a/src/components/projects/install_project_dialog/install_project_dialog.tscn b/src/components/projects/install_project_dialog/install_project_dialog.tscn index f15bffe3..e5fc523b 100644 --- a/src/components/projects/install_project_dialog/install_project_dialog.tscn +++ b/src/components/projects/install_project_dialog/install_project_dialog.tscn @@ -60,6 +60,18 @@ unique_name_in_owner = true layout_mode = 2 text = "Browse" +[node name="HBoxContainer3" type="HBoxContainer" parent="VBoxContainer"] +visible = false +layout_mode = 2 + +[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer3"] +layout_mode = 2 +text = "Rename project" + +[node name="RenameCheckBox" type="CheckBox" parent="VBoxContainer/HBoxContainer3"] +unique_name_in_owner = true +layout_mode = 2 + [node name="MessageLabel" type="Label" parent="VBoxContainer"] unique_name_in_owner = true layout_mode = 2 diff --git a/src/components/projects/projects.gd b/src/components/projects/projects.gd index 82c9d0a0..1436049f 100644 --- a/src/components/projects/projects.gd +++ b/src/components/projects/projects.gd @@ -197,6 +197,8 @@ func _on_projects_list_item_duplicate_requested(project: Projects.Item) -> void: return _duplicate_project_dialog.title = "Duplicate Project: %s" % project.name + _duplicate_project_dialog._rename_container.visible = true + _duplicate_project_dialog._rename_check_box.button_pressed = Cache.smart_value(self, "rename_duple", true).ret(false) _duplicate_project_dialog.get_ok_button().text = tr("Duplicate") _duplicate_project_dialog.raise(project.name) @@ -227,6 +229,12 @@ func _on_projects_list_item_duplicate_requested(project: Projects.Item) -> void: return var project_file_path = project_configs[0] + if _duplicate_project_dialog._rename_check_box.button_pressed: + var initial_settings = ConfigFile.new() + initial_settings.load(project_file_path._path) + initial_settings.set_value("application", "config/name", final_project_name) + initial_settings.save(project_file_path._path) + Cache.smart_value(self, "rename_duple", true).put(_duplicate_project_dialog._rename_check_box.button_pressed) _duplicate_project_dialog.hide() import(project_file_path.path) pass,