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) {
|
if (dir_name.length() == 0) {
|
||||||
EditorNode::get_singleton()->show_warning(TTR("No name provided"));
|
EditorNode::get_singleton()->show_warning(TTR("No name provided"));
|
||||||
return;
|
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"));
|
EditorNode::get_singleton()->show_warning(TTR("Provided name contains invalid characters"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -276,8 +275,7 @@ void FileSystemDock::_make_dir_confirm() {
|
|||||||
if (err == OK) {
|
if (err == OK) {
|
||||||
print_line("call rescan!");
|
print_line("call rescan!");
|
||||||
_rescan();
|
_rescan();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
EditorNode::get_singleton()->show_warning(TTR("Could not create folder."));
|
EditorNode::get_singleton()->show_warning(TTR("Could not create folder."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -288,8 +286,7 @@ void FileSystemDock::_rename_operation_confirm() {
|
|||||||
if (new_name.length() == 0) {
|
if (new_name.length() == 0) {
|
||||||
EditorNode::get_singleton()->show_warning(TTR("No name provided."));
|
EditorNode::get_singleton()->show_warning(TTR("No name provided."));
|
||||||
return;
|
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."));
|
EditorNode::get_singleton()->show_warning(TTR("Name contains invalid characters."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -339,12 +336,10 @@ void FileSystemDock::_try_move_item(const FileOrFolder &p_item, const String &p_
|
|||||||
|
|
||||||
if (new_path == old_path) {
|
if (new_path == old_path) {
|
||||||
return;
|
return;
|
||||||
}
|
} else if (old_path == "res://") {
|
||||||
else if (old_path == "res://") {
|
|
||||||
EditorNode::get_singleton()->add_io_error(TTR("Cannot move/rename resources root."));
|
EditorNode::get_singleton()->add_io_error(TTR("Cannot move/rename resources root."));
|
||||||
return;
|
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 "/"
|
//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;
|
return;
|
||||||
@@ -354,8 +349,7 @@ void FileSystemDock::_try_move_item(const FileOrFolder &p_item, const String &p_
|
|||||||
Vector<String> changed_paths;
|
Vector<String> changed_paths;
|
||||||
if (p_item.is_file) {
|
if (p_item.is_file) {
|
||||||
changed_paths.push_back(old_path);
|
changed_paths.push_back(old_path);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
_get_all_files_in_dir(EditorFileSystem::get_singleton()->get_path(old_path), changed_paths);
|
_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);
|
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]]);
|
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");
|
EditorNode::get_singleton()->add_io_error(TTR("Error moving:\n") + old_path + "\n");
|
||||||
}
|
}
|
||||||
memdelete(da);
|
memdelete(da);
|
||||||
@@ -1041,24 +1034,17 @@ void FileSystemDock::_file_option(int p_option) {
|
|||||||
case FILE_SHOW_IN_EXPLORER:
|
case FILE_SHOW_IN_EXPLORER:
|
||||||
case FILE_OPEN: {
|
case FILE_OPEN: {
|
||||||
int idx = -1;
|
int idx = -1;
|
||||||
|
int selectcount = files->get_selected_items().size();
|
||||||
for (int i = 0; i < files->get_item_count(); i++) {
|
for (int i = 0; i < files->get_item_count(); i++) {
|
||||||
if (files->is_selected(i)) {
|
if (files->is_selected(i)) {
|
||||||
idx = i;
|
String path = files->get_item_metadata(i);
|
||||||
break;
|
if (selectcount == 1) {
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (idx < 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
String path = files->get_item_metadata(idx);
|
|
||||||
if (p_option == FILE_SHOW_IN_EXPLORER) {
|
if (p_option == FILE_SHOW_IN_EXPLORER) {
|
||||||
String dir = Globals::get_singleton()->globalize_path(path);
|
String dir = Globals::get_singleton()->globalize_path(path);
|
||||||
dir = dir.substr(0, dir.find_last("/"));
|
dir = dir.substr(0, dir.find_last("/"));
|
||||||
OS::get_singleton()->shell_open(String("file://") + dir);
|
OS::get_singleton()->shell_open(String("file://") + dir);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (path.ends_with("/")) {
|
if (path.ends_with("/")) {
|
||||||
if (path != "res://") {
|
if (path != "res://") {
|
||||||
path = path.substr(0, path.length() - 1);
|
path = path.substr(0, path.length() - 1);
|
||||||
@@ -1077,6 +1063,13 @@ void FileSystemDock::_file_option(int p_option) {
|
|||||||
editor->load_resource(path);
|
editor->load_resource(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (selectcount > 1) {
|
||||||
|
if (ResourceLoader::get_resource_type(path) == "PackedScene") {
|
||||||
|
editor->open_request(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} break;
|
} break;
|
||||||
case FILE_INSTANCE: {
|
case FILE_INSTANCE: {
|
||||||
|
|
||||||
|
|||||||
@@ -173,12 +173,12 @@ private:
|
|||||||
void _push_to_history();
|
void _push_to_history();
|
||||||
|
|
||||||
void _dir_selected();
|
void _dir_selected();
|
||||||
void _dir_rmb_pressed(const Vector2 & p_pos);
|
void _dir_rmb_pressed(const Vector2 &p_pos);
|
||||||
void _make_dir_confirm();
|
void _make_dir_confirm();
|
||||||
void _rename_operation_confirm();
|
void _rename_operation_confirm();
|
||||||
void _move_operation_confirm(const String & p_to_path);
|
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 _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 _get_all_files_in_dir(EditorFileSystemDirectory *efsd, Vector<String> &files);
|
||||||
void _update_dependencies_after_move(Map<String, String> &p_renames);
|
void _update_dependencies_after_move(Map<String, String> &p_renames);
|
||||||
void _update_tree();
|
void _update_tree();
|
||||||
void _rescan();
|
void _rescan();
|
||||||
|
|||||||
Reference in New Issue
Block a user