diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-09-28 14:34:39 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-28 14:34:39 +0200 |
commit | 38a4d6da98bbd7a39e9adc442247ad46eaa5c56e (patch) | |
tree | 8883081eff05073806729519eeec8751c484d237 | |
parent | 64d3827b19851e71b61ae144828e0ea8f37b6615 (diff) | |
parent | 5fbcd8f9dffe3f505dbda17e52b5bc0339188e94 (diff) |
Merge pull request #38607 from aaronfranke/imported-rename
Rename the ".import" folder to ".godot/imported"
-rw-r--r-- | core/io/resource_importer.cpp | 3 | ||||
-rw-r--r-- | core/project_settings.cpp | 2 | ||||
-rw-r--r-- | core/project_settings.h | 1 | ||||
-rw-r--r-- | doc/classes/EditorImportPlugin.xml | 4 | ||||
-rw-r--r-- | editor/editor_file_dialog.cpp | 2 | ||||
-rw-r--r-- | editor/editor_file_system.cpp | 15 | ||||
-rw-r--r-- | editor/project_manager.cpp | 3 |
7 files changed, 18 insertions, 12 deletions
diff --git a/core/io/resource_importer.cpp b/core/io/resource_importer.cpp index 9ed159bd20..4d980bcf1a 100644 --- a/core/io/resource_importer.cpp +++ b/core/io/resource_importer.cpp @@ -31,6 +31,7 @@ #include "resource_importer.h" #include "core/os/os.h" +#include "core/project_settings.h" #include "core/variant_parser.h" bool ResourceFormatImporter::SortImporterByName::operator()(const Ref<ResourceImporter> &p_a, const Ref<ResourceImporter> &p_b) const { @@ -374,7 +375,7 @@ Ref<ResourceImporter> ResourceFormatImporter::get_importer_by_extension(const St } String ResourceFormatImporter::get_import_base_path(const String &p_for_file) const { - return "res://.import/" + p_for_file.get_file() + "-" + p_for_file.md5_text(); + return ProjectSettings::IMPORTED_FILES_PATH.plus_file(p_for_file.get_file() + "-" + p_for_file.md5_text()); } bool ResourceFormatImporter::are_import_settings_valid(const String &p_path) const { diff --git a/core/project_settings.cpp b/core/project_settings.cpp index efe13e740d..90f56694c2 100644 --- a/core/project_settings.cpp +++ b/core/project_settings.cpp @@ -53,6 +53,8 @@ String ProjectSettings::get_resource_path() const { return resource_path; } +const String ProjectSettings::IMPORTED_FILES_PATH("res://.godot/imported"); + String ProjectSettings::localize_path(const String &p_path) const { if (resource_path == "") { return p_path; //not initialized yet diff --git a/core/project_settings.h b/core/project_settings.h index 29b2406dd2..6cbb02d30e 100644 --- a/core/project_settings.h +++ b/core/project_settings.h @@ -41,6 +41,7 @@ class ProjectSettings : public Object { public: typedef Map<String, Variant> CustomMap; + static const String IMPORTED_FILES_PATH; enum { //properties that are not for built in values begin from this value, so builtin ones are displayed first diff --git a/doc/classes/EditorImportPlugin.xml b/doc/classes/EditorImportPlugin.xml index b290557336..2a7f27ef55 100644 --- a/doc/classes/EditorImportPlugin.xml +++ b/doc/classes/EditorImportPlugin.xml @@ -5,7 +5,7 @@ </brief_description> <description> EditorImportPlugins provide a way to extend the editor's resource import functionality. Use them to import resources from custom files or to provide alternatives to the editor's existing importers. Register your [EditorPlugin] with [method EditorPlugin.add_import_plugin]. - EditorImportPlugins work by associating with specific file extensions and a resource type. See [method get_recognized_extensions] and [method get_resource_type]. They may optionally specify some import presets that affect the import process. EditorImportPlugins are responsible for creating the resources and saving them in the [code].import[/code] directory. + EditorImportPlugins work by associating with specific file extensions and a resource type. See [method get_recognized_extensions] and [method get_resource_type]. They may optionally specify some import presets that affect the import process. EditorImportPlugins are responsible for creating the resources and saving them in the [code].godot/imported[/code] directory. Below is an example EditorImportPlugin that imports a [Mesh] from a file with the extension ".special" or ".spec": [codeblock] tool @@ -136,7 +136,7 @@ <return type="String"> </return> <description> - Gets the extension used to save this resource in the [code].import[/code] directory. + Gets the extension used to save this resource in the [code].godot/imported[/code] directory. </description> </method> <method name="get_visible_name" qualifiers="virtual"> diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index 0e851734a7..ba9f27f65f 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -559,7 +559,7 @@ void EditorFileDialog::_item_list_item_rmb_selected(int p_item, const Vector2 &p continue; } Dictionary item_meta = item_list->get_item_metadata(i); - if (item_meta["path"] == "res://.import") { + if (String(item_meta["path"]).begins_with("res://.godot")) { allow_delete = false; break; } diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index a5edcf5c22..5607bb3f17 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -1865,13 +1865,14 @@ void EditorFileSystem::_find_group_files(EditorFileSystemDirectory *efd, Map<Str } void EditorFileSystem::reimport_files(const Vector<String> &p_files) { - { //check that .import folder exists + { + // Ensure that ProjectSettings::IMPORTED_FILES_PATH exists. DirAccess *da = DirAccess::open("res://"); - if (da->change_dir(".import") != OK) { - Error err = da->make_dir(".import"); - if (err) { + if (da->change_dir(ProjectSettings::IMPORTED_FILES_PATH) != OK) { + Error err = da->make_dir_recursive(ProjectSettings::IMPORTED_FILES_PATH); + if (err || da->change_dir(ProjectSettings::IMPORTED_FILES_PATH) != OK) { memdelete(da); - ERR_FAIL_MSG("Failed to create 'res://.import' folder."); + ERR_FAIL_MSG("Failed to create '" + ProjectSettings::IMPORTED_FILES_PATH + "' folder."); } } memdelete(da); @@ -2055,8 +2056,8 @@ EditorFileSystem::EditorFileSystem() { scanning_changes_done = false; DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES); - if (da->change_dir("res://.import") != OK) { - da->make_dir("res://.import"); + if (da->change_dir(ProjectSettings::IMPORTED_FILES_PATH) != OK) { + da->make_dir(ProjectSettings::IMPORTED_FILES_PATH); } // This should probably also work on Unix and use the string it returns for FAT32 or exFAT using_fat32_or_exfat = (da->get_filesystem_type() == "FAT32" || da->get_filesystem_type() == "exFAT"); diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 1fb889d793..6393aa30ed 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -2093,7 +2093,8 @@ void ProjectManager::_run_project_confirm() { const String &selected = selected_list[i].project_key; String path = EditorSettings::get_singleton()->get("projects/" + selected); - if (!DirAccess::exists(path + "/.import")) { + // `.right(6)` on `IMPORTED_FILES_PATH` strips away the leading "res://". + if (!DirAccess::exists(path.plus_file(ProjectSettings::IMPORTED_FILES_PATH.right(6)))) { run_error_diag->set_text(TTR("Can't run project: Assets need to be imported.\nPlease edit the project to trigger the initial import.")); run_error_diag->popup_centered(); return; |