diff --git a/doc/classes/EditorSettings.xml b/doc/classes/EditorSettings.xml
index 8cf014b909f6..ffe4c1265d16 100644
--- a/doc/classes/EditorSettings.xml
+++ b/doc/classes/EditorSettings.xml
@@ -775,12 +775,9 @@
Path to the SSH executable (used for remote deploy to desktop platforms). If left empty, the editor will attempt to run [code]ssh[/code] from [code]PATH[/code].
- The folder where projects should be scanned for (recursively), in a way similar to the project manager's [b]Scan[/b] button. This can be set to the same value as [member filesystem/directories/default_project_path] for convenience.
+ The folder where projects should be scanned for (recursively), in a way similar to the project manager's [b]Scan[/b] button.
[b]Note:[/b] Setting this path to a folder with very large amounts of files/folders can slow down the project manager startup significantly. To keep the project manager quick to start up, it is recommended to set this value to a folder as "specific" as possible.
-
- The folder where new projects should be created by default when clicking the project manager's [b]New Project[/b] button. This can be set to the same value as [member filesystem/directories/autoscan_project_path] for convenience.
-
The program that opens 3D model scene files when clicking "Open in External Program" option in Filesystem Dock. If not specified, the file will be opened in the system's default program.
diff --git a/editor/project_manager/project_dialog.cpp b/editor/project_manager/project_dialog.cpp
index 0ce640d5f2ab..ffdefe9e94c7 100644
--- a/editor/project_manager/project_dialog.cpp
+++ b/editor/project_manager/project_dialog.cpp
@@ -307,6 +307,14 @@ void ProjectDialog::_set_target_path(const String &p_text) {
}
}
+String ProjectDialog::_get_default_project_path() const {
+ const String path = EDITOR_GET("_default_project_path");
+ if (path.is_empty()) {
+ return OS::get_singleton()->has_environment("HOME") ? OS::get_singleton()->get_environment("HOME") : OS::get_singleton()->get_system_dir(OS::SYSTEM_DIR_DOCUMENTS);
+ }
+ return path;
+}
+
void ProjectDialog::_update_target_auto_dir() {
String new_auto_dir;
if (mode == MODE_NEW || mode == MODE_INSTALL || mode == MODE_DUPLICATE) {
@@ -402,7 +410,7 @@ void ProjectDialog::_install_path_changed() {
void ProjectDialog::_browse_project_path() {
String path = project_path->get_text();
if (path.is_relative_path()) {
- path = EDITOR_GET("filesystem/directories/default_project_path");
+ path = _get_default_project_path();
}
if (mode == MODE_IMPORT && install_path->is_visible_in_tree()) {
// Select last ZIP file.
@@ -433,7 +441,7 @@ void ProjectDialog::_browse_install_path() {
String path = install_path->get_text();
if (path.is_relative_path() || !DirAccess::dir_exists_absolute(path)) {
- path = EDITOR_GET("filesystem/directories/default_project_path");
+ path = _get_default_project_path();
}
if (create_dir->is_pressed()) {
// Select parent directory of install path.
@@ -553,6 +561,9 @@ void ProjectDialog::ok_pressed() {
}
String path = project_path->get_text();
+ if (set_as_default_dir->is_pressed()) {
+ EditorSettings::get_singleton()->set("_default_project_path", path.get_base_dir());
+ }
if (mode == MODE_NEW) {
if (create_dir->is_pressed()) {
@@ -883,7 +894,7 @@ void ProjectDialog::show_dialog(bool p_reset_name, bool p_is_confirmed) {
install_path->set_text(original_dir);
fdialog_project->set_current_dir(original_dir);
} else {
- String fav_dir = EDITOR_GET("filesystem/directories/default_project_path");
+ String fav_dir = _get_default_project_path();
fav_dir = fav_dir.simplify_path();
if (!fav_dir.is_empty()) {
project_path->set_text(fav_dir);
@@ -1040,6 +1051,12 @@ ProjectDialog::ProjectDialog() {
l->set_h_size_flags(Control::SIZE_EXPAND_FILL);
pphb_label->add_child(l);
+ set_as_default_dir = memnew(CheckBox);
+ set_as_default_dir->set_text(TTRC("Set As Default"));
+ set_as_default_dir->set_tooltip_text(TTRC("If enabled, the base folder will be used as default folder for future projects."));
+ set_as_default_dir->set_pressed(EDITOR_DEF("_default_project_path", "").operator String().is_empty());
+ pphb_label->add_child(set_as_default_dir);
+
create_dir = memnew(CheckButton);
create_dir->set_text(TTRC("Create Folder"));
create_dir->set_pressed(true);
diff --git a/editor/project_manager/project_dialog.h b/editor/project_manager/project_dialog.h
index bad5570e1a93..35e9f049e52b 100644
--- a/editor/project_manager/project_dialog.h
+++ b/editor/project_manager/project_dialog.h
@@ -74,6 +74,7 @@ class ProjectDialog : public ConfirmationDialog {
bool is_folder_empty = true;
ConfirmationDialog *nonempty_confirmation = nullptr;
+ CheckBox *set_as_default_dir = nullptr;
CheckButton *create_dir = nullptr;
Button *project_browse = nullptr;
Button *install_browse = nullptr;
@@ -120,6 +121,7 @@ class ProjectDialog : public ConfirmationDialog {
// Install path is only visible when importing a ZIP.
String _get_target_path();
void _set_target_path(const String &p_text);
+ String _get_default_project_path() const;
// Calculated from project name / ZIP name.
String auto_dir;
diff --git a/editor/project_manager/project_manager.cpp b/editor/project_manager/project_manager.cpp
index 99aebcaf88d4..27d9b8207937 100644
--- a/editor/project_manager/project_manager.cpp
+++ b/editor/project_manager/project_manager.cpp
@@ -1764,7 +1764,7 @@ ProjectManager::ProjectManager() {
scan_dir->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
scan_dir->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_DIR);
scan_dir->set_title(TTRC("Select a Folder to Scan")); // Must be after mode or it's overridden.
- scan_dir->set_current_dir(EDITOR_GET("filesystem/directories/default_project_path"));
+ scan_dir->set_current_dir(EDITOR_GET("_default_project_path"));
add_child(scan_dir);
scan_dir->connect("dir_selected", callable_mp(project_list, &ProjectList::find_projects));
@@ -1934,7 +1934,7 @@ ProjectManager::ProjectManager() {
Ref dir_access = DirAccess::create(DirAccess::AccessType::ACCESS_FILESYSTEM);
- String default_project_path = EDITOR_GET("filesystem/directories/default_project_path");
+ String default_project_path = EDITOR_GET("_default_project_path");
if (!default_project_path.is_empty() && !dir_access->dir_exists(default_project_path)) {
Error error = dir_access->make_dir_recursive(default_project_path);
if (error != OK) {
diff --git a/editor/settings/editor_settings.cpp b/editor/settings/editor_settings.cpp
index 9177b1b008d7..211367a702b9 100644
--- a/editor/settings/editor_settings.cpp
+++ b/editor/settings/editor_settings.cpp
@@ -648,8 +648,6 @@ void EditorSettings::_load_defaults(Ref p_extra_config) {
// Directories
EDITOR_SETTING(Variant::STRING, PROPERTY_HINT_GLOBAL_DIR, "filesystem/directories/autoscan_project_path", "", "")
- const String fs_dir_default_project_path = OS::get_singleton()->has_environment("HOME") ? OS::get_singleton()->get_environment("HOME") : OS::get_singleton()->get_system_dir(OS::SYSTEM_DIR_DOCUMENTS);
- EDITOR_SETTING_BASIC(Variant::STRING, PROPERTY_HINT_GLOBAL_DIR, "filesystem/directories/default_project_path", fs_dir_default_project_path, "")
// On save
_initial_set("filesystem/on_save/compress_binary_resources", true);