Added nice icon to show when a file is broken on import.
This commit is contained in:
parent
145ff58277
commit
181420f3b2
|
@ -118,6 +118,12 @@ Vector<String> EditorFileSystemDirectory::get_file_deps(int p_idx) const {
|
|||
return files[p_idx]->deps;
|
||||
}
|
||||
|
||||
bool EditorFileSystemDirectory::get_file_import_is_valid(int p_idx) const {
|
||||
|
||||
ERR_FAIL_INDEX_V(p_idx, files.size(), false);
|
||||
return files[p_idx]->import_valid;
|
||||
}
|
||||
|
||||
StringName EditorFileSystemDirectory::get_file_type(int p_idx) const {
|
||||
|
||||
ERR_FAIL_INDEX_V(p_idx, files.size(), "");
|
||||
|
@ -142,6 +148,7 @@ void EditorFileSystemDirectory::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("get_file", "idx"), &EditorFileSystemDirectory::get_file);
|
||||
ClassDB::bind_method(D_METHOD("get_file_path", "idx"), &EditorFileSystemDirectory::get_file_path);
|
||||
ClassDB::bind_method(D_METHOD("get_file_type", "idx"), &EditorFileSystemDirectory::get_file_type);
|
||||
ClassDB::bind_method(D_METHOD("get_file_import_is_valid", "idx"), &EditorFileSystemDirectory::get_file_import_is_valid);
|
||||
ClassDB::bind_method(D_METHOD("get_name"), &EditorFileSystemDirectory::get_name);
|
||||
ClassDB::bind_method(D_METHOD("get_path"), &EditorFileSystemDirectory::get_path);
|
||||
ClassDB::bind_method(D_METHOD("get_parent"), &EditorFileSystemDirectory::get_parent);
|
||||
|
|
|
@ -84,6 +84,7 @@ public:
|
|||
String get_file_path(int p_idx) const;
|
||||
StringName get_file_type(int p_idx) const;
|
||||
Vector<String> get_file_deps(int p_idx) const;
|
||||
bool get_file_import_is_valid(int p_idx) const;
|
||||
|
||||
EditorFileSystemDirectory *get_parent();
|
||||
|
||||
|
|
|
@ -367,6 +367,7 @@ void FileSystemDock::_search(EditorFileSystemDirectory *p_path, List<FileInfo> *
|
|||
fi.name = file;
|
||||
fi.type = p_path->get_file_type(i);
|
||||
fi.path = p_path->get_file_path(i);
|
||||
fi.import_broken = !p_path->get_file_import_is_valid(i);
|
||||
fi.import_status = 0;
|
||||
|
||||
matches->push_back(fi);
|
||||
|
@ -401,6 +402,7 @@ void FileSystemDock::_update_files(bool p_keep_selection) {
|
|||
thumbnail_size *= EDSCALE;
|
||||
Ref<Texture> folder_thumbnail;
|
||||
Ref<Texture> file_thumbnail;
|
||||
Ref<Texture> file_thumbnail_broken;
|
||||
|
||||
bool use_thumbnails = (display_mode == DISPLAY_THUMBNAILS);
|
||||
bool use_folders = search_box->get_text().length() == 0 && split_mode;
|
||||
|
@ -434,8 +436,18 @@ void FileSystemDock::_update_files(bool p_keep_selection) {
|
|||
Theme::get_default()->set_icon("ResizedFile", "EditorIcons", resized_file);
|
||||
}
|
||||
|
||||
if (!has_icon("ResizedFileBroken", "EditorIcons")) {
|
||||
Ref<ImageTexture> file = get_icon("FileBigBroken", "EditorIcons");
|
||||
Ref<Image> img = file->get_data();
|
||||
img->resize(thumbnail_size, thumbnail_size);
|
||||
Ref<ImageTexture> resized_file = Ref<ImageTexture>(memnew(ImageTexture));
|
||||
resized_file->create_from_image(img, 0);
|
||||
Theme::get_default()->set_icon("ResizedFileBroken", "EditorIcons", resized_file);
|
||||
}
|
||||
|
||||
file_thumbnail = get_icon("ResizedFile", "EditorIcons");
|
||||
|
||||
file_thumbnail_broken = get_icon("ResizedFileBroken", "EditorIcons");
|
||||
} else {
|
||||
|
||||
files->set_icon_mode(ItemList::ICON_MODE_LEFT);
|
||||
|
@ -496,6 +508,7 @@ void FileSystemDock::_update_files(bool p_keep_selection) {
|
|||
fi.name = efd->get_file(i);
|
||||
fi.path = path.plus_file(fi.name);
|
||||
fi.type = efd->get_file_type(i);
|
||||
fi.import_broken = !efd->get_file_import_is_valid(i);
|
||||
fi.import_status = 0;
|
||||
|
||||
filelist.push_back(fi);
|
||||
|
@ -511,24 +524,21 @@ void FileSystemDock::_update_files(bool p_keep_selection) {
|
|||
StringName type = E->get().type;
|
||||
|
||||
Ref<Texture> type_icon;
|
||||
Ref<Texture> big_icon = file_thumbnail;
|
||||
|
||||
String tooltip = fname;
|
||||
|
||||
if (E->get().import_status == 0) {
|
||||
if (!E->get().import_broken) {
|
||||
|
||||
if (has_icon(type, ei)) {
|
||||
type_icon = get_icon(type, ei);
|
||||
} else {
|
||||
type_icon = get_icon(oi, ei);
|
||||
}
|
||||
} else if (E->get().import_status == 1) {
|
||||
type_icon = get_icon("DependencyOk", "EditorIcons");
|
||||
} else if (E->get().import_status == 2) {
|
||||
type_icon = get_icon("DependencyChanged", "EditorIcons");
|
||||
tooltip += TTR("\nStatus: Needs Re-Import");
|
||||
} else if (E->get().import_status == 3) {
|
||||
} else {
|
||||
type_icon = get_icon("ImportFail", "EditorIcons");
|
||||
tooltip += ("\nStatus: Missing Dependencies");
|
||||
big_icon = file_thumbnail_broken;
|
||||
tooltip += TTR("\nStatus: Import of file failed. Please fix file and reimport manually.");
|
||||
}
|
||||
|
||||
if (E->get().sources.size()) {
|
||||
|
@ -538,14 +548,16 @@ void FileSystemDock::_update_files(bool p_keep_selection) {
|
|||
}
|
||||
|
||||
if (use_thumbnails) {
|
||||
files->add_item(fname, file_thumbnail, true);
|
||||
files->add_item(fname, big_icon, true);
|
||||
files->set_item_metadata(files->get_item_count() - 1, fp);
|
||||
files->set_item_tag_icon(files->get_item_count() - 1, type_icon);
|
||||
Array udata;
|
||||
udata.resize(2);
|
||||
udata[0] = files->get_item_count() - 1;
|
||||
udata[1] = fname;
|
||||
EditorResourcePreview::get_singleton()->queue_resource_preview(fp, this, "_thumbnail_done", udata);
|
||||
if (!E->get().import_broken) {
|
||||
EditorResourcePreview::get_singleton()->queue_resource_preview(fp, this, "_thumbnail_done", udata);
|
||||
}
|
||||
} else {
|
||||
files->add_item(fname, type_icon, true);
|
||||
files->set_item_metadata(files->get_item_count() - 1, fp);
|
||||
|
|
|
@ -169,6 +169,7 @@ private:
|
|||
StringName type;
|
||||
int import_status; //0 not imported, 1 - ok, 2- must reimport, 3- broken
|
||||
Vector<String> sources;
|
||||
bool import_broken;
|
||||
|
||||
bool operator<(const FileInfo &fi) const {
|
||||
return name < fi.name;
|
||||
|
|
Loading…
Reference in New Issue