Provide a getter for the project data directory.
This commit is contained in:
parent
1cbb1f2796
commit
c8b022c165
8 changed files with 33 additions and 12 deletions
|
@ -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 {
|
||||
|
@ -380,7 +381,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::get_singleton()->get_project_data_path().plus_file(p_for_file.get_file() + "-" + p_for_file.md5_text());
|
||||
}
|
||||
|
||||
bool ResourceFormatImporter::are_import_settings_valid(const String &p_path) const {
|
||||
|
|
|
@ -49,6 +49,15 @@ ProjectSettings *ProjectSettings::get_singleton() {
|
|||
return singleton;
|
||||
}
|
||||
|
||||
String ProjectSettings::get_project_data_dir_name() const {
|
||||
return ".import";
|
||||
}
|
||||
|
||||
String ProjectSettings::get_project_data_path() const {
|
||||
String project_data_dir_name = get_project_data_dir_name();
|
||||
return "res://" + project_data_dir_name;
|
||||
}
|
||||
|
||||
String ProjectSettings::get_resource_path() const {
|
||||
return resource_path;
|
||||
};
|
||||
|
|
|
@ -127,6 +127,8 @@ public:
|
|||
bool property_can_revert(const String &p_name);
|
||||
Variant property_get_revert(const String &p_name);
|
||||
|
||||
String get_project_data_dir_name() const;
|
||||
String get_project_data_path() const;
|
||||
String get_resource_path() const;
|
||||
|
||||
static ProjectSettings *get_singleton();
|
||||
|
|
|
@ -568,7 +568,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 (item_meta["path"] == ProjectSettings::get_singleton()->get_project_data_path()) {
|
||||
allow_delete = false;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1888,13 +1888,14 @@ void EditorFileSystem::_find_group_files(EditorFileSystemDirectory *efd, Map<Str
|
|||
}
|
||||
|
||||
void EditorFileSystem::reimport_files(const Vector<String> &p_files) {
|
||||
{ //check that .import folder exists
|
||||
{ //check that the project data folder exists
|
||||
String project_data_dir_name = ProjectSettings::get_singleton()->get_project_data_dir_name();
|
||||
DirAccess *da = DirAccess::open("res://");
|
||||
if (da->change_dir(".import") != OK) {
|
||||
Error err = da->make_dir(".import");
|
||||
if (da->change_dir(project_data_dir_name) != OK) {
|
||||
Error err = da->make_dir(project_data_dir_name);
|
||||
if (err) {
|
||||
memdelete(da);
|
||||
ERR_FAIL_MSG("Failed to create 'res://.import' folder.");
|
||||
ERR_FAIL_MSG("Failed to create folder res://" + project_data_dir_name);
|
||||
}
|
||||
}
|
||||
memdelete(da);
|
||||
|
@ -1973,6 +1974,10 @@ Error EditorFileSystem::_resource_import(const String &p_path) {
|
|||
}
|
||||
|
||||
bool EditorFileSystem::_should_skip_directory(const String &p_path) {
|
||||
if (p_path == ProjectSettings::get_singleton()->get_project_data_path()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (FileAccess::exists(p_path.plus_file("project.godot"))) { // skip if another project inside this
|
||||
return true;
|
||||
}
|
||||
|
@ -2088,8 +2093,9 @@ 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");
|
||||
String project_data_path = ProjectSettings::get_singleton()->get_project_data_path();
|
||||
if (da->change_dir(project_data_path) != OK) {
|
||||
da->make_dir(project_data_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");
|
||||
|
|
|
@ -238,8 +238,9 @@ void FindInFiles::_scan_dir(String path, PoolStringArray &out_folders) {
|
|||
break;
|
||||
}
|
||||
|
||||
// Ignore special dirs (such as .git and .import)
|
||||
if (file == "." || file == ".." || file.begins_with(".")) {
|
||||
// Ignore special dirs (such as .git and project data directory)
|
||||
String project_data_dir_name = ProjectSettings::get_singleton()->get_project_data_dir_name();
|
||||
if (file.begins_with(".") || file == project_data_dir_name) {
|
||||
continue;
|
||||
}
|
||||
if (dir->current_is_hidden()) {
|
||||
|
|
|
@ -2080,7 +2080,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")) {
|
||||
String project_data_dir_name = ProjectSettings::get_singleton()->get_project_data_dir_name();
|
||||
if (!DirAccess::exists(path + "/" + project_data_dir_name)) {
|
||||
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();
|
||||
continue;
|
||||
|
|
|
@ -118,9 +118,10 @@ void JavaScriptToolsEditorPlugin::_zip_recursive(String p_path, String p_base_pa
|
|||
}
|
||||
dir->list_dir_begin();
|
||||
String cur = dir->get_next();
|
||||
String project_data_dir_name = ProjectSettings::get_singleton()->get_project_data_dir_name();
|
||||
while (!cur.empty()) {
|
||||
String cs = p_path.plus_file(cur);
|
||||
if (cur == "." || cur == ".." || cur == ".import") {
|
||||
if (cur == "." || cur == ".." || cur == project_data_dir_name) {
|
||||
// Skip
|
||||
} else if (dir->current_is_dir()) {
|
||||
String path = cs.replace_first(p_base_path, "") + "/";
|
||||
|
|
Loading…
Reference in a new issue