2014-02-10 01:10:30 +00:00
|
|
|
/*************************************************************************/
|
2017-01-16 07:04:19 +00:00
|
|
|
/* filesystem_dock.cpp */
|
2014-02-10 01:10:30 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2017-08-27 12:16:55 +00:00
|
|
|
/* https://godotengine.org */
|
2014-02-10 01:10:30 +00:00
|
|
|
/*************************************************************************/
|
2017-01-01 21:01:57 +00:00
|
|
|
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
|
2017-04-07 22:11:42 +00:00
|
|
|
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
|
2014-02-10 01:10:30 +00:00
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/*************************************************************************/
|
2016-07-21 13:34:57 +00:00
|
|
|
#include "filesystem_dock.h"
|
2017-01-16 07:04:19 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
#include "editor_node.h"
|
|
|
|
#include "editor_settings.h"
|
2014-02-10 01:10:30 +00:00
|
|
|
#include "io/resource_loader.h"
|
2017-03-05 15:44:50 +00:00
|
|
|
#include "os/dir_access.h"
|
|
|
|
#include "os/file_access.h"
|
2014-02-10 01:10:30 +00:00
|
|
|
#include "os/os.h"
|
2017-07-30 20:53:40 +00:00
|
|
|
#include "project_settings.h"
|
2016-05-15 23:25:51 +00:00
|
|
|
#include "scene/main/viewport.h"
|
2016-07-06 17:04:21 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory *p_dir) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
TreeItem *item = tree->create_item(p_parent);
|
2017-03-05 15:44:50 +00:00
|
|
|
String dname = p_dir->get_name();
|
|
|
|
if (dname == "")
|
|
|
|
dname = "res://";
|
2017-01-10 12:19:59 +00:00
|
|
|
else {
|
|
|
|
// collapse every tree item but the root folder
|
|
|
|
item->set_collapsed(true);
|
|
|
|
}
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
item->set_text(0, dname);
|
|
|
|
item->set_icon(0, get_icon("Folder", "EditorIcons"));
|
|
|
|
item->set_selectable(0, true);
|
2015-08-23 23:15:56 +00:00
|
|
|
String lpath = p_dir->get_path();
|
2017-03-05 15:44:50 +00:00
|
|
|
if (lpath != "res://" && lpath.ends_with("/")) {
|
|
|
|
lpath = lpath.substr(0, lpath.length() - 1);
|
2015-08-23 23:15:56 +00:00
|
|
|
}
|
2017-03-05 15:44:50 +00:00
|
|
|
item->set_metadata(0, lpath);
|
|
|
|
if (lpath == path) {
|
2015-08-23 23:15:56 +00:00
|
|
|
item->select(0);
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
for (int i = 0; i < p_dir->get_subdir_count(); i++)
|
|
|
|
_create_tree(item, p_dir->get_subdir(i));
|
2016-07-08 07:15:31 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-07-21 13:34:57 +00:00
|
|
|
void FileSystemDock::_update_tree() {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
tree->clear();
|
2017-03-05 15:44:50 +00:00
|
|
|
updating_tree = true;
|
2015-08-23 23:15:56 +00:00
|
|
|
TreeItem *root = tree->create_item();
|
|
|
|
TreeItem *favorites = tree->create_item(root);
|
2017-03-05 15:44:50 +00:00
|
|
|
favorites->set_icon(0, get_icon("Favorites", "EditorIcons"));
|
|
|
|
favorites->set_text(0, TTR("Favorites:"));
|
|
|
|
favorites->set_selectable(0, false);
|
|
|
|
Vector<String> faves = EditorSettings::get_singleton()->get_favorite_dirs();
|
|
|
|
for (int i = 0; i < faves.size(); i++) {
|
2015-08-23 23:15:56 +00:00
|
|
|
if (!faves[i].begins_with("res://"))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
TreeItem *ti = tree->create_item(favorites);
|
|
|
|
String fv = faves[i];
|
2017-03-05 15:44:50 +00:00
|
|
|
if (fv == "res://")
|
|
|
|
ti->set_text(0, "/");
|
2015-08-23 23:15:56 +00:00
|
|
|
else
|
2017-03-05 15:44:50 +00:00
|
|
|
ti->set_text(0, faves[i].get_file());
|
|
|
|
ti->set_icon(0, get_icon("Folder", "EditorIcons"));
|
|
|
|
ti->set_selectable(0, true);
|
|
|
|
ti->set_metadata(0, faves[i]);
|
2015-08-23 23:15:56 +00:00
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
_create_tree(root, EditorFileSystem::get_singleton()->get_filesystem());
|
|
|
|
updating_tree = false;
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2016-07-21 13:34:57 +00:00
|
|
|
void FileSystemDock::_notification(int p_what) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
switch (p_what) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-05-15 23:25:51 +00:00
|
|
|
case NOTIFICATION_RESIZED: {
|
|
|
|
|
2017-08-07 03:44:34 +00:00
|
|
|
bool new_mode = get_size().height < get_viewport_rect().size.height / 2;
|
2016-05-15 23:25:51 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (new_mode != split_mode) {
|
2016-05-15 23:25:51 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
split_mode = new_mode;
|
2016-05-15 23:25:51 +00:00
|
|
|
|
|
|
|
//print_line("SPLIT MODE? "+itos(split_mode));
|
|
|
|
if (split_mode) {
|
|
|
|
|
|
|
|
file_list_vb->hide();
|
2017-03-05 15:44:50 +00:00
|
|
|
tree->set_custom_minimum_size(Size2(0, 0));
|
2016-05-15 23:25:51 +00:00
|
|
|
tree->set_v_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
button_back->show();
|
|
|
|
} else {
|
|
|
|
|
|
|
|
tree->show();
|
|
|
|
file_list_vb->show();
|
2017-03-05 15:44:50 +00:00
|
|
|
tree->set_custom_minimum_size(Size2(0, 200) * EDSCALE);
|
2016-05-15 23:25:51 +00:00
|
|
|
tree->set_v_size_flags(SIZE_FILL);
|
|
|
|
button_back->hide();
|
|
|
|
if (!EditorFileSystem::get_singleton()->is_scanning()) {
|
|
|
|
_fs_changed();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} break;
|
2014-11-06 00:20:42 +00:00
|
|
|
case NOTIFICATION_ENTER_TREE: {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2015-08-23 23:15:56 +00:00
|
|
|
if (initialized)
|
|
|
|
return;
|
2017-03-05 15:44:50 +00:00
|
|
|
initialized = true;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
EditorFileSystem::get_singleton()->connect("filesystem_changed", this, "_fs_changed");
|
|
|
|
EditorResourcePreview::get_singleton()->connect("preview_invalidated", this, "_preview_invalidated");
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
button_reload->set_icon(get_icon("Reload", "EditorIcons"));
|
|
|
|
button_favorite->set_icon(get_icon("Favorites", "EditorIcons"));
|
2016-05-15 23:25:51 +00:00
|
|
|
//button_instance->set_icon( get_icon("Add","EditorIcons"));
|
|
|
|
//button_open->set_icon( get_icon("Folder","EditorIcons"));
|
2017-03-05 15:44:50 +00:00
|
|
|
button_back->set_icon(get_icon("Filesystem", "EditorIcons"));
|
2017-09-12 17:30:16 +00:00
|
|
|
_update_file_display_toggle_button();
|
2017-03-05 15:44:50 +00:00
|
|
|
button_display_mode->connect("pressed", this, "_change_file_display");
|
2016-05-15 23:25:51 +00:00
|
|
|
//file_options->set_icon( get_icon("Tools","EditorIcons"));
|
2017-03-05 15:44:50 +00:00
|
|
|
files->connect("item_activated", this, "_select_file");
|
|
|
|
button_hist_next->connect("pressed", this, "_fw_history");
|
|
|
|
button_hist_prev->connect("pressed", this, "_bw_history");
|
2017-07-18 19:35:37 +00:00
|
|
|
search_box->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
|
2017-03-05 15:44:50 +00:00
|
|
|
|
|
|
|
button_hist_next->set_icon(get_icon("Forward", "EditorIcons"));
|
|
|
|
button_hist_prev->set_icon(get_icon("Back", "EditorIcons"));
|
|
|
|
file_options->connect("id_pressed", this, "_file_option");
|
|
|
|
folder_options->connect("id_pressed", this, "_folder_option");
|
|
|
|
|
|
|
|
button_back->connect("pressed", this, "_go_to_tree", varray(), CONNECT_DEFERRED);
|
|
|
|
current_path->connect("text_entered", this, "_go_to_dir");
|
2015-08-23 23:15:56 +00:00
|
|
|
_update_tree(); //maybe it finished already
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2015-08-23 23:15:56 +00:00
|
|
|
if (EditorFileSystem::get_singleton()->is_scanning()) {
|
2017-01-21 12:07:29 +00:00
|
|
|
_set_scanning_mode();
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2015-08-23 23:15:56 +00:00
|
|
|
} break;
|
|
|
|
case NOTIFICATION_PROCESS: {
|
|
|
|
if (EditorFileSystem::get_singleton()->is_scanning()) {
|
2017-03-05 15:44:50 +00:00
|
|
|
scanning_progress->set_value(EditorFileSystem::get_singleton()->get_scanning_progress() * 100);
|
2015-08-23 23:15:56 +00:00
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
} break;
|
2014-11-06 00:20:42 +00:00
|
|
|
case NOTIFICATION_EXIT_TREE: {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-05-15 23:25:51 +00:00
|
|
|
} break;
|
|
|
|
case NOTIFICATION_DRAG_BEGIN: {
|
|
|
|
|
|
|
|
Dictionary dd = get_viewport()->gui_get_drag_data();
|
2017-03-05 15:44:50 +00:00
|
|
|
if (tree->is_visible_in_tree() && dd.has("type")) {
|
|
|
|
if ((String(dd["type"]) == "files") || (String(dd["type"]) == "files_and_dirs") || (String(dd["type"]) == "resource")) {
|
2016-05-24 02:24:17 +00:00
|
|
|
tree->set_drop_mode_flags(Tree::DROP_MODE_ON_ITEM);
|
|
|
|
}
|
2017-03-05 15:44:50 +00:00
|
|
|
if ((String(dd["type"]) == "favorite")) {
|
2016-05-24 02:24:17 +00:00
|
|
|
tree->set_drop_mode_flags(Tree::DROP_MODE_INBETWEEN);
|
|
|
|
}
|
2016-05-15 23:25:51 +00:00
|
|
|
}
|
2016-05-24 02:24:17 +00:00
|
|
|
|
2016-05-15 23:25:51 +00:00
|
|
|
} break;
|
|
|
|
case NOTIFICATION_DRAG_END: {
|
|
|
|
|
|
|
|
tree->set_drop_mode_flags(0);
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
} break;
|
2015-12-15 16:39:13 +00:00
|
|
|
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-01-05 22:41:36 +00:00
|
|
|
int new_mode = int(EditorSettings::get_singleton()->get("docks/filesystem/display_mode"));
|
2015-12-15 16:39:13 +00:00
|
|
|
|
2017-08-29 23:03:13 +00:00
|
|
|
//_update_icons
|
|
|
|
|
|
|
|
button_reload->set_icon(get_icon("Reload", "EditorIcons"));
|
|
|
|
button_favorite->set_icon(get_icon("Favorites", "EditorIcons"));
|
|
|
|
button_back->set_icon(get_icon("Filesystem", "EditorIcons"));
|
2017-09-12 17:30:16 +00:00
|
|
|
_update_file_display_toggle_button();
|
2017-08-29 23:03:13 +00:00
|
|
|
|
|
|
|
search_box->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
|
|
|
|
|
|
|
|
button_hist_next->set_icon(get_icon("Forward", "EditorIcons"));
|
|
|
|
button_hist_prev->set_icon(get_icon("Back", "EditorIcons"));
|
|
|
|
|
2016-08-16 16:25:42 +00:00
|
|
|
if (new_mode != display_mode) {
|
|
|
|
set_display_mode(new_mode);
|
|
|
|
} else {
|
|
|
|
_update_files(true);
|
|
|
|
}
|
2017-08-29 23:03:13 +00:00
|
|
|
|
|
|
|
_update_tree();
|
|
|
|
|
2015-12-15 16:39:13 +00:00
|
|
|
} break;
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-21 13:34:57 +00:00
|
|
|
void FileSystemDock::_dir_selected() {
|
2015-08-23 23:15:56 +00:00
|
|
|
|
|
|
|
TreeItem *ti = tree->get_selected();
|
|
|
|
if (!ti)
|
2014-02-10 01:10:30 +00:00
|
|
|
return;
|
2015-08-23 23:15:56 +00:00
|
|
|
String dir = ti->get_metadata(0);
|
2017-03-05 15:44:50 +00:00
|
|
|
bool found = false;
|
2015-08-23 23:15:56 +00:00
|
|
|
Vector<String> favorites = EditorSettings::get_singleton()->get_favorite_dirs();
|
2017-03-05 15:44:50 +00:00
|
|
|
for (int i = 0; i < favorites.size(); i++) {
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (favorites[i] == dir) {
|
|
|
|
found = true;
|
2015-08-23 23:15:56 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
button_favorite->set_pressed(found);
|
2016-05-15 23:25:51 +00:00
|
|
|
|
|
|
|
if (!split_mode) {
|
|
|
|
_open_pressed(); //go directly to dir
|
2015-08-23 23:15:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-21 13:34:57 +00:00
|
|
|
void FileSystemDock::_favorites_pressed() {
|
2015-08-23 23:15:56 +00:00
|
|
|
|
|
|
|
TreeItem *sel = tree->get_selected();
|
|
|
|
if (!sel)
|
2017-03-05 15:44:50 +00:00
|
|
|
return;
|
2015-08-23 23:15:56 +00:00
|
|
|
String dir = sel->get_metadata(0);
|
|
|
|
|
|
|
|
int idx = -1;
|
|
|
|
Vector<String> favorites = EditorSettings::get_singleton()->get_favorite_dirs();
|
2017-03-05 15:44:50 +00:00
|
|
|
for (int i = 0; i < favorites.size(); i++) {
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (favorites[i] == dir) {
|
|
|
|
idx = i;
|
2015-08-23 23:15:56 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (button_favorite->is_pressed() && idx == -1) {
|
2015-08-23 23:15:56 +00:00
|
|
|
favorites.push_back(dir);
|
|
|
|
EditorSettings::get_singleton()->set_favorite_dirs(favorites);
|
|
|
|
_update_tree();
|
2017-03-05 15:44:50 +00:00
|
|
|
} else if (!button_favorite->is_pressed() && idx != -1) {
|
2015-08-23 23:15:56 +00:00
|
|
|
favorites.remove(idx);
|
|
|
|
EditorSettings::get_singleton()->set_favorite_dirs(favorites);
|
|
|
|
_update_tree();
|
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2016-07-21 13:34:57 +00:00
|
|
|
String FileSystemDock::get_selected_path() const {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
TreeItem *sel = tree->get_selected();
|
|
|
|
if (!sel)
|
|
|
|
return "";
|
|
|
|
String path = sel->get_metadata(0);
|
2017-03-05 15:44:50 +00:00
|
|
|
return "res://" + path;
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2016-07-21 13:34:57 +00:00
|
|
|
String FileSystemDock::get_current_path() const {
|
2016-05-27 17:18:40 +00:00
|
|
|
|
|
|
|
return path;
|
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void FileSystemDock::navigate_to_path(const String &p_path) {
|
2017-01-14 17:14:46 +00:00
|
|
|
// If the path is a file, do not only go to the directory in the tree, also select the file in the file list.
|
2017-03-05 15:44:50 +00:00
|
|
|
String dir_path = "";
|
|
|
|
String file_name = "";
|
|
|
|
DirAccess *dirAccess = DirAccess::open("res://");
|
2017-01-14 17:14:46 +00:00
|
|
|
if (dirAccess->file_exists(p_path)) {
|
2017-03-05 15:44:50 +00:00
|
|
|
dir_path = p_path.get_base_dir();
|
|
|
|
file_name = p_path.get_file();
|
2017-01-14 17:14:46 +00:00
|
|
|
} else if (dirAccess->dir_exists(p_path)) {
|
2017-03-05 15:44:50 +00:00
|
|
|
dir_path = p_path;
|
2017-01-14 17:14:46 +00:00
|
|
|
} else {
|
|
|
|
ERR_EXPLAIN(TTR("Cannot navigate to '" + p_path + "' as it has not been found in the file system!"));
|
|
|
|
ERR_FAIL();
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
path = dir_path;
|
2017-01-14 17:14:46 +00:00
|
|
|
_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.
|
2017-03-05 15:44:50 +00:00
|
|
|
for (int i = 0; i < files->get_item_count(); i++) {
|
2017-01-14 17:14:46 +00:00
|
|
|
if (files->get_item_text(i) == file_name) {
|
2017-03-05 15:44:50 +00:00
|
|
|
files->select(i, true);
|
2017-01-14 17:14:46 +00:00
|
|
|
files->ensure_current_is_visible();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void FileSystemDock::_thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Variant &p_udata) {
|
2015-09-08 01:55:47 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
bool valid = false;
|
2015-09-08 01:55:47 +00:00
|
|
|
|
2017-01-13 13:45:50 +00:00
|
|
|
if (search_box->is_visible()) {
|
2017-03-05 15:44:50 +00:00
|
|
|
valid = true;
|
2016-05-15 23:25:51 +00:00
|
|
|
} else {
|
2017-03-05 15:44:50 +00:00
|
|
|
valid = (path == p_path.get_base_dir());
|
2015-09-08 01:55:47 +00:00
|
|
|
}
|
|
|
|
|
2016-05-15 23:25:51 +00:00
|
|
|
if (p_preview.is_valid() && valid) {
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
Array uarr = p_udata;
|
|
|
|
int idx = uarr[0];
|
|
|
|
String file = uarr[1];
|
|
|
|
if (idx >= files->get_item_count())
|
2015-08-23 23:15:56 +00:00
|
|
|
return;
|
2017-03-05 15:44:50 +00:00
|
|
|
if (files->get_item_text(idx) != file)
|
2016-05-15 23:25:51 +00:00
|
|
|
return;
|
2015-08-23 23:15:56 +00:00
|
|
|
String fpath = files->get_item_metadata(idx);
|
2017-03-05 15:44:50 +00:00
|
|
|
if (fpath != p_path)
|
2015-08-23 23:15:56 +00:00
|
|
|
return;
|
2017-03-05 15:44:50 +00:00
|
|
|
files->set_item_icon(idx, p_preview);
|
2015-08-23 23:15:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-12 17:30:16 +00:00
|
|
|
void FileSystemDock::_update_file_display_toggle_button() {
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2016-08-16 16:25:42 +00:00
|
|
|
if (button_display_mode->is_pressed()) {
|
|
|
|
display_mode = DISPLAY_LIST;
|
2017-03-05 15:44:50 +00:00
|
|
|
button_display_mode->set_icon(get_icon("FileThumbnail", "EditorIcons"));
|
2017-09-12 17:30:16 +00:00
|
|
|
button_display_mode->set_tooltip(TTR("View items as a grid of thumbnails"));
|
2015-08-23 23:15:56 +00:00
|
|
|
} else {
|
2016-08-16 16:25:42 +00:00
|
|
|
display_mode = DISPLAY_THUMBNAILS;
|
2017-03-05 15:44:50 +00:00
|
|
|
button_display_mode->set_icon(get_icon("FileList", "EditorIcons"));
|
2017-09-12 17:30:16 +00:00
|
|
|
button_display_mode->set_tooltip(TTR("View items as a list"));
|
2015-08-23 23:15:56 +00:00
|
|
|
}
|
2017-09-12 17:30:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FileSystemDock::_change_file_display() {
|
|
|
|
|
|
|
|
_update_file_display_toggle_button();
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2017-01-05 22:41:36 +00:00
|
|
|
EditorSettings::get_singleton()->set("docks/filesystem/display_mode", display_mode);
|
2016-08-16 16:25:42 +00:00
|
|
|
|
2015-08-23 23:15:56 +00:00
|
|
|
_update_files(true);
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void FileSystemDock::_search(EditorFileSystemDirectory *p_path, List<FileInfo> *matches, int p_max_items) {
|
2016-05-15 23:25:51 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (matches->size() > p_max_items)
|
2016-05-15 23:25:51 +00:00
|
|
|
return;
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
for (int i = 0; i < p_path->get_subdir_count(); i++) {
|
|
|
|
_search(p_path->get_subdir(i), matches, p_max_items);
|
2016-05-15 23:25:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
String match = search_box->get_text();
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
for (int i = 0; i < p_path->get_file_count(); i++) {
|
2016-05-15 23:25:51 +00:00
|
|
|
String file = p_path->get_file(i);
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (file.find(match) != -1) {
|
2016-05-15 23:25:51 +00:00
|
|
|
|
|
|
|
FileInfo fi;
|
2017-03-05 15:44:50 +00:00
|
|
|
fi.name = file;
|
|
|
|
fi.type = p_path->get_file_type(i);
|
|
|
|
fi.path = p_path->get_file_path(i);
|
2017-08-29 23:17:34 +00:00
|
|
|
fi.import_broken = !p_path->get_file_import_is_valid(i);
|
2017-03-05 15:44:50 +00:00
|
|
|
fi.import_status = 0;
|
2016-05-27 17:18:40 +00:00
|
|
|
|
2016-05-15 23:25:51 +00:00
|
|
|
matches->push_back(fi);
|
2017-03-05 15:44:50 +00:00
|
|
|
if (matches->size() > p_max_items)
|
2016-05-15 23:25:51 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-21 13:34:57 +00:00
|
|
|
void FileSystemDock::_update_files(bool p_keep_selection) {
|
2015-08-23 23:15:56 +00:00
|
|
|
|
|
|
|
Set<String> cselection;
|
|
|
|
|
|
|
|
if (p_keep_selection) {
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
for (int i = 0; i < files->get_item_count(); i++) {
|
2015-08-23 23:15:56 +00:00
|
|
|
|
|
|
|
if (files->is_selected(i))
|
|
|
|
cselection.insert(files->get_item_text(i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
files->clear();
|
|
|
|
|
2016-05-15 23:25:51 +00:00
|
|
|
current_path->set_text(path);
|
|
|
|
|
2017-01-14 14:07:57 +00:00
|
|
|
EditorFileSystemDirectory *efd = EditorFileSystem::get_singleton()->get_filesystem_path(path);
|
2015-08-23 23:15:56 +00:00
|
|
|
if (!efd)
|
2014-02-10 01:10:30 +00:00
|
|
|
return;
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2017-01-05 22:41:36 +00:00
|
|
|
int thumbnail_size = EditorSettings::get_singleton()->get("docks/filesystem/thumbnail_size");
|
2017-03-05 15:44:50 +00:00
|
|
|
thumbnail_size *= EDSCALE;
|
2015-08-23 23:15:56 +00:00
|
|
|
Ref<Texture> folder_thumbnail;
|
|
|
|
Ref<Texture> file_thumbnail;
|
2017-08-29 23:17:34 +00:00
|
|
|
Ref<Texture> file_thumbnail_broken;
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2017-09-12 17:23:16 +00:00
|
|
|
bool always_show_folders = EditorSettings::get_singleton()->get("docks/filesystem/always_show_folders");
|
|
|
|
|
2016-08-16 16:25:42 +00:00
|
|
|
bool use_thumbnails = (display_mode == DISPLAY_THUMBNAILS);
|
2017-09-12 17:23:16 +00:00
|
|
|
bool use_folders = search_box->get_text().length() == 0 && (split_mode || always_show_folders);
|
2015-08-23 23:15:56 +00:00
|
|
|
|
|
|
|
if (use_thumbnails) { //thumbnails
|
|
|
|
|
|
|
|
files->set_max_columns(0);
|
|
|
|
files->set_icon_mode(ItemList::ICON_MODE_TOP);
|
2017-03-05 15:44:50 +00:00
|
|
|
files->set_fixed_column_width(thumbnail_size * 3 / 2);
|
2015-08-23 23:15:56 +00:00
|
|
|
files->set_max_text_lines(2);
|
2017-03-05 15:44:50 +00:00
|
|
|
files->set_fixed_icon_size(Size2(thumbnail_size, thumbnail_size));
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2017-09-08 07:32:43 +00:00
|
|
|
if (thumbnail_size < 64) {
|
|
|
|
folder_thumbnail = get_icon("FolderMediumThumb", "EditorIcons");
|
|
|
|
file_thumbnail = get_icon("FileMediumThumb", "EditorIcons");
|
|
|
|
file_thumbnail_broken = get_icon("FileDeadMediumThumb", "EditorIcons");
|
|
|
|
} else {
|
|
|
|
folder_thumbnail = get_icon("FolderBigThumb", "EditorIcons");
|
|
|
|
file_thumbnail = get_icon("FileBigThumb", "EditorIcons");
|
|
|
|
file_thumbnail_broken = get_icon("FileDeadBigThumb", "EditorIcons");
|
2015-08-23 23:15:56 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
files->set_icon_mode(ItemList::ICON_MODE_LEFT);
|
|
|
|
files->set_max_columns(1);
|
|
|
|
files->set_max_text_lines(1);
|
|
|
|
files->set_fixed_column_width(0);
|
2016-06-12 19:51:27 +00:00
|
|
|
files->set_fixed_icon_size(Size2());
|
2014-10-14 22:44:41 +00:00
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-05-15 23:25:51 +00:00
|
|
|
if (use_folders) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (path != "res://") {
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2016-05-15 23:25:51 +00:00
|
|
|
if (use_thumbnails) {
|
2017-03-05 15:44:50 +00:00
|
|
|
files->add_item("..", folder_thumbnail, true);
|
2016-05-15 23:25:51 +00:00
|
|
|
} else {
|
2017-03-05 15:44:50 +00:00
|
|
|
files->add_item("..", get_icon("folder", "FileDialog"), true);
|
2016-05-15 23:25:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
String bd = path.get_base_dir();
|
2017-03-05 15:44:50 +00:00
|
|
|
if (bd != "res://" && !bd.ends_with("/"))
|
|
|
|
bd += "/";
|
2016-05-15 23:25:51 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
files->set_item_metadata(files->get_item_count() - 1, bd);
|
2015-08-23 23:15:56 +00:00
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
for (int i = 0; i < efd->get_subdir_count(); i++) {
|
2016-05-15 23:25:51 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
String dname = efd->get_subdir(i)->get_name();
|
2016-05-15 23:25:51 +00:00
|
|
|
|
|
|
|
if (use_thumbnails) {
|
2017-03-05 15:44:50 +00:00
|
|
|
files->add_item(dname, folder_thumbnail, true);
|
2016-05-15 23:25:51 +00:00
|
|
|
} else {
|
2017-03-05 15:44:50 +00:00
|
|
|
files->add_item(dname, get_icon("folder", "FileDialog"), true);
|
2016-05-15 23:25:51 +00:00
|
|
|
}
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
files->set_item_metadata(files->get_item_count() - 1, path.plus_file(dname) + "/");
|
2016-05-15 23:25:51 +00:00
|
|
|
|
|
|
|
if (cselection.has(dname))
|
2017-03-05 15:44:50 +00:00
|
|
|
files->select(files->get_item_count() - 1, false);
|
2016-05-15 23:25:51 +00:00
|
|
|
}
|
2015-08-23 23:15:56 +00:00
|
|
|
}
|
|
|
|
|
2016-05-15 23:25:51 +00:00
|
|
|
List<FileInfo> filelist;
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2016-05-24 02:24:17 +00:00
|
|
|
if (search_box->get_text().length()) {
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (search_box->get_text().length() > 1) {
|
|
|
|
_search(EditorFileSystem::get_singleton()->get_filesystem(), &filelist, 128);
|
2015-08-23 23:15:56 +00:00
|
|
|
}
|
|
|
|
|
2016-05-15 23:25:51 +00:00
|
|
|
filelist.sort();
|
|
|
|
} else {
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
for (int i = 0; i < efd->get_file_count(); i++) {
|
2016-05-15 23:25:51 +00:00
|
|
|
|
|
|
|
FileInfo fi;
|
2017-03-05 15:44:50 +00:00
|
|
|
fi.name = efd->get_file(i);
|
|
|
|
fi.path = path.plus_file(fi.name);
|
|
|
|
fi.type = efd->get_file_type(i);
|
2017-08-29 23:17:34 +00:00
|
|
|
fi.import_broken = !efd->get_file_import_is_valid(i);
|
2017-03-05 15:44:50 +00:00
|
|
|
fi.import_status = 0;
|
2016-05-15 23:25:51 +00:00
|
|
|
|
|
|
|
filelist.push_back(fi);
|
|
|
|
}
|
2015-08-23 23:15:56 +00:00
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
StringName ei = "EditorIcons"; //make it faster..
|
|
|
|
StringName oi = "Object";
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
for (List<FileInfo>::Element *E = filelist.front(); E; E = E->next()) {
|
|
|
|
String fname = E->get().name;
|
2016-05-15 23:25:51 +00:00
|
|
|
String fp = E->get().path;
|
|
|
|
StringName type = E->get().type;
|
2015-08-23 23:15:56 +00:00
|
|
|
|
|
|
|
Ref<Texture> type_icon;
|
2017-08-29 23:17:34 +00:00
|
|
|
Ref<Texture> big_icon = file_thumbnail;
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
String tooltip = fname;
|
2016-05-27 17:18:40 +00:00
|
|
|
|
2017-08-29 23:17:34 +00:00
|
|
|
if (!E->get().import_broken) {
|
2016-05-27 17:18:40 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (has_icon(type, ei)) {
|
|
|
|
type_icon = get_icon(type, ei);
|
2016-05-27 17:18:40 +00:00
|
|
|
} else {
|
2017-03-05 15:44:50 +00:00
|
|
|
type_icon = get_icon(oi, ei);
|
2016-05-27 17:18:40 +00:00
|
|
|
}
|
2017-08-29 23:17:34 +00:00
|
|
|
} else {
|
2017-03-05 15:44:50 +00:00
|
|
|
type_icon = get_icon("ImportFail", "EditorIcons");
|
2017-08-29 23:17:34 +00:00
|
|
|
big_icon = file_thumbnail_broken;
|
|
|
|
tooltip += TTR("\nStatus: Import of file failed. Please fix file and reimport manually.");
|
2016-05-27 17:18:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (E->get().sources.size()) {
|
2017-03-05 15:44:50 +00:00
|
|
|
for (int i = 0; i < E->get().sources.size(); i++) {
|
2017-08-23 20:25:14 +00:00
|
|
|
tooltip += TTR("\nSource: ") + E->get().sources[i];
|
2016-05-27 17:18:40 +00:00
|
|
|
}
|
2015-08-23 23:15:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (use_thumbnails) {
|
2017-08-29 23:17:34 +00:00
|
|
|
files->add_item(fname, big_icon, true);
|
2017-03-05 15:44:50 +00:00
|
|
|
files->set_item_metadata(files->get_item_count() - 1, fp);
|
|
|
|
files->set_item_tag_icon(files->get_item_count() - 1, type_icon);
|
2016-05-15 23:25:51 +00:00
|
|
|
Array udata;
|
|
|
|
udata.resize(2);
|
2017-03-05 15:44:50 +00:00
|
|
|
udata[0] = files->get_item_count() - 1;
|
|
|
|
udata[1] = fname;
|
2017-08-29 23:17:34 +00:00
|
|
|
if (!E->get().import_broken) {
|
|
|
|
EditorResourcePreview::get_singleton()->queue_resource_preview(fp, this, "_thumbnail_done", udata);
|
|
|
|
}
|
2015-08-23 23:15:56 +00:00
|
|
|
} else {
|
2017-03-05 15:44:50 +00:00
|
|
|
files->add_item(fname, type_icon, true);
|
|
|
|
files->set_item_metadata(files->get_item_count() - 1, fp);
|
2015-08-23 23:15:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (cselection.has(fname))
|
2017-03-05 15:44:50 +00:00
|
|
|
files->select(files->get_item_count() - 1, false);
|
2016-05-27 17:18:40 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
files->set_item_tooltip(files->get_item_count() - 1, tooltip);
|
2015-08-23 23:15:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-21 13:34:57 +00:00
|
|
|
void FileSystemDock::_select_file(int p_idx) {
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
files->select(p_idx, true);
|
2016-05-15 23:25:51 +00:00
|
|
|
_file_option(FILE_OPEN);
|
2015-08-23 23:15:56 +00:00
|
|
|
}
|
|
|
|
|
2016-07-21 13:34:57 +00:00
|
|
|
void FileSystemDock::_go_to_tree() {
|
2015-08-23 23:15:56 +00:00
|
|
|
|
|
|
|
tree->show();
|
2016-05-15 23:25:51 +00:00
|
|
|
file_list_vb->hide();
|
2015-08-23 23:15:56 +00:00
|
|
|
_update_tree();
|
|
|
|
tree->grab_focus();
|
|
|
|
tree->ensure_cursor_is_visible();
|
|
|
|
button_favorite->show();
|
2016-05-15 23:25:51 +00:00
|
|
|
//button_open->hide();
|
|
|
|
//file_options->hide();
|
2015-08-23 23:15:56 +00:00
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void FileSystemDock::_go_to_dir(const String &p_dir) {
|
2015-08-23 23:15:56 +00:00
|
|
|
|
|
|
|
DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
2017-03-05 15:44:50 +00:00
|
|
|
if (da->change_dir(p_dir) == OK) {
|
|
|
|
path = da->get_current_dir();
|
2015-08-23 23:15:56 +00:00
|
|
|
_update_files(false);
|
|
|
|
}
|
|
|
|
current_path->set_text(path);
|
|
|
|
memdelete(da);
|
|
|
|
}
|
2016-07-03 16:15:15 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void FileSystemDock::_preview_invalidated(const String &p_path) {
|
2016-07-03 16:15:15 +00:00
|
|
|
|
2017-08-03 16:55:48 +00:00
|
|
|
if (display_mode == DISPLAY_THUMBNAILS && p_path.get_base_dir() == path && search_box->get_text() == String() && file_list_vb->is_visible_in_tree()) {
|
2016-07-03 16:15:15 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
for (int i = 0; i < files->get_item_count(); i++) {
|
2016-07-03 16:15:15 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (files->get_item_metadata(i) == p_path) {
|
2016-07-03 16:15:15 +00:00
|
|
|
//re-request preview
|
|
|
|
Array udata;
|
|
|
|
udata.resize(2);
|
2017-03-05 15:44:50 +00:00
|
|
|
udata[0] = i;
|
|
|
|
udata[1] = files->get_item_text(i);
|
|
|
|
EditorResourcePreview::get_singleton()->queue_resource_preview(p_path, this, "_thumbnail_done", udata);
|
2016-07-03 16:15:15 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-21 13:34:57 +00:00
|
|
|
void FileSystemDock::_fs_changed() {
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
button_hist_prev->set_disabled(history_pos == 0);
|
|
|
|
button_hist_next->set_disabled(history_pos + 1 == history.size());
|
2015-08-23 23:15:56 +00:00
|
|
|
scanning_vb->hide();
|
2016-05-15 23:25:51 +00:00
|
|
|
split_box->show();
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2017-01-13 13:45:50 +00:00
|
|
|
if (tree->is_visible()) {
|
2015-08-23 23:15:56 +00:00
|
|
|
button_favorite->show();
|
|
|
|
_update_tree();
|
2016-05-15 23:25:51 +00:00
|
|
|
}
|
|
|
|
|
2017-01-13 13:45:50 +00:00
|
|
|
if (file_list_vb->is_visible()) {
|
2016-05-15 23:25:51 +00:00
|
|
|
|
2015-08-23 23:15:56 +00:00
|
|
|
_update_files(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
set_process(false);
|
|
|
|
}
|
|
|
|
|
2017-01-21 12:07:29 +00:00
|
|
|
void FileSystemDock::_set_scanning_mode() {
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2016-05-15 23:25:51 +00:00
|
|
|
split_box->hide();
|
2015-08-23 23:15:56 +00:00
|
|
|
button_hist_prev->set_disabled(true);
|
|
|
|
button_hist_next->set_disabled(true);
|
|
|
|
scanning_vb->show();
|
|
|
|
set_process(true);
|
|
|
|
if (EditorFileSystem::get_singleton()->is_scanning()) {
|
2017-03-05 15:44:50 +00:00
|
|
|
scanning_progress->set_value(EditorFileSystem::get_singleton()->get_scanning_progress() * 100);
|
2015-08-23 23:15:56 +00:00
|
|
|
} else {
|
2017-01-04 04:16:14 +00:00
|
|
|
scanning_progress->set_value(0);
|
2015-08-23 23:15:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-21 13:34:57 +00:00
|
|
|
void FileSystemDock::_fw_history() {
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (history_pos < history.size() - 1)
|
2015-08-23 23:15:56 +00:00
|
|
|
history_pos++;
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
path = history[history_pos];
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2017-01-13 13:45:50 +00:00
|
|
|
if (tree->is_visible()) {
|
2015-08-23 23:15:56 +00:00
|
|
|
_update_tree();
|
|
|
|
tree->grab_focus();
|
|
|
|
tree->ensure_cursor_is_visible();
|
2016-05-15 23:25:51 +00:00
|
|
|
}
|
|
|
|
|
2017-01-13 13:45:50 +00:00
|
|
|
if (file_list_vb->is_visible()) {
|
2015-08-23 23:15:56 +00:00
|
|
|
_update_files(false);
|
|
|
|
current_path->set_text(path);
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
button_hist_prev->set_disabled(history_pos == 0);
|
|
|
|
button_hist_next->set_disabled(history_pos + 1 == history.size());
|
2015-08-23 23:15:56 +00:00
|
|
|
}
|
|
|
|
|
2016-07-21 13:34:57 +00:00
|
|
|
void FileSystemDock::_bw_history() {
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (history_pos > 0)
|
2015-08-23 23:15:56 +00:00
|
|
|
history_pos--;
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
path = history[history_pos];
|
2016-05-15 23:25:51 +00:00
|
|
|
|
2017-01-13 13:45:50 +00:00
|
|
|
if (tree->is_visible()) {
|
2015-08-23 23:15:56 +00:00
|
|
|
_update_tree();
|
|
|
|
tree->grab_focus();
|
|
|
|
tree->ensure_cursor_is_visible();
|
2016-05-15 23:25:51 +00:00
|
|
|
}
|
|
|
|
|
2017-01-13 13:45:50 +00:00
|
|
|
if (file_list_vb->is_visible()) {
|
2015-08-23 23:15:56 +00:00
|
|
|
_update_files(false);
|
|
|
|
current_path->set_text(path);
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
button_hist_prev->set_disabled(history_pos == 0);
|
|
|
|
button_hist_next->set_disabled(history_pos + 1 == history.size());
|
2015-08-23 23:15:56 +00:00
|
|
|
}
|
|
|
|
|
2016-07-21 13:34:57 +00:00
|
|
|
void FileSystemDock::_push_to_history() {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
history.resize(history_pos + 1);
|
|
|
|
if (history[history_pos] != path) {
|
2015-08-23 23:15:56 +00:00
|
|
|
history.push_back(path);
|
|
|
|
history_pos++;
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
button_hist_prev->set_disabled(history_pos == 0);
|
|
|
|
button_hist_next->set_disabled(history_pos + 1 == history.size());
|
2015-08-23 23:15:56 +00:00
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void FileSystemDock::_find_inside_move_files(EditorFileSystemDirectory *efsd, Vector<String> &files) {
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
for (int i = 0; i < efsd->get_subdir_count(); i++) {
|
|
|
|
_find_inside_move_files(efsd->get_subdir(i), files);
|
2015-08-23 23:15:56 +00:00
|
|
|
}
|
2017-03-05 15:44:50 +00:00
|
|
|
for (int i = 0; i < efsd->get_file_count(); i++) {
|
2015-08-23 23:15:56 +00:00
|
|
|
files.push_back(efsd->get_file_path(i));
|
|
|
|
}
|
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void FileSystemDock::_find_remaps(EditorFileSystemDirectory *efsd, Map<String, String> &renames, List<String> &to_remaps) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
for (int i = 0; i < efsd->get_subdir_count(); i++) {
|
|
|
|
_find_remaps(efsd->get_subdir(i), renames, to_remaps);
|
2015-08-23 23:15:56 +00:00
|
|
|
}
|
2017-03-05 15:44:50 +00:00
|
|
|
for (int i = 0; i < efsd->get_file_count(); i++) {
|
|
|
|
Vector<String> deps = efsd->get_file_deps(i);
|
|
|
|
for (int j = 0; j < deps.size(); j++) {
|
2015-08-23 23:15:56 +00:00
|
|
|
if (renames.has(deps[j])) {
|
|
|
|
to_remaps.push_back(efsd->get_file_path(i));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void FileSystemDock::_rename_operation(const String &p_to_path) {
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (move_files[0] == p_to_path) {
|
2016-05-04 01:25:37 +00:00
|
|
|
EditorNode::get_singleton()->show_warning(TTR("Same source and destination files, doing nothing."));
|
2015-08-23 23:15:56 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (FileAccess::exists(p_to_path)) {
|
2017-08-23 20:25:14 +00:00
|
|
|
EditorNode::get_singleton()->show_warning(TTR("Target file exists, can't overwrite. Delete first."));
|
2015-08-23 23:15:56 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
Map<String, String> renames;
|
|
|
|
renames[move_files[0]] = p_to_path;
|
2015-08-23 23:15:56 +00:00
|
|
|
|
|
|
|
List<String> remap;
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
_find_remaps(EditorFileSystem::get_singleton()->get_filesystem(), renames, remap);
|
|
|
|
print_line("found files to remap: " + itos(remap.size()));
|
2015-08-23 23:15:56 +00:00
|
|
|
|
|
|
|
//perform remaps
|
2017-03-05 15:44:50 +00:00
|
|
|
for (List<String>::Element *E = remap.front(); E; E = E->next()) {
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
Error err = ResourceLoader::rename_dependencies(E->get(), renames);
|
|
|
|
print_line("remapping: " + E->get());
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (err != OK) {
|
|
|
|
EditorNode::get_singleton()->add_io_error("Can't rename deps for:\n" + E->get() + "\n");
|
2015-08-23 23:15:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//finally, perform moves
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
Error err = da->rename(move_files[0], p_to_path);
|
|
|
|
print_line("moving file " + move_files[0] + " to " + p_to_path);
|
|
|
|
if (err != OK) {
|
|
|
|
EditorNode::get_singleton()->add_io_error("Error moving file:\n" + move_files[0] + "\n");
|
2015-08-23 23:15:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//rescan everything
|
|
|
|
memdelete(da);
|
|
|
|
print_line("call rescan!");
|
|
|
|
_rescan();
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void FileSystemDock::_move_operation(const String &p_to_path) {
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (p_to_path == path) {
|
2016-05-04 01:25:37 +00:00
|
|
|
EditorNode::get_singleton()->show_warning(TTR("Same source and destination paths, doing nothing."));
|
2015-08-23 23:15:56 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//find files inside dirs to be moved
|
|
|
|
|
|
|
|
Vector<String> inside_files;
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
for (int i = 0; i < move_dirs.size(); i++) {
|
2015-08-23 23:15:56 +00:00
|
|
|
if (p_to_path.begins_with(move_dirs[i])) {
|
2016-05-18 22:08:12 +00:00
|
|
|
EditorNode::get_singleton()->show_warning(TTR("Can't move directories to within themselves."));
|
2014-02-10 01:10:30 +00:00
|
|
|
return;
|
2015-08-23 23:15:56 +00:00
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
EditorFileSystemDirectory *efsd = EditorFileSystem::get_singleton()->get_filesystem_path(move_dirs[i]);
|
2015-08-23 23:15:56 +00:00
|
|
|
if (!efsd)
|
|
|
|
continue;
|
2017-03-05 15:44:50 +00:00
|
|
|
_find_inside_move_files(efsd, inside_files);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2015-08-23 23:15:56 +00:00
|
|
|
//make list of remaps
|
2017-03-05 15:44:50 +00:00
|
|
|
Map<String, String> renames;
|
|
|
|
String repfrom = path == "res://" ? path : String(path + "/");
|
2017-09-03 03:22:54 +00:00
|
|
|
String repto = p_to_path;
|
|
|
|
if (!repto.ends_with("/")) {
|
|
|
|
repto += "/";
|
|
|
|
}
|
|
|
|
|
|
|
|
print_line("reprfrom: " + repfrom + " repto " + repto);
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
for (int i = 0; i < move_files.size(); i++) {
|
|
|
|
renames[move_files[i]] = move_files[i].replace_first(repfrom, repto);
|
|
|
|
print_line("move file " + move_files[i] + " -> " + renames[move_files[i]]);
|
2015-08-23 23:15:56 +00:00
|
|
|
}
|
2017-03-05 15:44:50 +00:00
|
|
|
for (int i = 0; i < inside_files.size(); i++) {
|
|
|
|
renames[inside_files[i]] = inside_files[i].replace_first(repfrom, repto);
|
|
|
|
print_line("inside file " + inside_files[i] + " -> " + renames[inside_files[i]]);
|
2015-08-23 23:15:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//make list of files that will be run the remapping
|
|
|
|
List<String> remap;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
_find_remaps(EditorFileSystem::get_singleton()->get_filesystem(), renames, remap);
|
|
|
|
print_line("found files to remap: " + itos(remap.size()));
|
2015-08-23 23:15:56 +00:00
|
|
|
|
|
|
|
//perform remaps
|
2017-03-05 15:44:50 +00:00
|
|
|
for (List<String>::Element *E = remap.front(); E; E = E->next()) {
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
Error err = ResourceLoader::rename_dependencies(E->get(), renames);
|
|
|
|
print_line("remapping: " + E->get());
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (err != OK) {
|
2017-08-23 20:25:14 +00:00
|
|
|
EditorNode::get_singleton()->add_io_error(TTR("Can't rename deps for:\n") + E->get() + "\n");
|
2015-08-23 23:15:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//finally, perform moves
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
for (int i = 0; i < move_files.size(); i++) {
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
String to = move_files[i].replace_first(repfrom, repto);
|
|
|
|
Error err = da->rename(move_files[i], to);
|
|
|
|
print_line("moving file " + move_files[i] + " to " + to);
|
|
|
|
if (err != OK) {
|
2017-08-23 20:25:14 +00:00
|
|
|
EditorNode::get_singleton()->add_io_error(TTR("Error moving file:\n") + move_files[i] + "\n");
|
2015-08-23 23:15:56 +00:00
|
|
|
}
|
2017-09-03 03:22:54 +00:00
|
|
|
if (FileAccess::exists(move_files[i] + ".import")) { //move imported files too
|
|
|
|
//@todo should remove the files in .import folder
|
|
|
|
err = da->rename(move_files[i] + ".import", to + ".import");
|
|
|
|
if (err != OK) {
|
|
|
|
EditorNode::get_singleton()->add_io_error(TTR("Error moving file:\n") + move_files[i] + ".import\n");
|
|
|
|
}
|
|
|
|
}
|
2015-08-23 23:15:56 +00:00
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
for (int i = 0; i < move_dirs.size(); i++) {
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2016-05-15 23:25:51 +00:00
|
|
|
String mdir = move_dirs[i];
|
2017-03-05 15:44:50 +00:00
|
|
|
if (mdir == "res://")
|
2016-05-15 23:25:51 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if (mdir.ends_with("/")) {
|
2017-03-05 15:44:50 +00:00
|
|
|
mdir = mdir.substr(0, mdir.length() - 1);
|
2016-05-15 23:25:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
String to = p_to_path.plus_file(mdir.get_file());
|
2017-03-05 15:44:50 +00:00
|
|
|
Error err = da->rename(mdir, to);
|
|
|
|
print_line("moving dir " + mdir + " to " + to);
|
|
|
|
if (err != OK) {
|
2017-08-23 20:25:14 +00:00
|
|
|
EditorNode::get_singleton()->add_io_error(TTR("Error moving dir:\n") + move_dirs[i] + "\n");
|
2015-08-23 23:15:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
memdelete(da);
|
|
|
|
//rescan everything
|
|
|
|
print_line("call rescan!");
|
|
|
|
_rescan();
|
|
|
|
}
|
|
|
|
|
2016-07-21 13:34:57 +00:00
|
|
|
void FileSystemDock::_file_option(int p_option) {
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
switch (p_option) {
|
2016-05-15 23:25:51 +00:00
|
|
|
|
2016-05-18 07:37:59 +00:00
|
|
|
case FILE_SHOW_IN_EXPLORER:
|
2016-05-15 23:25:51 +00:00
|
|
|
case FILE_OPEN: {
|
2017-03-05 15:44:50 +00:00
|
|
|
int idx = -1;
|
|
|
|
for (int i = 0; i < files->get_item_count(); i++) {
|
2016-05-15 23:25:51 +00:00
|
|
|
if (files->is_selected(i)) {
|
2017-03-05 15:44:50 +00:00
|
|
|
idx = i;
|
2016-05-15 23:25:51 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (idx < 0)
|
2016-05-15 23:25:51 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
String path = files->get_item_metadata(idx);
|
2016-05-18 07:37:59 +00:00
|
|
|
if (p_option == FILE_SHOW_IN_EXPLORER) {
|
2017-07-19 20:00:46 +00:00
|
|
|
String dir = ProjectSettings::get_singleton()->globalize_path(path);
|
2016-05-21 12:08:35 +00:00
|
|
|
dir = dir.substr(0, dir.find_last("/"));
|
2017-03-05 15:44:50 +00:00
|
|
|
OS::get_singleton()->shell_open(String("file://") + dir);
|
2016-05-18 07:37:59 +00:00
|
|
|
return;
|
|
|
|
}
|
2016-05-15 23:25:51 +00:00
|
|
|
|
|
|
|
if (path.ends_with("/")) {
|
2017-03-05 15:44:50 +00:00
|
|
|
if (path != "res://") {
|
|
|
|
path = path.substr(0, path.length() - 1);
|
2016-05-15 23:25:51 +00:00
|
|
|
}
|
2017-03-05 15:44:50 +00:00
|
|
|
this->path = path;
|
2016-05-15 23:25:51 +00:00
|
|
|
_update_files(false);
|
|
|
|
current_path->set_text(path);
|
|
|
|
_push_to_history();
|
|
|
|
} else {
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (ResourceLoader::get_resource_type(path) == "PackedScene") {
|
2016-05-15 23:25:51 +00:00
|
|
|
|
|
|
|
editor->open_request(path);
|
|
|
|
} else {
|
|
|
|
|
|
|
|
editor->load_resource(path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
case FILE_INSTANCE: {
|
|
|
|
|
2016-07-20 17:09:03 +00:00
|
|
|
Vector<String> paths;
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
for (int i = 0; i < files->get_item_count(); i++) {
|
2016-07-21 13:36:47 +00:00
|
|
|
if (!files->is_selected(i))
|
|
|
|
continue;
|
2017-03-05 15:44:50 +00:00
|
|
|
String path = files->get_item_metadata(i);
|
|
|
|
if (EditorFileSystem::get_singleton()->get_file_type(path) == "PackedScene") {
|
2016-07-20 17:09:03 +00:00
|
|
|
paths.push_back(path);
|
2016-05-15 23:25:51 +00:00
|
|
|
}
|
|
|
|
}
|
2016-07-20 17:09:03 +00:00
|
|
|
|
|
|
|
if (!paths.empty()) {
|
|
|
|
emit_signal("instance", paths);
|
|
|
|
}
|
2016-05-15 23:25:51 +00:00
|
|
|
} break;
|
2015-08-23 23:15:56 +00:00
|
|
|
case FILE_DEPENDENCIES: {
|
|
|
|
|
|
|
|
int idx = files->get_current();
|
2017-03-05 15:44:50 +00:00
|
|
|
if (idx < 0 || idx >= files->get_item_count())
|
2015-08-23 23:15:56 +00:00
|
|
|
break;
|
|
|
|
String path = files->get_item_metadata(idx);
|
|
|
|
deps_editor->edit(path);
|
|
|
|
} break;
|
|
|
|
case FILE_OWNERS: {
|
|
|
|
|
|
|
|
int idx = files->get_current();
|
2017-03-05 15:44:50 +00:00
|
|
|
if (idx < 0 || idx >= files->get_item_count())
|
2015-08-23 23:15:56 +00:00
|
|
|
break;
|
|
|
|
String path = files->get_item_metadata(idx);
|
|
|
|
owners_editor->show(path);
|
|
|
|
} break;
|
|
|
|
case FILE_MOVE: {
|
|
|
|
|
2017-01-14 17:03:38 +00:00
|
|
|
move_dirs.clear();
|
2015-08-23 23:15:56 +00:00
|
|
|
move_files.clear();
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
for (int i = 0; i < files->get_item_count(); i++) {
|
2015-08-23 23:15:56 +00:00
|
|
|
|
|
|
|
String path = files->get_item_metadata(i);
|
|
|
|
if (!files->is_selected(i))
|
|
|
|
continue;
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (files->get_item_text(i) == "..") {
|
|
|
|
EditorNode::get_singleton()->show_warning(TTR("Can't operate on '..'"));
|
|
|
|
return;
|
|
|
|
}
|
2015-08-23 23:15:56 +00:00
|
|
|
|
|
|
|
if (path.ends_with("/")) {
|
2017-03-05 15:44:50 +00:00
|
|
|
move_dirs.push_back(path.substr(0, path.length() - 1));
|
2015-08-23 23:15:56 +00:00
|
|
|
} else {
|
|
|
|
move_files.push_back(path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (move_dirs.empty() && move_files.size() == 1) {
|
2015-08-23 23:15:56 +00:00
|
|
|
|
|
|
|
rename_dialog->clear_filters();
|
2017-03-05 15:44:50 +00:00
|
|
|
rename_dialog->add_filter("*." + move_files[0].get_extension());
|
2015-08-23 23:15:56 +00:00
|
|
|
rename_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE);
|
|
|
|
rename_dialog->set_current_path(move_files[0]);
|
|
|
|
rename_dialog->popup_centered_ratio();
|
2017-03-05 15:44:50 +00:00
|
|
|
rename_dialog->set_title(TTR("Pick New Name and Location For:") + " " + move_files[0].get_file());
|
2015-08-23 23:15:56 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
//just move
|
|
|
|
move_dialog->popup_centered_ratio();
|
|
|
|
}
|
|
|
|
|
|
|
|
} break;
|
|
|
|
case FILE_REMOVE: {
|
|
|
|
|
|
|
|
Vector<String> torem;
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
for (int i = 0; i < files->get_item_count(); i++) {
|
2015-08-23 23:15:56 +00:00
|
|
|
|
|
|
|
String path = files->get_item_metadata(i);
|
|
|
|
if (path.ends_with("/") || !files->is_selected(i))
|
|
|
|
continue;
|
|
|
|
torem.push_back(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (torem.empty()) {
|
2016-05-04 01:25:37 +00:00
|
|
|
EditorNode::get_singleton()->show_warning(TTR("No files selected!"));
|
2015-08-23 23:15:56 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
remove_dialog->show(torem);
|
|
|
|
//1) find if used
|
|
|
|
//2) warn
|
|
|
|
|
|
|
|
} break;
|
|
|
|
case FILE_INFO: {
|
|
|
|
|
|
|
|
} break;
|
2016-05-27 17:18:40 +00:00
|
|
|
case FILE_REIMPORT: {
|
|
|
|
|
|
|
|
Vector<String> reimport;
|
2017-03-05 15:44:50 +00:00
|
|
|
for (int i = 0; i < files->get_item_count(); i++) {
|
2016-05-27 17:18:40 +00:00
|
|
|
|
|
|
|
if (!files->is_selected(i))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
String path = files->get_item_metadata(i);
|
|
|
|
reimport.push_back(path);
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
ERR_FAIL_COND(reimport.size() == 0);
|
|
|
|
/*
|
2016-05-27 17:18:40 +00:00
|
|
|
Ref<ResourceImportMetadata> rimd = ResourceLoader::load_import_metadata(reimport[0]);
|
|
|
|
ERR_FAIL_COND(!rimd.is_valid());
|
|
|
|
String editor=rimd->get_editor();
|
|
|
|
|
|
|
|
if (editor.begins_with("texture_")) { //compatibility fix for old texture format
|
|
|
|
editor="texture";
|
|
|
|
}
|
|
|
|
|
|
|
|
Ref<EditorImportPlugin> rimp = EditorImportExport::get_singleton()->get_import_plugin_by_name(editor);
|
|
|
|
ERR_FAIL_COND(!rimp.is_valid());
|
|
|
|
|
|
|
|
if (reimport.size()==1) {
|
|
|
|
rimp->import_dialog(reimport[0]);
|
|
|
|
} else {
|
|
|
|
rimp->reimport_multiple_files(reimport);
|
|
|
|
|
|
|
|
}
|
2017-01-26 00:55:59 +00:00
|
|
|
*/
|
2016-05-27 17:18:40 +00:00
|
|
|
|
|
|
|
} break;
|
2016-06-06 15:20:03 +00:00
|
|
|
case FILE_COPY_PATH:
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2016-06-06 15:20:03 +00:00
|
|
|
int idx = files->get_current();
|
2017-03-05 15:44:50 +00:00
|
|
|
if (idx < 0 || idx >= files->get_item_count())
|
2016-06-06 15:20:03 +00:00
|
|
|
break;
|
|
|
|
String path = files->get_item_metadata(idx);
|
|
|
|
OS::get_singleton()->set_clipboard(path);
|
2015-08-23 23:15:56 +00:00
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2017-01-10 12:19:59 +00:00
|
|
|
void FileSystemDock::_folder_option(int p_option) {
|
|
|
|
|
|
|
|
TreeItem *item = tree->get_selected();
|
|
|
|
TreeItem *child = item->get_children();
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
switch (p_option) {
|
|
|
|
|
2017-01-10 12:19:59 +00:00
|
|
|
case FOLDER_EXPAND_ALL:
|
|
|
|
item->set_collapsed(false);
|
2017-03-05 15:44:50 +00:00
|
|
|
while (child) {
|
2017-01-10 12:19:59 +00:00
|
|
|
child->set_collapsed(false);
|
|
|
|
child = child->get_next();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FOLDER_COLLAPSE_ALL:
|
2017-03-05 15:44:50 +00:00
|
|
|
while (child) {
|
2017-01-10 12:19:59 +00:00
|
|
|
child->set_collapsed(true);
|
|
|
|
child = child->get_next();
|
|
|
|
}
|
|
|
|
break;
|
2017-04-24 15:54:51 +00:00
|
|
|
case FOLDER_SHOW_IN_EXPLORER:
|
|
|
|
String path = item->get_metadata(tree->get_selected_column());
|
2017-07-19 20:00:46 +00:00
|
|
|
String dir = ProjectSettings::get_singleton()->globalize_path(path);
|
2017-04-24 15:54:51 +00:00
|
|
|
OS::get_singleton()->shell_open(String("file://") + dir);
|
|
|
|
return;
|
2017-01-10 12:19:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void FileSystemDock::_open_pressed() {
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2016-05-15 23:25:51 +00:00
|
|
|
TreeItem *sel = tree->get_selected();
|
|
|
|
if (!sel) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
path = sel->get_metadata(0);
|
|
|
|
/*if (path!="res://" && path.ends_with("/")) {
|
|
|
|
path=path.substr(0,path.length()-1);
|
|
|
|
}*/
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2016-05-15 23:25:51 +00:00
|
|
|
//tree_mode=false;
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2016-05-15 23:25:51 +00:00
|
|
|
if (split_mode) {
|
2015-08-23 23:15:56 +00:00
|
|
|
tree->hide();
|
2016-05-15 23:25:51 +00:00
|
|
|
file_list_vb->show();
|
2015-08-23 23:15:56 +00:00
|
|
|
button_favorite->hide();
|
2016-05-15 23:25:51 +00:00
|
|
|
}
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2016-05-15 23:25:51 +00:00
|
|
|
//file_options->show();
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2016-05-15 23:25:51 +00:00
|
|
|
_update_files(false);
|
|
|
|
current_path->set_text(path);
|
|
|
|
_push_to_history();
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2017-01-14 11:26:56 +00:00
|
|
|
//emit_signal("open",path);
|
2016-05-15 23:25:51 +00:00
|
|
|
}
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void FileSystemDock::_dir_rmb_pressed(const Vector2 &p_pos) {
|
2017-01-10 12:19:59 +00:00
|
|
|
folder_options->clear();
|
2017-03-05 15:44:50 +00:00
|
|
|
folder_options->set_size(Size2(1, 1));
|
2017-01-10 12:19:59 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
folder_options->add_item(TTR("Expand all"), FOLDER_EXPAND_ALL);
|
|
|
|
folder_options->add_item(TTR("Collapse all"), FOLDER_COLLAPSE_ALL);
|
2017-01-10 12:19:59 +00:00
|
|
|
|
2017-04-24 15:54:51 +00:00
|
|
|
folder_options->add_separator();
|
|
|
|
folder_options->add_item(TTR("Show In File Manager"), FOLDER_SHOW_IN_EXPLORER);
|
|
|
|
|
2017-03-29 15:29:38 +00:00
|
|
|
folder_options->set_position(tree->get_global_position() + p_pos);
|
2017-01-10 12:19:59 +00:00
|
|
|
folder_options->popup();
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void FileSystemDock::_search_changed(const String &p_text) {
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2017-01-13 13:45:50 +00:00
|
|
|
if (!search_box->is_visible_in_tree())
|
2016-05-15 23:25:51 +00:00
|
|
|
return; //wtf
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-05-15 23:25:51 +00:00
|
|
|
_update_files(false);
|
|
|
|
}
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2016-07-21 13:34:57 +00:00
|
|
|
void FileSystemDock::_rescan() {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-01-21 12:07:29 +00:00
|
|
|
_set_scanning_mode();
|
2014-02-10 01:10:30 +00:00
|
|
|
EditorFileSystem::get_singleton()->scan();
|
2015-08-23 23:15:56 +00:00
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void FileSystemDock::fix_dependencies(const String &p_for_file) {
|
2015-08-23 23:15:56 +00:00
|
|
|
deps_editor->edit(p_for_file);
|
|
|
|
}
|
|
|
|
|
2016-07-21 13:34:57 +00:00
|
|
|
void FileSystemDock::focus_on_filter() {
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2017-01-21 12:07:29 +00:00
|
|
|
if (!search_box->is_visible_in_tree()) {
|
|
|
|
// Tree mode, switch to files list with search box
|
|
|
|
tree->hide();
|
|
|
|
file_list_vb->show();
|
|
|
|
button_favorite->hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
search_box->grab_focus();
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2016-08-16 16:25:42 +00:00
|
|
|
void FileSystemDock::set_display_mode(int p_mode) {
|
|
|
|
|
|
|
|
if (p_mode == display_mode)
|
|
|
|
return;
|
2015-12-15 16:39:13 +00:00
|
|
|
|
2016-08-16 16:25:42 +00:00
|
|
|
button_display_mode->set_pressed(p_mode == DISPLAY_LIST);
|
|
|
|
_change_file_display();
|
2015-12-15 16:39:13 +00:00
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
Variant FileSystemDock::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
|
2016-05-11 14:46:08 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (p_from == tree) {
|
2016-05-15 23:25:51 +00:00
|
|
|
|
|
|
|
TreeItem *selected = tree->get_selected();
|
|
|
|
if (!selected)
|
|
|
|
return Variant();
|
|
|
|
|
|
|
|
String path = selected->get_metadata(0);
|
2017-03-05 15:44:50 +00:00
|
|
|
if (path == String())
|
2016-05-15 23:25:51 +00:00
|
|
|
return Variant();
|
|
|
|
if (!path.ends_with("/"))
|
2017-03-05 15:44:50 +00:00
|
|
|
path = path + "/";
|
2016-05-15 23:25:51 +00:00
|
|
|
Vector<String> paths;
|
|
|
|
paths.push_back(path);
|
2017-03-05 15:44:50 +00:00
|
|
|
Dictionary d = EditorNode::get_singleton()->drag_files(paths, p_from);
|
2016-05-24 02:24:17 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (selected->get_parent() && tree->get_root()->get_children() == selected->get_parent()) {
|
2016-05-24 02:24:17 +00:00
|
|
|
//a favorite.. treat as such
|
2017-03-05 15:44:50 +00:00
|
|
|
d["type"] = "favorite";
|
2016-05-24 02:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return d;
|
2016-05-15 23:25:51 +00:00
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (p_from == files) {
|
2016-05-11 14:46:08 +00:00
|
|
|
|
|
|
|
List<int> seldirs;
|
|
|
|
List<int> selfiles;
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
for (int i = 0; i < files->get_item_count(); i++) {
|
2016-05-11 14:46:08 +00:00
|
|
|
if (files->is_selected(i)) {
|
|
|
|
String path = files->get_item_metadata(i);
|
|
|
|
if (path.ends_with("/"))
|
|
|
|
seldirs.push_back(i);
|
|
|
|
else
|
|
|
|
selfiles.push_back(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (seldirs.empty() && selfiles.empty())
|
|
|
|
return Variant();
|
2017-01-14 11:26:56 +00:00
|
|
|
/*
|
|
|
|
if (seldirs.size() && selfiles.size())
|
|
|
|
return Variant(); //can't really mix files and dirs (i think?) - yes you can, commenting
|
|
|
|
*/
|
2016-05-11 14:46:08 +00:00
|
|
|
|
|
|
|
/*if (selfiles.size()==1) {
|
|
|
|
Ref<Resource> resource = ResourceLoader::load(files->get_item_metadata(selfiles.front()->get()));
|
|
|
|
if (resource.is_valid()) {
|
|
|
|
return EditorNode::get_singleton()->drag_resource(resource,p_from);
|
|
|
|
}
|
|
|
|
}*/
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (selfiles.size() > 0 && seldirs.size() == 0) {
|
2016-05-11 14:46:08 +00:00
|
|
|
Vector<String> fnames;
|
2017-03-05 15:44:50 +00:00
|
|
|
for (List<int>::Element *E = selfiles.front(); E; E = E->next()) {
|
2016-05-11 14:46:08 +00:00
|
|
|
fnames.push_back(files->get_item_metadata(E->get()));
|
|
|
|
}
|
2017-03-05 15:44:50 +00:00
|
|
|
return EditorNode::get_singleton()->drag_files(fnames, p_from);
|
2016-05-11 14:46:08 +00:00
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (selfiles.size() > 0 || seldirs.size() > 0) {
|
2016-05-11 14:46:08 +00:00
|
|
|
Vector<String> fnames;
|
2017-03-05 15:44:50 +00:00
|
|
|
for (List<int>::Element *E = selfiles.front(); E; E = E->next()) {
|
2016-05-11 14:46:08 +00:00
|
|
|
fnames.push_back(files->get_item_metadata(E->get()));
|
|
|
|
}
|
2017-03-05 15:44:50 +00:00
|
|
|
for (List<int>::Element *E = seldirs.front(); E; E = E->next()) {
|
2016-05-11 14:46:08 +00:00
|
|
|
fnames.push_back(files->get_item_metadata(E->get()));
|
|
|
|
}
|
2017-03-05 15:44:50 +00:00
|
|
|
return EditorNode::get_singleton()->drag_files_and_dirs(fnames, p_from);
|
2016-05-11 14:46:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return Variant();
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
bool FileSystemDock::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
|
2016-05-11 14:46:08 +00:00
|
|
|
|
|
|
|
Dictionary drag_data = p_data;
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (drag_data.has("type") && String(drag_data["type"]) == "favorite") {
|
2016-05-24 02:24:17 +00:00
|
|
|
|
|
|
|
//moving favorite around
|
2017-09-10 13:37:49 +00:00
|
|
|
TreeItem *ti = tree->get_item_at_position(p_point);
|
2016-05-24 02:24:17 +00:00
|
|
|
if (!ti)
|
|
|
|
return false;
|
|
|
|
|
2017-09-10 13:37:49 +00:00
|
|
|
int what = tree->get_drop_section_at_position(p_point);
|
2016-05-24 02:24:17 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (ti == tree->get_root()->get_children()) {
|
|
|
|
return (what == 1); //the parent, first fav
|
2016-05-24 02:24:17 +00:00
|
|
|
}
|
2017-03-05 15:44:50 +00:00
|
|
|
if (ti->get_parent() && tree->get_root()->get_children() == ti->get_parent()) {
|
2016-05-24 02:24:17 +00:00
|
|
|
return true; // a favorite
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (ti == tree->get_root()->get_children()->get_next()) {
|
|
|
|
return (what == -1); //the tree, last fav
|
2016-05-24 02:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (drag_data.has("type") && String(drag_data["type"]) == "resource") {
|
2016-05-11 14:46:08 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (drag_data.has("type") && (String(drag_data["type"]) == "files" || String(drag_data["type"]) == "files_and_dirs")) {
|
2016-05-11 14:46:08 +00:00
|
|
|
|
|
|
|
Vector<String> fnames = drag_data["files"];
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (p_from == files) {
|
2016-05-11 14:46:08 +00:00
|
|
|
|
2017-09-10 13:37:49 +00:00
|
|
|
int at_pos = files->get_item_at_position(p_point);
|
2017-03-05 15:44:50 +00:00
|
|
|
if (at_pos != -1) {
|
2016-05-11 14:46:08 +00:00
|
|
|
|
|
|
|
String dir = files->get_item_metadata(at_pos);
|
|
|
|
if (dir.ends_with("/"))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2016-05-15 23:25:51 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (p_from == tree) {
|
2016-05-15 23:25:51 +00:00
|
|
|
|
2017-09-10 13:37:49 +00:00
|
|
|
TreeItem *ti = tree->get_item_at_position(p_point);
|
2016-05-15 23:25:51 +00:00
|
|
|
if (!ti)
|
|
|
|
return false;
|
|
|
|
String path = ti->get_metadata(0);
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (path == String())
|
2016-05-15 23:25:51 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2016-05-11 14:46:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void FileSystemDock::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
|
2016-05-11 14:46:08 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (!can_drop_data_fw(p_point, p_data, p_from))
|
2016-05-11 14:46:08 +00:00
|
|
|
return;
|
|
|
|
Dictionary drag_data = p_data;
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (drag_data.has("type") && String(drag_data["type"]) == "favorite") {
|
2016-05-24 02:24:17 +00:00
|
|
|
|
|
|
|
//moving favorite around
|
2017-09-10 13:37:49 +00:00
|
|
|
TreeItem *ti = tree->get_item_at_position(p_point);
|
2016-05-24 02:24:17 +00:00
|
|
|
if (!ti)
|
|
|
|
return;
|
|
|
|
|
|
|
|
Vector<String> files = drag_data["files"];
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
ERR_FAIL_COND(files.size() != 1);
|
2016-05-24 02:24:17 +00:00
|
|
|
|
|
|
|
String swap = files[0];
|
2017-03-05 15:44:50 +00:00
|
|
|
if (swap != "res://" && swap.ends_with("/")) {
|
|
|
|
swap = swap.substr(0, swap.length() - 1);
|
2016-05-24 02:24:17 +00:00
|
|
|
}
|
|
|
|
|
2017-09-10 13:37:49 +00:00
|
|
|
int what = tree->get_drop_section_at_position(p_point);
|
2016-05-24 02:24:17 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
TreeItem *swap_item = NULL;
|
2016-05-24 02:24:17 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (ti == tree->get_root()->get_children()) {
|
|
|
|
swap_item = tree->get_root()->get_children()->get_children();
|
2016-05-24 02:24:17 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
} else if (ti->get_parent() && tree->get_root()->get_children() == ti->get_parent()) {
|
|
|
|
if (what == -1) {
|
|
|
|
swap_item = ti;
|
2016-05-24 02:24:17 +00:00
|
|
|
} else {
|
2017-03-05 15:44:50 +00:00
|
|
|
swap_item = ti->get_next();
|
2016-05-24 02:24:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
String swap_with;
|
|
|
|
|
|
|
|
if (swap_item) {
|
2017-03-05 15:44:50 +00:00
|
|
|
swap_with = swap_item->get_metadata(0);
|
|
|
|
if (swap_with != "res://" && swap_with.ends_with("/")) {
|
|
|
|
swap_with = swap_with.substr(0, swap_with.length() - 1);
|
2016-05-24 02:24:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (swap == swap_with)
|
2016-05-24 02:24:17 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
Vector<String> dirs = EditorSettings::get_singleton()->get_favorite_dirs();
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
ERR_FAIL_COND(dirs.find(swap) == -1);
|
|
|
|
ERR_FAIL_COND(swap_with != String() && dirs.find(swap_with) == -1);
|
2016-05-24 02:24:17 +00:00
|
|
|
|
|
|
|
dirs.erase(swap);
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (swap_with == String()) {
|
2016-05-24 02:24:17 +00:00
|
|
|
dirs.push_back(swap);
|
|
|
|
} else {
|
|
|
|
int idx = dirs.find(swap_with);
|
2017-03-05 15:44:50 +00:00
|
|
|
dirs.insert(idx, swap);
|
2016-05-24 02:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
EditorSettings::get_singleton()->set_favorite_dirs(dirs);
|
|
|
|
_update_tree();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (drag_data.has("type") && String(drag_data["type"]) == "resource") {
|
2016-05-11 14:46:08 +00:00
|
|
|
Ref<Resource> res = drag_data["resource"];
|
|
|
|
|
|
|
|
if (!res.is_valid()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (p_from == tree) {
|
2016-05-15 23:25:51 +00:00
|
|
|
|
2017-09-10 13:37:49 +00:00
|
|
|
TreeItem *ti = tree->get_item_at_position(p_point);
|
2016-05-15 23:25:51 +00:00
|
|
|
if (!ti)
|
|
|
|
return;
|
|
|
|
String path = ti->get_metadata(0);
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (path == String())
|
2016-05-15 23:25:51 +00:00
|
|
|
return;
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
EditorNode::get_singleton()->save_resource_as(res, path);
|
2016-05-15 23:25:51 +00:00
|
|
|
return;
|
2016-05-11 14:46:08 +00:00
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (p_from == files) {
|
|
|
|
String save_path = path;
|
2016-05-15 23:25:51 +00:00
|
|
|
|
2017-09-10 13:37:49 +00:00
|
|
|
int at_pos = files->get_item_at_position(p_point);
|
2017-03-05 15:44:50 +00:00
|
|
|
if (at_pos != -1) {
|
2016-05-15 23:25:51 +00:00
|
|
|
String to_dir = files->get_item_metadata(at_pos);
|
|
|
|
if (to_dir.ends_with("/")) {
|
2017-03-05 15:44:50 +00:00
|
|
|
save_path = to_dir;
|
|
|
|
if (save_path != "res://")
|
|
|
|
save_path = save_path.substr(0, save_path.length() - 1);
|
2016-05-15 23:25:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
EditorNode::get_singleton()->save_resource_as(res, save_path);
|
2016-05-15 23:25:51 +00:00
|
|
|
return;
|
|
|
|
}
|
2016-05-11 14:46:08 +00:00
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (drag_data.has("type") && (String(drag_data["type"]) == "files" || String(drag_data["type"]) == "files_and_dirs")) {
|
2016-05-11 14:46:08 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (p_from == files || p_from == tree) {
|
2016-05-11 14:46:08 +00:00
|
|
|
|
2016-05-15 23:25:51 +00:00
|
|
|
String to_dir;
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (p_from == files) {
|
2016-05-11 14:46:08 +00:00
|
|
|
|
2017-09-10 13:37:49 +00:00
|
|
|
int at_pos = files->get_item_at_position(p_point);
|
2017-03-05 15:44:50 +00:00
|
|
|
ERR_FAIL_COND(at_pos == -1);
|
2016-05-23 21:14:47 +00:00
|
|
|
to_dir = files->get_item_metadata(at_pos);
|
2017-03-05 15:44:50 +00:00
|
|
|
} else {
|
2017-09-10 13:37:49 +00:00
|
|
|
TreeItem *ti = tree->get_item_at_position(p_point);
|
2016-05-15 23:25:51 +00:00
|
|
|
if (!ti)
|
|
|
|
return;
|
|
|
|
to_dir = ti->get_metadata(0);
|
2017-03-05 15:44:50 +00:00
|
|
|
ERR_FAIL_COND(to_dir == String());
|
2016-05-15 23:25:51 +00:00
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (to_dir != "res://" && to_dir.ends_with("/")) {
|
|
|
|
to_dir = to_dir.substr(0, to_dir.length() - 1);
|
2016-05-15 23:25:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Vector<String> fnames = drag_data["files"];
|
|
|
|
move_files.clear();
|
|
|
|
move_dirs.clear();
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
for (int i = 0; i < fnames.size(); i++) {
|
2016-05-15 23:25:51 +00:00
|
|
|
if (fnames[i].ends_with("/"))
|
|
|
|
move_dirs.push_back(fnames[i]);
|
|
|
|
else
|
|
|
|
move_files.push_back(fnames[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
_move_operation(to_dir);
|
|
|
|
}
|
2016-05-11 14:46:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void FileSystemDock::_files_list_rmb_select(int p_item, const Vector2 &p_pos) {
|
2016-05-15 23:25:51 +00:00
|
|
|
|
|
|
|
Vector<String> filenames;
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
bool all_scenes = true;
|
|
|
|
bool all_can_reimport = true;
|
2016-05-27 17:18:40 +00:00
|
|
|
Set<String> types;
|
2016-05-15 23:25:51 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
for (int i = 0; i < files->get_item_count(); i++) {
|
2016-05-15 23:25:51 +00:00
|
|
|
|
|
|
|
if (!files->is_selected(i))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
String path = files->get_item_metadata(i);
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (files->get_item_text(i) == "..") {
|
2016-05-15 23:25:51 +00:00
|
|
|
// no operate on ..
|
2017-03-05 15:44:50 +00:00
|
|
|
return;
|
2016-05-15 23:25:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (path.ends_with("/")) {
|
|
|
|
//no operate on dirs
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-05-27 17:18:40 +00:00
|
|
|
int pos;
|
|
|
|
|
2017-08-21 19:15:36 +00:00
|
|
|
EditorFileSystemDirectory *efsd = EditorFileSystem::get_singleton()->find_file(path, &pos);
|
2016-05-27 17:18:40 +00:00
|
|
|
|
|
|
|
if (efsd) {
|
|
|
|
|
|
|
|
} else {
|
2017-03-05 15:44:50 +00:00
|
|
|
all_can_reimport = false;
|
2016-05-27 17:18:40 +00:00
|
|
|
}
|
|
|
|
|
2016-05-15 23:25:51 +00:00
|
|
|
filenames.push_back(path);
|
2017-03-05 15:44:50 +00:00
|
|
|
if (EditorFileSystem::get_singleton()->get_file_type(path) != "PackedScene")
|
|
|
|
all_scenes = false;
|
2016-05-15 23:25:51 +00:00
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (filenames.size() == 0)
|
2016-05-15 23:25:51 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
file_options->clear();
|
2017-03-05 15:44:50 +00:00
|
|
|
file_options->set_size(Size2(1, 1));
|
2016-05-15 23:25:51 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
file_options->add_item(TTR("Open"), FILE_OPEN);
|
2016-05-15 23:25:51 +00:00
|
|
|
if (all_scenes) {
|
2017-03-05 15:44:50 +00:00
|
|
|
file_options->add_item(TTR("Instance"), FILE_INSTANCE);
|
2016-05-15 23:25:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
file_options->add_separator();
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (filenames.size() == 1) {
|
|
|
|
file_options->add_item(TTR("Edit Dependencies.."), FILE_DEPENDENCIES);
|
|
|
|
file_options->add_item(TTR("View Owners.."), FILE_OWNERS);
|
2016-05-15 23:25:51 +00:00
|
|
|
file_options->add_separator();
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (filenames.size() == 1) {
|
2016-06-06 15:20:03 +00:00
|
|
|
file_options->add_item(TTR("Copy Path"), FILE_COPY_PATH);
|
2017-03-05 15:44:50 +00:00
|
|
|
file_options->add_item(TTR("Rename or Move.."), FILE_MOVE);
|
2016-05-15 23:25:51 +00:00
|
|
|
} else {
|
2017-03-05 15:44:50 +00:00
|
|
|
file_options->add_item(TTR("Move To.."), FILE_MOVE);
|
2016-05-15 23:25:51 +00:00
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
file_options->add_item(TTR("Delete"), FILE_REMOVE);
|
2016-05-27 17:18:40 +00:00
|
|
|
|
2016-05-15 23:25:51 +00:00
|
|
|
//file_options->add_item(TTR("Info"),FILE_INFO);
|
2016-05-18 07:37:59 +00:00
|
|
|
|
|
|
|
file_options->add_separator();
|
2017-03-05 15:44:50 +00:00
|
|
|
file_options->add_item(TTR("Show In File Manager"), FILE_SHOW_IN_EXPLORER);
|
2016-05-18 07:37:59 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (all_can_reimport && types.size() == 1) { //all can reimport and are of the same type
|
2016-05-27 17:18:40 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
/*
|
2016-05-27 17:18:40 +00:00
|
|
|
bool valid=true;
|
|
|
|
Ref<EditorImportPlugin> rimp = EditorImportExport::get_singleton()->get_import_plugin_by_name(types.front()->get());
|
|
|
|
if (rimp.is_valid()) {
|
|
|
|
|
|
|
|
if (filenames.size()>1 && !rimp->can_reimport_multiple_files()) {
|
|
|
|
valid=false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
valid=false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (valid) {
|
|
|
|
file_options->add_separator();
|
|
|
|
file_options->add_item(TTR("Re-Import.."),FILE_REIMPORT);
|
|
|
|
}
|
2017-01-26 00:55:59 +00:00
|
|
|
*/
|
2016-05-27 17:18:40 +00:00
|
|
|
}
|
|
|
|
|
2017-03-29 15:29:38 +00:00
|
|
|
file_options->set_position(files->get_global_position() + p_pos);
|
2016-05-15 23:25:51 +00:00
|
|
|
file_options->popup();
|
|
|
|
}
|
2016-05-11 14:46:08 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void FileSystemDock::select_file(const String &p_file) {
|
2017-01-25 17:30:40 +00:00
|
|
|
|
|
|
|
_go_to_dir(p_file.get_base_dir());
|
2017-03-05 15:44:50 +00:00
|
|
|
for (int i = 0; i < files->get_item_count(); i++) {
|
|
|
|
if (files->get_item_metadata(i) == p_file) {
|
2017-01-25 17:30:40 +00:00
|
|
|
files->select(i);
|
|
|
|
files->ensure_current_is_visible();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void FileSystemDock::_file_multi_selected(int p_index, bool p_selected) {
|
2017-02-01 12:45:45 +00:00
|
|
|
|
|
|
|
_file_selected();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FileSystemDock::_file_selected() {
|
|
|
|
|
|
|
|
//check import
|
|
|
|
Vector<String> imports;
|
|
|
|
String import_type;
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
for (int i = 0; i < files->get_item_count(); i++) {
|
2017-02-01 12:45:45 +00:00
|
|
|
if (!files->is_selected(i))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
String p = files->get_item_metadata(i);
|
2017-03-05 15:44:50 +00:00
|
|
|
if (!FileAccess::exists(p + ".import")) {
|
2017-02-01 12:45:45 +00:00
|
|
|
imports.clear();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
Ref<ConfigFile> cf;
|
|
|
|
cf.instance();
|
2017-03-05 15:44:50 +00:00
|
|
|
Error err = cf->load(p + ".import");
|
|
|
|
if (err != OK) {
|
2017-02-01 12:45:45 +00:00
|
|
|
imports.clear();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
String type = cf->get_value("remap", "type");
|
|
|
|
if (import_type == "") {
|
|
|
|
import_type = type;
|
|
|
|
} else if (import_type != type) {
|
2017-02-01 12:45:45 +00:00
|
|
|
//all should be the same type
|
|
|
|
imports.clear();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
imports.push_back(p);
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (imports.size() == 0) {
|
2017-02-01 12:45:45 +00:00
|
|
|
EditorNode::get_singleton()->get_import_dock()->clear();
|
2017-03-05 15:44:50 +00:00
|
|
|
} else if (imports.size() == 1) {
|
2017-02-01 12:45:45 +00:00
|
|
|
EditorNode::get_singleton()->get_import_dock()->set_edit_path(imports[0]);
|
|
|
|
} else {
|
|
|
|
EditorNode::get_singleton()->get_import_dock()->set_edit_multiple_paths(imports);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-21 13:34:57 +00:00
|
|
|
void FileSystemDock::_bind_methods() {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("_update_tree"), &FileSystemDock::_update_tree);
|
|
|
|
ClassDB::bind_method(D_METHOD("_rescan"), &FileSystemDock::_rescan);
|
|
|
|
ClassDB::bind_method(D_METHOD("_favorites_pressed"), &FileSystemDock::_favorites_pressed);
|
2017-02-13 11:47:24 +00:00
|
|
|
//ClassDB::bind_method(D_METHOD("_instance_pressed"),&ScenesDock::_instance_pressed);
|
2017-03-05 15:44:50 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("_open_pressed"), &FileSystemDock::_open_pressed);
|
|
|
|
ClassDB::bind_method(D_METHOD("_dir_rmb_pressed"), &FileSystemDock::_dir_rmb_pressed);
|
2017-02-13 11:47:24 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("_thumbnail_done"), &FileSystemDock::_thumbnail_done);
|
2017-02-13 11:47:24 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("_select_file"), &FileSystemDock::_select_file);
|
|
|
|
ClassDB::bind_method(D_METHOD("_go_to_tree"), &FileSystemDock::_go_to_tree);
|
|
|
|
ClassDB::bind_method(D_METHOD("_go_to_dir"), &FileSystemDock::_go_to_dir);
|
|
|
|
ClassDB::bind_method(D_METHOD("_change_file_display"), &FileSystemDock::_change_file_display);
|
|
|
|
ClassDB::bind_method(D_METHOD("_fw_history"), &FileSystemDock::_fw_history);
|
|
|
|
ClassDB::bind_method(D_METHOD("_bw_history"), &FileSystemDock::_bw_history);
|
|
|
|
ClassDB::bind_method(D_METHOD("_fs_changed"), &FileSystemDock::_fs_changed);
|
|
|
|
ClassDB::bind_method(D_METHOD("_dir_selected"), &FileSystemDock::_dir_selected);
|
|
|
|
ClassDB::bind_method(D_METHOD("_file_option"), &FileSystemDock::_file_option);
|
|
|
|
ClassDB::bind_method(D_METHOD("_folder_option"), &FileSystemDock::_folder_option);
|
|
|
|
ClassDB::bind_method(D_METHOD("_move_operation"), &FileSystemDock::_move_operation);
|
|
|
|
ClassDB::bind_method(D_METHOD("_rename_operation"), &FileSystemDock::_rename_operation);
|
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("_search_changed"), &FileSystemDock::_search_changed);
|
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("get_drag_data_fw"), &FileSystemDock::get_drag_data_fw);
|
|
|
|
ClassDB::bind_method(D_METHOD("can_drop_data_fw"), &FileSystemDock::can_drop_data_fw);
|
|
|
|
ClassDB::bind_method(D_METHOD("drop_data_fw"), &FileSystemDock::drop_data_fw);
|
2017-03-05 15:44:50 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("_files_list_rmb_select"), &FileSystemDock::_files_list_rmb_select);
|
2016-07-03 16:15:15 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("_preview_invalidated"), &FileSystemDock::_preview_invalidated);
|
|
|
|
ClassDB::bind_method(D_METHOD("_file_selected"), &FileSystemDock::_file_selected);
|
|
|
|
ClassDB::bind_method(D_METHOD("_file_multi_selected"), &FileSystemDock::_file_multi_selected);
|
2016-07-03 16:15:15 +00:00
|
|
|
|
2017-01-11 03:52:51 +00:00
|
|
|
ADD_SIGNAL(MethodInfo("instance", PropertyInfo(Variant::POOL_STRING_ARRAY, "files")));
|
2014-02-10 01:10:30 +00:00
|
|
|
ADD_SIGNAL(MethodInfo("open"));
|
|
|
|
}
|
|
|
|
|
2016-07-21 13:34:57 +00:00
|
|
|
FileSystemDock::FileSystemDock(EditorNode *p_editor) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
editor = p_editor;
|
2016-05-15 23:25:51 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
HBoxContainer *toolbar_hbc = memnew(HBoxContainer);
|
2014-05-16 11:48:23 +00:00
|
|
|
add_child(toolbar_hbc);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
button_hist_prev = memnew(ToolButton);
|
2015-08-23 23:15:56 +00:00
|
|
|
toolbar_hbc->add_child(button_hist_prev);
|
|
|
|
button_hist_prev->set_disabled(true);
|
2016-05-04 01:25:37 +00:00
|
|
|
button_hist_prev->set_tooltip(TTR("Previous Directory"));
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
button_hist_next = memnew(ToolButton);
|
2015-08-23 23:15:56 +00:00
|
|
|
toolbar_hbc->add_child(button_hist_next);
|
|
|
|
button_hist_next->set_disabled(true);
|
|
|
|
button_hist_prev->set_focus_mode(FOCUS_NONE);
|
|
|
|
button_hist_next->set_focus_mode(FOCUS_NONE);
|
2016-05-04 01:25:37 +00:00
|
|
|
button_hist_next->set_tooltip(TTR("Next Directory"));
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
current_path = memnew(LineEdit);
|
2016-05-24 02:24:17 +00:00
|
|
|
current_path->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
toolbar_hbc->add_child(current_path);
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
button_reload = memnew(Button);
|
2014-02-10 01:10:30 +00:00
|
|
|
button_reload->set_flat(true);
|
2017-03-05 15:44:50 +00:00
|
|
|
button_reload->connect("pressed", this, "_rescan");
|
2014-05-16 11:48:23 +00:00
|
|
|
toolbar_hbc->add_child(button_reload);
|
2015-08-23 23:15:56 +00:00
|
|
|
button_reload->set_focus_mode(FOCUS_NONE);
|
2016-05-04 01:25:37 +00:00
|
|
|
button_reload->set_tooltip(TTR("Re-Scan Filesystem"));
|
2016-05-24 02:24:17 +00:00
|
|
|
button_reload->hide();
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2017-05-02 21:02:06 +00:00
|
|
|
//toolbar_hbc->add_spacer();
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
button_favorite = memnew(Button);
|
2014-02-10 01:10:30 +00:00
|
|
|
button_favorite->set_flat(true);
|
|
|
|
button_favorite->set_toggle_mode(true);
|
2017-03-05 15:44:50 +00:00
|
|
|
button_favorite->connect("pressed", this, "_favorites_pressed");
|
2014-05-16 11:48:23 +00:00
|
|
|
toolbar_hbc->add_child(button_favorite);
|
2016-05-04 01:25:37 +00:00
|
|
|
button_favorite->set_tooltip(TTR("Toggle folder status as Favorite"));
|
2015-08-23 23:15:56 +00:00
|
|
|
|
|
|
|
button_favorite->set_focus_mode(FOCUS_NONE);
|
2016-05-24 02:24:17 +00:00
|
|
|
|
2017-01-14 11:26:56 +00:00
|
|
|
//Control *spacer = memnew( Control);
|
2016-05-24 02:24:17 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
/*
|
2014-02-10 01:10:30 +00:00
|
|
|
button_open = memnew( Button );
|
|
|
|
button_open->set_flat(true);
|
|
|
|
button_open->connect("pressed",this,"_open_pressed");
|
2014-05-16 11:48:23 +00:00
|
|
|
toolbar_hbc->add_child(button_open);
|
2015-08-23 23:15:56 +00:00
|
|
|
button_open->hide();
|
|
|
|
button_open->set_focus_mode(FOCUS_NONE);
|
|
|
|
button_open->set_tooltip("Open the selected file.\nOpen as scene if a scene, or as resource otherwise.");
|
|
|
|
|
2014-05-16 11:48:23 +00:00
|
|
|
|
|
|
|
button_instance = memnew( Button );
|
|
|
|
button_instance->set_flat(true);
|
|
|
|
button_instance->connect("pressed",this,"_instance_pressed");
|
|
|
|
toolbar_hbc->add_child(button_instance);
|
2015-08-23 23:15:56 +00:00
|
|
|
button_instance->hide();
|
|
|
|
button_instance->set_focus_mode(FOCUS_NONE);
|
2016-05-04 01:25:37 +00:00
|
|
|
button_instance->set_tooltip(TTR("Instance the selected scene(s) as child of the selected node."));
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2016-05-15 23:25:51 +00:00
|
|
|
*/
|
2017-03-05 15:44:50 +00:00
|
|
|
file_options = memnew(PopupMenu);
|
2016-05-15 23:25:51 +00:00
|
|
|
add_child(file_options);
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
folder_options = memnew(PopupMenu);
|
2017-01-10 12:19:59 +00:00
|
|
|
add_child(folder_options);
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
split_box = memnew(VSplitContainer);
|
2016-05-15 23:25:51 +00:00
|
|
|
add_child(split_box);
|
|
|
|
split_box->set_v_size_flags(SIZE_EXPAND_FILL);
|
2014-05-16 11:48:23 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
tree = memnew(Tree);
|
2015-08-23 23:15:56 +00:00
|
|
|
|
|
|
|
tree->set_hide_root(true);
|
2016-05-15 23:25:51 +00:00
|
|
|
split_box->add_child(tree);
|
|
|
|
tree->set_drag_forwarding(this);
|
2017-01-10 12:19:59 +00:00
|
|
|
tree->set_allow_rmb_select(true);
|
2014-05-16 11:48:23 +00:00
|
|
|
|
2016-05-15 23:25:51 +00:00
|
|
|
//tree->set_v_size_flags(SIZE_EXPAND_FILL);
|
2017-03-05 15:44:50 +00:00
|
|
|
tree->connect("item_edited", this, "_favorite_toggled");
|
|
|
|
tree->connect("item_activated", this, "_open_pressed");
|
|
|
|
tree->connect("cell_selected", this, "_dir_selected");
|
|
|
|
tree->connect("item_rmb_selected", this, "_dir_rmb_pressed");
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
files = memnew(ItemList);
|
2015-08-23 23:15:56 +00:00
|
|
|
files->set_v_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
files->set_select_mode(ItemList::SELECT_MULTI);
|
2016-05-11 14:46:08 +00:00
|
|
|
files->set_drag_forwarding(this);
|
2017-03-05 15:44:50 +00:00
|
|
|
files->connect("item_rmb_selected", this, "_files_list_rmb_select");
|
|
|
|
files->connect("item_selected", this, "_file_selected");
|
|
|
|
files->connect("multi_selected", this, "_file_multi_selected");
|
2016-05-15 23:25:51 +00:00
|
|
|
files->set_allow_rmb_select(true);
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
file_list_vb = memnew(VBoxContainer);
|
2016-05-15 23:25:51 +00:00
|
|
|
split_box->add_child(file_list_vb);
|
|
|
|
file_list_vb->set_v_size_flags(SIZE_EXPAND_FILL);
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
path_hb = memnew(HBoxContainer);
|
2016-05-15 23:25:51 +00:00
|
|
|
file_list_vb->add_child(path_hb);
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
button_back = memnew(ToolButton);
|
2015-08-23 23:15:56 +00:00
|
|
|
path_hb->add_child(button_back);
|
2016-05-15 23:25:51 +00:00
|
|
|
button_back->hide();
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
search_box = memnew(LineEdit);
|
2016-05-15 23:25:51 +00:00
|
|
|
search_box->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
path_hb->add_child(search_box);
|
2017-03-05 15:44:50 +00:00
|
|
|
search_box->connect("text_changed", this, "_search_changed");
|
2016-05-15 23:25:51 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
button_display_mode = memnew(ToolButton);
|
2016-08-16 16:25:42 +00:00
|
|
|
path_hb->add_child(button_display_mode);
|
|
|
|
button_display_mode->set_toggle_mode(true);
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2016-05-15 23:25:51 +00:00
|
|
|
file_list_vb->add_child(files);
|
2015-08-23 23:15:56 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
scanning_vb = memnew(VBoxContainer);
|
|
|
|
Label *slabel = memnew(Label);
|
2017-08-23 20:25:14 +00:00
|
|
|
slabel->set_text(TTR("Scanning Files,\nPlease Wait.."));
|
2015-08-23 23:15:56 +00:00
|
|
|
slabel->set_align(Label::ALIGN_CENTER);
|
|
|
|
scanning_vb->add_child(slabel);
|
2017-03-05 15:44:50 +00:00
|
|
|
scanning_progress = memnew(ProgressBar);
|
2015-08-23 23:15:56 +00:00
|
|
|
scanning_vb->add_child(scanning_progress);
|
|
|
|
add_child(scanning_vb);
|
|
|
|
scanning_vb->hide();
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
deps_editor = memnew(DependencyEditor);
|
2015-08-23 23:15:56 +00:00
|
|
|
add_child(deps_editor);
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
owners_editor = memnew(DependencyEditorOwners);
|
2015-08-23 23:15:56 +00:00
|
|
|
add_child(owners_editor);
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
remove_dialog = memnew(DependencyRemoveDialog);
|
2015-08-23 23:15:56 +00:00
|
|
|
add_child(remove_dialog);
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
move_dialog = memnew(EditorDirDialog);
|
2016-03-08 23:00:52 +00:00
|
|
|
add_child(move_dialog);
|
2017-03-05 15:44:50 +00:00
|
|
|
move_dialog->connect("dir_selected", this, "_move_operation");
|
2016-05-04 01:25:37 +00:00
|
|
|
move_dialog->get_ok()->set_text(TTR("Move"));
|
2016-03-08 23:00:52 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
rename_dialog = memnew(EditorFileDialog);
|
2015-08-23 23:15:56 +00:00
|
|
|
rename_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE);
|
2017-03-05 15:44:50 +00:00
|
|
|
rename_dialog->connect("file_selected", this, "_rename_operation");
|
2015-08-23 23:15:56 +00:00
|
|
|
add_child(rename_dialog);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
updating_tree = false;
|
|
|
|
initialized = false;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2015-08-23 23:15:56 +00:00
|
|
|
history.push_back("res://");
|
2017-03-05 15:44:50 +00:00
|
|
|
history_pos = 0;
|
2016-05-15 23:25:51 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
split_mode = false;
|
2016-08-16 16:25:42 +00:00
|
|
|
display_mode = DISPLAY_THUMBNAILS;
|
2014-05-16 11:48:23 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
path = "res://";
|
2014-05-16 11:48:23 +00:00
|
|
|
}
|
|
|
|
|
2016-07-21 13:34:57 +00:00
|
|
|
FileSystemDock::~FileSystemDock() {
|
2014-05-16 11:48:23 +00:00
|
|
|
}
|