Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/editor/file_system/dependency_editor.h
9896 views
1
/**************************************************************************/
2
/* dependency_editor.h */
3
/**************************************************************************/
4
/* This file is part of: */
5
/* GODOT ENGINE */
6
/* https://godotengine.org */
7
/**************************************************************************/
8
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10
/* */
11
/* Permission is hereby granted, free of charge, to any person obtaining */
12
/* a copy of this software and associated documentation files (the */
13
/* "Software"), to deal in the Software without restriction, including */
14
/* without limitation the rights to use, copy, modify, merge, publish, */
15
/* distribute, sublicense, and/or sell copies of the Software, and to */
16
/* permit persons to whom the Software is furnished to do so, subject to */
17
/* the following conditions: */
18
/* */
19
/* The above copyright notice and this permission notice shall be */
20
/* included in all copies or substantial portions of the Software. */
21
/* */
22
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29
/**************************************************************************/
30
31
#pragma once
32
33
#include "scene/gui/box_container.h"
34
#include "scene/gui/dialogs.h"
35
#include "scene/gui/item_list.h"
36
#include "scene/gui/tree.h"
37
38
class EditorFileDialog;
39
class EditorFileSystemDirectory;
40
41
class DependencyEditor : public AcceptDialog {
42
GDCLASS(DependencyEditor, AcceptDialog);
43
44
Tree *tree = nullptr;
45
Button *fixdeps = nullptr;
46
47
EditorFileDialog *search = nullptr;
48
49
String replacing;
50
String editing;
51
List<String> missing;
52
53
void _fix_and_find(EditorFileSystemDirectory *efsd, HashMap<String, HashMap<String, String>> &candidates);
54
55
void _searched(const String &p_path);
56
void _load_pressed(Object *p_item, int p_cell, int p_button, MouseButton p_mouse_button);
57
void _fix_all();
58
void _update_list();
59
60
void _update_file();
61
62
public:
63
void edit(const String &p_path);
64
DependencyEditor();
65
};
66
67
class DependencyEditorOwners : public AcceptDialog {
68
GDCLASS(DependencyEditorOwners, AcceptDialog);
69
70
ItemList *owners = nullptr;
71
PopupMenu *file_options = nullptr;
72
String editing;
73
74
void _fill_owners(EditorFileSystemDirectory *efsd);
75
76
void _list_rmb_clicked(int p_item, const Vector2 &p_pos, MouseButton p_mouse_button_index);
77
void _select_file(int p_idx);
78
void _empty_clicked(const Vector2 &p_pos, MouseButton p_mouse_button_index);
79
void _file_option(int p_option);
80
81
private:
82
enum FileMenu {
83
FILE_MENU_OPEN,
84
};
85
86
public:
87
void show(const String &p_path);
88
DependencyEditorOwners();
89
};
90
91
class DependencyRemoveDialog : public ConfirmationDialog {
92
GDCLASS(DependencyRemoveDialog, ConfirmationDialog);
93
94
Label *text = nullptr;
95
Tree *owners = nullptr;
96
VBoxContainer *vb_owners = nullptr;
97
ItemList *files_to_delete_list = nullptr;
98
99
HashMap<String, String> all_remove_files;
100
Vector<String> dirs_to_delete;
101
Vector<String> files_to_delete;
102
103
struct RemovedDependency {
104
String file;
105
String file_type;
106
String dependency;
107
String dependency_folder;
108
109
bool operator<(const RemovedDependency &p_other) const {
110
if (dependency_folder.is_empty() != p_other.dependency_folder.is_empty()) {
111
return p_other.dependency_folder.is_empty();
112
} else {
113
return dependency < p_other.dependency;
114
}
115
}
116
};
117
118
LocalVector<StringName> path_project_settings;
119
120
void _find_files_in_removed_folder(EditorFileSystemDirectory *efsd, const String &p_folder);
121
void _find_all_removed_dependencies(EditorFileSystemDirectory *efsd, Vector<RemovedDependency> &p_removed);
122
void _find_localization_remaps_of_removed_files(Vector<RemovedDependency> &p_removed);
123
void _build_removed_dependency_tree(const Vector<RemovedDependency> &p_removed);
124
void _show_files_to_delete_list();
125
126
void ok_pressed() override;
127
128
static void _bind_methods();
129
130
public:
131
void show(const Vector<String> &p_folders, const Vector<String> &p_files);
132
DependencyRemoveDialog();
133
};
134
135
class DependencyErrorDialog : public ConfirmationDialog {
136
GDCLASS(DependencyErrorDialog, ConfirmationDialog);
137
138
private:
139
String for_file;
140
Mode mode;
141
Button *fdep = nullptr;
142
Label *text = nullptr;
143
Tree *files = nullptr;
144
void ok_pressed() override;
145
void custom_action(const String &) override;
146
147
public:
148
void show(const String &p_for_file, const Vector<String> &report);
149
DependencyErrorDialog();
150
};
151
152
class OrphanResourcesDialog : public ConfirmationDialog {
153
GDCLASS(OrphanResourcesDialog, ConfirmationDialog);
154
155
DependencyEditor *dep_edit = nullptr;
156
Tree *files = nullptr;
157
ConfirmationDialog *delete_confirm = nullptr;
158
void ok_pressed() override;
159
160
bool _fill_owners(EditorFileSystemDirectory *efsd, HashMap<String, int> &refs, TreeItem *p_parent);
161
162
List<String> paths;
163
void _find_to_delete(TreeItem *p_item, List<String> &r_paths);
164
void _delete_confirm();
165
void _button_pressed(Object *p_item, int p_column, int p_id, MouseButton p_button);
166
167
void refresh();
168
169
public:
170
void show();
171
OrphanResourcesDialog();
172
};
173
174