project_manager.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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 "editor/editor_about.h"
  33. #include "editor/plugins/asset_library_editor_plugin.h"
  34. #include "scene/gui/dialogs.h"
  35. #include "scene/gui/file_dialog.h"
  36. #include "scene/gui/scroll_container.h"
  37. #include "scene/gui/tool_button.h"
  38. #include "scene/gui/tree.h"
  39. class ProjectDialog;
  40. class ProjectList;
  41. class ProjectListFilter;
  42. class ProjectManager : public Control {
  43. GDCLASS(ProjectManager, Control);
  44. Button *erase_btn;
  45. Button *erase_missing_btn;
  46. Button *open_btn;
  47. Button *rename_btn;
  48. Button *run_btn;
  49. Button *about_btn;
  50. EditorAssetLibrary *asset_library = nullptr;
  51. ProjectListFilter *project_filter;
  52. ProjectListFilter *project_order_filter;
  53. Label *loading_label;
  54. FileDialog *scan_dir;
  55. ConfirmationDialog *language_restart_ask;
  56. ConfirmationDialog *erase_ask;
  57. Label *erase_ask_label;
  58. CheckBox *delete_project_contents;
  59. ConfirmationDialog *erase_missing_ask;
  60. ConfirmationDialog *multi_open_ask;
  61. ConfirmationDialog *multi_run_ask;
  62. ConfirmationDialog *multi_scan_ask;
  63. ConfirmationDialog *ask_update_settings;
  64. ConfirmationDialog *open_templates = nullptr;
  65. EditorAbout *about;
  66. AcceptDialog *run_error_diag;
  67. AcceptDialog *dialog_error;
  68. ProjectDialog *npdialog;
  69. HBoxContainer *local_projects_hb;
  70. TabContainer *tabs;
  71. ProjectList *_project_list;
  72. LinkButton *version_btn;
  73. OptionButton *language_btn;
  74. Control *gui_base;
  75. bool importing;
  76. void _open_asset_library();
  77. void _scan_projects();
  78. void _run_project();
  79. void _run_project_confirm();
  80. void _open_selected_projects();
  81. void _open_selected_projects_ask();
  82. void _import_project();
  83. void _new_project();
  84. void _rename_project();
  85. void _erase_project();
  86. void _erase_missing_projects();
  87. void _erase_project_confirm();
  88. void _erase_missing_projects_confirm();
  89. void _show_about();
  90. void _update_project_buttons();
  91. void _language_selected(int p_id);
  92. void _restart_confirm();
  93. void _scan_begin(const String &p_base);
  94. void _global_menu_action(const Variant &p_id, const Variant &p_meta);
  95. void _confirm_update_settings();
  96. void _load_recent_projects();
  97. void _on_project_created(const String &dir);
  98. void _on_projects_updated();
  99. void _scan_dir(const String &path, List<String> *r_projects);
  100. void _install_project(const String &p_zip_path, const String &p_title);
  101. void _dim_window();
  102. void _unhandled_input(const Ref<InputEvent> &p_ev);
  103. void _files_dropped(PoolStringArray p_files, int p_screen);
  104. void _scan_multiple_folders(PoolStringArray p_files);
  105. void _version_button_pressed();
  106. void _on_order_option_changed();
  107. void _on_filter_option_changed();
  108. void _on_tab_changed(int p_tab);
  109. protected:
  110. void _notification(int p_what);
  111. static void _bind_methods();
  112. public:
  113. ProjectManager();
  114. ~ProjectManager();
  115. };
  116. class ProjectListFilter : public HBoxContainer {
  117. GDCLASS(ProjectListFilter, HBoxContainer);
  118. public:
  119. enum FilterOption {
  120. FILTER_NAME,
  121. FILTER_PATH,
  122. FILTER_MODIFIED,
  123. };
  124. private:
  125. friend class ProjectManager;
  126. OptionButton *filter_option;
  127. LineEdit *search_box;
  128. bool has_search_box;
  129. FilterOption _current_filter;
  130. void _search_text_changed(const String &p_newtext);
  131. void _filter_option_selected(int p_idx);
  132. protected:
  133. void _notification(int p_what);
  134. static void _bind_methods();
  135. public:
  136. void _setup_filters(Vector<String> options);
  137. void add_filter_option();
  138. void add_search_box();
  139. // May return `nullptr` if the search box wasn't created yet, so check for validity
  140. // before using the returned value.
  141. LineEdit *get_search_box() const;
  142. void set_filter_size(int h_size);
  143. String get_search_term();
  144. FilterOption get_filter_option();
  145. void set_filter_option(FilterOption);
  146. ProjectListFilter();
  147. void clear();
  148. };
  149. #endif // PROJECT_MANAGER_H