editor_build_profile.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. /**************************************************************************/
  2. /* editor_build_profile.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_BUILD_PROFILE_H
  31. #define EDITOR_BUILD_PROFILE_H
  32. #include "core/object/ref_counted.h"
  33. #include "editor/editor_help.h"
  34. #include "scene/gui/dialogs.h"
  35. #include "scene/gui/tree.h"
  36. class EditorBuildProfile : public RefCounted {
  37. GDCLASS(EditorBuildProfile, RefCounted);
  38. public:
  39. enum BuildOption {
  40. BUILD_OPTION_3D,
  41. BUILD_OPTION_PHYSICS_2D,
  42. BUILD_OPTION_PHYSICS_3D,
  43. BUILD_OPTION_NAVIGATION,
  44. BUILD_OPTION_XR,
  45. BUILD_OPTION_RENDERING_DEVICE,
  46. BUILD_OPTION_OPENGL,
  47. BUILD_OPTION_VULKAN,
  48. BUILD_OPTION_TEXT_SERVER_FALLBACK,
  49. BUILD_OPTION_TEXT_SERVER_ADVANCED,
  50. BUILD_OPTION_DYNAMIC_FONTS,
  51. BUILD_OPTION_WOFF2_FONTS,
  52. BUILD_OPTION_GRAPHITE_FONTS,
  53. BUILD_OPTION_MSDFGEN,
  54. BUILD_OPTION_MAX,
  55. };
  56. enum BuildOptionCategory {
  57. BUILD_OPTION_CATEGORY_GENERAL,
  58. BUILD_OPTION_CATEGORY_TEXT_SERVER,
  59. BUILD_OPTION_CATEGORY_MAX,
  60. };
  61. private:
  62. HashSet<StringName> disabled_classes;
  63. HashSet<StringName> collapsed_classes;
  64. String force_detect_classes;
  65. bool build_options_disabled[BUILD_OPTION_MAX] = {};
  66. static const char *build_option_identifiers[BUILD_OPTION_MAX];
  67. static const bool build_option_disabled_by_default[BUILD_OPTION_MAX];
  68. static const bool build_option_disable_values[BUILD_OPTION_MAX];
  69. static const BuildOptionCategory build_option_category[BUILD_OPTION_MAX];
  70. String _get_build_option_name(BuildOption p_build_option) { return get_build_option_name(p_build_option); }
  71. protected:
  72. static void _bind_methods();
  73. public:
  74. void set_disable_class(const StringName &p_class, bool p_disabled);
  75. bool is_class_disabled(const StringName &p_class) const;
  76. void set_item_collapsed(const StringName &p_class, bool p_collapsed);
  77. bool is_item_collapsed(const StringName &p_class) const;
  78. void set_disable_build_option(BuildOption p_build_option, bool p_disable);
  79. bool is_build_option_disabled(BuildOption p_build_option) const;
  80. void set_force_detect_classes(const String &p_classes);
  81. String get_force_detect_classes() const;
  82. void clear_disabled_classes();
  83. Error save_to_file(const String &p_path);
  84. Error load_from_file(const String &p_path);
  85. static String get_build_option_name(BuildOption p_build_option);
  86. static String get_build_option_description(BuildOption p_build_option);
  87. static bool get_build_option_disable_value(BuildOption p_build_option);
  88. static BuildOptionCategory get_build_option_category(BuildOption p_build_option);
  89. static String get_build_option_category_name(BuildOptionCategory p_build_option_category);
  90. EditorBuildProfile();
  91. };
  92. VARIANT_ENUM_CAST(EditorBuildProfile::BuildOption)
  93. VARIANT_ENUM_CAST(EditorBuildProfile::BuildOptionCategory)
  94. class EditorFileDialog;
  95. class EditorFileSystemDirectory;
  96. class EditorBuildProfileManager : public AcceptDialog {
  97. GDCLASS(EditorBuildProfileManager, AcceptDialog);
  98. enum Action {
  99. ACTION_NEW,
  100. ACTION_RESET,
  101. ACTION_LOAD,
  102. ACTION_SAVE,
  103. ACTION_SAVE_AS,
  104. ACTION_DETECT,
  105. ACTION_MAX
  106. };
  107. Action last_action = ACTION_NEW;
  108. ConfirmationDialog *confirm_dialog = nullptr;
  109. Button *profile_actions[ACTION_MAX];
  110. Tree *class_list = nullptr;
  111. EditorHelpBit *description_bit = nullptr;
  112. EditorFileDialog *import_profile = nullptr;
  113. EditorFileDialog *export_profile = nullptr;
  114. LineEdit *profile_path = nullptr;
  115. LineEdit *force_detect_classes = nullptr;
  116. void _profile_action(int p_action);
  117. void _action_confirm();
  118. void _hide_requested();
  119. void _update_edited_profile();
  120. void _fill_classes_from(TreeItem *p_parent, const String &p_class, const String &p_selected);
  121. Ref<EditorBuildProfile> edited;
  122. void _import_profile(const String &p_path);
  123. void _export_profile(const String &p_path);
  124. bool updating_build_options = false;
  125. void _class_list_item_selected();
  126. void _class_list_item_edited();
  127. void _class_list_item_collapsed(Object *p_item);
  128. void _detect_classes();
  129. void _force_detect_classes_changed(const String &p_text);
  130. struct DetectedFile {
  131. uint32_t timestamp = 0;
  132. String md5;
  133. Vector<String> classes;
  134. };
  135. void _find_files(EditorFileSystemDirectory *p_dir, const HashMap<String, DetectedFile> &p_cache, HashMap<String, DetectedFile> &r_detected);
  136. static EditorBuildProfileManager *singleton;
  137. protected:
  138. static void _bind_methods();
  139. void _notification(int p_what);
  140. public:
  141. Ref<EditorBuildProfile> get_current_profile();
  142. static EditorBuildProfileManager *get_singleton() { return singleton; }
  143. EditorBuildProfileManager();
  144. };
  145. #endif // EDITOR_BUILD_PROFILE_H