Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/editor/settings/editor_feature_profile.h
9896 views
1
/**************************************************************************/
2
/* editor_feature_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/option_button.h"
37
#include "scene/gui/split_container.h"
38
#include "scene/gui/tree.h"
39
40
class EditorFileDialog;
41
42
class EditorFeatureProfile : public RefCounted {
43
GDCLASS(EditorFeatureProfile, RefCounted);
44
45
public:
46
enum Feature {
47
FEATURE_3D,
48
FEATURE_SCRIPT,
49
FEATURE_ASSET_LIB,
50
FEATURE_SCENE_TREE,
51
FEATURE_NODE_DOCK,
52
FEATURE_FILESYSTEM_DOCK,
53
FEATURE_IMPORT_DOCK,
54
FEATURE_HISTORY_DOCK,
55
FEATURE_GAME,
56
FEATURE_MAX
57
};
58
59
private:
60
HashSet<StringName> disabled_classes;
61
HashSet<StringName> disabled_editors;
62
HashMap<StringName, HashSet<StringName>> disabled_properties;
63
64
HashSet<StringName> collapsed_classes;
65
66
bool features_disabled[FEATURE_MAX];
67
static const char *feature_names[FEATURE_MAX];
68
static const char *feature_descriptions[FEATURE_MAX];
69
static const char *feature_identifiers[FEATURE_MAX];
70
71
String _get_feature_name(Feature p_feature) { return get_feature_name(p_feature); }
72
73
protected:
74
static void _bind_methods();
75
76
public:
77
void set_disable_class(const StringName &p_class, bool p_disabled);
78
bool is_class_disabled(const StringName &p_class) const;
79
80
void set_disable_class_editor(const StringName &p_class, bool p_disabled);
81
bool is_class_editor_disabled(const StringName &p_class) const;
82
83
void set_disable_class_property(const StringName &p_class, const StringName &p_property, bool p_disabled);
84
bool is_class_property_disabled(const StringName &p_class, const StringName &p_property) const;
85
bool has_class_properties_disabled(const StringName &p_class) const;
86
87
void set_item_collapsed(const StringName &p_class, bool p_collapsed);
88
bool is_item_collapsed(const StringName &p_class) const;
89
90
void set_disable_feature(Feature p_feature, bool p_disable);
91
bool is_feature_disabled(Feature p_feature) const;
92
93
Error save_to_file(const String &p_path);
94
Error load_from_file(const String &p_path);
95
96
static String get_feature_name(Feature p_feature);
97
static String get_feature_description(Feature p_feature);
98
99
EditorFeatureProfile();
100
};
101
102
VARIANT_ENUM_CAST(EditorFeatureProfile::Feature)
103
104
class EditorFeatureProfileManager : public AcceptDialog {
105
GDCLASS(EditorFeatureProfileManager, AcceptDialog);
106
107
enum Action {
108
PROFILE_CLEAR,
109
PROFILE_SET,
110
PROFILE_IMPORT,
111
PROFILE_EXPORT,
112
PROFILE_NEW,
113
PROFILE_ERASE,
114
PROFILE_MAX
115
};
116
117
enum ClassOptions {
118
CLASS_OPTION_DISABLE_EDITOR
119
};
120
121
ConfirmationDialog *erase_profile_dialog = nullptr;
122
ConfirmationDialog *new_profile_dialog = nullptr;
123
LineEdit *new_profile_name = nullptr;
124
125
LineEdit *current_profile_name = nullptr;
126
OptionButton *profile_list = nullptr;
127
Button *profile_actions[PROFILE_MAX];
128
129
HSplitContainer *h_split = nullptr;
130
131
VBoxContainer *class_list_vbc = nullptr;
132
Tree *class_list = nullptr;
133
VBoxContainer *property_list_vbc = nullptr;
134
Tree *property_list = nullptr;
135
EditorHelpBit *description_bit = nullptr;
136
Label *no_profile_selected_help = nullptr;
137
138
EditorFileDialog *import_profiles = nullptr;
139
EditorFileDialog *export_profile = nullptr;
140
141
void _profile_action(int p_action);
142
void _profile_selected(int p_what);
143
void _hide_requested();
144
145
String current_profile;
146
void _update_profile_list(const String &p_select_profile = String());
147
void _update_selected_profile();
148
void _update_profile_tree_from(TreeItem *p_edited);
149
void _fill_classes_from(TreeItem *p_parent, const String &p_class, const String &p_selected, int p_class_insert_index = -1);
150
151
Ref<EditorFeatureProfile> current;
152
Ref<EditorFeatureProfile> edited;
153
154
void _erase_selected_profile();
155
void _create_new_profile();
156
String _get_selected_profile();
157
158
void _import_profiles(const Vector<String> &p_paths);
159
void _export_profile(const String &p_path);
160
161
bool updating_features = false;
162
163
void _class_list_item_selected();
164
void _class_list_item_edited();
165
void _class_list_item_collapsed(Object *p_item);
166
void _property_item_edited();
167
void _save_and_update();
168
169
Timer *update_timer = nullptr;
170
void _emit_current_profile_changed();
171
172
static EditorFeatureProfileManager *singleton;
173
174
protected:
175
static void _bind_methods();
176
void _notification(int p_what);
177
178
public:
179
Ref<EditorFeatureProfile> get_current_profile();
180
String get_current_profile_name() const;
181
void set_current_profile(const String &p_profile_name, bool p_validate_profile);
182
void notify_changed();
183
184
static EditorFeatureProfileManager *get_singleton() { return singleton; }
185
EditorFeatureProfileManager();
186
};
187
188