summaryrefslogtreecommitdiff
path: root/tools/editor/filesystem_dock.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/editor/filesystem_dock.cpp')
-rw-r--r--tools/editor/filesystem_dock.cpp149
1 files changed, 87 insertions, 62 deletions
diff --git a/tools/editor/filesystem_dock.cpp b/tools/editor/filesystem_dock.cpp
index b85bd6dfdb..08b8307eb4 100644
--- a/tools/editor/filesystem_dock.cpp
+++ b/tools/editor/filesystem_dock.cpp
@@ -170,7 +170,7 @@ void FileSystemDock::_notification(int p_what) {
_update_tree(); //maybe it finished already
if (EditorFileSystem::get_singleton()->is_scanning()) {
- _set_scannig_mode();
+ _set_scanning_mode();
}
} break;
@@ -350,25 +350,9 @@ void FileSystemDock::_search(EditorFileSystemDirectory *p_path,List<FileInfo>* m
FileInfo fi;
fi.name=file;
fi.type=p_path->get_file_type(i);
- fi.path=p_path->get_file_path(i);
- if (p_path->get_file_meta(i)) {
- if (p_path->is_missing_sources(i)) {
- fi.import_status=3;
- } else if (p_path->have_sources_changed(i)) {
- fi.import_status=2;
- } else {
- fi.import_status=1;
- }
- } else {
- fi.import_status=0;
- }
- for(int j=0;j<p_path->get_source_count(i);j++) {
- String s = EditorImportPlugin::expand_source_path(p_path->get_source_file(i,j));
- if (p_path->is_source_file_missing(i,j)) {
- s+=" (Missing)";
- }
- fi.sources.push_back(s);
- }
+ fi.path=p_path->get_file_path(i);
+ fi.import_status=0;
+
matches->push_back(fi);
if (matches->size()>p_max_items)
@@ -500,25 +484,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);
- if (efd->get_file_meta(i)) {
- if (efd->is_missing_sources(i)) {
- fi.import_status=3;
- } else if (efd->have_sources_changed(i)) {
- fi.import_status=2;
- } else {
- fi.import_status=1;
- }
-
- for(int j=0;j<efd->get_source_count(i);j++) {
- String s = EditorImportPlugin::expand_source_path(efd->get_source_file(i,j));
- if (efd->is_source_file_missing(i,j)) {
- s+=" (Missing)";
- }
- fi.sources.push_back(s);
- }
- } else {
- fi.import_status=0;
- }
+ fi.import_status=0;
@@ -662,7 +628,7 @@ void FileSystemDock::_fs_changed() {
set_process(false);
}
-void FileSystemDock::_set_scannig_mode() {
+void FileSystemDock::_set_scanning_mode() {
split_box->hide();
button_hist_prev->set_disabled(true);
@@ -1068,7 +1034,7 @@ void FileSystemDock::_file_option(int p_option) {
}
ERR_FAIL_COND(reimport.size()==0);
-
+/*
Ref<ResourceImportMetadata> rimd = ResourceLoader::load_import_metadata(reimport[0]);
ERR_FAIL_COND(!rimd.is_valid());
String editor=rimd->get_editor();
@@ -1086,6 +1052,7 @@ void FileSystemDock::_file_option(int p_option) {
rimp->reimport_multiple_files(reimport);
}
+ */
} break;
case FILE_COPY_PATH:
@@ -1174,7 +1141,7 @@ void FileSystemDock::_search_changed(const String& p_text) {
void FileSystemDock::_rescan() {
- _set_scannig_mode();
+ _set_scanning_mode();
EditorFileSystem::get_singleton()->scan();
}
@@ -1186,6 +1153,14 @@ void FileSystemDock::fix_dependencies(const String& p_for_file) {
void FileSystemDock::focus_on_filter() {
+ if (!search_box->is_visible_in_tree()) {
+ // Tree mode, switch to files list with search box
+ tree->hide();
+ file_list_vb->show();
+ button_favorite->hide();
+ }
+
+ search_box->grab_focus();
}
void FileSystemDock::set_display_mode(int p_mode) {
@@ -1529,25 +1504,6 @@ void FileSystemDock::_files_list_rmb_select(int p_item,const Vector2& p_pos) {
if (efsd) {
- if (!efsd->get_file_meta(pos)) {
- all_can_reimport=false;
-
-
- } else {
- Ref<ResourceImportMetadata> rimd = ResourceLoader::load_import_metadata(path);
- if (rimd.is_valid()) {
-
- String editor=rimd->get_editor();
- if (editor.begins_with("texture_")) { //compatibility fix for old texture format
- editor="texture";
- }
- types.insert(editor);
-
- } else {
- all_can_reimport=false;
-
- }
- }
} else {
all_can_reimport=false;
@@ -1595,7 +1551,7 @@ void FileSystemDock::_files_list_rmb_select(int p_item,const Vector2& p_pos) {
if (all_can_reimport && types.size()==1) { //all can reimport and are of the same type
-
+/*
bool valid=true;
Ref<EditorImportPlugin> rimp = EditorImportExport::get_singleton()->get_import_plugin_by_name(types.front()->get());
if (rimp.is_valid()) {
@@ -1611,6 +1567,7 @@ void FileSystemDock::_files_list_rmb_select(int p_item,const Vector2& p_pos) {
file_options->add_separator();
file_options->add_item(TTR("Re-Import.."),FILE_REIMPORT);
}
+ */
}
file_options->set_pos(files->get_global_pos() + p_pos);
@@ -1618,6 +1575,70 @@ void FileSystemDock::_files_list_rmb_select(int p_item,const Vector2& p_pos) {
}
+void FileSystemDock::select_file(const String& p_file) {
+
+ _go_to_dir(p_file.get_base_dir());
+ for(int i=0;i<files->get_item_count();i++) {
+ if (files->get_item_metadata(i)==p_file) {
+ files->select(i);
+ files->ensure_current_is_visible();
+ break;
+ }
+ }
+
+}
+
+void FileSystemDock::_file_multi_selected(int p_index,bool p_selected) {
+
+
+ _file_selected();
+}
+
+void FileSystemDock::_file_selected() {
+
+ //check import
+ Vector<String> imports;
+ String import_type;
+
+ for(int i=0;i<files->get_item_count();i++) {
+ if (!files->is_selected(i))
+ continue;
+
+ String p = files->get_item_metadata(i);
+ if (!FileAccess::exists(p+".import")) {
+ imports.clear();
+ break;
+ }
+ Ref<ConfigFile> cf;
+ cf.instance();
+ Error err = cf->load(p+".import");
+ if (err!=OK) {
+ imports.clear();
+ break;
+ }
+
+ String type = cf->get_value("remap","type");
+ if (import_type=="") {
+ import_type=type;
+ } else if (import_type!=type) {
+ //all should be the same type
+ imports.clear();
+ break;
+ }
+ imports.push_back(p);
+ }
+
+
+ if (imports.size()==0) {
+ EditorNode::get_singleton()->get_import_dock()->clear();
+ } else if (imports.size()==1) {
+ EditorNode::get_singleton()->get_import_dock()->set_edit_path(imports[0]);
+ } else {
+ EditorNode::get_singleton()->get_import_dock()->set_edit_multiple_paths(imports);
+ }
+}
+
+
void FileSystemDock::_bind_methods() {
ClassDB::bind_method(_MD("_update_tree"),&FileSystemDock::_update_tree);
@@ -1649,6 +1670,8 @@ void FileSystemDock::_bind_methods() {
ClassDB::bind_method(_MD("_files_list_rmb_select"),&FileSystemDock::_files_list_rmb_select);
ClassDB::bind_method(_MD("_preview_invalidated"),&FileSystemDock::_preview_invalidated);
+ ClassDB::bind_method(_MD("_file_selected"),&FileSystemDock::_file_selected);
+ ClassDB::bind_method(_MD("_file_multi_selected"),&FileSystemDock::_file_multi_selected);
ADD_SIGNAL(MethodInfo("instance", PropertyInfo(Variant::POOL_STRING_ARRAY, "files")));
@@ -1753,6 +1776,8 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) {
files->set_select_mode(ItemList::SELECT_MULTI);
files->set_drag_forwarding(this);
files->connect("item_rmb_selected",this,"_files_list_rmb_select");
+ files->connect("item_selected",this,"_file_selected");
+ files->connect("multi_selected",this,"_file_multi_selected");
files->set_allow_rmb_select(true);
file_list_vb = memnew( VBoxContainer );