project_manager.h 8.0 KB

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