project_manager.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /*************************************************************************/
  2. /* project_manager.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2019 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 ProjectListFilter;
  40. class ProjectManager : public Control {
  41. GDCLASS(ProjectManager, Control);
  42. Button *erase_btn;
  43. Button *erase_missing_btn;
  44. Button *open_btn;
  45. Button *rename_btn;
  46. Button *run_btn;
  47. EditorAssetLibrary *asset_library;
  48. ProjectListFilter *project_filter;
  49. ProjectListFilter *project_order_filter;
  50. FileDialog *scan_dir;
  51. ConfirmationDialog *language_restart_ask;
  52. ConfirmationDialog *erase_ask;
  53. ConfirmationDialog *erase_missing_ask;
  54. ConfirmationDialog *multi_open_ask;
  55. ConfirmationDialog *multi_run_ask;
  56. ConfirmationDialog *multi_scan_ask;
  57. ConfirmationDialog *ask_update_settings;
  58. ConfirmationDialog *open_templates;
  59. AcceptDialog *run_error_diag;
  60. AcceptDialog *dialog_error;
  61. ProjectDialog *npdialog;
  62. ScrollContainer *scroll;
  63. VBoxContainer *scroll_children;
  64. HBoxContainer *projects_hb;
  65. TabContainer *tabs;
  66. OptionButton *language_btn;
  67. Control *gui_base;
  68. Map<String, String> selected_list; // name -> main_scene
  69. String last_clicked;
  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 _show_project(const String &p_path);
  78. void _import_project();
  79. void _new_project();
  80. void _rename_project();
  81. void _erase_project();
  82. void _erase_missing_projects();
  83. void _erase_project_confirm();
  84. void _erase_missing_projects_confirm();
  85. void _update_project_buttons();
  86. void _language_selected(int p_id);
  87. void _restart_confirm();
  88. void _exit_dialog();
  89. void _scan_begin(const String &p_base);
  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(DirAccess *da, float pos, float total, List<String> *r_projects);
  96. void _install_project(const String &p_zip_path, const String &p_title);
  97. void _panel_draw(Node *p_hb);
  98. void _panel_input(const Ref<InputEvent> &p_ev, Node *p_hb);
  99. void _unhandled_input(const Ref<InputEvent> &p_ev);
  100. void _favorite_pressed(Node *p_hb);
  101. void _files_dropped(PoolStringArray p_files, int p_screen);
  102. void _scan_multiple_folders(PoolStringArray p_files);
  103. protected:
  104. void _notification(int p_what);
  105. static void _bind_methods();
  106. public:
  107. ProjectManager();
  108. ~ProjectManager();
  109. };
  110. class ProjectListFilter : public HBoxContainer {
  111. GDCLASS(ProjectListFilter, HBoxContainer);
  112. private:
  113. friend class ProjectManager;
  114. OptionButton *filter_option;
  115. LineEdit *search_box;
  116. bool has_search_box;
  117. enum FilterOption {
  118. FILTER_NAME,
  119. FILTER_PATH,
  120. };
  121. FilterOption _current_filter;
  122. void _search_text_changed(const String &p_newtext);
  123. void _filter_option_selected(int p_idx);
  124. protected:
  125. void _notification(int p_what);
  126. static void _bind_methods();
  127. public:
  128. void _setup_filters(Vector<String> options);
  129. void add_search_box();
  130. void set_filter_size(int h_size);
  131. String get_search_term();
  132. FilterOption get_filter_option();
  133. void set_filter_option(FilterOption);
  134. ProjectListFilter();
  135. void clear();
  136. };
  137. #endif // PROJECT_MANAGER_H