editor_export_preset.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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. friend class EditorExport;
  68. friend class EditorExportPlatform;
  69. HashMap<StringName, PropertyInfo> properties;
  70. HashMap<StringName, Variant> values;
  71. HashMap<StringName, Variant> value_overrides;
  72. HashMap<StringName, bool> update_visibility;
  73. String name;
  74. String custom_features;
  75. String enc_in_filters;
  76. String enc_ex_filters;
  77. bool enc_pck = false;
  78. bool enc_directory = false;
  79. String script_key;
  80. int script_mode = MODE_SCRIPT_BINARY_TOKENS_COMPRESSED;
  81. protected:
  82. bool _set(const StringName &p_name, const Variant &p_value);
  83. bool _get(const StringName &p_name, Variant &r_ret) const;
  84. void _get_property_list(List<PropertyInfo> *p_list) const;
  85. String _get_property_warning(const StringName &p_name) const;
  86. static void _bind_methods();
  87. public:
  88. Ref<EditorExportPlatform> get_platform() const;
  89. bool has(const StringName &p_property) const { return values.has(p_property); }
  90. void update_files();
  91. void update_value_overrides();
  92. Vector<String> get_files_to_export() const;
  93. Dictionary get_customized_files() const;
  94. int get_customized_files_count() const;
  95. void set_customized_files(const Dictionary &p_files);
  96. void add_export_file(const String &p_path);
  97. void remove_export_file(const String &p_path);
  98. bool has_export_file(const String &p_path);
  99. void set_file_export_mode(const String &p_path, FileExportMode p_mode);
  100. FileExportMode get_file_export_mode(const String &p_path, FileExportMode p_default = MODE_FILE_NOT_CUSTOMIZED) const;
  101. void set_name(const String &p_name);
  102. String get_name() const;
  103. void set_runnable(bool p_enable);
  104. bool is_runnable() const;
  105. void set_advanced_options_enabled(bool p_enabled);
  106. bool are_advanced_options_enabled() const;
  107. void set_dedicated_server(bool p_enable);
  108. bool is_dedicated_server() const;
  109. void set_export_filter(ExportFilter p_filter);
  110. ExportFilter get_export_filter() const;
  111. void set_include_filter(const String &p_include);
  112. String get_include_filter() const;
  113. void set_exclude_filter(const String &p_exclude);
  114. String get_exclude_filter() const;
  115. void set_custom_features(const String &p_custom_features);
  116. String get_custom_features() const;
  117. void set_export_path(const String &p_path);
  118. String get_export_path() const;
  119. void set_enc_in_filter(const String &p_filter);
  120. String get_enc_in_filter() const;
  121. void set_enc_ex_filter(const String &p_filter);
  122. String get_enc_ex_filter() const;
  123. void set_enc_pck(bool p_enabled);
  124. bool get_enc_pck() const;
  125. void set_enc_directory(bool p_enabled);
  126. bool get_enc_directory() const;
  127. void set_script_encryption_key(const String &p_key);
  128. String get_script_encryption_key() const;
  129. void set_script_export_mode(int p_mode);
  130. int get_script_export_mode() const;
  131. Variant get_or_env(const StringName &p_name, const String &p_env_var, bool *r_valid = nullptr) const;
  132. // Return the preset's version number, or fall back to the
  133. // `application/config/version` project setting if set to an empty string.
  134. // If `p_windows_version` is `true`, formats the returned version number to
  135. // be compatible with Windows executable metadata (which requires a
  136. // 4-component format).
  137. String get_version(const StringName &p_name, bool p_windows_version = false) const;
  138. const HashMap<StringName, PropertyInfo> &get_properties() const { return properties; }
  139. const HashMap<StringName, Variant> &get_values() const { return values; }
  140. EditorExportPreset();
  141. };
  142. #endif // EDITOR_EXPORT_PRESET_H