diff options
| author | Rémi Verschelde | 2017-02-27 23:14:55 +0100 |
|---|---|---|
| committer | GitHub | 2017-02-27 23:14:55 +0100 |
| commit | 8d7879e09a85aa8953f265366bb50d089a7c1d02 (patch) | |
| tree | 0fb75c00b257b16c6d650d084d0187507a88697c /tools/editor/filesystem_dock.cpp | |
| parent | 4c98d1791fcd85279a3417ab9ae732592bbc3cf1 (diff) | |
| parent | c02eb9a07a487350064c3d1a25e6b45a5a336cf0 (diff) | |
| download | godot-8d7879e09a85aa8953f265366bb50d089a7c1d02.tar.gz godot-8d7879e09a85aa8953f265366bb50d089a7c1d02.tar.zst godot-8d7879e09a85aa8953f265366bb50d089a7c1d02.zip | |
Merge pull request #7527 from RayKoopa/inspector_show_in_file_system
Add menu item in the inspector to show file in FileSystem
Diffstat (limited to 'tools/editor/filesystem_dock.cpp')
| -rw-r--r-- | tools/editor/filesystem_dock.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tools/editor/filesystem_dock.cpp b/tools/editor/filesystem_dock.cpp index f5e4ef661..bce0e9148 100644 --- a/tools/editor/filesystem_dock.cpp +++ b/tools/editor/filesystem_dock.cpp @@ -287,6 +287,39 @@ String FileSystemDock::get_current_path() const { return path; } +void FileSystemDock::navigate_to_path(const String& p_path) { + // If the path is a file, do not only go to the directory in the tree, also select the file in the file list. + String dir_path=""; + String file_name=""; + DirAccess* dirAccess=DirAccess::open("res://"); + if (dirAccess->file_exists(p_path)) { + dir_path=p_path.get_base_dir(); + file_name=p_path.get_file(); + } else if (dirAccess->dir_exists(p_path)) { + dir_path=p_path; + } else { + ERR_EXPLAIN(TTR("Cannot navigate to '" + p_path + "' as it has not been found in the file system!")); + ERR_FAIL(); + } + + path=dir_path; + _update_tree(); + tree->ensure_cursor_is_visible(); + + if (!file_name.empty()) { + _open_pressed(); // Seems to be the only way to get into the file view. This also pushes to history. + + // Focus the given file. + for (int i=0; i<files->get_item_count(); i++) { + if (files->get_item_text(i) == file_name) { + files->select(i,true); + files->ensure_current_is_visible(); + break; + } + } + } +} + void FileSystemDock::_thumbnail_done(const String& p_path,const Ref<Texture>& p_preview, const Variant& p_udata) { bool valid=false; |
