diff options
Diffstat (limited to 'tools/editor')
22 files changed, 858 insertions, 531 deletions
diff --git a/tools/editor/animation_editor.cpp b/tools/editor/animation_editor.cpp index 2d274dc91b..9a0dde783b 100644 --- a/tools/editor/animation_editor.cpp +++ b/tools/editor/animation_editor.cpp @@ -1702,7 +1702,7 @@ bool AnimationKeyEditor::_edit_if_single_selection() { if (selection.size()==0) { curve_edit->set_mode(AnimationCurveEdit::MODE_DISABLED); - print_line("disable"); + //print_line("disable"); } else { curve_edit->set_mode(AnimationCurveEdit::MODE_MULTIPLE); @@ -1713,13 +1713,13 @@ bool AnimationKeyEditor::_edit_if_single_selection() { curve_edit->set_multiple(animation->track_get_key_transition(E->key().track,E->key().key)); } - print_line("multiple"); + //print_line("multiple"); } return false; } curve_edit->set_mode(AnimationCurveEdit::MODE_SINGLE); - print_line("regular"); + //print_line("regular"); int idx = selection.front()->key().track; int key = selection.front()->key().key; @@ -3017,7 +3017,7 @@ void AnimationKeyEditor::set_keying(bool p_enabled) { keying=p_enabled; _update_menu(); - emit_signal("keying_changed",p_enabled); + emit_signal("keying_changed"); } diff --git a/tools/editor/editor_file_dialog.cpp b/tools/editor/editor_file_dialog.cpp index 28a9b63412..22cd3845e1 100644 --- a/tools/editor/editor_file_dialog.cpp +++ b/tools/editor/editor_file_dialog.cpp @@ -53,13 +53,52 @@ void EditorFileDialog::_notification(int p_what) { //RID ci = get_canvas_item(); //get_stylebox("panel","PopupMenu")->draw(ci,Rect2(Point2(),get_size())); + } else if (p_what==NOTIFICATION_POPUP_HIDE) { + + set_process_unhandled_input(false); + } else if (p_what==EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { - set_show_hidden_files(EditorSettings::get_singleton()->get("file_dialog/show_hidden_files")); + bool show_hidden=EditorSettings::get_singleton()->get("file_dialog/show_hidden_files"); + if (show_hidden_files!=show_hidden) + set_show_hidden_files(show_hidden); set_display_mode((DisplayMode)EditorSettings::get_singleton()->get("file_dialog/display_mode").operator int()); } } +void EditorFileDialog::_unhandled_input(const InputEvent& p_event) { + + if (p_event.type==InputEvent::KEY && is_window_modal_on_top()) { + + const InputEventKey &k=p_event.key; + + if (k.pressed) { + + bool handled=true; + + switch (k.scancode) { + + case KEY_H: { + + if (k.mod.command) { + + bool show=!show_hidden_files; + set_show_hidden_files(show); + EditorSettings::get_singleton()->set("file_dialog/show_hidden_files",show); + } else { + handled=false; + } + + } break; + default: { handled=false; } + } + + if (handled) + accept_event(); + } + } +} + void EditorFileDialog::set_enable_multiple_selection(bool p_enable) { item_list->set_select_mode(p_enable?ItemList::SELECT_MULTI:ItemList::SELECT_SINGLE); @@ -151,6 +190,8 @@ void EditorFileDialog::_post_popup() { _update_favorites(); } + set_process_unhandled_input(true); + } void EditorFileDialog::_thumbnail_result(const String& p_path,const Ref<Texture>& p_preview, const Variant& p_udata) { @@ -1049,6 +1090,8 @@ EditorFileDialog::DisplayMode EditorFileDialog::get_display_mode() const{ void EditorFileDialog::_bind_methods() { + ObjectTypeDB::bind_method(_MD("_unhandled_input"),&EditorFileDialog::_unhandled_input); + ObjectTypeDB::bind_method(_MD("_item_selected"),&EditorFileDialog::_item_selected); ObjectTypeDB::bind_method(_MD("_item_db_selected"),&EditorFileDialog::_item_dc_selected); ObjectTypeDB::bind_method(_MD("_dir_entered"),&EditorFileDialog::_dir_entered); diff --git a/tools/editor/editor_file_dialog.h b/tools/editor/editor_file_dialog.h index db3201e5c4..3590964a51 100644 --- a/tools/editor/editor_file_dialog.h +++ b/tools/editor/editor_file_dialog.h @@ -176,6 +176,8 @@ private: void _thumbnail_done(const String& p_path,const Ref<Texture>& p_preview, const Variant& p_udata); void _request_single_thumbnail(const String& p_path); + void _unhandled_input(const InputEvent& p_event); + protected: void _notification(int p_what); diff --git a/tools/editor/editor_file_system.cpp b/tools/editor/editor_file_system.cpp index 673607706a..c7c1a48e34 100644 --- a/tools/editor/editor_file_system.cpp +++ b/tools/editor/editor_file_system.cpp @@ -37,6 +37,31 @@ EditorFileSystem *EditorFileSystem::singleton=NULL; +void EditorFileSystemDirectory::sort_files() { + + files.sort_custom<FileInfoSort>(); +} + +int EditorFileSystemDirectory::find_file_index(const String& p_file) const { + + for(int i=0;i<files.size();i++) { + if (files[i]->file==p_file) + return i; + } + return -1; + +} +int EditorFileSystemDirectory::find_dir_index(const String& p_dir) const{ + + + for(int i=0;i<subdirs.size();i++) { + if (subdirs[i]->name==p_dir) + return i; + } + + return -1; +} + int EditorFileSystemDirectory::get_subdir_count() const { @@ -59,7 +84,7 @@ String EditorFileSystemDirectory::get_file(int p_idx) const{ ERR_FAIL_INDEX_V(p_idx,files.size(),""); - return files[p_idx].file; + return files[p_idx]->file; } String EditorFileSystemDirectory::get_path() const { @@ -91,22 +116,22 @@ String EditorFileSystemDirectory::get_file_path(int p_idx) const { bool EditorFileSystemDirectory::get_file_meta(int p_idx) const { ERR_FAIL_INDEX_V(p_idx,files.size(),""); - return files[p_idx].meta.enabled; + return files[p_idx]->meta.enabled; } Vector<String> EditorFileSystemDirectory::get_file_deps(int p_idx) const { ERR_FAIL_INDEX_V(p_idx,files.size(),Vector<String>()); - return files[p_idx].meta.deps; + return files[p_idx]->meta.deps; } Vector<String> EditorFileSystemDirectory::get_missing_sources(int p_idx) const { ERR_FAIL_INDEX_V(p_idx,files.size(),Vector<String>()); Vector<String> missing; - for(int i=0;i<files[p_idx].meta.sources.size();i++) { - if (files[p_idx].meta.sources[i].missing) - missing.push_back(files[p_idx].meta.sources[i].path); + for(int i=0;i<files[p_idx]->meta.sources.size();i++) { + if (files[p_idx]->meta.sources[i].missing) + missing.push_back(files[p_idx]->meta.sources[i].path); } return missing; @@ -116,8 +141,8 @@ Vector<String> EditorFileSystemDirectory::get_missing_sources(int p_idx) const { bool EditorFileSystemDirectory::is_missing_sources(int p_idx) const { ERR_FAIL_INDEX_V(p_idx,files.size(),false); - for(int i=0;i<files[p_idx].meta.sources.size();i++) { - if (files[p_idx].meta.sources[i].missing) + for(int i=0;i<files[p_idx]->meta.sources.size();i++) { + if (files[p_idx]->meta.sources[i].missing) return true; } @@ -127,7 +152,7 @@ bool EditorFileSystemDirectory::is_missing_sources(int p_idx) const { StringName EditorFileSystemDirectory::get_file_type(int p_idx) const { ERR_FAIL_INDEX_V(p_idx,files.size(),""); - return files[p_idx].type; + return files[p_idx]->type; } String EditorFileSystemDirectory::get_name() { @@ -157,11 +182,17 @@ void EditorFileSystemDirectory::_bind_methods() { EditorFileSystemDirectory::EditorFileSystemDirectory() { + modified_time=0; parent=NULL; } EditorFileSystemDirectory::~EditorFileSystemDirectory() { + for(int i=0;i<files.size();i++) { + + memdelete(files[i]); + } + for(int i=0;i<subdirs.size();i++) { memdelete(subdirs[i]); @@ -173,19 +204,6 @@ EditorFileSystemDirectory::~EditorFileSystemDirectory() { - - -EditorFileSystem::DirItem::~DirItem() { - - for(int i=0;i<dirs.size();i++) { - memdelete(dirs[i]); - } - - for(int i=0;i<files.size();i++) { - memdelete(files[i]); - } -} - EditorFileSystemDirectory::ImportMeta EditorFileSystem::_get_meta(const String& p_path) { Ref<ResourceImportMetadata> imd = ResourceLoader::load_import_metadata(p_path); @@ -214,160 +232,16 @@ EditorFileSystemDirectory::ImportMeta EditorFileSystem::_get_meta(const String& return m; } -EditorFileSystem::DirItem* EditorFileSystem::_scan_dir(DirAccess *da,Set<String> &extensions,String p_name,float p_from,float p_range,const String& p_path,HashMap<String,FileCache> &file_cache,HashMap<String,DirCache> &dir_cache,EditorProgressBG& p_prog) { - if (abort_scan) - return NULL; - - if (p_path!=String()) { - if (FileAccess::exists(("res://"+p_path).plus_file("engine.cfg"))) { - return NULL; - } - } - - List<String> dirs; - List<String> files; - Set<String> pngs; - - String path=p_path; - if (path.ends_with("/")) - path=path.substr(0,path.length()-1); - String global_path = Globals::get_singleton()->get_resource_path().plus_file(path); - - path="res://"+path; - uint64_t mtime = FileAccess::get_modified_time(global_path); - - DirCache *dc = dir_cache.getptr(path); - - - if (false && dc && dc->modification_time==mtime) { - //use the cached files, since directory did not change - for (Set<String>::Element *E=dc->subdirs.front();E;E=E->next()) { - dirs.push_back(E->get()); - } - for (Set<String>::Element *E=dc->files.front();E;E=E->next()) { - files.push_back(E->get()); - } - - } else { - //use the filesystem, some files may have changed - Error err = da->change_dir(global_path); - if (err!=OK) { - print_line("Can't change to: "+path); - ERR_FAIL_COND_V(err!=OK,NULL); - } +void EditorFileSystem::_scan_filesystem() { - - da->list_dir_begin(); - while (true) { - - bool isdir; - String f = da->get_next(&isdir); - if (f=="") - break; - if (isdir) { - dirs.push_back(f); - } else { - String ext = f.extension().to_lower(); - if (extensions.has(ext)) - files.push_back(f); - - } - - } - - da->list_dir_end(); - files.sort(); - dirs.sort(); - - } - - - - //print_line(da->get_current_dir()+": dirs: "+itos(dirs.size())+" files:"+itos(files.size()) ); - - //find subdirs - Vector<DirItem*> subdirs; - - //String current = da->get_current_dir(); - float idx=0; - for (List<String>::Element *E=dirs.front();E;E=E->next(),idx+=1.0) { - - String d = E->get(); - if (d.begins_with(".")) //ignore hidden and . / .. - continue; - - //ERR_CONTINUE( da->change_dir(d)!= OK ); - DirItem *sdi = _scan_dir(da,extensions,d,p_from+(idx/dirs.size())*p_range,p_range/dirs.size(),p_path+d+"/",file_cache,dir_cache,p_prog); - if (sdi) { - subdirs.push_back(sdi); - } - //da->change_dir(current); - } - - - if (subdirs.empty() && files.empty()) { - total=p_from+p_range; - p_prog.step(total*100); - return NULL; //give up, nothing to do here - } - - DirItem *di = memnew( DirItem ); - di->path=path; - di->name=p_name; - di->dirs=subdirs; - di->modified_time=mtime; - - //add files - for (List<String>::Element *E=files.front();E;E=E->next()) { - - SceneItem * si = memnew( SceneItem ); - si->file=E->get(); - si->path="res://"+p_path+si->file; - FileCache *fc = file_cache.getptr(si->path); - uint64_t mt = FileAccess::get_modified_time(si->path); - - if (fc && fc->modification_time == mt) { - - si->meta=fc->meta; - si->type=fc->type; - si->modified_time=fc->modification_time; - } else { - si->meta=_get_meta(si->path); - si->type=ResourceLoader::get_resource_type(si->path); - si->modified_time=mt; - - } - - if (si->meta.enabled) { - md_count++; - if (_check_meta_sources(si->meta)) { - sources_changed.push_back(si->path); - } - } - di->files.push_back(si); - } - - total=p_from+p_range; - p_prog.step(total*100); - - return di; -} - - -void EditorFileSystem::_scan_scenes() { - - ERR_FAIL_COND(!scanning || scandir); + ERR_FAIL_COND(!scanning || new_filesystem); //read .fscache - HashMap<String,FileCache> file_cache; - HashMap<String,DirCache> dir_cache; - DirCache *dc=NULL; String cpath; sources_changed.clear(); - - + file_cache.clear(); String project=Globals::get_singleton()->get_resource_path(); @@ -387,26 +261,7 @@ void EditorFileSystem::_scan_scenes() { ERR_CONTINUE( split.size() != 3); String name = split[1]; - dir_cache[name]=DirCache(); - dc=&dir_cache[name]; - dc->modification_time=split[2].to_int64(); - - if (name!="res://") { - - cpath=name+"/"; - - int sp=name.find_last("/"); - if (sp==5) - sp=6; - String pd = name.substr(0,sp); - DirCache *dcp = dir_cache.getptr(pd); - ERR_CONTINUE(!dcp); - dcp->subdirs.insert(name.get_file()); - } else { - - cpath=name; - } - + cpath=name; } else { Vector<String> split = l.split("::"); @@ -414,12 +269,8 @@ void EditorFileSystem::_scan_scenes() { String name = split[0]; String file; - if (!name.begins_with("res://")) { - file=name; - name=cpath+name; - } else { - file=name.get_file(); - } + file=name; + name=cpath.plus_file(name); FileCache fc; fc.type=split[1]; @@ -453,8 +304,6 @@ void EditorFileSystem::_scan_scenes() { file_cache[name]=fc; - ERR_CONTINUE(!dc); - dc->files.insert(file); } } @@ -465,39 +314,31 @@ void EditorFileSystem::_scan_scenes() { + EditorProgressBG scan_progress("efs","ScanFS",1000); + ScanProgress sp; + sp.low=0; + sp.hi=1; + sp.progress=&scan_progress; - total=0; - DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); - //da->change_dir( Globals::get_singleton()->get_resource_path() ); + new_filesystem = memnew( EditorFileSystemDirectory ); + new_filesystem->parent=NULL; + DirAccess *d = DirAccess::create(DirAccess::ACCESS_RESOURCES); + d->change_dir("res://"); + _scan_new_dir(new_filesystem,d,sp); - List<String> extensionsl; - ResourceLoader::get_recognized_extensions_for_type("",&extensionsl); - Set<String> extensions; - for(List<String>::Element *E = extensionsl.front();E;E=E->next()) { + file_cache.clear(); //clear caches, no longer needed - extensions.insert(E->get()); - } - - EditorProgressBG scan_progress("efs","ScanFS",100); - - md_count=0; - scandir=_scan_dir(da,extensions,"",0,1,"",file_cache,dir_cache,scan_progress); - memdelete(da); - if (abort_scan && scandir) { - memdelete(scandir); - scandir=NULL; - - } + memdelete(d); //save back the findings // String fscache = EditorSettings::get_singleton()->get_project_settings_path().plus_file("file_cache"); f=FileAccess::open(fscache,FileAccess::WRITE); - _save_type_cache_fs(scandir,f); + _save_filesystem_cache(new_filesystem,f); f->close(); memdelete(f); @@ -510,7 +351,95 @@ void EditorFileSystem::_scan_scenes() { void EditorFileSystem::_thread_func(void *_userdata) { EditorFileSystem *sd = (EditorFileSystem*)_userdata; - sd->_scan_scenes(); + sd->_scan_filesystem(); + +} + +bool EditorFileSystem::_update_scan_actions() { + + sources_changed.clear(); + + bool fs_changed=false; + + for (List<ItemAction>::Element *E=scan_actions.front();E;E=E->next()) { + + ItemAction&ia = E->get(); + + switch(ia.action) { + case ItemAction::ACTION_NONE: { + + } break; + case ItemAction::ACTION_DIR_ADD: { + + //print_line("*ACTION ADD DIR: "+ia.new_dir->get_name()); + int idx=0; + for(int i=0;i<ia.dir->subdirs.size();i++) { + + if (ia.new_dir->name<ia.dir->subdirs[i]->name) + break; + idx++; + } + if (idx==ia.dir->subdirs.size()) { + ia.dir->subdirs.push_back(ia.new_dir); + } else { + ia.dir->subdirs.insert(idx,ia.new_dir); + } + + fs_changed=true; + } break; + case ItemAction::ACTION_DIR_REMOVE: { + + ERR_CONTINUE(!ia.dir->parent); + //print_line("*ACTION REMOVE DIR: "+ia.dir->get_name()); + ia.dir->parent->subdirs.erase(ia.dir); + memdelete( ia.dir ); + fs_changed=true; + } break; + case ItemAction::ACTION_FILE_ADD: { + + int idx=0; + for(int i=0;i<ia.dir->files.size();i++) { + + if (ia.new_file->file<ia.dir->files[i]->file) + break; + idx++; + } + if (idx==ia.dir->files.size()) { + ia.dir->files.push_back(ia.new_file); + } else { + ia.dir->files.insert(idx,ia.new_file); + } + + fs_changed=true; + //print_line("*ACTION ADD FILE: "+ia.new_file->file); + + } break; + case ItemAction::ACTION_FILE_REMOVE: { + + int idx = ia.dir->find_file_index(ia.file); + ERR_CONTINUE(idx==-1); + memdelete( ia.dir->files[idx] ); + ia.dir->files.remove(idx); + + fs_changed=true; + //print_line("*ACTION REMOVE FILE: "+ia.file); + + } break; + case ItemAction::ACTION_FILE_SOURCES_CHANGED: { + + int idx = ia.dir->find_file_index(ia.file); + ERR_CONTINUE(idx==-1); + String full_path = ia.dir->get_file_path(idx); + sources_changed.push_back(full_path); + + } break; + + } + } + + scan_actions.clear(); + + return fs_changed; } @@ -526,19 +455,15 @@ void EditorFileSystem::scan() { abort_scan=false; if (!use_threads) { scanning=true; - _scan_scenes(); - if (rootdir) - memdelete(rootdir); - rootdir=scandir; + scan_total=0; + _scan_filesystem(); if (filesystem) memdelete(filesystem); // file_type_cache.clear(); - filesystem=_update_tree(rootdir); - - if (rootdir) - memdelete(rootdir); - rootdir=NULL; - scanning=false; + filesystem=new_filesystem; + new_filesystem=NULL; + _update_scan_actions(); + scanning=false; emit_signal("filesystem_changed"); emit_signal("sources_changed",sources_changed.size()>0); @@ -548,6 +473,7 @@ void EditorFileSystem::scan() { set_process(true); Thread::Settings s; scanning=true; + scan_total=0; s.priority=Thread::PRIORITY_LOW; thread = Thread::create(_thread_func,this,s); //tree->hide(); @@ -559,14 +485,10 @@ void EditorFileSystem::scan() { } -bool EditorFileSystem::_check_meta_sources(EditorFileSystemDirectory::ImportMeta & p_meta,EditorProgressBG *ep) { +bool EditorFileSystem::_check_meta_sources(EditorFileSystemDirectory::ImportMeta & p_meta) { if (p_meta.enabled) { - if (ep) { - ep->step(ss_amount++); - } - for(int j=0;j<p_meta.sources.size();j++) { @@ -584,9 +506,9 @@ bool EditorFileSystem::_check_meta_sources(EditorFileSystemDirectory::ImportMeta if (mt!=p_meta.sources[j].modified_time) { //scan String md5 = FileAccess::get_md5(src); - print_line("checking: "+src); - print_line("md5: "+md5); - print_line("vs: "+p_meta.sources[j].md5); + //print_line("checking: "+src); + //print_line("md5: "+md5); + //print_line("vs: "+p_meta.sources[j].md5); if (md5!=p_meta.sources[j].md5) { //really changed return true; @@ -599,18 +521,300 @@ bool EditorFileSystem::_check_meta_sources(EditorFileSystemDirectory::ImportMeta return false; } -void EditorFileSystem::_scan_sources(EditorFileSystemDirectory *p_dir,EditorProgressBG *ep) { +void EditorFileSystem::ScanProgress::update(int p_current,int p_total) const { + + float ratio = low + ((hi-low)/p_total)*p_current; + progress->step(ratio*1000); + EditorFileSystem::singleton->scan_total=ratio; +} + +EditorFileSystem::ScanProgress EditorFileSystem::ScanProgress::get_sub(int p_current,int p_total) const{ + + ScanProgress sp=*this; + float slice = (sp.hi-sp.low)/p_total; + sp.low+=slice*p_current; + sp.hi=slice; + return sp; + + +} + + +void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir,DirAccess *da,const ScanProgress& p_progress) { + + List<String> dirs; + List<String> files; + + String cd = da->get_current_dir(); + + p_dir->modified_time = FileAccess::get_modified_time(cd); + + + da->list_dir_begin(); + while (true) { + + bool isdir; + String f = da->get_next(&isdir); + if (f=="") + break; + + if (isdir) { + + if (f.begins_with(".")) //ignore hidden and . / .. + continue; + + if (FileAccess::exists(cd.plus_file(f).plus_file("engine.cfg"))) // skip if another project inside this + continue; + + dirs.push_back(f); + + } else { + + files.push_back(f); + } + + } + + da->list_dir_end(); + + dirs.sort(); + files.sort(); + + int total = dirs.size()+files.size(); + int idx=0; + + for (List<String>::Element *E=dirs.front();E;E=E->next(),idx++) { + + if (da->change_dir(E->get())==OK) { + + EditorFileSystemDirectory *efd = memnew( EditorFileSystemDirectory ); + + efd->parent=p_dir; + efd->name=E->get(); + + _scan_new_dir(efd,da,p_progress.get_sub(idx,total)); + + int idx=0; + for(int i=0;i<p_dir->subdirs.size();i++) { + + if (efd->name<p_dir->subdirs[i]->name) + break; + idx++; + } + if (idx==p_dir->subdirs.size()) { + p_dir->subdirs.push_back(efd); + } else { + p_dir->subdirs.insert(idx,efd); + } + + da->change_dir(".."); + } else { + ERR_PRINTS("Can't go into subdir: "+E->get()); + } + + p_progress.update(idx,total); + + } + + for (List<String>::Element*E=files.front();E;E=E->next(),idx++) { + + String ext = E->get().extension().to_lower(); + if (!valid_extensions.has(ext)) + continue; //invalid + + EditorFileSystemDirectory::FileInfo *fi = memnew( EditorFileSystemDirectory::FileInfo ); + fi->file=E->get(); + + String path = cd.plus_file(fi->file); + + FileCache *fc = file_cache.getptr(path); + uint64_t mt = FileAccess::get_modified_time(path); + + if (fc && fc->modification_time == mt) { + + fi->meta=fc->meta; + fi->type=fc->type; + fi->modified_time=fc->modification_time; + } else { + fi->meta=_get_meta(path); + fi->type=ResourceLoader::get_resource_type(path); + fi->modified_time=mt; + + } + + if (fi->meta.enabled) { + if (_check_meta_sources(fi->meta)) { + ItemAction ia; + ia.action=ItemAction::ACTION_FILE_SOURCES_CHANGED; + ia.dir=p_dir; + ia.file=E->get(); + scan_actions.push_back(ia); + } + } + + p_dir->files.push_back(fi); + p_progress.update(idx,total); + } + +} + + +void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir,const ScanProgress& p_progress) { + + uint64_t current_mtime = FileAccess::get_modified_time(p_dir->get_path()); + + bool updated_dir=false; + + //print_line("dir: "+p_dir->get_path()+" MODTIME: "+itos(p_dir->modified_time)+" CTIME: "+itos(current_mtime)); + + if (current_mtime!=p_dir->modified_time) { + + updated_dir=true; + p_dir->modified_time=current_mtime; + //ooooops, dir changed, see what's going on + + //first mark everything as veryfied + + for(int i=0;i<p_dir->files.size();i++) { + + p_dir->files[i]->verified=false; + } + + for(int i=0;i<p_dir->subdirs.size();i++) { + + p_dir->get_subdir(i)->verified=false; + } + + //then scan files and directories and check what's different + + DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES); + String cd = p_dir->get_path(); + da->change_dir(cd); + da->list_dir_begin(); + while (true) { + + bool isdir; + String f = da->get_next(&isdir); + if (f=="") + break; + + if (isdir) { + + if (f.begins_with(".")) //ignore hidden and . / .. + continue; + + int idx = p_dir->find_dir_index(f); + if (idx==-1) { + + if (FileAccess::exists(cd.plus_file(f).plus_file("engine.cfg"))) // skip if another project inside this + continue; + + EditorFileSystemDirectory *efd = memnew( EditorFileSystemDirectory ); + + efd->parent=p_dir; + efd->name=f; + DirAccess *d = DirAccess::create(DirAccess::ACCESS_RESOURCES); + d->change_dir(cd.plus_file(f)); + _scan_new_dir(efd,d,p_progress.get_sub(1,1)); + memdelete(d); + + + ItemAction ia; + ia.action=ItemAction::ACTION_DIR_ADD; + ia.dir=p_dir; + ia.file=f; + ia.new_dir=efd; + scan_actions.push_back(ia); + } else { + p_dir->subdirs[idx]->verified=true; + } + + + } else { + String ext = f.extension().to_lower(); + if (!valid_extensions.has(ext)) + continue; //invalid + + int idx = p_dir->find_file_index(f); + + if (idx==-1) { + //never seen this file, add actition to add it + EditorFileSystemDirectory::FileInfo *fi = memnew( EditorFileSystemDirectory::FileInfo ); + fi->file=f; + + String path = cd.plus_file(fi->file); + fi->modified_time=FileAccess::get_modified_time(path); + fi->meta=_get_meta(path); + fi->type=ResourceLoader::get_resource_type(path); + + { + ItemAction ia; + ia.action=ItemAction::ACTION_FILE_ADD; + ia.dir=p_dir; + ia.file=f; + ia.new_file=fi; + scan_actions.push_back(ia); + } + + //take the chance and scan sources + if (_check_meta_sources(fi->meta)) { + + ItemAction ia; + ia.action=ItemAction::ACTION_FILE_SOURCES_CHANGED; + ia.dir=p_dir; + ia.file=f; + scan_actions.push_back(ia); + } + + } else { + p_dir->files[idx]->verified=true; + } + + + } + + } + da->list_dir_end(); + memdelete(da); + + + + + } for(int i=0;i<p_dir->files.size();i++) { - if (_check_meta_sources(p_dir->files[i].meta,ep)) { - sources_changed.push_back(p_dir->get_file_path(i)); + if (updated_dir && !p_dir->files[i]->verified) { + //this file was removed, add action to remove it + ItemAction ia; + ia.action=ItemAction::ACTION_FILE_REMOVE; + ia.dir=p_dir; + ia.file=p_dir->files[i]->file; + scan_actions.push_back(ia); + continue; + + } + if (_check_meta_sources(p_dir->files[i]->meta)) { + ItemAction ia; + ia.action=ItemAction::ACTION_FILE_SOURCES_CHANGED; + ia.dir=p_dir; + ia.file=p_dir->files[i]->file; + scan_actions.push_back(ia); } } for(int i=0;i<p_dir->subdirs.size();i++) { - _scan_sources(p_dir->get_subdir(i),ep); + if (updated_dir && !p_dir->subdirs[i]->verified) { + //this directory was removed, add action to remove it + ItemAction ia; + ia.action=ItemAction::ACTION_DIR_REMOVE; + ia.dir=p_dir->subdirs[i]; + scan_actions.push_back(ia); + continue; + + } + _scan_fs_changes(p_dir->get_subdir(i),p_progress); } } @@ -619,9 +823,12 @@ void EditorFileSystem::_thread_func_sources(void *_userdata) { EditorFileSystem *efs = (EditorFileSystem*)_userdata; if (efs->filesystem) { - EditorProgressBG pr("sources","ScanSources",efs->md_count); - efs->ss_amount=0; - efs->_scan_sources(efs->filesystem,&pr); + EditorProgressBG pr("sources","ScanSources",1000); + ScanProgress sp; + sp.progress=≺ + sp.hi=1; + sp.low=0; + efs->_scan_fs_changes(efs->filesystem,sp); } efs->scanning_sources_done=true; } @@ -643,8 +850,17 @@ void EditorFileSystem::scan_sources() { abort_scan=false; if (!use_threads) { - if (filesystem) - _scan_sources(filesystem,NULL); + if (filesystem) { + EditorProgressBG pr("sources","ScanSources",1000); + ScanProgress sp; + sp.progress=≺ + sp.hi=1; + sp.low=0; + scan_total=0; + _scan_fs_changes(filesystem,sp); + if (_update_scan_actions()) + emit_signal("filesystem_changed"); + } scanning_sources=false; scanning_sources_done=true; emit_signal("sources_changed",sources_changed.size()>0); @@ -652,8 +868,8 @@ void EditorFileSystem::scan_sources() { ERR_FAIL_COND(thread_sources); set_process(true); + scan_total=0; Thread::Settings s; - ss_amount=0; s.priority=Thread::PRIORITY_LOW; thread_sources = Thread::create(_thread_func_sources,this,s); //tree->hide(); @@ -665,53 +881,14 @@ void EditorFileSystem::scan_sources() { } -EditorFileSystemDirectory* EditorFileSystem::_update_tree(DirItem *p_item) { - - EditorFileSystemDirectory *efd = memnew( EditorFileSystemDirectory ); - - if (!p_item) - return efd; //empty likely - efd->name=p_item->name; - - for(int i=0;i<p_item->files.size();i++) { - - String s = p_item->files[i]->type; - //if (p_item->files[i]->meta) - // s="*"+s; - -// file_type_cache[p_item->files[i]->path]=s; - if (p_item->files[i]->type=="") - continue; //ignore because it's invalid - EditorFileSystemDirectory::FileInfo fi; - fi.file=p_item->files[i]->file; - fi.type=p_item->files[i]->type; - fi.meta=p_item->files[i]->meta; - fi.modified_time=p_item->files[i]->modified_time; - - efd->files.push_back(fi); - - } - - for(int i=0;i<p_item->dirs.size();i++) { - - EditorFileSystemDirectory *efsd =_update_tree(p_item->dirs[i]); - efsd->parent=efd; - efd->subdirs.push_back( efsd ); - - } - - - return efd; -} - void EditorFileSystem::_notification(int p_what) { switch(p_what) { case NOTIFICATION_ENTER_TREE: { - _load_type_cache(); - scan(); + + scan(); } break; case NOTIFICATION_EXIT_TREE: { if (use_threads && thread) { @@ -727,13 +904,13 @@ void EditorFileSystem::_notification(int p_what) { set_process(false); } - if (rootdir) - memdelete(rootdir); - rootdir=NULL; if (filesystem) memdelete(filesystem); + if (new_filesystem) + memdelete(new_filesystem); filesystem=NULL; + new_filesystem=NULL; } break; case NOTIFICATION_PROCESS: { @@ -751,6 +928,8 @@ void EditorFileSystem::_notification(int p_what) { Thread::wait_to_finish(thread_sources); memdelete(thread_sources); thread_sources=NULL; + if (_update_scan_actions()) + emit_signal("filesystem_changed"); //print_line("sources changed: "+itos(sources_changed.size())); emit_signal("sources_changed",sources_changed.size()>0); } @@ -758,21 +937,14 @@ void EditorFileSystem::_notification(int p_what) { set_process(false); - if (rootdir) - memdelete(rootdir); if (filesystem) memdelete(filesystem); - rootdir=scandir; - scandir=NULL; -// file_type_cache.clear(); - filesystem=_update_tree(rootdir); - - if (rootdir) - memdelete(rootdir); - rootdir=NULL; + filesystem=new_filesystem; + new_filesystem=NULL; Thread::wait_to_finish(thread); memdelete(thread); thread=NULL; + _update_scan_actions(); emit_signal("filesystem_changed"); emit_signal("sources_changed",sources_changed.size()>0); //print_line("initial sources changed: "+itos(sources_changed.size())); @@ -794,7 +966,7 @@ bool EditorFileSystem::is_scanning() const { } float EditorFileSystem::get_scanning_progress() const { - return total; + return scan_total; } EditorFileSystemDirectory *EditorFileSystem::get_filesystem() { @@ -802,12 +974,12 @@ EditorFileSystemDirectory *EditorFileSystem::get_filesystem() { return filesystem; } -void EditorFileSystem::_save_type_cache_fs(DirItem *p_dir,FileAccess *p_file) { +void EditorFileSystem::_save_filesystem_cache(EditorFileSystemDirectory*p_dir,FileAccess *p_file) { if (!p_dir) return; //none - p_file->store_line("::"+p_dir->path+"::"+String::num(p_dir->modified_time)); + p_file->store_line("::"+p_dir->get_path()+"::"+String::num(p_dir->modified_time)); for(int i=0;i<p_dir->files.size();i++) { @@ -832,126 +1004,96 @@ void EditorFileSystem::_save_type_cache_fs(DirItem *p_dir,FileAccess *p_file) { p_file->store_line(s); } - for(int i=0;i<p_dir->dirs.size();i++) { + for(int i=0;i<p_dir->subdirs.size();i++) { - _save_type_cache_fs(p_dir->dirs[i],p_file); + _save_filesystem_cache(p_dir->subdirs[i],p_file); } } -void EditorFileSystem::_load_type_cache(){ - - GLOBAL_LOCK_FUNCTION - - -#if 0 - //this is not good, removed for now as it interferes with metadata stored in files - - String project=Globals::get_singleton()->get_resource_path(); - FileAccess *f =FileAccess::open(project+"/types.cache",FileAccess::READ); - - if (!f) { - - WARN_PRINT("Can't open types.cache."); - return; - } - - file_type_cache.clear(); - while(!f->eof_reached()) { - - String path=f->get_line(); - if (f->eof_reached()) - break; - String type=f->get_line(); - file_type_cache[path]=type; - } - - memdelete(f); -#endif -} bool EditorFileSystem::_find_file(const String& p_file,EditorFileSystemDirectory ** r_d, int &r_file_pos) const { //todo make faster - if (!filesystem || scanning) - return false; + if (!filesystem || scanning) + return false; - String f = Globals::get_singleton()->localize_path(p_file); + String f = Globals::get_singleton()->localize_path(p_file); - if (!f.begins_with("res://")) - return false; - f=f.substr(6,f.length()); - f=f.replace("\\","/"); + if (!f.begins_with("res://")) + return false; + f=f.substr(6,f.length()); + f=f.replace("\\","/"); - Vector<String> path = f.split("/"); + Vector<String> path = f.split("/"); - if (path.size()==0) - return false; - String file=path[path.size()-1]; - path.resize(path.size()-1); + if (path.size()==0) + return false; + String file=path[path.size()-1]; + path.resize(path.size()-1); - EditorFileSystemDirectory *fs=filesystem; + EditorFileSystemDirectory *fs=filesystem; - for(int i=0;i<path.size();i++) { + for(int i=0;i<path.size();i++) { - int idx=-1; - for(int j=0;j<fs->get_subdir_count();j++) { + int idx=-1; + for(int j=0;j<fs->get_subdir_count();j++) { - if (fs->get_subdir(j)->get_name()==path[i]) { - idx=j; - break; - } - } + if (fs->get_subdir(j)->get_name()==path[i]) { + idx=j; + break; + } + } - if (idx==-1) { - //does not exist, create i guess? - EditorFileSystemDirectory *efsd = memnew( EditorFileSystemDirectory ); - efsd->name=path[i]; - int idx2=0; - for(int j=0;j<fs->get_subdir_count();j++) { + if (idx==-1) { + //does not exist, create i guess? + EditorFileSystemDirectory *efsd = memnew( EditorFileSystemDirectory ); + efsd->name=path[i]; + int idx2=0; + for(int j=0;j<fs->get_subdir_count();j++) { - if (efsd->name<fs->get_subdir(j)->get_name()) - break; - idx2++; - } + if (efsd->name<fs->get_subdir(j)->get_name()) + break; + idx2++; + } - if (idx2==fs->get_subdir_count()) - fs->subdirs.push_back(efsd); - else - fs->subdirs.insert(idx2,efsd); - fs=efsd; - } else { + if (idx2==fs->get_subdir_count()) + fs->subdirs.push_back(efsd); + else + fs->subdirs.insert(idx2,efsd); + fs=efsd; + } else { - fs=fs->get_subdir(idx); + fs=fs->get_subdir(idx); + } } - } - int cpos=-1; - for(int i=0;i<fs->files.size();i++) { + int cpos=-1; + for(int i=0;i<fs->files.size();i++) { - if (fs->files[i].file==file) { - cpos=i; - break; + if (fs->files[i]->file==file) { + cpos=i; + break; + } } - } r_file_pos=cpos; *r_d=fs; - if (cpos!=-1) { + if (cpos!=-1) { - return true; - } else { + return true; + } else { - return false; - } + return false; + } } @@ -967,7 +1109,7 @@ String EditorFileSystem::get_file_type(const String& p_file) const { } - return fs->files[cpos].type; + return fs->files[cpos]->type; } @@ -1024,16 +1166,16 @@ EditorFileSystemDirectory *EditorFileSystem::get_path(const String& p_path) { void EditorFileSystem::_resource_saved(const String& p_path){ - print_line("resource saved: "+p_path); + //print_line("resource saved: "+p_path); EditorFileSystem::get_singleton()->update_file(p_path); } String EditorFileSystem::_find_first_from_source(EditorFileSystemDirectory* p_dir,const String &p_src) const { for(int i=0;i<p_dir->files.size();i++) { - for(int j=0;j<p_dir->files[i].meta.sources.size();j++) { + for(int j=0;j<p_dir->files[i]->meta.sources.size();j++) { - if (p_dir->files[i].meta.sources[j].path==p_src) + if (p_dir->files[i]->meta.sources[j].path==p_src) return p_dir->get_file_path(i); } } @@ -1070,6 +1212,7 @@ void EditorFileSystem::update_file(const String& p_file) { if (!FileAccess::exists(p_file)) { //was removed + memdelete( fs->files[cpos] ); fs->files.remove(cpos); call_deferred("emit_signal","filesystem_changed"); //update later return; @@ -1083,13 +1226,13 @@ void EditorFileSystem::update_file(const String& p_file) { int idx=0; for(int i=0;i<fs->files.size();i++) { - if (p_file<fs->files[i].file) + if (p_file<fs->files[i]->file) break; idx++; } - EditorFileSystemDirectory::FileInfo fi; - fi.file=p_file.get_file(); + EditorFileSystemDirectory::FileInfo *fi = memnew( EditorFileSystemDirectory::FileInfo ); + fi->file=p_file.get_file(); if (idx==fs->files.size()) { fs->files.push_back(fi); @@ -1102,10 +1245,10 @@ void EditorFileSystem::update_file(const String& p_file) { } - print_line("UPDATING: "+p_file); - fs->files[cpos].type=type; - fs->files[cpos].modified_time=FileAccess::get_modified_time(p_file); - fs->files[cpos].meta=_get_meta(p_file); + //print_line("UPDATING: "+p_file); + fs->files[cpos]->type=type; + fs->files[cpos]->modified_time=FileAccess::get_modified_time(p_file); + fs->files[cpos]->meta=_get_meta(p_file); call_deferred("emit_signal","filesystem_changed"); //update later @@ -1128,15 +1271,22 @@ EditorFileSystem::EditorFileSystem() { thread = NULL; scanning=false; - scandir=NULL; - rootdir=NULL; use_threads=true; thread_sources=NULL; + new_filesystem=NULL; scanning_sources=false; ResourceSaver::set_save_callback(_resource_saved); + List<String> extensionsl; + ResourceLoader::get_recognized_extensions_for_type("",&extensionsl); + for(List<String>::Element *E = extensionsl.front();E;E=E->next()) { + + valid_extensions.insert(E->get()); + } + + scan_total=0; } EditorFileSystem::~EditorFileSystem() { diff --git a/tools/editor/editor_file_system.h b/tools/editor/editor_file_system.h index 0db2dc150e..d11fa0cfb1 100644 --- a/tools/editor/editor_file_system.h +++ b/tools/editor/editor_file_system.h @@ -42,6 +42,8 @@ class EditorFileSystemDirectory : public Object { OBJ_TYPE( EditorFileSystemDirectory,Object ); String name; + uint64_t modified_time; + bool verified; //used for checking changes EditorFileSystemDirectory *parent; Vector<EditorFileSystemDirectory*> subdirs; @@ -68,11 +70,20 @@ class EditorFileSystemDirectory : public Object { String file; StringName type; uint64_t modified_time; - ImportMeta meta; + bool verified; //used for checking changes + + }; + + struct FileInfoSort { + bool operator()(const FileInfo *p_a,const FileInfo *p_b) const { + return p_a->file<p_b->file; + } }; - Vector<FileInfo> files; + void sort_files(); + + Vector<FileInfo*> files; static void _bind_methods(); @@ -96,6 +107,9 @@ public: EditorFileSystemDirectory *get_parent(); + int find_file_index(const String& p_file) const; + int find_dir_index(const String& p_dir) const; + EditorFileSystemDirectory(); ~EditorFileSystemDirectory(); @@ -107,45 +121,47 @@ class EditorFileSystem : public Node { _THREAD_SAFE_CLASS_ - struct SceneItem { + + struct ItemAction { + + enum Action { + ACTION_NONE, + ACTION_DIR_ADD, + ACTION_DIR_REMOVE, + ACTION_FILE_ADD, + ACTION_FILE_REMOVE, + ACTION_FILE_SOURCES_CHANGED + }; + + Action action; + EditorFileSystemDirectory *dir; String file; - String path; - String type; - uint64_t modified_time; - EditorFileSystemDirectory::ImportMeta meta; - }; + EditorFileSystemDirectory *new_dir; + EditorFileSystemDirectory::FileInfo *new_file; - struct DirItem { + ItemAction() { action=ACTION_NONE; dir=NULL; new_dir=NULL; new_file=NULL; } - uint64_t modified_time; - String path; - String name; - Vector<DirItem*> dirs; - Vector<SceneItem*> files; - ~DirItem(); }; - float total; bool use_threads; Thread *thread; static void _thread_func(void *_userdata); - DirItem *scandir; - DirItem *rootdir; + EditorFileSystemDirectory *new_filesystem; bool abort_scan; bool scanning; + float scan_total; - EditorFileSystemDirectory* _update_tree(DirItem *p_item); - void _scan_scenes(); - void _load_type_cache(); + void _scan_filesystem(); EditorFileSystemDirectory *filesystem; static EditorFileSystem *singleton; + /* Used for reading the filesystem cache file */ struct FileCache { String type; @@ -154,34 +170,43 @@ class EditorFileSystem : public Node { Vector<String> deps; }; - struct DirCache { + HashMap<String,FileCache> file_cache; - uint64_t modification_time; - Set<String> files; - Set<String> subdirs; - }; + struct ScanProgress { + float low; + float hi; + mutable EditorProgressBG *progress; + void update(int p_current,int p_total) const; + ScanProgress get_sub(int p_current,int p_total) const; + }; static EditorFileSystemDirectory::ImportMeta _get_meta(const String& p_path); - bool _check_meta_sources(EditorFileSystemDirectory::ImportMeta & p_meta,EditorProgressBG *ep=NULL); + bool _check_meta_sources(EditorFileSystemDirectory::ImportMeta & p_meta); - DirItem* _scan_dir(DirAccess *da,Set<String> &extensions,String p_name,float p_from,float p_range,const String& p_path,HashMap<String,FileCache> &file_cache,HashMap<String,DirCache> &dir_cache,EditorProgressBG& p_prog); - void _save_type_cache_fs(DirItem *p_dir,FileAccess *p_file); + void _save_filesystem_cache(EditorFileSystemDirectory *p_dir,FileAccess *p_file); bool _find_file(const String& p_file,EditorFileSystemDirectory ** r_d, int &r_file_pos) const; - void _scan_sources(EditorFileSystemDirectory *p_dir,EditorProgressBG *ep); + void _scan_fs_changes(EditorFileSystemDirectory *p_dir, const ScanProgress &p_progress); int md_count; + Set<String> valid_extensions; + + void _scan_new_dir(EditorFileSystemDirectory *p_dir,DirAccess *da,const ScanProgress& p_progress); Thread *thread_sources; bool scanning_sources; bool scanning_sources_done; - int ss_amount; + static void _thread_func_sources(void *_userdata); + List<String> sources_changed; + List<ItemAction> scan_actions; + + bool _update_scan_actions(); static void _resource_saved(const String& p_path); String _find_first_from_source(EditorFileSystemDirectory* p_dir,const String &p_src) const; diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index 2d9decaaf9..2e67bb66fe 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -415,7 +415,7 @@ void EditorNode::_rebuild_import_menu() { PopupMenu* p = import_menu->get_popup(); p->clear(); - p->add_item("Sub-Scene", FILE_IMPORT_SUBSCENE); + p->add_item("Node from scene", FILE_IMPORT_SUBSCENE); p->add_separator(); for (int i = 0; i < editor_import_export->get_import_plugin_count(); i++) { p->add_item(editor_import_export->get_import_plugin(i)->get_visible_name(), IMPORT_PLUGIN_BASE + i); @@ -520,7 +520,7 @@ void EditorNode::save_resource_as(const Ref<Resource>& p_resource) { List<String> preferred; for(int i=0;i<extensions.size();i++) { - if (p_resource->is_type("Script") && extensions[i]=="tres" || extensions[i]=="res" || extensions[i]=="xml") { + if (p_resource->is_type("Script") && (extensions[i]=="tres" || extensions[i]=="res" || extensions[i]=="xml")) { //this serves no purpose and confused people continue; } @@ -1321,10 +1321,18 @@ void EditorNode::_dialog_action(String p_file) { case FILE_EXPORT_TILESET: { Ref<TileSet> ml; - if (file_export_lib_merge->is_pressed() && FileAccess::exists(p_file)) { + if (FileAccess::exists(p_file)) { ml=ResourceLoader::load(p_file,"TileSet"); - if (ml.is_null()) { + if (!file_export_lib_merge->is_pressed()) { + ml->clear(); + } + + } + + if (ml.is_null()) { + + if (file_export_lib_merge->is_pressed()) { current_option=-1; //accept->get_cancel()->hide(); accept->get_ok()->set_text("I see.."); @@ -1333,9 +1341,6 @@ void EditorNode::_dialog_action(String p_file) { return; } - } - - if (ml.is_null()) { ml = Ref<TileSet>( memnew( TileSet )); } @@ -1454,8 +1459,13 @@ void EditorNode::_dialog_action(String p_file) { Ref<ConfigFile> config; config.instance(); Error err = config->load(EditorSettings::get_singleton()->get_settings_path().plus_file("editor_layouts.cfg")); - if (err!=OK && err!=ERR_FILE_NOT_FOUND) { - return; //no config + + if (err==ERR_CANT_OPEN) { + config.instance(); // new config + } else if (err!=OK) { + confirm_error->set_text("Error trying to save layout!"); + confirm_error->popup_centered_minsize(); + return; } _save_docks_to_config(config, p_file); @@ -1480,11 +1490,8 @@ void EditorNode::_dialog_action(String p_file) { Ref<ConfigFile> config; config.instance(); Error err = config->load(EditorSettings::get_singleton()->get_settings_path().plus_file("editor_layouts.cfg")); - if (err!=OK) { - return; //no config - } - if (!config->has_section(p_file)) { + if (err!=OK || !config->has_section(p_file)) { confirm_error->set_text("Layout name not found!"); confirm_error->popup_centered_minsize(); return; @@ -2074,21 +2081,21 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { } break; case FILE_QUICK_OPEN_SCENE: { - quick_open->popup("PackedScene"); + quick_open->popup("PackedScene", true); quick_open->set_title("Quick Open Scene.."); } break; case FILE_QUICK_OPEN_SCRIPT: { - quick_open->popup("Script"); + quick_open->popup("Script", true); quick_open->set_title("Quick Open Script.."); } break; case FILE_QUICK_OPEN_FILE: { - quick_open->popup("Resource",false,true); + quick_open->popup("Resource", false, true); quick_open->set_title("Quick Search File.."); } break; @@ -2106,7 +2113,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { } break; case FILE_CLOSE: { - if (!p_confirmed) { + if (!p_confirmed && unsaved_cache) { confirmation->get_ok()->set_text("Yes"); //confirmation->get_cancel()->show(); confirmation->set_text("Close scene? (Unsaved changes will be lost)"); @@ -3533,11 +3540,13 @@ Error EditorNode::load_scene(const String& p_scene, bool p_ignore_broken_deps,bo } - for(int i=0;i<editor_data.get_edited_scene_count();i++) { + if(!p_set_inherited) { + for(int i=0;i<editor_data.get_edited_scene_count();i++) { - if (editor_data.get_scene_path(i)==p_scene) { - _scene_tab_changed(i); - return OK; + if (editor_data.get_scene_path(i)==p_scene) { + _scene_tab_changed(i); + return OK; + } } } @@ -3822,7 +3831,6 @@ void EditorNode::animation_editor_make_visible(bool p_visible) { } animation_editor->set_keying(p_visible); - _update_keying(); } @@ -3923,19 +3931,26 @@ void EditorNode::hide_animation_player_editors() { emit_signal("hide_animation_player_editors"); } -void EditorNode::_quick_opened(const String& p_resource) { +void EditorNode::_quick_opened() { if (current_option==FILE_QUICK_OPEN_FILE) { - scenes_dock->open(p_resource); + String res_path = quick_open->get_selected(); + + scenes_dock->open(res_path); return; } - if (quick_open->get_base_type()=="PackedScene") { - open_request(p_resource); - } else { - load_resource(p_resource); - } + Vector<String> files = quick_open->get_selected_files(); + + for (int i = 0; i < files.size(); i++) { + String res_path = files[i]; + if (quick_open->get_base_type()=="PackedScene") { + open_request(res_path); + } else { + load_resource(res_path); + } + } } void EditorNode::_quick_run(const String& p_resource) { @@ -4715,11 +4730,13 @@ void EditorNode::_scene_tab_changed(int p_tab) { editor_data.get_undo_redo().add_do_method(this,"set_current_version",unsaved?saved_version:0); editor_data.get_undo_redo().add_do_method(this,"set_current_scene",p_tab); editor_data.get_undo_redo().add_do_method(scene_tabs,"set_current_tab",p_tab); + editor_data.get_undo_redo().add_do_method(scene_tabs,"ensure_tab_visible",p_tab); editor_data.get_undo_redo().add_do_method(this,"set_current_version",next_scene_version==0?editor_data.get_undo_redo().get_version()+1:next_scene_version); editor_data.get_undo_redo().add_undo_method(this,"set_current_version",next_scene_version); editor_data.get_undo_redo().add_undo_method(this,"set_current_scene",editor_data.get_edited_scene()); editor_data.get_undo_redo().add_undo_method(scene_tabs,"set_current_tab",editor_data.get_edited_scene()); + editor_data.get_undo_redo().add_undo_method(scene_tabs,"ensure_tab_visible",p_tab,editor_data.get_edited_scene()); editor_data.get_undo_redo().add_undo_method(this,"set_current_version",saved_version); editor_data.get_undo_redo().commit_action(); @@ -5187,7 +5204,11 @@ EditorNode::EditorNode() { p->add_separator(); p->add_item("Revert Scene",EDIT_REVERT); p->add_separator(); +#ifdef OSX_ENABLED p->add_item("Quit to Project List",RUN_PROJECT_MANAGER,KEY_MASK_SHIFT+KEY_MASK_ALT+KEY_Q); +#else + p->add_item("Quit to Project List",RUN_PROJECT_MANAGER,KEY_MASK_SHIFT+KEY_MASK_CTRL+KEY_Q); +#endif p->add_item("Quit",FILE_QUIT,KEY_MASK_CMD+KEY_Q); recent_scenes = memnew( PopupMenu ); diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h index 2228e0948b..ca230a4d5e 100644 --- a/tools/editor/editor_node.h +++ b/tools/editor/editor_node.h @@ -440,7 +440,7 @@ class EditorNode : public Node { void _update_keying(); void _hide_top_editors(); - void _quick_opened(const String& p_resource); + void _quick_opened(); void _quick_run(const String& p_resource); void _run(bool p_current=false, const String &p_custom=""); diff --git a/tools/editor/plugins/canvas_item_editor_plugin.cpp b/tools/editor/plugins/canvas_item_editor_plugin.cpp index f3cf53cbdf..56ed95fb16 100644 --- a/tools/editor/plugins/canvas_item_editor_plugin.cpp +++ b/tools/editor/plugins/canvas_item_editor_plugin.cpp @@ -405,9 +405,9 @@ void CanvasItemEditor::_node_removed(Node *p_node) { #endif } -void CanvasItemEditor::_keying_changed(bool p_changed) { +void CanvasItemEditor::_keying_changed() { - if (p_changed) + if (editor->get_animation_editor()->has_keying()) animation_hb->show(); else animation_hb->hide(); @@ -1541,6 +1541,7 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent& p_event) { continue; } + dfrom = drag_point_from; dto = snap_point(dto - (drag == DRAG_ALL ? drag_from - drag_point_from : Vector2(0, 0)), drag_point_from); @@ -1548,30 +1549,35 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent& p_event) { canvas_item->get_global_transform_with_canvas().affine_inverse().xform(dto) - canvas_item->get_global_transform_with_canvas().affine_inverse().xform(dfrom); - Rect2 local_rect = canvas_item->get_item_rect(); - - if (false && drag!=DRAG_ALL && m.mod.alt) { - float aspect = local_rect.size.get_aspect(); - if (aspect!=0) { - if (ABS(drag_vector.x) > ABS(drag_vector.y)) { - - drag_vector.y = ABS(drag_vector.x)/aspect * SGN(drag_vector.y); - } else { - - drag_vector.x = ABS(drag_vector.y)*aspect * SGN(drag_vector.x); - } - } - } - - - Vector2 begin=local_rect.pos; Vector2 end=local_rect.pos+local_rect.size; Vector2 minsize = canvas_item->edit_get_minimum_size(); bool uniform = m.mod.shift; bool symmetric=m.mod.alt; + if (uniform) { + float aspect = local_rect.size.get_aspect(); + switch(drag) { + case DRAG_BOTTOM_LEFT: + case DRAG_TOP_RIGHT: { + if (aspect > 1.0) { // width > height, take x as reference + drag_vector.y = -drag_vector.x/aspect; + } else { // height > width, take y as reference + drag_vector.x = -drag_vector.y*aspect; + } + } break; + case DRAG_BOTTOM_RIGHT: + case DRAG_TOP_LEFT: { + if (aspect > 1.0) { // width > height, take x as reference + drag_vector.y = drag_vector.x/aspect; + } else { // height > width, take y as reference + drag_vector.x = drag_vector.y*aspect; + } + } break; + default: {} + } + } switch(drag) { case DRAG_ALL: { @@ -1590,19 +1596,11 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent& p_event) { } break; case DRAG_BOTTOM_RIGHT: { - if (uniform) { - drag_vector.y=drag_vector.x; - minsize.y=minsize.x; - } incend(begin.x,end.x,drag_vector.x,minsize.x,symmetric); incend(begin.y,end.y,drag_vector.y,minsize.y,symmetric); - } break; + } break; case DRAG_TOP_LEFT: { - if (uniform) { - drag_vector.y=drag_vector.x; - minsize.y=minsize.x; - } incbeg(begin.x,end.x,drag_vector.x,minsize.x,symmetric); incbeg(begin.y,end.y,drag_vector.y,minsize.y,symmetric); } break; @@ -1618,20 +1616,12 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent& p_event) { } break; case DRAG_TOP_RIGHT: { - if (uniform) { - drag_vector.x=-drag_vector.y; - minsize.x=minsize.y; - } incbeg(begin.y,end.y,drag_vector.y,minsize.y,symmetric); incend(begin.x,end.x,drag_vector.x,minsize.x,symmetric); } break; case DRAG_BOTTOM_LEFT: { - if (uniform) { - drag_vector.x=-drag_vector.y; - minsize.x=minsize.y; - } incbeg(begin.x,end.x,drag_vector.x,minsize.x,symmetric); incend(begin.y,end.y,drag_vector.y,minsize.y,symmetric); } break; diff --git a/tools/editor/plugins/canvas_item_editor_plugin.h b/tools/editor/plugins/canvas_item_editor_plugin.h index 91cfab9863..df24734fd7 100644 --- a/tools/editor/plugins/canvas_item_editor_plugin.h +++ b/tools/editor/plugins/canvas_item_editor_plugin.h @@ -344,7 +344,7 @@ class CanvasItemEditor : public VBoxContainer { CanvasItem *get_single_item(); int get_item_count(); - void _keying_changed(bool p_changed); + void _keying_changed(); void _unhandled_key_input(const InputEvent& p_ev); diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp index ded27d1fef..fc0d68b2f8 100644 --- a/tools/editor/plugins/script_editor_plugin.cpp +++ b/tools/editor/plugins/script_editor_plugin.cpp @@ -327,7 +327,11 @@ void ScriptTextEditor::_load_theme_settings() { for(List<StringName>::Element *E=types.front();E;E=E->next()) { - get_text_edit()->add_keyword_color(E->get(),type_color); + String n = E->get(); + if (n.begins_with("_")) + n = n.substr(1, n.length()); + + get_text_edit()->add_keyword_color(n,type_color); } //colorize comments @@ -2413,7 +2417,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { debug_menu->get_popup()->add_item("Continue",DEBUG_CONTINUE); debug_menu->get_popup()->add_separator(); debug_menu->get_popup()->add_check_item("Show Debugger",DEBUG_SHOW); - debug_menu->get_popup()->add_check_item("Keep Debuger Open",DEBUG_SHOW_KEEP_OPEN); + debug_menu->get_popup()->add_check_item("Keep Debugger Open",DEBUG_SHOW_KEEP_OPEN); debug_menu->get_popup()->connect("item_pressed", this,"_menu_option"); debug_menu->get_popup()->set_item_disabled( debug_menu->get_popup()->get_item_index(DEBUG_NEXT), true); diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp index f536077f9a..0fac1346fc 100644 --- a/tools/editor/plugins/spatial_editor_plugin.cpp +++ b/tools/editor/plugins/spatial_editor_plugin.cpp @@ -1617,6 +1617,8 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { case InputEvent::KEY: { const InputEventKey &k = p_event.key; + if (!k.pressed) + break; switch(k.scancode) { case KEY_S: { @@ -1677,7 +1679,8 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { } break; case KEY_KP_5: { - orthogonal = !orthogonal; + + //orthogonal = !orthogonal; _menu_option(orthogonal?VIEW_PERSPECTIVE:VIEW_ORTHOGONAL); _update_name(); @@ -3501,13 +3504,7 @@ void SpatialEditor::_instance_scene() { undo_redo->commit_action(); #endif } -/* -void SpatialEditor::_update_selection() { - - -} -*/ void SpatialEditor::_unhandled_key_input(InputEvent p_event) { if (!is_visible()) @@ -3712,7 +3709,6 @@ void SpatialEditor::_bind_methods() { ObjectTypeDB::bind_method("_menu_item_pressed",&SpatialEditor::_menu_item_pressed); ObjectTypeDB::bind_method("_xform_dialog_action",&SpatialEditor::_xform_dialog_action); ObjectTypeDB::bind_method("_instance_scene",&SpatialEditor::_instance_scene); -// ObjectTypeDB::bind_method("_update_selection",&SpatialEditor::_update_selection); ObjectTypeDB::bind_method("_get_editor_data",&SpatialEditor::_get_editor_data); ObjectTypeDB::bind_method("_request_gizmo",&SpatialEditor::_request_gizmo); ObjectTypeDB::bind_method("_default_light_angle_input",&SpatialEditor::_default_light_angle_input); @@ -3814,7 +3810,6 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { editor=p_editor; editor_selection=editor->get_editor_selection(); editor_selection->add_editor_plugin(this); - editor_selection->connect("selection_changed",this,"_update_selection"); snap_enabled=false; tool_mode = TOOL_MODE_SELECT; diff --git a/tools/editor/plugins/spatial_editor_plugin.h b/tools/editor/plugins/spatial_editor_plugin.h index e8856d5a8f..b0e366b140 100644 --- a/tools/editor/plugins/spatial_editor_plugin.h +++ b/tools/editor/plugins/spatial_editor_plugin.h @@ -137,7 +137,6 @@ private: Vector3 _get_screen_to_space(const Vector3& p_vector3); void _select_region(); - void _update_selection(); bool _gizmo_select(const Vector2& p_screenpos,bool p_hilite_only=false); float get_znear() const; diff --git a/tools/editor/plugins/sprite_frames_editor_plugin.cpp b/tools/editor/plugins/sprite_frames_editor_plugin.cpp index 7b8f1535be..048df2d682 100644 --- a/tools/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/tools/editor/plugins/sprite_frames_editor_plugin.cpp @@ -338,7 +338,6 @@ void SpriteFramesEditor::_update_library() { TreeItem *ti = tree->create_item(root); ti->set_cell_mode(0,TreeItem::CELL_MODE_STRING); - ti->set_editable(0,true); ti->set_selectable(0,true); if (frames->get_frame(i).is_null()) { @@ -346,7 +345,7 @@ void SpriteFramesEditor::_update_library() { ti->set_text(0,"Frame "+itos(i)+" (empty)"); } else { - ti->set_text(0,"Frame "+itos(i)); + ti->set_text(0,"Frame "+itos(i)+" ("+frames->get_frame(i)->get_name()+")"); ti->set_icon(0,frames->get_frame(i)); } if (frames->get_frame(i).is_valid()) diff --git a/tools/editor/plugins/sprite_region_editor_plugin.cpp b/tools/editor/plugins/sprite_region_editor_plugin.cpp index 2653973226..725de19dd7 100644 --- a/tools/editor/plugins/sprite_region_editor_plugin.cpp +++ b/tools/editor/plugins/sprite_region_editor_plugin.cpp @@ -411,6 +411,7 @@ SpriteRegionEditor::SpriteRegionEditor(EditorNode* p_editor) snap_step=Vector2(10,10); use_snap=false; snap_show_grid=false; + drag=false; add_child( memnew( VSeparator )); edit_node = memnew( ToolButton ); @@ -449,7 +450,7 @@ SpriteRegionEditor::SpriteRegionEditor(EditorNode* p_editor) hb_tools->add_child( memnew( VSeparator )); hb_tools->add_child( memnew( Label("Grid Offset:") ) ); - SpinBox *sb_off_x = memnew( SpinBox ); + sb_off_x = memnew( SpinBox ); sb_off_x->set_min(-256); sb_off_x->set_max(256); sb_off_x->set_step(1); @@ -458,7 +459,7 @@ SpriteRegionEditor::SpriteRegionEditor(EditorNode* p_editor) sb_off_x->connect("value_changed", this, "_set_snap_off_x"); hb_tools->add_child(sb_off_x); - SpinBox *sb_off_y = memnew( SpinBox ); + sb_off_y = memnew( SpinBox ); sb_off_y->set_min(-256); sb_off_y->set_max(256); sb_off_y->set_step(1); @@ -470,7 +471,7 @@ SpriteRegionEditor::SpriteRegionEditor(EditorNode* p_editor) hb_tools->add_child( memnew( VSeparator )); hb_tools->add_child( memnew( Label("Grid Step:") ) ); - SpinBox *sb_step_x = memnew( SpinBox ); + sb_step_x = memnew( SpinBox ); sb_step_x->set_min(-256); sb_step_x->set_max(256); sb_step_x->set_step(1); @@ -479,7 +480,7 @@ SpriteRegionEditor::SpriteRegionEditor(EditorNode* p_editor) sb_step_x->connect("value_changed", this, "_set_snap_step_x"); hb_tools->add_child(sb_step_x); - SpinBox *sb_step_y = memnew( SpinBox ); + sb_step_y = memnew( SpinBox ); sb_step_y->set_min(-256); sb_step_y->set_max(256); sb_step_y->set_step(1); @@ -488,8 +489,6 @@ SpriteRegionEditor::SpriteRegionEditor(EditorNode* p_editor) sb_step_y->connect("value_changed", this, "_set_snap_step_y"); hb_tools->add_child(sb_step_y); -// MARIANOGNU::TODO: Add more tools? - HBoxContainer *main_hb = memnew( HBoxContainer ); main_vb->add_child(main_hb); edit_draw = memnew( Control ); @@ -554,6 +553,50 @@ void SpriteRegionEditorPlugin::make_visible(bool p_visible) } } + +Dictionary SpriteRegionEditorPlugin::get_state() const { + + Dictionary state; + state["zoom"]=region_editor->zoom->get_val(); + state["snap_offset"]=region_editor->snap_offset; + state["snap_step"]=region_editor->snap_step; + state["use_snap"]=region_editor->use_snap; + state["snap_show_grid"]=region_editor->snap_show_grid; + return state; +} + +void SpriteRegionEditorPlugin::set_state(const Dictionary& p_state){ + + Dictionary state=p_state; + if (state.has("zoom")) { + region_editor->zoom->set_val(p_state["zoom"]); + } + + if (state.has("snap_step")) { + Vector2 s = state["snap_step"]; + region_editor->sb_step_x->set_val(s.x); + region_editor->sb_step_y->set_val(s.y); + region_editor->snap_step = s; + } + + if (state.has("snap_offset")) { + Vector2 ofs = state["snap_offset"]; + region_editor->sb_off_x->set_val(ofs.x); + region_editor->sb_off_y->set_val(ofs.y); + region_editor->snap_offset = ofs; + } + + if (state.has("use_snap")) { + region_editor->use_snap=state["use_snap"]; + region_editor->b_snap_enable->set_pressed(state["use_snap"]); + } + + if (state.has("snap_show_grid")) { + region_editor->snap_show_grid=state["snap_show_grid"]; + region_editor->b_snap_grid->set_pressed(state["snap_show_grid"]); + } +} + SpriteRegionEditorPlugin::SpriteRegionEditorPlugin(EditorNode *p_node) { editor = p_node; diff --git a/tools/editor/plugins/sprite_region_editor_plugin.h b/tools/editor/plugins/sprite_region_editor_plugin.h index fafa2e119b..47cb210863 100644 --- a/tools/editor/plugins/sprite_region_editor_plugin.h +++ b/tools/editor/plugins/sprite_region_editor_plugin.h @@ -41,6 +41,8 @@ class SpriteRegionEditor : public HBoxContainer { OBJ_TYPE(SpriteRegionEditor, HBoxContainer ); + friend class SpriteRegionEditorPlugin; + ToolButton *edit_node; // Button *use_region; ToolButton *b_snap_enable; @@ -48,6 +50,10 @@ class SpriteRegionEditor : public HBoxContainer { TextureFrame *icon_zoom; HSlider *zoom; SpinBox *zoom_value; + SpinBox *sb_step_y; + SpinBox *sb_step_x; + SpinBox *sb_off_y; + SpinBox *sb_off_x; Control *edit_draw; VScrollBar *vscroll; @@ -113,11 +119,13 @@ class SpriteRegionEditorPlugin : public EditorPlugin EditorNode *editor; public: - virtual String get_name() const { return "Sprite"; } + virtual String get_name() const { return "SpriteRegion"; } bool has_main_screen() const { return false; } virtual void edit(Object *p_node); virtual bool handles(Object *p_node) const; virtual void make_visible(bool p_visible); + void set_state(const Dictionary &p_state); + Dictionary get_state() const; SpriteRegionEditorPlugin(EditorNode *p_node); }; diff --git a/tools/editor/project_settings.cpp b/tools/editor/project_settings.cpp index b61fcfa780..6c5e18ec9a 100644 --- a/tools/editor/project_settings.cpp +++ b/tools/editor/project_settings.cpp @@ -530,7 +530,7 @@ void ProjectSettings::_item_selected() { return; if (!ti->get_parent()) return; - category->set_text(ti->get_parent()->get_text(0)); + category->set_text(globals_editor->get_current_section()); property->set_text(ti->get_text(0)); popup_platform->set_disabled(false); @@ -569,7 +569,8 @@ void ProjectSettings::_item_add() { String name = catname+"/"+propname; Globals::get_singleton()->set(name,value); - globals_editor->get_property_editor()->update_tree(); + globals_editor->edit(NULL); + globals_editor->edit(Globals::get_singleton()); } void ProjectSettings::_item_del() { diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp index fc5fce1d47..9743dc7202 100644 --- a/tools/editor/property_editor.cpp +++ b/tools/editor/property_editor.cpp @@ -727,7 +727,17 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty RES cb=EditorSettings::get_singleton()->get_resource_clipboard(); - bool paste_valid=cb.is_valid() && (hint_text=="" || ObjectTypeDB::is_type(cb->get_type(),hint_text)); + bool paste_valid=false; + if (cb.is_valid()) { + if (hint_text=="") + paste_valid=true; + else + for (int i = 0; i < hint_text.get_slice_count(",");i++) + if (ObjectTypeDB::is_type(cb->get_type(),hint_text.get_slice(",",i))) { + paste_valid=true; + break; + } + } if (!RES(v).is_null() || paste_valid) { menu->add_separator(); @@ -3812,6 +3822,11 @@ void SectionedPropertyEditor::_section_selected(int p_which) { filter->set_section( sections->get_item_metadata(p_which) ); } +String SectionedPropertyEditor::get_current_section() const { + + return sections->get_item_metadata( sections->get_current() ); +} + String SectionedPropertyEditor::get_full_item_path(const String& p_item) { String base = sections->get_item_metadata( sections->get_current() ); diff --git a/tools/editor/property_editor.h b/tools/editor/property_editor.h index 4f03c0381f..63ad090901 100644 --- a/tools/editor/property_editor.h +++ b/tools/editor/property_editor.h @@ -270,6 +270,7 @@ public: PropertyEditor *get_property_editor(); void edit(Object* p_object); String get_full_item_path(const String& p_item); + String get_current_section() const; SectionedPropertyEditor(); ~SectionedPropertyEditor(); diff --git a/tools/editor/quick_open.cpp b/tools/editor/quick_open.cpp index bfbcb739ac..22f4a40c83 100644 --- a/tools/editor/quick_open.cpp +++ b/tools/editor/quick_open.cpp @@ -30,7 +30,7 @@ #include "os/keyboard.h" -void EditorQuickOpen::popup(const StringName &p_base, bool p_dontclear, bool p_add_dirs) { +void EditorQuickOpen::popup(const StringName &p_base, bool p_enable_multi, bool p_add_dirs, bool p_dontclear) { add_directories=p_add_dirs; popup_centered_ratio(0.6); @@ -38,13 +38,38 @@ void EditorQuickOpen::popup(const StringName &p_base, bool p_dontclear, bool p_a search_box->select_all(); else search_box->clear(); + if (p_enable_multi) + search_options->set_select_mode(Tree::SELECT_MULTI); + else + search_options->set_select_mode(Tree::SELECT_SINGLE); search_box->grab_focus(); base_type=p_base; _update_search(); +} + +String EditorQuickOpen::get_selected() const { + TreeItem *ti = search_options->get_selected(); + if (!ti) + return String(); + return "res://" + ti->get_text(0); } +Vector<String> EditorQuickOpen::get_selected_files() const { + + Vector<String> files; + + TreeItem* item = search_options->get_next_selected(search_options->get_root()); + while (item) { + + files.push_back("res://"+item->get_text(0)); + + item = search_options->get_next_selected(item); + } + + return files; +} void EditorQuickOpen::_text_changed(const String& p_newtext) { @@ -132,7 +157,7 @@ void EditorQuickOpen::_confirmed() { TreeItem *ti = search_options->get_selected(); if (!ti) return; - emit_signal("quick_open","res://"+ti->get_text(0)); + emit_signal("quick_open"); hide(); } @@ -156,7 +181,7 @@ void EditorQuickOpen::_bind_methods() { ObjectTypeDB::bind_method(_MD("_confirmed"),&EditorQuickOpen::_confirmed); ObjectTypeDB::bind_method(_MD("_sbox_input"),&EditorQuickOpen::_sbox_input); - ADD_SIGNAL(MethodInfo("quick_open",PropertyInfo(Variant::STRING,"respath"))); + ADD_SIGNAL(MethodInfo("quick_open")); } diff --git a/tools/editor/quick_open.h b/tools/editor/quick_open.h index 7f2091e5d1..520f7e569d 100644 --- a/tools/editor/quick_open.h +++ b/tools/editor/quick_open.h @@ -61,7 +61,10 @@ public: StringName get_base_type() const; - void popup(const StringName& p_base,bool p_dontclear=false,bool p_add_dirs=false); + String get_selected() const; + Vector<String> get_selected_files() const; + + void popup(const StringName& p_base,bool p_enable_multi=false,bool p_add_dirs=false,bool p_dontclear=false); EditorQuickOpen(); }; diff --git a/tools/editor/scenes_dock.cpp b/tools/editor/scenes_dock.cpp index cdc0bf0d25..5abc4992df 100644 --- a/tools/editor/scenes_dock.cpp +++ b/tools/editor/scenes_dock.cpp @@ -1254,6 +1254,8 @@ ScenesDock::ScenesDock(EditorNode *p_editor) { history_pos=0; tree_mode=true; + path="res://"; + } diff --git a/tools/editor/script_editor_debugger.cpp b/tools/editor/script_editor_debugger.cpp index fb821573f9..aad89d1272 100644 --- a/tools/editor/script_editor_debugger.cpp +++ b/tools/editor/script_editor_debugger.cpp @@ -569,8 +569,8 @@ void ScriptEditorDebugger::_notification(int p_what) { ppeer->set_stream_peer(connection); - show(); + emit_signal("show_debugger",true); dobreak->set_disabled(false); tabs->set_current_tab(0); @@ -770,6 +770,7 @@ void ScriptEditorDebugger::_stack_dump_frame_selected() { void ScriptEditorDebugger::_hide_request() { + hide(); emit_signal("show_debugger",false); } |