summaryrefslogtreecommitdiffstats
path: root/editor/dependency_editor.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2020-05-14 13:23:58 +0200
committerRémi Verschelde <rverschelde@gmail.com>2020-05-14 16:54:55 +0200
commit0be6d925dc3c6413bce7a3ccb49631b8e4a6e67a (patch)
treea27e497da7104dd0a64f98a04fa3067668735e91 /editor/dependency_editor.cpp
parent710b34b70227becdc652b4ae027fe0ac47409642 (diff)
downloadredot-engine-0be6d925dc3c6413bce7a3ccb49631b8e4a6e67a.tar.gz
Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks
Which means that reduz' beloved style which we all became used to will now be changed automatically to remove the first empty line. This makes us lean closer to 1TBS (the one true brace style) instead of hybridating it with some Allman-inspired spacing. There's still the case of braces around single-statement blocks that needs to be addressed (but clang-format can't help with that, but clang-tidy may if we agree about it). Part of #33027.
Diffstat (limited to 'editor/dependency_editor.cpp')
-rw-r--r--editor/dependency_editor.cpp45
1 files changed, 0 insertions, 45 deletions
diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp
index 2302fb0780..9c8a7eaef0 100644
--- a/editor/dependency_editor.cpp
+++ b/editor/dependency_editor.cpp
@@ -37,7 +37,6 @@
#include "scene/gui/margin_container.h"
void DependencyEditor::_searched(const String &p_path) {
-
Map<String, String> dep_rename;
dep_rename[replacing] = p_path;
@@ -48,7 +47,6 @@ void DependencyEditor::_searched(const String &p_path) {
}
void DependencyEditor::_load_pressed(Object *p_item, int p_cell, int p_button) {
-
TreeItem *ti = Object::cast_to<TreeItem>(p_item);
replacing = ti->get_text(1);
@@ -64,13 +62,11 @@ void DependencyEditor::_load_pressed(Object *p_item, int p_cell, int p_button) {
}
void DependencyEditor::_fix_and_find(EditorFileSystemDirectory *efsd, Map<String, Map<String, String>> &candidates) {
-
for (int i = 0; i < efsd->get_subdir_count(); i++) {
_fix_and_find(efsd->get_subdir(i), candidates);
}
for (int i = 0; i < efsd->get_file_count(); i++) {
-
String file = efsd->get_file(i);
if (!candidates.has(file))
continue;
@@ -78,7 +74,6 @@ void DependencyEditor::_fix_and_find(EditorFileSystemDirectory *efsd, Map<String
String path = efsd->get_file_path(i);
for (Map<String, String>::Element *E = candidates[file].front(); E; E = E->next()) {
-
if (E->get() == String()) {
E->get() = path;
continue;
@@ -100,7 +95,6 @@ void DependencyEditor::_fix_and_find(EditorFileSystemDirectory *efsd, Map<String
int current_score = 0;
for (int j = 0; j < lostv.size(); j++) {
-
if (j < existingv.size() && lostv[j] == existingv[j]) {
existing_score++;
}
@@ -110,7 +104,6 @@ void DependencyEditor::_fix_and_find(EditorFileSystemDirectory *efsd, Map<String
}
if (current_score > existing_score) {
-
//if it was the same, could track distance to new path but..
E->get() = path; //replace by more accurate
@@ -120,14 +113,12 @@ void DependencyEditor::_fix_and_find(EditorFileSystemDirectory *efsd, Map<String
}
void DependencyEditor::_fix_all() {
-
if (!EditorFileSystem::get_singleton()->get_filesystem())
return;
Map<String, Map<String, String>> candidates;
for (List<String>::Element *E = missing.front(); E; E = E->next()) {
-
String base = E->get().get_file();
if (!candidates.has(base)) {
candidates[base] = Map<String, String>();
@@ -141,9 +132,7 @@ void DependencyEditor::_fix_all() {
Map<String, String> remaps;
for (Map<String, Map<String, String>>::Element *E = candidates.front(); E; E = E->next()) {
-
for (Map<String, String>::Element *F = E->get().front(); F; F = F->next()) {
-
if (F->get() != String()) {
remaps[F->key()] = F->get();
}
@@ -151,7 +140,6 @@ void DependencyEditor::_fix_all() {
}
if (remaps.size()) {
-
ResourceLoader::rename_dependencies(editing, remaps);
_update_list();
@@ -160,12 +148,10 @@ void DependencyEditor::_fix_all() {
}
void DependencyEditor::_update_file() {
-
EditorFileSystem::get_singleton()->update_file(editing);
}
void DependencyEditor::_update_list() {
-
List<String> deps;
ResourceLoader::get_dependencies(editing, &deps, true);
@@ -179,7 +165,6 @@ void DependencyEditor::_update_list() {
bool broken = false;
for (List<String>::Element *E = deps.front(); E; E = E->next()) {
-
TreeItem *item = tree->create_item(root);
String n = E->get();
@@ -214,7 +199,6 @@ void DependencyEditor::_update_list() {
}
void DependencyEditor::edit(const String &p_path) {
-
editing = p_path;
set_title(TTR("Dependencies For:") + " " + p_path.get_file());
@@ -232,7 +216,6 @@ void DependencyEditor::_bind_methods() {
}
DependencyEditor::DependencyEditor() {
-
VBoxContainer *vb = memnew(VBoxContainer);
vb->set_name(TTR("Dependencies"));
add_child(vb);
@@ -271,7 +254,6 @@ DependencyEditor::DependencyEditor() {
/////////////////////////////////////
void DependencyEditorOwners::_list_rmb_select(int p_item, const Vector2 &p_pos) {
-
file_options->clear();
file_options->set_size(Size2(1, 1));
if (p_item >= 0) {
@@ -283,7 +265,6 @@ void DependencyEditorOwners::_list_rmb_select(int p_item, const Vector2 &p_pos)
}
void DependencyEditorOwners::_select_file(int p_idx) {
-
String fpath = owners->get_item_text(p_idx);
if (ResourceLoader::get_resource_type(fpath) == "PackedScene") {
@@ -294,7 +275,6 @@ void DependencyEditorOwners::_select_file(int p_idx) {
}
void DependencyEditorOwners::_file_option(int p_option) {
-
switch (p_option) {
case FILE_OPEN: {
int idx = owners->get_current();
@@ -309,7 +289,6 @@ void DependencyEditorOwners::_bind_methods() {
}
void DependencyEditorOwners::_fill_owners(EditorFileSystemDirectory *efsd) {
-
if (!efsd)
return;
@@ -318,7 +297,6 @@ void DependencyEditorOwners::_fill_owners(EditorFileSystemDirectory *efsd) {
}
for (int i = 0; i < efsd->get_file_count(); i++) {
-
Vector<String> deps = efsd->get_file_deps(i);
bool found = false;
for (int j = 0; j < deps.size(); j++) {
@@ -337,7 +315,6 @@ void DependencyEditorOwners::_fill_owners(EditorFileSystemDirectory *efsd) {
}
void DependencyEditorOwners::show(const String &p_path) {
-
editing = p_path;
owners->clear();
_fill_owners(EditorFileSystem::get_singleton()->get_filesystem());
@@ -347,7 +324,6 @@ void DependencyEditorOwners::show(const String &p_path) {
}
DependencyEditorOwners::DependencyEditorOwners(EditorNode *p_editor) {
-
editor = p_editor;
file_options = memnew(PopupMenu);
@@ -479,7 +455,6 @@ void DependencyRemoveDialog::show(const Vector<String> &p_folders, const Vector<
}
void DependencyRemoveDialog::ok_pressed() {
-
for (int i = 0; i < files_to_delete.size(); ++i) {
if (ResourceCache::has(files_to_delete[i])) {
Resource *res = ResourceCache::get(files_to_delete[i]);
@@ -528,7 +503,6 @@ void DependencyRemoveDialog::ok_pressed() {
for (int i = 0; i < files_to_delete.size(); ++i)
EditorFileSystem::get_singleton()->update_file(files_to_delete[i]);
} else {
-
for (int i = 0; i < dirs_to_delete.size(); ++i) {
String path = OS::get_singleton()->get_resource_dir() + dirs_to_delete[i].replace_first("res://", "/");
print_verbose("Moving to trash: " + path);
@@ -568,7 +542,6 @@ void DependencyRemoveDialog::_bind_methods() {
}
DependencyRemoveDialog::DependencyRemoveDialog() {
-
get_ok()->set_text(TTR("Remove"));
VBoxContainer *vb = memnew(VBoxContainer);
@@ -586,7 +559,6 @@ DependencyRemoveDialog::DependencyRemoveDialog() {
//////////////
void DependencyErrorDialog::show(Mode p_mode, const String &p_for_file, const Vector<String> &report) {
-
mode = p_mode;
for_file = p_for_file;
set_title(TTR("Error loading:") + " " + p_for_file.get_file());
@@ -594,7 +566,6 @@ void DependencyErrorDialog::show(Mode p_mode, const String &p_for_file, const Ve
TreeItem *root = files->create_item(nullptr);
for (int i = 0; i < report.size(); i++) {
-
String dep;
String type = "Object";
dep = report[i].get_slice("::", 0);
@@ -612,7 +583,6 @@ void DependencyErrorDialog::show(Mode p_mode, const String &p_for_file, const Ve
}
void DependencyErrorDialog::ok_pressed() {
-
switch (mode) {
case MODE_SCENE:
EditorNode::get_singleton()->load_scene(for_file, true);
@@ -624,12 +594,10 @@ void DependencyErrorDialog::ok_pressed() {
}
void DependencyErrorDialog::custom_action(const String &) {
-
EditorNode::get_singleton()->fix_dependencies(for_file);
}
DependencyErrorDialog::DependencyErrorDialog() {
-
VBoxContainer *vb = memnew(VBoxContainer);
add_child(vb);
@@ -654,7 +622,6 @@ DependencyErrorDialog::DependencyErrorDialog() {
//////////////////////////////////////////////////////////////////////
void OrphanResourcesDialog::ok_pressed() {
-
paths.clear();
_find_to_delete(files->get_root(), paths);
@@ -666,14 +633,12 @@ void OrphanResourcesDialog::ok_pressed() {
}
bool OrphanResourcesDialog::_fill_owners(EditorFileSystemDirectory *efsd, HashMap<String, int> &refs, TreeItem *p_parent) {
-
if (!efsd)
return false;
bool has_children = false;
for (int i = 0; i < efsd->get_subdir_count(); i++) {
-
TreeItem *dir_item = nullptr;
if (p_parent) {
dir_item = files->create_item(p_parent);
@@ -692,17 +657,14 @@ bool OrphanResourcesDialog::_fill_owners(EditorFileSystemDirectory *efsd, HashMa
}
for (int i = 0; i < efsd->get_file_count(); i++) {
-
if (!p_parent) {
Vector<String> deps = efsd->get_file_deps(i);
for (int j = 0; j < deps.size(); j++) {
-
if (!refs.has(deps[j])) {
refs[deps[j]] = 1;
}
}
} else {
-
String path = efsd->get_file_path(i);
if (!refs.has(path)) {
TreeItem *ti = files->create_item(p_parent);
@@ -737,15 +699,12 @@ void OrphanResourcesDialog::refresh() {
}
void OrphanResourcesDialog::show() {
-
refresh();
popup_centered_ratio();
}
void OrphanResourcesDialog::_find_to_delete(TreeItem *p_item, List<String> &paths) {
-
while (p_item) {
-
if (p_item->get_cell_mode(0) == TreeItem::CELL_MODE_CHECK && p_item->is_checked(0)) {
paths.push_back(p_item->get_metadata(0));
}
@@ -759,10 +718,8 @@ void OrphanResourcesDialog::_find_to_delete(TreeItem *p_item, List<String> &path
}
void OrphanResourcesDialog::_delete_confirm() {
-
DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
for (List<String>::Element *E = paths.front(); E; E = E->next()) {
-
da->remove(E->get());
EditorFileSystem::get_singleton()->update_file(E->get());
}
@@ -771,7 +728,6 @@ void OrphanResourcesDialog::_delete_confirm() {
}
void OrphanResourcesDialog::_button_pressed(Object *p_item, int p_column, int p_id) {
-
TreeItem *ti = Object::cast_to<TreeItem>(p_item);
String path = ti->get_metadata(0);
@@ -782,7 +738,6 @@ void OrphanResourcesDialog::_bind_methods() {
}
OrphanResourcesDialog::OrphanResourcesDialog() {
-
set_title(TTR("Orphan Resource Explorer"));
delete_confirm = memnew(ConfirmationDialog);
get_ok()->set_text(TTR("Delete"));