editor_build_profile.h 6.4 KB

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