Debian Codegraph @

editor/project_manager/project_manager.h

raw symbols SCIP
1 /**************************************************************************/
2 /* project_manager.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 #include "scene/gui/scroll_container.h"
35
36 class CheckBox;
37 class EditorAbout;
38 class EditorAssetLibrary;
39 class EditorFileDialog;
40 class EditorTitleBar;
41 class HFlowContainer;
42 class LineEdit;
43 class MarginContainer;
44 class OptionButton;
45 class PanelContainer;
46 class PopupMenu;
47 class ProjectDialog;
48 class ProjectList;
49 class QuickSettingsDialog;
50 class RichTextLabel;
51 class TabContainer;
52 class VBoxContainer;
53
54 class ProjectManager : public Control {
55 GDCLASS(ProjectManager, Control);
56
57 static ProjectManager *singleton;
58
59 // Utility data.
60
61 static Ref<Texture2D> _file_dialog_get_icon(const String &p_path);
62 static Ref<Texture2D> _file_dialog_get_thumbnail(const String &p_path);
63
64 HashMap<String, Ref<Texture2D>> icon_type_cache;
65
66 void _build_icon_type_cache(Ref<Theme> p_theme);
67
68 enum PostDuplicateAction {
69 POST_DUPLICATE_ACTION_NONE,
70 POST_DUPLICATE_ACTION_OPEN,
71 POST_DUPLICATE_ACTION_FULL_CONVERSION,
72 };
73
74 PostDuplicateAction post_duplicate_action = POST_DUPLICATE_ACTION_NONE;
75
76 // Main layout.
77
78 Ref<Theme> theme;
79
80 void _update_size_limits();
81 void _update_theme(bool p_skip_creation = false);
82 void _titlebar_resized();
83
84 MarginContainer *root_container = nullptr;
85 Panel *background_panel = nullptr;
86 VBoxContainer *main_vbox = nullptr;
87
88 EditorTitleBar *title_bar = nullptr;
89 Control *left_menu_spacer = nullptr;
90 Control *left_spacer = nullptr;
91 Control *right_menu_spacer = nullptr;
92 Control *right_spacer = nullptr;
93 Button *title_bar_logo = nullptr;
94 HBoxContainer *main_view_toggles = nullptr;
95 Button *quick_settings_button = nullptr;
96
97 enum MainViewTab {
98 MAIN_VIEW_PROJECTS,
99 MAIN_VIEW_ASSETLIB,
100 MAIN_VIEW_MAX
101 };
102
103 MainViewTab current_main_view = MAIN_VIEW_PROJECTS;
104 HashMap<MainViewTab, Control *> main_view_map;
105 HashMap<MainViewTab, Button *> main_view_toggle_map;
106
107 PanelContainer *main_view_container = nullptr;
108 Ref<ButtonGroup> main_view_toggles_group;
109
110 Button *_add_main_view(MainViewTab p_id, const String &p_name, const Ref<Texture2D> &p_icon, Control *p_view_control);
111 void _set_main_view_icon(MainViewTab p_id, const Ref<Texture2D> &p_icon);
112 void _select_main_view(int p_id);
113
114 VBoxContainer *local_projects_vb = nullptr;
115 EditorAssetLibrary *asset_library = nullptr;
116
117 EditorAbout *about_dialog = nullptr;
118
119 void _show_about();
120 void _open_asset_library_confirmed();
121 void _project_list_menu_option(int p_option);
122
123 AcceptDialog *error_dialog = nullptr;
124
125 void _show_error(const String &p_message, const Size2 &p_min_size = Size2());
126 void _dim_window();
127
128 // Quick settings.
129
130 QuickSettingsDialog *quick_settings_dialog = nullptr;
131
132 void _show_quick_settings();
133 void _restart_confirmed();
134
135 // Project list.
136
137 VBoxContainer *empty_list_placeholder = nullptr;
138 RichTextLabel *empty_list_message = nullptr;
139 Button *empty_list_create_project = nullptr;
140 Button *empty_list_import_project = nullptr;
141 Button *empty_list_open_assetlib = nullptr;
142 Label *empty_list_online_warning = nullptr;
143
144 void _update_list_placeholder();
145
146 ProjectList *project_list = nullptr;
147 bool initialized = false;
148
149 LineEdit *search_box = nullptr;
150 Label *loading_label = nullptr;
151 Label *sort_label = nullptr;
152 OptionButton *filter_option = nullptr;
153 PanelContainer *project_list_panel = nullptr;
154
155 Button *create_btn = nullptr;
156 Button *import_btn = nullptr;
157 Button *scan_btn = nullptr;
158 Button *open_btn = nullptr;
159 Button *open_options_btn = nullptr;
160 Button *run_btn = nullptr;
161 Button *rename_btn = nullptr;
162 Button *duplicate_btn = nullptr;
163 Button *manage_tags_btn = nullptr;
164 Button *erase_btn = nullptr;
165 Button *erase_missing_btn = nullptr;
166 Button *donate_btn = nullptr;
167
168 HBoxContainer *open_btn_container = nullptr;
169 PopupMenu *open_options_popup = nullptr;
170
171 EditorFileDialog *scan_dir = nullptr;
172
173 ConfirmationDialog *erase_ask = nullptr;
174 Label *erase_ask_label = nullptr;
175 // Comment out for now until we have a better warning system to
176 // ensure users delete their project only.
177 //CheckBox *delete_project_contents = nullptr;
178 ConfirmationDialog *erase_missing_ask = nullptr;
179 ConfirmationDialog *multi_open_ask = nullptr;
180 ConfirmationDialog *multi_run_ask = nullptr;
181 ConfirmationDialog *open_recovery_mode_ask = nullptr;
182
183 ProjectDialog *project_dialog = nullptr;
184
185 void _scan_projects();
186 void _run_project();
187 void _run_project_confirm();
188 void _open_selected_projects();
189 void _open_selected_projects_with_migration();
190 void _open_selected_projects_check_warnings();
191 void _open_selected_projects_check_recovery_mode();
192
193 void _install_project(const String &p_zip_path, const String &p_title);
194 void _import_project();
195 void _new_project();
196 void _rename_project();
197 void _duplicate_project();
198 void _duplicate_project_with_action(PostDuplicateAction p_action);
199 void _show_project_in_file_manager();
200 void _erase_project();
201 void _erase_missing_projects();
202 void _erase_project_confirm();
203 void _erase_missing_projects_confirm();
204 void _update_project_buttons();
205 void _open_options_popup();
206 void _open_recovery_mode_ask(bool manual = false);
207 void _open_donate_page();
208
209 void _on_project_created(const String &dir, bool edit);
210 void _on_project_duplicated(const String &p_original_path, const String &p_duplicate_path, bool p_edit);
211 void _on_projects_updated();
212 void _on_open_options_selected(int p_option);
213 void _on_recovery_mode_popup_open_normal();
214 void _on_recovery_mode_popup_open_recovery();
215
216 void _on_order_option_changed(int p_idx);
217 void _on_search_term_changed(const String &p_term);
218 void _on_search_term_submitted(const String &p_text);
219
220 // Project tag management.
221
222 HashSet<String> tag_set;
223 PackedStringArray current_project_tags;
224 PackedStringArray forbidden_tag_characters{ "/", "\\", "-" };
225
226 ConfirmationDialog *tag_manage_dialog = nullptr;
227 HFlowContainer *project_tags = nullptr;
228 HFlowContainer *all_tags = nullptr;
229 Label *tag_edit_error = nullptr;
230
231 Button *create_tag_btn = nullptr;
232 ConfirmationDialog *create_tag_dialog = nullptr;
233 LineEdit *new_tag_name = nullptr;
234 Label *tag_error = nullptr;
235
236 void _manage_project_tags();
237 void _add_project_tag(const String &p_tag);
238 void _delete_project_tag(const String &p_tag);
239 void _apply_project_tags();
240 void _set_new_tag_name(const String p_name);
241 void _create_new_tag();
242
243 // Project converter/migration tool.
244
245 ConfirmationDialog *ask_full_convert_dialog = nullptr;
246 ConfirmationDialog *ask_update_settings = nullptr;
247 VBoxContainer *ask_update_vb = nullptr;
248 Label *ask_update_label = nullptr;
249 CheckBox *ask_update_backup = nullptr;
250 Button *full_convert_button = nullptr;
251 Button *migration_guide_button = nullptr;
252
253 String version_convert_feature;
254 bool open_in_recovery_mode = false;
255 bool open_in_verbose_mode = false;
256
257 #ifndef DISABLE_DEPRECATED
258 void _minor_project_migrate();
259 #endif
260 void _full_convert_button_pressed();
261 void _migration_guide_button_pressed();
262 void _perform_full_project_conversion();
263
264 // Input and I/O.
265
266 virtual void shortcut_input(const Ref<InputEvent> &p_ev) override;
267
268 void _files_dropped(PackedStringArray p_files);
269
270 protected:
271 void _notification(int p_what);
272
273 public:
274 static ProjectManager *get_singleton() { return singleton; }
275
276 static constexpr int DEFAULT_WINDOW_WIDTH = 1152;
277 static constexpr int DEFAULT_WINDOW_HEIGHT = 800;
278
279 // Project list.
280
281 bool is_initialized() const { return initialized; }
282 LineEdit *get_search_box();
283
284 // Project tag management.
285
286 void add_new_tag(const String &p_tag);
287
288 ProjectManager();
289 ~ProjectManager();
290 };