editor_build_profile.h 6.6 KB

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