Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/editor/export/editor_export_preset.h
9903 views
1
/**************************************************************************/
2
/* editor_export_preset.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
class EditorExportPlatform;
34
35
#include "core/object/ref_counted.h"
36
37
class EditorExportPreset : public RefCounted {
38
GDCLASS(EditorExportPreset, RefCounted);
39
40
public:
41
enum ExportFilter {
42
EXPORT_ALL_RESOURCES,
43
EXPORT_SELECTED_SCENES,
44
EXPORT_SELECTED_RESOURCES,
45
EXCLUDE_SELECTED_RESOURCES,
46
EXPORT_CUSTOMIZED,
47
};
48
49
enum FileExportMode {
50
MODE_FILE_NOT_CUSTOMIZED,
51
MODE_FILE_STRIP,
52
MODE_FILE_KEEP,
53
MODE_FILE_REMOVE,
54
};
55
56
enum ScriptExportMode {
57
MODE_SCRIPT_TEXT,
58
MODE_SCRIPT_BINARY_TOKENS,
59
MODE_SCRIPT_BINARY_TOKENS_COMPRESSED,
60
};
61
62
private:
63
Ref<EditorExportPlatform> platform;
64
ExportFilter export_filter = EXPORT_ALL_RESOURCES;
65
String include_filter;
66
String exclude_filter;
67
String export_path;
68
69
String exporter;
70
HashSet<String> selected_files;
71
HashMap<String, FileExportMode> customized_files;
72
bool runnable = false;
73
bool advanced_options_enabled = false;
74
bool dedicated_server = false;
75
76
Vector<String> patches;
77
78
friend class EditorExport;
79
friend class EditorExportPlatform;
80
81
HashMap<StringName, PropertyInfo> properties;
82
HashMap<StringName, Variant> values;
83
HashMap<StringName, Variant> value_overrides;
84
HashMap<StringName, bool> update_visibility;
85
86
String name;
87
88
String custom_features;
89
90
String enc_in_filters;
91
String enc_ex_filters;
92
bool enc_pck = false;
93
bool enc_directory = false;
94
uint64_t seed = 0;
95
96
String script_key;
97
int script_mode = MODE_SCRIPT_BINARY_TOKENS_COMPRESSED;
98
99
protected:
100
bool _set(const StringName &p_name, const Variant &p_value);
101
bool _get(const StringName &p_name, Variant &r_ret) const;
102
void _get_property_list(List<PropertyInfo> *p_list) const;
103
104
String _get_property_warning(const StringName &p_name) const;
105
106
static void _bind_methods();
107
108
public:
109
Ref<EditorExportPlatform> get_platform() const;
110
111
bool has(const StringName &p_property) const { return values.has(p_property); }
112
113
void update_files();
114
void update_value_overrides();
115
116
Vector<String> get_files_to_export() const;
117
Dictionary get_customized_files() const;
118
int get_customized_files_count() const;
119
void set_customized_files(const Dictionary &p_files);
120
121
void add_export_file(const String &p_path);
122
void remove_export_file(const String &p_path);
123
bool has_export_file(const String &p_path);
124
125
void set_file_export_mode(const String &p_path, FileExportMode p_mode);
126
FileExportMode get_file_export_mode(const String &p_path, FileExportMode p_default = MODE_FILE_NOT_CUSTOMIZED) const;
127
128
Variant get_project_setting(const StringName &p_name);
129
130
void set_name(const String &p_name);
131
String get_name() const;
132
133
void set_runnable(bool p_enable);
134
bool is_runnable() const;
135
136
void set_advanced_options_enabled(bool p_enabled);
137
bool are_advanced_options_enabled() const;
138
139
void set_dedicated_server(bool p_enable);
140
bool is_dedicated_server() const;
141
142
void set_export_filter(ExportFilter p_filter);
143
ExportFilter get_export_filter() const;
144
145
void set_include_filter(const String &p_include);
146
String get_include_filter() const;
147
148
void set_exclude_filter(const String &p_exclude);
149
String get_exclude_filter() const;
150
151
void add_patch(const String &p_path, int p_at_pos = -1);
152
void set_patch(int p_index, const String &p_path);
153
String get_patch(int p_index);
154
void remove_patch(int p_index);
155
void set_patches(const Vector<String> &p_patches);
156
Vector<String> get_patches() const;
157
158
void set_custom_features(const String &p_custom_features);
159
String get_custom_features() const;
160
161
void set_export_path(const String &p_path);
162
String get_export_path() const;
163
164
void set_enc_in_filter(const String &p_filter);
165
String get_enc_in_filter() const;
166
167
void set_enc_ex_filter(const String &p_filter);
168
String get_enc_ex_filter() const;
169
170
void set_seed(uint64_t p_seed);
171
uint64_t get_seed() const;
172
173
void set_enc_pck(bool p_enabled);
174
bool get_enc_pck() const;
175
176
void set_enc_directory(bool p_enabled);
177
bool get_enc_directory() const;
178
179
void set_script_encryption_key(const String &p_key);
180
String get_script_encryption_key() const;
181
182
void set_script_export_mode(int p_mode);
183
int get_script_export_mode() const;
184
185
Variant _get_or_env(const StringName &p_name, const String &p_env_var) const {
186
return get_or_env(p_name, p_env_var);
187
}
188
Variant get_or_env(const StringName &p_name, const String &p_env_var, bool *r_valid = nullptr) const;
189
190
// Return the preset's version number, or fall back to the
191
// `application/config/version` project setting if set to an empty string.
192
// If `p_windows_version` is `true`, formats the returned version number to
193
// be compatible with Windows executable metadata (which requires a
194
// 4-component format).
195
String get_version(const StringName &p_name, bool p_windows_version = false) const;
196
197
const HashMap<StringName, PropertyInfo> &get_properties() const { return properties; }
198
const HashMap<StringName, Variant> &get_values() const { return values; }
199
};
200
201
VARIANT_ENUM_CAST(EditorExportPreset::ExportFilter);
202
VARIANT_ENUM_CAST(EditorExportPreset::FileExportMode);
203
VARIANT_ENUM_CAST(EditorExportPreset::ScriptExportMode);
204
205