| 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 | #ifndef EDITOR_EXPORT_PRESET_H |
| 32 | #define EDITOR_EXPORT_PRESET_H |
| 33 | |
| 34 | class EditorExportPlatform; |
| 35 | |
| 36 | #include "core/object/ref_counted.h" |
| 37 | |
| 38 | class EditorExportPreset : public RefCounted { |
| 39 | GDCLASS(EditorExportPreset, RefCounted); |
| 40 | |
| 41 | public: |
| 42 | enum ExportFilter { |
| 43 | EXPORT_ALL_RESOURCES, |
| 44 | EXPORT_SELECTED_SCENES, |
| 45 | EXPORT_SELECTED_RESOURCES, |
| 46 | EXCLUDE_SELECTED_RESOURCES, |
| 47 | EXPORT_CUSTOMIZED, |
| 48 | }; |
| 49 | |
| 50 | enum FileExportMode { |
| 51 | MODE_FILE_NOT_CUSTOMIZED, |
| 52 | MODE_FILE_STRIP, |
| 53 | MODE_FILE_KEEP, |
| 54 | MODE_FILE_REMOVE, |
| 55 | }; |
| 56 | |
| 57 | private: |
| 58 | Ref<EditorExportPlatform> platform; |
| 59 | ExportFilter export_filter = EXPORT_ALL_RESOURCES; |
| 60 | String include_filter; |
| 61 | String exclude_filter; |
| 62 | String export_path; |
| 63 | |
| 64 | String exporter; |
| 65 | HashSet<String> selected_files; |
| 66 | HashMap<String, FileExportMode> customized_files; |
| 67 | bool runnable = false; |
| 68 | bool dedicated_server = false; |
| 69 | |
| 70 | friend class EditorExport; |
| 71 | friend class EditorExportPlatform; |
| 72 | |
| 73 | HashMap<StringName, PropertyInfo> properties; |
| 74 | HashMap<StringName, Variant> values; |
| 75 | HashMap<StringName, bool> update_visibility; |
| 76 | |
| 77 | String name; |
| 78 | |
| 79 | String custom_features; |
| 80 | |
| 81 | String enc_in_filters; |
| 82 | String enc_ex_filters; |
| 83 | bool enc_pck = false; |
| 84 | bool enc_directory = false; |
| 85 | |
| 86 | String script_key; |
| 87 | |
| 88 | protected: |
| 89 | bool _set(const StringName &p_name, const Variant &p_value); |
| 90 | bool _get(const StringName &p_name, Variant &r_ret) const; |
| 91 | void _get_property_list(List<PropertyInfo> *p_list) const; |
| 92 | |
| 93 | String _get_property_warning(const StringName &p_name) const; |
| 94 | |
| 95 | static void _bind_methods(); |
| 96 | |
| 97 | public: |
| 98 | Ref<EditorExportPlatform> get_platform() const; |
| 99 | |
| 100 | bool has(const StringName &p_property) const { return values.has(p_property); } |
| 101 | |
| 102 | void update_files(); |
| 103 | |
| 104 | Vector<String> get_files_to_export() const; |
| 105 | Dictionary get_customized_files() const; |
| 106 | int get_customized_files_count() const; |
| 107 | void set_customized_files(const Dictionary &p_files); |
| 108 | |
| 109 | void add_export_file(const String &p_path); |
| 110 | void remove_export_file(const String &p_path); |
| 111 | bool has_export_file(const String &p_path); |
| 112 | |
| 113 | void set_file_export_mode(const String &p_path, FileExportMode p_mode); |
| 114 | FileExportMode get_file_export_mode(const String &p_path, FileExportMode p_default = MODE_FILE_NOT_CUSTOMIZED) const; |
| 115 | |
| 116 | void set_name(const String &p_name); |
| 117 | String get_name() const; |
| 118 | |
| 119 | void set_runnable(bool p_enable); |
| 120 | bool is_runnable() const; |
| 121 | |
| 122 | void set_dedicated_server(bool p_enable); |
| 123 | bool is_dedicated_server() const; |
| 124 | |
| 125 | void set_export_filter(ExportFilter p_filter); |
| 126 | ExportFilter get_export_filter() const; |
| 127 | |
| 128 | void set_include_filter(const String &p_include); |
| 129 | String get_include_filter() const; |
| 130 | |
| 131 | void set_exclude_filter(const String &p_exclude); |
| 132 | String get_exclude_filter() const; |
| 133 | |
| 134 | void set_custom_features(const String &p_custom_features); |
| 135 | String get_custom_features() const; |
| 136 | |
| 137 | void set_export_path(const String &p_path); |
| 138 | String get_export_path() const; |
| 139 | |
| 140 | void set_enc_in_filter(const String &p_filter); |
| 141 | String get_enc_in_filter() const; |
| 142 | |
| 143 | void set_enc_ex_filter(const String &p_filter); |
| 144 | String get_enc_ex_filter() const; |
| 145 | |
| 146 | void set_enc_pck(bool p_enabled); |
| 147 | bool get_enc_pck() const; |
| 148 | |
| 149 | void set_enc_directory(bool p_enabled); |
| 150 | bool get_enc_directory() const; |
| 151 | |
| 152 | void set_script_encryption_key(const String &p_key); |
| 153 | String get_script_encryption_key() const; |
| 154 | |
| 155 | Variant get_or_env(const StringName &p_name, const String &p_env_var, bool *r_valid = nullptr) const; |
| 156 | |
| 157 | // Return the preset's version number, or fall back to the |
| 158 | // `application/config/version` project setting if set to an empty string. |
| 159 | // If `p_windows_version` is `true`, formats the returned version number to |
| 160 | // be compatible with Windows executable metadata (which requires a |
| 161 | // 4-component format). |
| 162 | String get_version(const StringName &p_name, bool p_windows_version = false) const; |
| 163 | |
| 164 | const HashMap<StringName, PropertyInfo> &get_properties() const { return properties; } |
| 165 | const HashMap<StringName, Variant> &get_values() const { return values; } |
| 166 | |
| 167 | EditorExportPreset(); |
| 168 | }; |
| 169 | |
| 170 | #endif // EDITOR_EXPORT_PRESET_H |
| 171 | |