summaryrefslogtreecommitdiff
path: root/editor/filesystem_dock.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/filesystem_dock.cpp')
-rw-r--r--editor/filesystem_dock.cpp41
1 files changed, 24 insertions, 17 deletions
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index 949455ff98..8ead8d3982 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "filesystem_dock.h"
#include "editor_node.h"
@@ -76,7 +77,7 @@ bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory
return true;
}
-void FileSystemDock::_update_tree(bool keep_collapse_state) {
+void FileSystemDock::_update_tree(bool keep_collapse_state, bool p_uncollapse_root) {
Vector<String> uncollapsed_paths;
if (keep_collapse_state) {
@@ -128,6 +129,10 @@ void FileSystemDock::_update_tree(bool keep_collapse_state) {
ti->set_metadata(0, fave);
}
+ if (p_uncollapse_root) {
+ uncollapsed_paths.push_back("res://");
+ }
+
_create_tree(root, EditorFileSystem::get_singleton()->get_filesystem(), uncollapsed_paths);
tree->ensure_cursor_is_visible();
updating_tree = false;
@@ -153,6 +158,7 @@ void FileSystemDock::_notification(int p_what) {
} else {
tree->set_v_size_flags(SIZE_FILL);
+ button_tree->hide();
if (!tree->is_visible()) {
tree->show();
button_favorite->show();
@@ -162,7 +168,6 @@ void FileSystemDock::_notification(int p_what) {
if (!file_list_vb->is_visible()) {
file_list_vb->show();
- button_tree->hide();
_update_files(true);
}
}
@@ -203,7 +208,7 @@ void FileSystemDock::_notification(int p_what) {
if (EditorFileSystem::get_singleton()->is_scanning()) {
_set_scanning_mode();
} else {
- _update_tree(false);
+ _update_tree(false, true);
}
} break;
@@ -548,7 +553,7 @@ void FileSystemDock::_update_files(bool p_keep_selection) {
} else {
type_icon = get_icon("ImportFail", ei);
big_icon = file_thumbnail_broken;
- tooltip += TTR("\nStatus: Import of file failed. Please fix file and reimport manually.");
+ tooltip += "\n" + TTR("Status: Import of file failed. Please fix file and reimport manually.");
}
int item_index;
@@ -752,7 +757,7 @@ void FileSystemDock::_try_move_item(const FileOrFolder &p_item, const String &p_
return;
} else if (!p_item.is_file && new_path.begins_with(old_path)) {
//This check doesn't erroneously catch renaming to a longer name as folder paths always end with "/"
- EditorNode::get_singleton()->add_io_error(TTR("Cannot move a folder into itself.\n") + old_path + "\n");
+ EditorNode::get_singleton()->add_io_error(TTR("Cannot move a folder into itself.") + "\n" + old_path + "\n");
return;
}
@@ -772,7 +777,7 @@ void FileSystemDock::_try_move_item(const FileOrFolder &p_item, const String &p_
if (p_item.is_file && FileAccess::exists(old_path + ".import")) {
err = da->rename(old_path + ".import", new_path + ".import");
if (err != OK) {
- EditorNode::get_singleton()->add_io_error(TTR("Error moving:\n") + old_path + ".import\n");
+ EditorNode::get_singleton()->add_io_error(TTR("Error moving:") + "\n" + old_path + ".import\n");
}
}
@@ -796,7 +801,7 @@ void FileSystemDock::_try_move_item(const FileOrFolder &p_item, const String &p_
print_line(" Remap: " + changed_paths[i] + " -> " + p_renames[changed_paths[i]]);
}
} else {
- EditorNode::get_singleton()->add_io_error(TTR("Error moving:\n") + old_path + "\n");
+ EditorNode::get_singleton()->add_io_error(TTR("Error moving:") + "\n" + old_path + "\n");
}
memdelete(da);
}
@@ -813,23 +818,23 @@ void FileSystemDock::_try_duplicate_item(const FileOrFolder &p_item, const Strin
return;
} else if (!p_item.is_file && new_path.begins_with(old_path)) {
//This check doesn't erroneously catch renaming to a longer name as folder paths always end with "/"
- EditorNode::get_singleton()->add_io_error(TTR("Cannot move a folder into itself.\n") + old_path + "\n");
+ EditorNode::get_singleton()->add_io_error(TTR("Cannot move a folder into itself.") + "\n" + old_path + "\n");
return;
}
DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
print_line("Duplicating " + old_path + " -> " + new_path);
- Error err = da->copy(old_path, new_path);
+ Error err = p_item.is_file ? da->copy(old_path, new_path) : da->copy_dir(old_path, new_path);
if (err == OK) {
//Move/Rename any corresponding import settings too
if (p_item.is_file && FileAccess::exists(old_path + ".import")) {
err = da->copy(old_path + ".import", new_path + ".import");
if (err != OK) {
- EditorNode::get_singleton()->add_io_error(TTR("Error duplicating:\n") + old_path + ".import\n");
+ EditorNode::get_singleton()->add_io_error(TTR("Error duplicating:") + "\n" + old_path + ".import\n");
}
}
} else {
- EditorNode::get_singleton()->add_io_error(TTR("Error duplicating:\n") + old_path + "\n");
+ EditorNode::get_singleton()->add_io_error(TTR("Error duplicating:") + "\n" + old_path + "\n");
}
memdelete(da);
}
@@ -901,7 +906,7 @@ void FileSystemDock::_update_dependencies_after_move(const Map<String, String> &
if (ResourceLoader::get_resource_type(file) == "PackedScene")
editor->reload_scene(file);
} else {
- EditorNode::get_singleton()->add_io_error(TTR("Unable to update dependencies:\n") + remaps[i] + "\n");
+ EditorNode::get_singleton()->add_io_error(TTR("Unable to update dependencies:") + "\n" + remaps[i] + "\n");
}
}
}
@@ -980,10 +985,12 @@ void FileSystemDock::_duplicate_operation_confirm() {
return;
}
- String old_path = to_duplicate.path.ends_with("/") ? to_duplicate.path.substr(0, to_duplicate.path.length() - 1) : to_rename.path;
- String new_path = old_path.get_base_dir().plus_file(new_name);
- if (old_path == new_path) {
- return;
+ String new_path;
+ String base_dir = to_duplicate.path.get_base_dir();
+ if (to_duplicate.is_file) {
+ new_path = base_dir.plus_file(new_name);
+ } else {
+ new_path = base_dir.substr(0, base_dir.find_last("/")) + "/" + new_name;
}
//Present a more user friendly warning for name conflict
@@ -995,7 +1002,7 @@ void FileSystemDock::_duplicate_operation_confirm() {
}
memdelete(da);
- _try_duplicate_item(to_duplicate, new_name);
+ _try_duplicate_item(to_duplicate, new_path);
//Rescan everything
print_line("call rescan!");