editor_export_preset.cpp 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. /*************************************************************************/
  2. /* editor_export_preset.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
  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. #include "editor_export.h"
  31. bool EditorExportPreset::_set(const StringName &p_name, const Variant &p_value) {
  32. if (values.has(p_name)) {
  33. values[p_name] = p_value;
  34. EditorExport::singleton->save_presets();
  35. if (update_visibility[p_name]) {
  36. notify_property_list_changed();
  37. }
  38. return true;
  39. }
  40. return false;
  41. }
  42. bool EditorExportPreset::_get(const StringName &p_name, Variant &r_ret) const {
  43. if (values.has(p_name)) {
  44. r_ret = values[p_name];
  45. return true;
  46. }
  47. return false;
  48. }
  49. void EditorExportPreset::_get_property_list(List<PropertyInfo> *p_list) const {
  50. for (const PropertyInfo &E : properties) {
  51. if (platform->get_export_option_visibility(this, E.name, values)) {
  52. p_list->push_back(E);
  53. }
  54. }
  55. }
  56. Ref<EditorExportPlatform> EditorExportPreset::get_platform() const {
  57. return platform;
  58. }
  59. void EditorExportPreset::update_files_to_export() {
  60. Vector<String> to_remove;
  61. for (const String &E : selected_files) {
  62. if (!FileAccess::exists(E)) {
  63. to_remove.push_back(E);
  64. }
  65. }
  66. for (int i = 0; i < to_remove.size(); ++i) {
  67. selected_files.erase(to_remove[i]);
  68. }
  69. }
  70. Vector<String> EditorExportPreset::get_files_to_export() const {
  71. Vector<String> files;
  72. for (const String &E : selected_files) {
  73. files.push_back(E);
  74. }
  75. return files;
  76. }
  77. void EditorExportPreset::set_name(const String &p_name) {
  78. name = p_name;
  79. EditorExport::singleton->save_presets();
  80. }
  81. String EditorExportPreset::get_name() const {
  82. return name;
  83. }
  84. void EditorExportPreset::set_runnable(bool p_enable) {
  85. runnable = p_enable;
  86. EditorExport::singleton->save_presets();
  87. }
  88. bool EditorExportPreset::is_runnable() const {
  89. return runnable;
  90. }
  91. void EditorExportPreset::set_export_filter(ExportFilter p_filter) {
  92. export_filter = p_filter;
  93. EditorExport::singleton->save_presets();
  94. }
  95. EditorExportPreset::ExportFilter EditorExportPreset::get_export_filter() const {
  96. return export_filter;
  97. }
  98. void EditorExportPreset::set_include_filter(const String &p_include) {
  99. include_filter = p_include;
  100. EditorExport::singleton->save_presets();
  101. }
  102. String EditorExportPreset::get_include_filter() const {
  103. return include_filter;
  104. }
  105. void EditorExportPreset::set_export_path(const String &p_path) {
  106. export_path = p_path;
  107. /* NOTE(SonerSound): if there is a need to implement a PropertyHint that specifically indicates a relative path,
  108. * this should be removed. */
  109. if (export_path.is_absolute_path()) {
  110. String res_path = OS::get_singleton()->get_resource_dir();
  111. export_path = res_path.path_to_file(export_path);
  112. }
  113. EditorExport::singleton->save_presets();
  114. }
  115. String EditorExportPreset::get_export_path() const {
  116. return export_path;
  117. }
  118. void EditorExportPreset::set_exclude_filter(const String &p_exclude) {
  119. exclude_filter = p_exclude;
  120. EditorExport::singleton->save_presets();
  121. }
  122. String EditorExportPreset::get_exclude_filter() const {
  123. return exclude_filter;
  124. }
  125. void EditorExportPreset::add_export_file(const String &p_path) {
  126. selected_files.insert(p_path);
  127. EditorExport::singleton->save_presets();
  128. }
  129. void EditorExportPreset::remove_export_file(const String &p_path) {
  130. selected_files.erase(p_path);
  131. EditorExport::singleton->save_presets();
  132. }
  133. bool EditorExportPreset::has_export_file(const String &p_path) {
  134. return selected_files.has(p_path);
  135. }
  136. void EditorExportPreset::set_custom_features(const String &p_custom_features) {
  137. custom_features = p_custom_features;
  138. EditorExport::singleton->save_presets();
  139. }
  140. String EditorExportPreset::get_custom_features() const {
  141. return custom_features;
  142. }
  143. void EditorExportPreset::set_enc_in_filter(const String &p_filter) {
  144. enc_in_filters = p_filter;
  145. EditorExport::singleton->save_presets();
  146. }
  147. String EditorExportPreset::get_enc_in_filter() const {
  148. return enc_in_filters;
  149. }
  150. void EditorExportPreset::set_enc_ex_filter(const String &p_filter) {
  151. enc_ex_filters = p_filter;
  152. EditorExport::singleton->save_presets();
  153. }
  154. String EditorExportPreset::get_enc_ex_filter() const {
  155. return enc_ex_filters;
  156. }
  157. void EditorExportPreset::set_enc_pck(bool p_enabled) {
  158. enc_pck = p_enabled;
  159. EditorExport::singleton->save_presets();
  160. }
  161. bool EditorExportPreset::get_enc_pck() const {
  162. return enc_pck;
  163. }
  164. void EditorExportPreset::set_enc_directory(bool p_enabled) {
  165. enc_directory = p_enabled;
  166. EditorExport::singleton->save_presets();
  167. }
  168. bool EditorExportPreset::get_enc_directory() const {
  169. return enc_directory;
  170. }
  171. void EditorExportPreset::set_script_export_mode(int p_mode) {
  172. script_mode = p_mode;
  173. EditorExport::singleton->save_presets();
  174. }
  175. int EditorExportPreset::get_script_export_mode() const {
  176. return script_mode;
  177. }
  178. void EditorExportPreset::set_script_encryption_key(const String &p_key) {
  179. script_key = p_key;
  180. EditorExport::singleton->save_presets();
  181. }
  182. String EditorExportPreset::get_script_encryption_key() const {
  183. return script_key;
  184. }
  185. EditorExportPreset::EditorExportPreset() {}