project_manager.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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 *open_btn;
  44. Button *rename_btn;
  45. Button *run_btn;
  46. EditorAssetLibrary *asset_library;
  47. ProjectListFilter *project_filter;
  48. ProjectListFilter *project_order_filter;
  49. FileDialog *scan_dir;
  50. ConfirmationDialog *language_restart_ask;
  51. ConfirmationDialog *erase_ask;
  52. ConfirmationDialog *multi_open_ask;
  53. ConfirmationDialog *multi_run_ask;
  54. ConfirmationDialog *multi_scan_ask;
  55. ConfirmationDialog *ask_update_settings;
  56. ConfirmationDialog *open_templates;
  57. AcceptDialog *run_error_diag;
  58. AcceptDialog *dialog_error;
  59. ProjectDialog *npdialog;
  60. ScrollContainer *scroll;
  61. VBoxContainer *scroll_children;
  62. HBoxContainer *projects_hb;
  63. TabContainer *tabs;
  64. OptionButton *language_btn;
  65. Control *gui_base;
  66. Map<String, String> selected_list; // name -> main_scene
  67. String last_clicked;
  68. bool importing;
  69. void _open_asset_library();
  70. void _scan_projects();
  71. void _run_project();
  72. void _run_project_confirm();
  73. void _open_selected_projects();
  74. void _open_selected_projects_ask();
  75. void _show_project(const String &p_path);
  76. void _import_project();
  77. void _new_project();
  78. void _rename_project();
  79. void _erase_project();
  80. void _erase_project_confirm();
  81. void _update_project_buttons();
  82. void _language_selected(int p_id);
  83. void _restart_confirm();
  84. void _exit_dialog();
  85. void _scan_begin(const String &p_base);
  86. void _confirm_update_settings();
  87. void _load_recent_projects();
  88. void _on_project_created(const String &dir);
  89. void _on_projects_updated();
  90. void _update_scroll_position(const String &dir);
  91. void _scan_dir(DirAccess *da, float pos, float total, List<String> *r_projects);
  92. void _install_project(const String &p_zip_path, const String &p_title);
  93. void _panel_draw(Node *p_hb);
  94. void _panel_input(const Ref<InputEvent> &p_ev, Node *p_hb);
  95. void _unhandled_input(const Ref<InputEvent> &p_ev);
  96. void _favorite_pressed(Node *p_hb);
  97. void _files_dropped(PoolStringArray p_files, int p_screen);
  98. void _scan_multiple_folders(PoolStringArray p_files);
  99. protected:
  100. void _notification(int p_what);
  101. static void _bind_methods();
  102. public:
  103. ProjectManager();
  104. ~ProjectManager();
  105. };
  106. class ProjectListFilter : public HBoxContainer {
  107. GDCLASS(ProjectListFilter, HBoxContainer);
  108. private:
  109. friend class ProjectManager;
  110. OptionButton *filter_option;
  111. LineEdit *search_box;
  112. bool has_search_box;
  113. enum FilterOption {
  114. FILTER_NAME,
  115. FILTER_PATH,
  116. };
  117. FilterOption _current_filter;
  118. void _search_text_changed(const String &p_newtext);
  119. void _filter_option_selected(int p_idx);
  120. protected:
  121. void _notification(int p_what);
  122. static void _bind_methods();
  123. public:
  124. void _setup_filters(Vector<String> options);
  125. void add_search_box();
  126. void set_filter_size(int h_size);
  127. String get_search_term();
  128. FilterOption get_filter_option();
  129. void set_filter_option(FilterOption);
  130. ProjectListFilter();
  131. };
  132. #endif // PROJECT_MANAGER_H