summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2017-08-29 20:17:34 -0300
committerJuan Linietsky <reduzio@gmail.com>2017-08-29 20:17:59 -0300
commit181420f3b229f8e40a1bfe7bfafd3f3a19af0d32 (patch)
tree727e5287efb07770cac6f2f0cc322c638f1b2c12
parent145ff58277a5145026be9887666a2acd50559e80 (diff)
Added nice icon to show when a file is broken on import.
-rw-r--r--editor/editor_file_system.cpp7
-rw-r--r--editor/editor_file_system.h1
-rw-r--r--editor/filesystem_dock.cpp32
-rw-r--r--editor/filesystem_dock.h1
4 files changed, 31 insertions, 10 deletions
diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp
index 48825d5218..c175886d14 100644
--- a/editor/editor_file_system.cpp
+++ b/editor/editor_file_system.cpp
@@ -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);
diff --git a/editor/editor_file_system.h b/editor/editor_file_system.h
index efbbec0e08..cee3219b43 100644
--- a/editor/editor_file_system.h
+++ b/editor/editor_file_system.h
@@ -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();
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index d0d8b0f0cd..9aa856119d 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -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);
diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h
index c33a745ce4..a35b145085 100644
--- a/editor/filesystem_dock.h
+++ b/editor/filesystem_dock.h
@@ -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;