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