You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-20 14:45:44 +00:00
Enhanced 'open' in filesystemdock and fixed some non clang-format code
This commit is contained in:
@@ -259,8 +259,7 @@ void FileSystemDock::_make_dir_confirm() {
|
||||
if (dir_name.length() == 0) {
|
||||
EditorNode::get_singleton()->show_warning(TTR("No name provided"));
|
||||
return;
|
||||
}
|
||||
else if (dir_name.find("/") != -1 || dir_name.find("\\") != -1 || dir_name.find(":") != -1) {
|
||||
} else if (dir_name.find("/") != -1 || dir_name.find("\\") != -1 || dir_name.find(":") != -1) {
|
||||
EditorNode::get_singleton()->show_warning(TTR("Provided name contains invalid characters"));
|
||||
return;
|
||||
}
|
||||
@@ -276,8 +275,7 @@ void FileSystemDock::_make_dir_confirm() {
|
||||
if (err == OK) {
|
||||
print_line("call rescan!");
|
||||
_rescan();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
EditorNode::get_singleton()->show_warning(TTR("Could not create folder."));
|
||||
}
|
||||
}
|
||||
@@ -288,8 +286,7 @@ void FileSystemDock::_rename_operation_confirm() {
|
||||
if (new_name.length() == 0) {
|
||||
EditorNode::get_singleton()->show_warning(TTR("No name provided."));
|
||||
return;
|
||||
}
|
||||
else if (new_name.find("/") != -1 || new_name.find("\\") != -1 || new_name.find(":") != -1) {
|
||||
} else if (new_name.find("/") != -1 || new_name.find("\\") != -1 || new_name.find(":") != -1) {
|
||||
EditorNode::get_singleton()->show_warning(TTR("Name contains invalid characters."));
|
||||
return;
|
||||
}
|
||||
@@ -339,12 +336,10 @@ void FileSystemDock::_try_move_item(const FileOrFolder &p_item, const String &p_
|
||||
|
||||
if (new_path == old_path) {
|
||||
return;
|
||||
}
|
||||
else if (old_path == "res://") {
|
||||
} else if (old_path == "res://") {
|
||||
EditorNode::get_singleton()->add_io_error(TTR("Cannot move/rename resources root."));
|
||||
return;
|
||||
}
|
||||
else if (!p_item.is_file && new_path.begins_with(old_path)) {
|
||||
} 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");
|
||||
return;
|
||||
@@ -354,8 +349,7 @@ void FileSystemDock::_try_move_item(const FileOrFolder &p_item, const String &p_
|
||||
Vector<String> changed_paths;
|
||||
if (p_item.is_file) {
|
||||
changed_paths.push_back(old_path);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
_get_all_files_in_dir(EditorFileSystem::get_singleton()->get_path(old_path), changed_paths);
|
||||
}
|
||||
|
||||
@@ -368,8 +362,7 @@ void FileSystemDock::_try_move_item(const FileOrFolder &p_item, const String &p_
|
||||
p_renames[changed_paths[i]] = changed_paths[i].replace_first(old_path, new_path);
|
||||
print_line(" Remap: " + changed_paths[i] + " -> " + p_renames[changed_paths[i]]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
EditorNode::get_singleton()->add_io_error(TTR("Error moving:\n") + old_path + "\n");
|
||||
}
|
||||
memdelete(da);
|
||||
@@ -1041,24 +1034,17 @@ void FileSystemDock::_file_option(int p_option) {
|
||||
case FILE_SHOW_IN_EXPLORER:
|
||||
case FILE_OPEN: {
|
||||
int idx = -1;
|
||||
int selectcount = files->get_selected_items().size();
|
||||
for (int i = 0; i < files->get_item_count(); i++) {
|
||||
if (files->is_selected(i)) {
|
||||
idx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (idx < 0)
|
||||
return;
|
||||
|
||||
String path = files->get_item_metadata(idx);
|
||||
String path = files->get_item_metadata(i);
|
||||
if (selectcount == 1) {
|
||||
if (p_option == FILE_SHOW_IN_EXPLORER) {
|
||||
String dir = Globals::get_singleton()->globalize_path(path);
|
||||
dir = dir.substr(0, dir.find_last("/"));
|
||||
OS::get_singleton()->shell_open(String("file://") + dir);
|
||||
return;
|
||||
}
|
||||
|
||||
if (path.ends_with("/")) {
|
||||
if (path != "res://") {
|
||||
path = path.substr(0, path.length() - 1);
|
||||
@@ -1077,6 +1063,13 @@ void FileSystemDock::_file_option(int p_option) {
|
||||
editor->load_resource(path);
|
||||
}
|
||||
}
|
||||
} else if (selectcount > 1) {
|
||||
if (ResourceLoader::get_resource_type(path) == "PackedScene") {
|
||||
editor->open_request(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case FILE_INSTANCE: {
|
||||
|
||||
|
||||
@@ -173,12 +173,12 @@ private:
|
||||
void _push_to_history();
|
||||
|
||||
void _dir_selected();
|
||||
void _dir_rmb_pressed(const Vector2 & p_pos);
|
||||
void _dir_rmb_pressed(const Vector2 &p_pos);
|
||||
void _make_dir_confirm();
|
||||
void _rename_operation_confirm();
|
||||
void _move_operation_confirm(const String & p_to_path);
|
||||
void _try_move_item(const FileOrFolder & p_item, const String & p_new_path, Map<String, String>& p_renames);
|
||||
void _get_all_files_in_dir(EditorFileSystemDirectory * efsd, Vector<String>& files);
|
||||
void _move_operation_confirm(const String &p_to_path);
|
||||
void _try_move_item(const FileOrFolder &p_item, const String &p_new_path, Map<String, String> &p_renames);
|
||||
void _get_all_files_in_dir(EditorFileSystemDirectory *efsd, Vector<String> &files);
|
||||
void _update_dependencies_after_move(Map<String, String> &p_renames);
|
||||
void _update_tree();
|
||||
void _rescan();
|
||||
|
||||
Reference in New Issue
Block a user