project_manager.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /*************************************************************************/
  2. /* project_manager.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
  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/plugins/asset_library_editor_plugin.h"
  33. #include "scene/gui/dialogs.h"
  34. #include "scene/gui/file_dialog.h"
  35. #include "scene/gui/scroll_container.h"
  36. #include "scene/gui/tool_button.h"
  37. #include "scene/gui/tree.h"
  38. class ProjectDialog;
  39. class ProjectList;
  40. class ProjectListFilter;
  41. class ProjectManager : public Control {
  42. GDCLASS(ProjectManager, Control);
  43. Button *erase_btn;
  44. Button *erase_missing_btn;
  45. Button *open_btn;
  46. Button *rename_btn;
  47. Button *run_btn;
  48. EditorAssetLibrary *asset_library;
  49. ProjectListFilter *project_filter;
  50. ProjectListFilter *project_order_filter;
  51. Label *loading_label;
  52. FileDialog *scan_dir;
  53. ConfirmationDialog *language_restart_ask;
  54. ConfirmationDialog *erase_ask;
  55. ConfirmationDialog *erase_missing_ask;
  56. ConfirmationDialog *multi_open_ask;
  57. ConfirmationDialog *multi_run_ask;
  58. ConfirmationDialog *multi_scan_ask;
  59. ConfirmationDialog *ask_update_settings;
  60. ConfirmationDialog *open_templates;
  61. AcceptDialog *run_error_diag;
  62. AcceptDialog *dialog_error;
  63. ProjectDialog *npdialog;
  64. HBoxContainer *projects_hb;
  65. TabContainer *tabs;
  66. ProjectList *_project_list;
  67. LinkButton *version_btn;
  68. OptionButton *language_btn;
  69. Control *gui_base;
  70. bool importing;
  71. void _open_asset_library();
  72. void _scan_projects();
  73. void _run_project();
  74. void _run_project_confirm();
  75. void _open_selected_projects();
  76. void _open_selected_projects_ask();
  77. void _import_project();
  78. void _new_project();
  79. void _rename_project();
  80. void _erase_project();
  81. void _erase_missing_projects();
  82. void _erase_project_confirm();
  83. void _erase_missing_projects_confirm();
  84. void _update_project_buttons();
  85. void _language_selected(int p_id);
  86. void _restart_confirm();
  87. void _exit_dialog();
  88. void _scan_begin(const String &p_base);
  89. void _global_menu_action(const Variant &p_id, const Variant &p_meta);
  90. void _confirm_update_settings();
  91. void _load_recent_projects();
  92. void _on_project_created(const String &dir);
  93. void _on_projects_updated();
  94. void _update_scroll_position(const String &dir);
  95. void _scan_dir(const String &path, List<String> *r_projects);
  96. void _install_project(const String &p_zip_path, const String &p_title);
  97. void _dim_window();
  98. void _unhandled_input(const Ref<InputEvent> &p_ev);
  99. void _files_dropped(PoolStringArray p_files, int p_screen);
  100. void _scan_multiple_folders(PoolStringArray p_files);
  101. void _version_button_pressed();
  102. void _on_order_option_changed();
  103. void _on_filter_option_changed();
  104. protected:
  105. void _notification(int p_what);
  106. static void _bind_methods();
  107. public:
  108. ProjectManager();
  109. ~ProjectManager();
  110. };
  111. class ProjectListFilter : public HBoxContainer {
  112. GDCLASS(ProjectListFilter, HBoxContainer);
  113. public:
  114. enum FilterOption {
  115. FILTER_NAME,
  116. FILTER_PATH,
  117. FILTER_MODIFIED,
  118. };
  119. private:
  120. friend class ProjectManager;
  121. OptionButton *filter_option;
  122. LineEdit *search_box;
  123. bool has_search_box;
  124. FilterOption _current_filter;
  125. void _search_text_changed(const String &p_newtext);
  126. void _filter_option_selected(int p_idx);
  127. protected:
  128. void _notification(int p_what);
  129. static void _bind_methods();
  130. public:
  131. void _setup_filters(Vector<String> options);
  132. void add_filter_option();
  133. void add_search_box();
  134. void set_filter_size(int h_size);
  135. String get_search_term();
  136. FilterOption get_filter_option();
  137. void set_filter_option(FilterOption);
  138. ProjectListFilter();
  139. void clear();
  140. };
  141. #endif // PROJECT_MANAGER_H