project_manager.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. /**************************************************************************/
  2. /* project_manager.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 PROJECT_MANAGER_H
  31. #define PROJECT_MANAGER_H
  32. #include "scene/gui/dialogs.h"
  33. #include "scene/gui/scroll_container.h"
  34. class CheckBox;
  35. class EditorAbout;
  36. class EditorAssetLibrary;
  37. class EditorFileDialog;
  38. class EditorTitleBar;
  39. class HFlowContainer;
  40. class LineEdit;
  41. class MarginContainer;
  42. class OptionButton;
  43. class PanelContainer;
  44. class ProjectDialog;
  45. class ProjectList;
  46. class QuickSettingsDialog;
  47. class RichTextLabel;
  48. class TabContainer;
  49. class VBoxContainer;
  50. class ProjectManager : public Control {
  51. GDCLASS(ProjectManager, Control);
  52. static ProjectManager *singleton;
  53. // Utility data.
  54. static Ref<Texture2D> _file_dialog_get_icon(const String &p_path);
  55. static Ref<Texture2D> _file_dialog_get_thumbnail(const String &p_path);
  56. HashMap<String, Ref<Texture2D>> icon_type_cache;
  57. void _build_icon_type_cache(Ref<Theme> p_theme);
  58. // Main layout.
  59. Ref<Theme> theme;
  60. void _update_size_limits();
  61. void _update_theme(bool p_skip_creation = false);
  62. void _titlebar_resized();
  63. MarginContainer *root_container = nullptr;
  64. Panel *background_panel = nullptr;
  65. VBoxContainer *main_vbox = nullptr;
  66. EditorTitleBar *title_bar = nullptr;
  67. Control *left_menu_spacer = nullptr;
  68. Control *left_spacer = nullptr;
  69. Control *right_menu_spacer = nullptr;
  70. Control *right_spacer = nullptr;
  71. Button *title_bar_logo = nullptr;
  72. HBoxContainer *main_view_toggles = nullptr;
  73. Button *quick_settings_button = nullptr;
  74. enum MainViewTab {
  75. MAIN_VIEW_PROJECTS,
  76. MAIN_VIEW_ASSETLIB,
  77. MAIN_VIEW_MAX
  78. };
  79. MainViewTab current_main_view = MAIN_VIEW_PROJECTS;
  80. HashMap<MainViewTab, Control *> main_view_map;
  81. HashMap<MainViewTab, Button *> main_view_toggle_map;
  82. PanelContainer *main_view_container = nullptr;
  83. Ref<ButtonGroup> main_view_toggles_group;
  84. Button *_add_main_view(MainViewTab p_id, const String &p_name, const Ref<Texture2D> &p_icon, Control *p_view_control);
  85. void _set_main_view_icon(MainViewTab p_id, const Ref<Texture2D> &p_icon);
  86. void _select_main_view(int p_id);
  87. VBoxContainer *local_projects_vb = nullptr;
  88. EditorAssetLibrary *asset_library = nullptr;
  89. EditorAbout *about_dialog = nullptr;
  90. void _show_about();
  91. void _open_asset_library_confirmed();
  92. AcceptDialog *error_dialog = nullptr;
  93. void _show_error(const String &p_message, const Size2 &p_min_size = Size2());
  94. void _dim_window();
  95. // Quick settings.
  96. QuickSettingsDialog *quick_settings_dialog = nullptr;
  97. void _show_quick_settings();
  98. void _restart_confirmed();
  99. // Project list.
  100. VBoxContainer *empty_list_placeholder = nullptr;
  101. Button *empty_list_create_project = nullptr;
  102. Button *empty_list_import_project = nullptr;
  103. Button *empty_list_open_assetlib = nullptr;
  104. Label *empty_list_online_warning = nullptr;
  105. void _update_list_placeholder();
  106. ProjectList *project_list = nullptr;
  107. bool initialized = false;
  108. LineEdit *search_box = nullptr;
  109. Label *loading_label = nullptr;
  110. OptionButton *filter_option = nullptr;
  111. PanelContainer *project_list_panel = nullptr;
  112. Button *create_btn = nullptr;
  113. Button *import_btn = nullptr;
  114. Button *scan_btn = nullptr;
  115. Button *open_btn = nullptr;
  116. Button *run_btn = nullptr;
  117. Button *rename_btn = nullptr;
  118. Button *manage_tags_btn = nullptr;
  119. Button *erase_btn = nullptr;
  120. Button *erase_missing_btn = nullptr;
  121. EditorFileDialog *scan_dir = nullptr;
  122. ConfirmationDialog *erase_ask = nullptr;
  123. Label *erase_ask_label = nullptr;
  124. // Comment out for now until we have a better warning system to
  125. // ensure users delete their project only.
  126. //CheckBox *delete_project_contents = nullptr;
  127. ConfirmationDialog *erase_missing_ask = nullptr;
  128. ConfirmationDialog *multi_open_ask = nullptr;
  129. ConfirmationDialog *multi_run_ask = nullptr;
  130. ProjectDialog *project_dialog = nullptr;
  131. void _scan_projects();
  132. void _run_project();
  133. void _run_project_confirm();
  134. void _open_selected_projects();
  135. void _open_selected_projects_ask();
  136. void _open_selected_projects_with_migration();
  137. void _install_project(const String &p_zip_path, const String &p_title);
  138. void _import_project();
  139. void _new_project();
  140. void _rename_project();
  141. void _erase_project();
  142. void _erase_missing_projects();
  143. void _erase_project_confirm();
  144. void _erase_missing_projects_confirm();
  145. void _update_project_buttons();
  146. void _on_project_created(const String &dir);
  147. void _on_projects_updated();
  148. void _on_order_option_changed(int p_idx);
  149. void _on_search_term_changed(const String &p_term);
  150. void _on_search_term_submitted(const String &p_text);
  151. // Project tag management.
  152. HashSet<String> tag_set;
  153. PackedStringArray current_project_tags;
  154. PackedStringArray forbidden_tag_characters{ "/", "\\", "-" };
  155. ConfirmationDialog *tag_manage_dialog = nullptr;
  156. HFlowContainer *project_tags = nullptr;
  157. HFlowContainer *all_tags = nullptr;
  158. Label *tag_edit_error = nullptr;
  159. Button *create_tag_btn = nullptr;
  160. ConfirmationDialog *create_tag_dialog = nullptr;
  161. LineEdit *new_tag_name = nullptr;
  162. Label *tag_error = nullptr;
  163. void _manage_project_tags();
  164. void _add_project_tag(const String &p_tag);
  165. void _delete_project_tag(const String &p_tag);
  166. void _apply_project_tags();
  167. void _set_new_tag_name(const String p_name);
  168. void _create_new_tag();
  169. // Project converter/migration tool.
  170. ConfirmationDialog *ask_full_convert_dialog = nullptr;
  171. ConfirmationDialog *ask_update_settings = nullptr;
  172. Button *full_convert_button = nullptr;
  173. String version_convert_feature;
  174. #ifndef DISABLE_DEPRECATED
  175. void _minor_project_migrate();
  176. #endif
  177. void _full_convert_button_pressed();
  178. void _perform_full_project_conversion();
  179. // Input and I/O.
  180. virtual void shortcut_input(const Ref<InputEvent> &p_ev) override;
  181. void _files_dropped(PackedStringArray p_files);
  182. protected:
  183. void _notification(int p_what);
  184. public:
  185. static ProjectManager *get_singleton() { return singleton; }
  186. // Project list.
  187. bool is_initialized() const { return initialized; }
  188. LineEdit *get_search_box();
  189. // Project tag management.
  190. void add_new_tag(const String &p_tag);
  191. ProjectManager();
  192. ~ProjectManager();
  193. };
  194. #endif // PROJECT_MANAGER_H