Debian Codegraph @

editor/settings/editor_build_profile.h

raw symbols SCIP
1 /**************************************************************************/
2 /* editor_build_profile.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 "core/object/ref_counted.h"
34 #include "editor/doc/editor_help.h"
35 #include "scene/gui/dialogs.h"
36 #include "scene/gui/tree.h"
37
38 class EditorBuildProfile : public RefCounted {
39 GDCLASS(EditorBuildProfile, RefCounted);
40
41 public:
42 enum BuildOption {
43 BUILD_OPTION_3D,
44 BUILD_OPTION_NAVIGATION_2D,
45 BUILD_OPTION_NAVIGATION_3D,
46 BUILD_OPTION_XR,
47 BUILD_OPTION_OPENXR,
48 BUILD_OPTION_WAYLAND,
49 BUILD_OPTION_X11,
50 BUILD_OPTION_RENDERING_DEVICE,
51 BUILD_OPTION_FORWARD_RENDERER,
52 BUILD_OPTION_MOBILE_RENDERER,
53 BUILD_OPTION_VULKAN,
54 BUILD_OPTION_D3D12,
55 BUILD_OPTION_METAL,
56 BUILD_OPTION_OPENGL,
57 BUILD_OPTION_PHYSICS_2D,
58 BUILD_OPTION_PHYSICS_GODOT_2D,
59 BUILD_OPTION_PHYSICS_3D,
60 BUILD_OPTION_PHYSICS_GODOT_3D,
61 BUILD_OPTION_PHYSICS_JOLT,
62 BUILD_OPTION_TEXT_SERVER_FALLBACK,
63 BUILD_OPTION_TEXT_SERVER_ADVANCED,
64 BUILD_OPTION_DYNAMIC_FONTS,
65 BUILD_OPTION_WOFF2_FONTS,
66 BUILD_OPTION_GRAPHITE_FONTS,
67 BUILD_OPTION_MSDFGEN,
68 BUILD_OPTION_MAX,
69 };
70
71 enum BuildOptionCategory {
72 BUILD_OPTION_CATEGORY_GENERAL,
73 BUILD_OPTION_CATEGORY_GRAPHICS,
74 BUILD_OPTION_CATEGORY_PHYSICS,
75 BUILD_OPTION_CATEGORY_TEXT_SERVER,
76 BUILD_OPTION_CATEGORY_MAX,
77 };
78
79 private:
80 HashSet<StringName> disabled_classes;
81
82 HashSet<StringName> collapsed_classes;
83
84 String force_detect_classes;
85
86 bool build_options_disabled[BUILD_OPTION_MAX] = {};
87 static const char *build_option_identifiers[BUILD_OPTION_MAX];
88 static const bool build_option_disabled_by_default[BUILD_OPTION_MAX];
89 static const bool build_option_disable_values[BUILD_OPTION_MAX];
90 static const bool build_option_explicit_use[BUILD_OPTION_MAX];
91 static const BuildOptionCategory build_option_category[BUILD_OPTION_MAX];
92 static const HashMap<BuildOption, LocalVector<BuildOption>> build_option_dependencies;
93 static HashMap<BuildOption, HashMap<String, LocalVector<Variant>>> build_option_settings;
94 static const HashMap<BuildOption, LocalVector<String>> build_option_classes;
95
96 String _get_build_option_name(BuildOption p_build_option) { return get_build_option_name(p_build_option); }
97
98 protected:
99 static void _bind_methods();
100
101 public:
102 void set_disable_class(const StringName &p_class, bool p_disabled);
103 bool is_class_disabled(const StringName &p_class) const;
104
105 void set_item_collapsed(const StringName &p_class, bool p_collapsed);
106 bool is_item_collapsed(const StringName &p_class) const;
107
108 void set_disable_build_option(BuildOption p_build_option, bool p_disable);
109 bool is_build_option_disabled(BuildOption p_build_option) const;
110
111 void reset_build_options();
112
113 void set_force_detect_classes(const String &p_classes);
114 String get_force_detect_classes() const;
115
116 void clear_disabled_classes();
117
118 Error save_to_file(const String &p_path);
119 Error load_from_file(const String &p_path);
120
121 static String get_build_option_name(BuildOption p_build_option);
122 static String get_build_option_description(BuildOption p_build_option);
123 static String get_build_option_identifier(BuildOption p_build_option);
124 static bool get_build_option_disable_value(BuildOption p_build_option);
125 static bool get_build_option_explicit_use(BuildOption p_build_option);
126 static BuildOptionCategory get_build_option_category(BuildOption p_build_option);
127 static LocalVector<BuildOption> get_build_option_dependencies(BuildOption p_build_option);
128 static HashMap<String, LocalVector<Variant>> get_build_option_settings(BuildOption p_build_option);
129 static LocalVector<String> get_build_option_classes(BuildOption p_build_option);
130
131 static String get_build_option_category_name(BuildOptionCategory p_build_option_category);
132
133 EditorBuildProfile();
134 };
135
136 VARIANT_ENUM_CAST(EditorBuildProfile::BuildOption)
137 VARIANT_ENUM_CAST(EditorBuildProfile::BuildOptionCategory)
138
139 class EditorFileDialog;
140 class EditorFileSystemDirectory;
141
142 class EditorBuildProfileManager : public AcceptDialog {
143 GDCLASS(EditorBuildProfileManager, AcceptDialog);
144
145 enum Action {
146 ACTION_NEW,
147 ACTION_RESET,
148 ACTION_LOAD,
149 ACTION_SAVE,
150 ACTION_SAVE_AS,
151 ACTION_DETECT,
152 ACTION_MAX
153 };
154
155 Action last_action = ACTION_NEW;
156
157 ConfirmationDialog *confirm_dialog = nullptr;
158 Button *profile_actions[ACTION_MAX];
159
160 Tree *class_list = nullptr;
161 EditorHelpBit *description_bit = nullptr;
162
163 EditorFileDialog *import_profile = nullptr;
164 EditorFileDialog *export_profile = nullptr;
165
166 LineEdit *profile_path = nullptr;
167
168 LineEdit *force_detect_classes = nullptr;
169
170 void _profile_action(int p_action);
171 void _action_confirm();
172 void _hide_requested();
173
174 void _update_edited_profile();
175 void _fill_classes_from(TreeItem *p_parent, const String &p_class, const String &p_selected);
176
177 Ref<EditorBuildProfile> edited;
178
179 void _import_profile(const String &p_path);
180 void _export_profile(const String &p_path);
181
182 bool updating_build_options = false;
183
184 void _class_list_item_selected();
185 void _class_list_item_edited();
186 void _class_list_item_collapsed(Object *p_item);
187
188 bool project_scan_canceled = false;
189
190 void _detect_from_project();
191
192 void _force_detect_classes_changed(const String &p_text);
193
194 struct DetectedFile {
195 uint32_t timestamp = 0;
196 String md5;
197 Vector<String> classes;
198 Vector<String> build_deps;
199 };
200
201 void _find_files(EditorFileSystemDirectory *p_dir, const HashMap<String, DetectedFile> &p_cache, HashMap<String, DetectedFile> &r_detected);
202
203 static EditorBuildProfileManager *singleton;
204
205 protected:
206 static void _bind_methods();
207 void _notification(int p_what);
208
209 public:
210 Ref<EditorBuildProfile> get_current_profile();
211
212 static EditorBuildProfileManager *get_singleton() { return singleton; }
213 EditorBuildProfileManager();
214 };