Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/editor/project_manager/project_manager.h
9902 views
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
122
AcceptDialog *error_dialog = nullptr;
123
124
void _show_error(const String &p_message, const Size2 &p_min_size = Size2());
125
void _dim_window();
126
127
// Quick settings.
128
129
QuickSettingsDialog *quick_settings_dialog = nullptr;
130
131
void _show_quick_settings();
132
void _restart_confirmed();
133
134
// Project list.
135
136
VBoxContainer *empty_list_placeholder = nullptr;
137
RichTextLabel *empty_list_message = nullptr;
138
Button *empty_list_create_project = nullptr;
139
Button *empty_list_import_project = nullptr;
140
Button *empty_list_open_assetlib = nullptr;
141
Label *empty_list_online_warning = nullptr;
142
143
void _update_list_placeholder();
144
145
ProjectList *project_list = nullptr;
146
bool initialized = false;
147
148
LineEdit *search_box = nullptr;
149
Label *loading_label = nullptr;
150
Label *sort_label = nullptr;
151
OptionButton *filter_option = nullptr;
152
PanelContainer *project_list_panel = nullptr;
153
154
Button *create_btn = nullptr;
155
Button *import_btn = nullptr;
156
Button *scan_btn = nullptr;
157
Button *open_btn = nullptr;
158
Button *open_options_btn = nullptr;
159
Button *run_btn = nullptr;
160
Button *rename_btn = nullptr;
161
Button *duplicate_btn = nullptr;
162
Button *manage_tags_btn = nullptr;
163
Button *erase_btn = nullptr;
164
Button *erase_missing_btn = nullptr;
165
166
HBoxContainer *open_btn_container = nullptr;
167
PopupMenu *open_options_popup = nullptr;
168
169
EditorFileDialog *scan_dir = nullptr;
170
171
ConfirmationDialog *erase_ask = nullptr;
172
Label *erase_ask_label = nullptr;
173
// Comment out for now until we have a better warning system to
174
// ensure users delete their project only.
175
//CheckBox *delete_project_contents = nullptr;
176
ConfirmationDialog *erase_missing_ask = nullptr;
177
ConfirmationDialog *multi_open_ask = nullptr;
178
ConfirmationDialog *multi_run_ask = nullptr;
179
ConfirmationDialog *open_recovery_mode_ask = nullptr;
180
181
ProjectDialog *project_dialog = nullptr;
182
183
void _scan_projects();
184
void _run_project();
185
void _run_project_confirm();
186
void _open_selected_projects();
187
void _open_selected_projects_with_migration();
188
void _open_selected_projects_check_warnings();
189
void _open_selected_projects_check_recovery_mode();
190
191
void _install_project(const String &p_zip_path, const String &p_title);
192
void _import_project();
193
void _new_project();
194
void _rename_project();
195
void _duplicate_project();
196
void _duplicate_project_with_action(PostDuplicateAction p_action);
197
void _erase_project();
198
void _erase_missing_projects();
199
void _erase_project_confirm();
200
void _erase_missing_projects_confirm();
201
void _update_project_buttons();
202
void _open_options_popup();
203
void _open_recovery_mode_ask(bool manual = false);
204
205
void _on_project_created(const String &dir, bool edit);
206
void _on_project_duplicated(const String &p_original_path, const String &p_duplicate_path, bool p_edit);
207
void _on_projects_updated();
208
void _on_open_options_selected(int p_option);
209
void _on_recovery_mode_popup_open_normal();
210
void _on_recovery_mode_popup_open_recovery();
211
212
void _on_order_option_changed(int p_idx);
213
void _on_search_term_changed(const String &p_term);
214
void _on_search_term_submitted(const String &p_text);
215
216
// Project tag management.
217
218
HashSet<String> tag_set;
219
PackedStringArray current_project_tags;
220
PackedStringArray forbidden_tag_characters{ "/", "\\", "-" };
221
222
ConfirmationDialog *tag_manage_dialog = nullptr;
223
HFlowContainer *project_tags = nullptr;
224
HFlowContainer *all_tags = nullptr;
225
Label *tag_edit_error = nullptr;
226
227
Button *create_tag_btn = nullptr;
228
ConfirmationDialog *create_tag_dialog = nullptr;
229
LineEdit *new_tag_name = nullptr;
230
Label *tag_error = nullptr;
231
232
void _manage_project_tags();
233
void _add_project_tag(const String &p_tag);
234
void _delete_project_tag(const String &p_tag);
235
void _apply_project_tags();
236
void _set_new_tag_name(const String p_name);
237
void _create_new_tag();
238
239
// Project converter/migration tool.
240
241
ConfirmationDialog *ask_full_convert_dialog = nullptr;
242
ConfirmationDialog *ask_update_settings = nullptr;
243
VBoxContainer *ask_update_vb = nullptr;
244
Label *ask_update_label = nullptr;
245
CheckBox *ask_update_backup = nullptr;
246
Button *full_convert_button = nullptr;
247
Button *migration_guide_button = nullptr;
248
249
String version_convert_feature;
250
bool open_in_recovery_mode = false;
251
bool open_in_verbose_mode = false;
252
253
#ifndef DISABLE_DEPRECATED
254
void _minor_project_migrate();
255
#endif
256
void _full_convert_button_pressed();
257
void _migration_guide_button_pressed();
258
void _perform_full_project_conversion();
259
260
// Input and I/O.
261
262
virtual void shortcut_input(const Ref<InputEvent> &p_ev) override;
263
264
void _files_dropped(PackedStringArray p_files);
265
266
protected:
267
void _notification(int p_what);
268
269
public:
270
static ProjectManager *get_singleton() { return singleton; }
271
272
static constexpr int DEFAULT_WINDOW_WIDTH = 1152;
273
static constexpr int DEFAULT_WINDOW_HEIGHT = 800;
274
275
// Project list.
276
277
bool is_initialized() const { return initialized; }
278
LineEdit *get_search_box();
279
280
// Project tag management.
281
282
void add_new_tag(const String &p_tag);
283
284
ProjectManager();
285
~ProjectManager();
286
};
287
288