Debian Codegraph @

editor/file_system/dependency_editor.h

raw symbols SCIP
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/dialogs.h"
34
35 class EditorFileDialog;
36 class EditorFileSystemDirectory;
37 class ItemList;
38 class PopupMenu;
39 class Tree;
40 class TreeItem;
41 class VBoxContainer;
42
43 class DependencyEditor : public AcceptDialog {
44 GDCLASS(DependencyEditor, AcceptDialog);
45
46 Tree *tree = nullptr;
47 Button *fixdeps = nullptr;
48 Label *warning_label = nullptr;
49
50 EditorFileDialog *search = nullptr;
51
52 String replacing;
53 String editing;
54 List<String> missing;
55
56 void _fix_and_find(EditorFileSystemDirectory *efsd, HashMap<String, HashMap<String, String>> &candidates);
57
58 void _searched(const String &p_path);
59 void _load_pressed(Object *p_item, int p_cell, int p_button, MouseButton p_mouse_button);
60 void _fix_all();
61 void _update_list();
62
63 void _update_file();
64
65 protected:
66 void _notification(int p_what);
67
68 public:
69 void edit(const String &p_path);
70 DependencyEditor();
71 };
72
73 class DependencyEditorOwners : public AcceptDialog {
74 GDCLASS(DependencyEditorOwners, AcceptDialog);
75
76 Label *owners_count = nullptr;
77 Label *empty = nullptr;
78 MarginContainer *owners_mc = nullptr;
79 ItemList *owners = nullptr;
80 PopupMenu *file_options = nullptr;
81 String editing;
82
83 void _fill_owners(EditorFileSystemDirectory *efsd);
84
85 void _list_rmb_clicked(int p_item, const Vector2 &p_pos, MouseButton p_mouse_button_index);
86 void _select_file(int p_idx);
87 void _empty_clicked(const Vector2 &p_pos, MouseButton p_mouse_button_index);
88 void _file_option(int p_option);
89
90 private:
91 enum FileMenu {
92 FILE_MENU_OPEN,
93 };
94
95 public:
96 void show(const String &p_path);
97 DependencyEditorOwners();
98 };
99
100 class DependencyRemoveDialog : public ConfirmationDialog {
101 GDCLASS(DependencyRemoveDialog, ConfirmationDialog);
102
103 Label *text = nullptr;
104 Tree *owners = nullptr;
105 VBoxContainer *vb_owners = nullptr;
106 ItemList *files_to_delete_list = nullptr;
107
108 HashMap<String, String> all_remove_files;
109 Vector<String> dirs_to_delete;
110 Vector<String> files_to_delete;
111
112 struct RemovedDependency {
113 String file;
114 String file_type;
115 String dependency;
116 String dependency_folder;
117
118 bool operator<(const RemovedDependency &p_other) const {
119 if (dependency_folder.is_empty() != p_other.dependency_folder.is_empty()) {
120 return p_other.dependency_folder.is_empty();
121 } else {
122 return dependency < p_other.dependency;
123 }
124 }
125 };
126
127 LocalVector<StringName> path_project_settings;
128
129 void _find_files_in_removed_folder(EditorFileSystemDirectory *efsd, const String &p_folder);
130 void _find_all_removed_dependencies(EditorFileSystemDirectory *efsd, Vector<RemovedDependency> &p_removed);
131 void _find_localization_remaps_of_removed_files(Vector<RemovedDependency> &p_removed);
132 void _build_removed_dependency_tree(const Vector<RemovedDependency> &p_removed);
133 void _show_files_to_delete_list();
134
135 void ok_pressed() override;
136
137 static void _bind_methods();
138
139 public:
140 void show(const Vector<String> &p_folders, const Vector<String> &p_files);
141 DependencyRemoveDialog();
142 };
143
144 class DependencyErrorDialog : public ConfirmationDialog {
145 GDCLASS(DependencyErrorDialog, ConfirmationDialog);
146
147 StringName icon_name_fail;
148 StringName icon_name_check;
149
150 String for_file;
151
152 TreeItem *replacing_item = nullptr;
153 bool errors_fixed = false;
154
155 Tree *files = nullptr;
156
157 EditorFileDialog *replacement_file_dialog = nullptr;
158 DependencyEditor *deps_editor = nullptr;
159
160 void ok_pressed() override;
161
162 void _on_files_button_clicked(TreeItem *p_item, int p_column, int p_id, MouseButton p_button);
163 void _on_replacement_file_selected(const String &p_path);
164 void _check_for_resolved();
165
166 public:
167 void show(const String &p_for_file, const HashMap<String, HashSet<String>> &p_report);
168
169 DependencyErrorDialog();
170 };
171
172 class OrphanResourcesDialog : public ConfirmationDialog {
173 GDCLASS(OrphanResourcesDialog, ConfirmationDialog);
174
175 DependencyEditor *dep_edit = nullptr;
176 Tree *files = nullptr;
177 ConfirmationDialog *delete_confirm = nullptr;
178 void ok_pressed() override;
179
180 bool _fill_owners(EditorFileSystemDirectory *efsd, HashMap<String, int> &refs, TreeItem *p_parent);
181
182 List<String> paths;
183 void _find_to_delete(TreeItem *p_item, List<String> &r_paths);
184 void _delete_confirm();
185 void _button_pressed(Object *p_item, int p_column, int p_id, MouseButton p_button);
186
187 void refresh();
188
189 public:
190 void show();
191 OrphanResourcesDialog();
192 };