editor_export_preset.h 7.1 KB

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