mirror of
https://github.com/godotengine/godot.git
synced 2025-01-22 10:32:54 -05:00
Create .uid files in EditorFileSystem
This commit is contained in:
parent
36a62d0c6a
commit
8aa3ee6a35
5 changed files with 29 additions and 36 deletions
|
@ -2348,16 +2348,17 @@ void EditorFileSystem::update_files(const Vector<String> &p_script_paths) {
|
|||
_save_late_updated_files(); //files need to be updated in the re-scan
|
||||
}
|
||||
|
||||
const String old_script_class_icon_path = fs->files[cpos]->script_class_icon_path;
|
||||
const String old_class_name = fs->files[cpos]->script_class_name;
|
||||
fs->files[cpos]->type = type;
|
||||
fs->files[cpos]->resource_script_class = script_class;
|
||||
fs->files[cpos]->uid = uid;
|
||||
fs->files[cpos]->script_class_name = _get_global_script_class(type, file, &fs->files[cpos]->script_class_extends, &fs->files[cpos]->script_class_icon_path);
|
||||
fs->files[cpos]->import_group_file = ResourceLoader::get_import_group_file(file);
|
||||
fs->files[cpos]->modified_time = FileAccess::get_modified_time(file);
|
||||
fs->files[cpos]->deps = _get_dependencies(file);
|
||||
fs->files[cpos]->import_valid = (type == "TextFile" || type == "OtherFile") ? true : ResourceLoader::is_import_valid(file);
|
||||
EditorFileSystemDirectory::FileInfo *fi = fs->files[cpos];
|
||||
const String old_script_class_icon_path = fi->script_class_icon_path;
|
||||
const String old_class_name = fi->script_class_name;
|
||||
fi->type = type;
|
||||
fi->resource_script_class = script_class;
|
||||
fi->uid = uid;
|
||||
fi->script_class_name = _get_global_script_class(type, file, &fi->script_class_extends, &fi->script_class_icon_path);
|
||||
fi->import_group_file = ResourceLoader::get_import_group_file(file);
|
||||
fi->modified_time = FileAccess::get_modified_time(file);
|
||||
fi->deps = _get_dependencies(file);
|
||||
fi->import_valid = type == "TextFile" || type == "OtherFile" || ResourceLoader::is_import_valid(file);
|
||||
|
||||
if (uid != ResourceUID::INVALID_ID) {
|
||||
if (ResourceUID::get_singleton()->has_id(uid)) {
|
||||
|
@ -2367,25 +2368,36 @@ void EditorFileSystem::update_files(const Vector<String> &p_script_paths) {
|
|||
}
|
||||
|
||||
ResourceUID::get_singleton()->update_cache();
|
||||
} else {
|
||||
if (ResourceLoader::exists(file) && !ResourceLoader::has_custom_uid_support(file) && !FileAccess::exists(file + ".uid")) {
|
||||
Ref<FileAccess> f = FileAccess::open(file + ".uid", FileAccess::WRITE);
|
||||
if (f.is_valid()) {
|
||||
const ResourceUID::ID id = ResourceUID::get_singleton()->create_id();
|
||||
ResourceUID::get_singleton()->add_id(id, file);
|
||||
f->store_line(ResourceUID::get_singleton()->id_to_text(id));
|
||||
fi->uid = id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update preview
|
||||
EditorResourcePreview::get_singleton()->check_for_invalidation(file);
|
||||
|
||||
if (ClassDB::is_parent_class(fs->files[cpos]->type, SNAME("Script"))) {
|
||||
_queue_update_script_class(file, fs->files[cpos]->type, fs->files[cpos]->script_class_name, fs->files[cpos]->script_class_extends, fs->files[cpos]->script_class_icon_path);
|
||||
if (ClassDB::is_parent_class(fi->type, SNAME("Script"))) {
|
||||
_queue_update_script_class(file, fi->type, fi->script_class_name, fi->script_class_extends, fi->script_class_icon_path);
|
||||
}
|
||||
if (fs->files[cpos]->type == SNAME("PackedScene")) {
|
||||
if (fi->type == SNAME("PackedScene")) {
|
||||
_queue_update_scene_groups(file);
|
||||
}
|
||||
|
||||
if (ClassDB::is_parent_class(fs->files[cpos]->type, SNAME("Resource"))) {
|
||||
files_to_update_icon_path.push_back(fs->files[cpos]);
|
||||
} else if (old_script_class_icon_path != fs->files[cpos]->script_class_icon_path) {
|
||||
if (ClassDB::is_parent_class(fi->type, SNAME("Resource"))) {
|
||||
files_to_update_icon_path.push_back(fi);
|
||||
} else if (old_script_class_icon_path != fi->script_class_icon_path) {
|
||||
update_files_icon_cache = true;
|
||||
}
|
||||
|
||||
// Restore another script as the global class name if multiple scripts had the same old class name.
|
||||
if (!old_class_name.is_empty() && fs->files[cpos]->script_class_name != old_class_name && ClassDB::is_parent_class(type, SNAME("Script"))) {
|
||||
if (!old_class_name.is_empty() && fi->script_class_name != old_class_name && ClassDB::is_parent_class(type, SNAME("Script"))) {
|
||||
EditorFileSystemDirectory::FileInfo *old_fi = nullptr;
|
||||
String old_file = _get_file_by_class_name(filesystem, old_class_name, old_fi);
|
||||
if (!old_file.is_empty() && old_fi) {
|
||||
|
|
|
@ -1482,16 +1482,6 @@ void EditorNode::save_resource_as(const Ref<Resource> &p_resource, const String
|
|||
file->popup_file_dialog();
|
||||
}
|
||||
|
||||
void EditorNode::ensure_uid_file(const String &p_new_resource_path) {
|
||||
if (ResourceLoader::exists(p_new_resource_path) && !ResourceLoader::has_custom_uid_support(p_new_resource_path) && !FileAccess::exists(p_new_resource_path + ".uid")) {
|
||||
Ref<FileAccess> f = FileAccess::open(p_new_resource_path + ".uid", FileAccess::WRITE);
|
||||
if (f.is_valid()) {
|
||||
const ResourceUID::ID id = ResourceUID::get_singleton()->create_id();
|
||||
f->store_line(ResourceUID::get_singleton()->id_to_text(id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EditorNode::_menu_option(int p_option) {
|
||||
_menu_option_confirm(p_option, false);
|
||||
}
|
||||
|
@ -2233,11 +2223,6 @@ void EditorNode::_dialog_action(String p_file) {
|
|||
ERR_FAIL_COND(saving_resource.is_null());
|
||||
save_resource_in_path(saving_resource, p_file);
|
||||
|
||||
if (current_menu_option == RESOURCE_SAVE_AS) {
|
||||
// Create .uid file when making new Resource.
|
||||
ensure_uid_file(p_file);
|
||||
}
|
||||
|
||||
saving_resource = Ref<Resource>();
|
||||
ObjectID current_id = editor_history.get_current();
|
||||
Object *current_obj = current_id.is_valid() ? ObjectDB::get_instance(current_id) : nullptr;
|
||||
|
|
|
@ -746,7 +746,6 @@ public:
|
|||
void save_resource_in_path(const Ref<Resource> &p_resource, const String &p_path);
|
||||
void save_resource(const Ref<Resource> &p_resource);
|
||||
void save_resource_as(const Ref<Resource> &p_resource, const String &p_at_path = String());
|
||||
void ensure_uid_file(const String &p_new_resource_path);
|
||||
|
||||
void show_about() { _menu_option_confirm(HELP_ABOUT, false); }
|
||||
|
||||
|
|
|
@ -374,7 +374,6 @@ void ScriptCreateDialog::_create_new() {
|
|||
alert->popup_centered();
|
||||
return;
|
||||
}
|
||||
EditorNode::get_singleton()->ensure_uid_file(lpath);
|
||||
}
|
||||
|
||||
emit_signal(SNAME("script_created"), scr);
|
||||
|
|
|
@ -241,7 +241,6 @@ void fog() {
|
|||
alert->popup_centered();
|
||||
return;
|
||||
}
|
||||
EditorNode::get_singleton()->ensure_uid_file(lpath);
|
||||
|
||||
emit_signal(SNAME("shader_include_created"), shader_inc);
|
||||
} else {
|
||||
|
@ -260,7 +259,6 @@ void fog() {
|
|||
alert->popup_centered();
|
||||
return;
|
||||
}
|
||||
EditorNode::get_singleton()->ensure_uid_file(lpath);
|
||||
}
|
||||
|
||||
emit_signal(SNAME("shader_created"), shader);
|
||||
|
|
Loading…
Reference in a new issue