project_manager.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /*************************************************************************/
  2. /* project_manager.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2020 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/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 NewProjectDialog;
  39. class ProjectListFilter;
  40. class ProjectManager : public Control {
  41. OBJ_TYPE(ProjectManager, Control);
  42. Button *show_btn;
  43. Button *erase_btn;
  44. Button *open_btn;
  45. Button *run_btn;
  46. FileDialog *scan_dir;
  47. EditorAssetLibrary *asset_library;
  48. ProjectListFilter *project_filter;
  49. ConfirmationDialog *erase_ask;
  50. ConfirmationDialog *multi_open_ask;
  51. ConfirmationDialog *multi_run_ask;
  52. ConfirmationDialog *multi_scan_ask;
  53. NewProjectDialog *npdialog;
  54. ScrollContainer *scroll;
  55. VBoxContainer *scroll_childs;
  56. Map<String, String> selected_list; // name -> main_scene
  57. String last_clicked;
  58. bool importing;
  59. HBoxContainer *projects_hb;
  60. TabContainer *tabs;
  61. Control *gui_base;
  62. void _scan_projects();
  63. void _run_project();
  64. void _run_project_confirm();
  65. void _open_project();
  66. void _open_project_confirm();
  67. void _import_project();
  68. void _new_project();
  69. void _erase_project();
  70. void _show_project();
  71. void _erase_project_confirm();
  72. void _update_project_buttons();
  73. void _exit_dialog();
  74. void _scan_begin(const String &p_base);
  75. void _load_recent_projects();
  76. void _on_project_created(const String &dir);
  77. void _update_scroll_pos(const String &dir);
  78. void _scan_dir(DirAccess *da, float pos, float total, List<String> *r_projects);
  79. void _install_project(const String &p_zip_path, const String &p_title);
  80. void _panel_draw(Node *p_hb);
  81. void _panel_input(const InputEvent &p_ev, Node *p_hb);
  82. void _unhandled_input(const InputEvent &p_ev);
  83. void _favorite_pressed(Node *p_hb);
  84. void _files_dropped(StringArray p_files, int p_screen);
  85. void _scan_multiple_folders(StringArray p_files);
  86. protected:
  87. void _notification(int p_what);
  88. static void _bind_methods();
  89. public:
  90. ProjectManager();
  91. ~ProjectManager();
  92. };
  93. class ProjectListFilter : public HBoxContainer {
  94. OBJ_TYPE(ProjectListFilter, HBoxContainer);
  95. private:
  96. friend class ProjectManager;
  97. enum Command {
  98. CMD_CLEAR_FILTER,
  99. };
  100. OptionButton *filter_option;
  101. LineEdit *search_box;
  102. ToolButton *clear_search_button;
  103. enum FilterOption {
  104. FILTER_NAME,
  105. FILTER_PATH,
  106. };
  107. FilterOption _current_filter;
  108. void _command(int p_command);
  109. void _search_text_changed(const String &p_newtext);
  110. void _setup_filters();
  111. void _filter_option_selected(int p_idx);
  112. protected:
  113. void _notification(int p_what);
  114. static void _bind_methods();
  115. public:
  116. String get_search_term();
  117. FilterOption get_filter_option();
  118. ProjectListFilter();
  119. };
  120. #endif // PROJECT_MANAGER_H