You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-11 13:10:58 +00:00
Merge pull request #52714 from m4gr3d/provide_getter_for_project_data_dir_3x
This commit is contained in:
@@ -31,6 +31,7 @@
|
|||||||
#include "resource_importer.h"
|
#include "resource_importer.h"
|
||||||
|
|
||||||
#include "core/os/os.h"
|
#include "core/os/os.h"
|
||||||
|
#include "core/project_settings.h"
|
||||||
#include "core/variant_parser.h"
|
#include "core/variant_parser.h"
|
||||||
|
|
||||||
bool ResourceFormatImporter::SortImporterByName::operator()(const Ref<ResourceImporter> &p_a, const Ref<ResourceImporter> &p_b) const {
|
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 {
|
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 {
|
bool ResourceFormatImporter::are_import_settings_valid(const String &p_path) const {
|
||||||
|
|||||||
@@ -49,6 +49,15 @@ ProjectSettings *ProjectSettings::get_singleton() {
|
|||||||
return 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 {
|
String ProjectSettings::get_resource_path() const {
|
||||||
return resource_path;
|
return resource_path;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -127,6 +127,8 @@ public:
|
|||||||
bool property_can_revert(const String &p_name);
|
bool property_can_revert(const String &p_name);
|
||||||
Variant property_get_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;
|
String get_resource_path() const;
|
||||||
|
|
||||||
static ProjectSettings *get_singleton();
|
static ProjectSettings *get_singleton();
|
||||||
|
|||||||
@@ -568,7 +568,7 @@ void EditorFileDialog::_item_list_item_rmb_selected(int p_item, const Vector2 &p
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Dictionary item_meta = item_list->get_item_metadata(i);
|
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;
|
allow_delete = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1888,13 +1888,14 @@ void EditorFileSystem::_find_group_files(EditorFileSystemDirectory *efd, Map<Str
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EditorFileSystem::reimport_files(const Vector<String> &p_files) {
|
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://");
|
DirAccess *da = DirAccess::open("res://");
|
||||||
if (da->change_dir(".import") != OK) {
|
if (da->change_dir(project_data_dir_name) != OK) {
|
||||||
Error err = da->make_dir(".import");
|
Error err = da->make_dir(project_data_dir_name);
|
||||||
if (err) {
|
if (err) {
|
||||||
memdelete(da);
|
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);
|
memdelete(da);
|
||||||
@@ -1973,6 +1974,10 @@ Error EditorFileSystem::_resource_import(const String &p_path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool EditorFileSystem::_should_skip_directory(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
|
if (FileAccess::exists(p_path.plus_file("project.godot"))) { // skip if another project inside this
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -2088,8 +2093,9 @@ EditorFileSystem::EditorFileSystem() {
|
|||||||
scanning_changes_done = false;
|
scanning_changes_done = false;
|
||||||
|
|
||||||
DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
||||||
if (da->change_dir("res://.import") != OK) {
|
String project_data_path = ProjectSettings::get_singleton()->get_project_data_path();
|
||||||
da->make_dir("res://.import");
|
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
|
// 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");
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ignore special dirs (such as .git and .import)
|
// Ignore special dirs (such as .git and project data directory)
|
||||||
if (file == "." || file == ".." || file.begins_with(".")) {
|
String project_data_dir_name = ProjectSettings::get_singleton()->get_project_data_dir_name();
|
||||||
|
if (file.begins_with(".") || file == project_data_dir_name) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (dir->current_is_hidden()) {
|
if (dir->current_is_hidden()) {
|
||||||
|
|||||||
@@ -2080,7 +2080,8 @@ void ProjectManager::_run_project_confirm() {
|
|||||||
const String &selected = selected_list[i].project_key;
|
const String &selected = selected_list[i].project_key;
|
||||||
String path = EditorSettings::get_singleton()->get("projects/" + selected);
|
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->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();
|
run_error_diag->popup_centered();
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -118,9 +118,10 @@ void JavaScriptToolsEditorPlugin::_zip_recursive(String p_path, String p_base_pa
|
|||||||
}
|
}
|
||||||
dir->list_dir_begin();
|
dir->list_dir_begin();
|
||||||
String cur = dir->get_next();
|
String cur = dir->get_next();
|
||||||
|
String project_data_dir_name = ProjectSettings::get_singleton()->get_project_data_dir_name();
|
||||||
while (!cur.empty()) {
|
while (!cur.empty()) {
|
||||||
String cs = p_path.plus_file(cur);
|
String cs = p_path.plus_file(cur);
|
||||||
if (cur == "." || cur == ".." || cur == ".import") {
|
if (cur == "." || cur == ".." || cur == project_data_dir_name) {
|
||||||
// Skip
|
// Skip
|
||||||
} else if (dir->current_is_dir()) {
|
} else if (dir->current_is_dir()) {
|
||||||
String path = cs.replace_first(p_base_path, "") + "/";
|
String path = cs.replace_first(p_base_path, "") + "/";
|
||||||
|
|||||||
Reference in New Issue
Block a user