diff --git a/editor/editor_import_export.cpp b/editor/editor_import_export.cpp index c524e609ad7..79a7941dfa7 100644 --- a/editor/editor_import_export.cpp +++ b/editor/editor_import_export.cpp @@ -199,11 +199,29 @@ EditorExportPlugin::EditorExportPlugin() { ///////////////////////////////////////////////////////////////////////////////////////////////////// -static void _add_to_list(EditorFileSystemDirectory *p_efsd, Set &r_list) { +static void _split_by_comma(List &p_list, const String &p_src) { + + if (p_src == "") + return; + Vector split = p_src.split(","); + for (int i = 0; i < split.size(); i++) { + String f = split[i].strip_edges(); + if (f.empty()) + continue; + p_list.push_back(f); + } +} + +static void _add_to_list(EditorFileSystemDirectory *p_efsd, Set &r_list, const String &p_filter) { + + List filters; + _split_by_comma(filters, p_filter); for (int i = 0; i < p_efsd->get_subdir_count(); i++) { - - _add_to_list(p_efsd->get_subdir(i), r_list); + if (p_filter == "" || filters.find(p_efsd->get_subdir(i)->get_name()) == NULL) + _add_to_list(p_efsd->get_subdir(i), r_list, p_filter); + else + print_line("Folder ignored by settings: " + p_efsd->get_subdir(i)->get_name()); } for (int i = 0; i < p_efsd->get_file_count(); i++) { @@ -273,14 +291,8 @@ static void _edit_filter_list(Set &r_list, const String &p_filter, b if (p_filter == "") return; - Vector split = p_filter.split(","); List filters; - for (int i = 0; i < split.size(); i++) { - String f = split[i].strip_edges(); - if (f.empty()) - continue; - filters.push_back(f); - } + _split_by_comma(filters, p_filter); DirAccess *da = DirAccess::open("res://"); ERR_FAIL_NULL(da); @@ -365,8 +377,9 @@ Vector EditorExportPlatform::get_dependencies(bool p_bundles) const if (EditorImportExport::get_singleton()->get_export_filter() == EditorImportExport::EXPORT_ALL) { _add_filter_to_list(exported, "*"); } else { - _add_to_list(EditorFileSystem::get_singleton()->get_filesystem(), exported); - String cf = EditorImportExport::get_singleton()->get_export_custom_filter(); + String cf = EditorImportExport::get_singleton()->get_export_custom_filter_exclude_dir(); + _add_to_list(EditorFileSystem::get_singleton()->get_filesystem(), exported, cf); + cf = EditorImportExport::get_singleton()->get_export_custom_filter(); if (cf != "") cf += ","; cf += "*.flags"; @@ -1550,12 +1563,18 @@ void EditorImportExport::set_export_custom_filter(const String &p_custom_filter) void EditorImportExport::set_export_custom_filter_exclude(const String &p_custom_filter) { export_custom_filter_exclude = p_custom_filter; } +void EditorImportExport::set_export_custom_filter_exclude_dir(const String &p_custom_filter) { + export_custom_filter_exclude_dir = p_custom_filter; +} String EditorImportExport::get_export_custom_filter() const { return export_custom_filter; } String EditorImportExport::get_export_custom_filter_exclude() const { return export_custom_filter_exclude; } +String EditorImportExport::get_export_custom_filter_exclude_dir() const { + return export_custom_filter_exclude_dir; +} void EditorImportExport::set_export_image_action(ImageAction p_action) { @@ -1703,6 +1722,7 @@ void EditorImportExport::load_config() { export_custom_filter = cf->get_value("export_filter", "filter"); export_custom_filter_exclude = cf->get_value("export_filter", "filter_exclude"); + export_custom_filter_exclude_dir = cf->get_value("export_filter", "filter_exclude_dir"); String t = cf->get_value("export_filter", "type"); if (t == "selected") export_filter = EXPORT_SELECTED; @@ -1880,6 +1900,7 @@ void EditorImportExport::save_config() { cf->set_value("export_filter", "filter", export_custom_filter); cf->set_value("export_filter", "filter_exclude", export_custom_filter_exclude); + cf->set_value("export_filter", "filter_exclude_dir", export_custom_filter_exclude_dir); String file_action_section = "export_filter_files"; @@ -2091,6 +2112,9 @@ void EditorImportExport::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_export_custom_filter_exclude", "filter_exclude"), &EditorImportExport::set_export_custom_filter_exclude); ObjectTypeDB::bind_method(_MD("get_export_custom_filter_exclude"), &EditorImportExport::get_export_custom_filter_exclude); + ObjectTypeDB::bind_method(_MD("set_export_custom_filter_exclude_dir", "filter_exclude_dir"), &EditorImportExport::set_export_custom_filter_exclude_dir); + ObjectTypeDB::bind_method(_MD("get_export_custom_filter_exclude_dir"), &EditorImportExport::get_export_custom_filter_exclude_dir); + ObjectTypeDB::bind_method(_MD("image_export_group_create"), &EditorImportExport::image_export_group_create); ObjectTypeDB::bind_method(_MD("image_export_group_remove"), &EditorImportExport::image_export_group_remove); ObjectTypeDB::bind_method(_MD("image_export_group_set_image_action"), &EditorImportExport::image_export_group_set_image_action); diff --git a/editor/editor_import_export.h b/editor/editor_import_export.h index 3a5334245a1..b4114ac9105 100644 --- a/editor/editor_import_export.h +++ b/editor/editor_import_export.h @@ -288,7 +288,7 @@ protected: Set image_formats; ExportFilter export_filter; - String export_custom_filter, export_custom_filter_exclude; + String export_custom_filter, export_custom_filter_exclude, export_custom_filter_exclude_dir; Map files; Map > exporters; Map image_groups; @@ -340,8 +340,10 @@ public: void set_export_custom_filter(const String &p_custom_filter); void set_export_custom_filter_exclude(const String &p_custom_filter); + void set_export_custom_filter_exclude_dir(const String &p_custom_filter); String get_export_custom_filter() const; String get_export_custom_filter_exclude() const; + String get_export_custom_filter_exclude_dir() const; void set_export_image_action(ImageAction p_action); ImageAction get_export_image_action() const; diff --git a/editor/project_export.cpp b/editor/project_export.cpp index 6417baf83f8..a0a23654b79 100644 --- a/editor/project_export.cpp +++ b/editor/project_export.cpp @@ -202,10 +202,17 @@ void ProjectExportDialog::_filters_edited(String what) { } void ProjectExportDialog::_filters_exclude_edited(String what) { + EditorImportExport::get_singleton()->set_export_custom_filter_exclude(what); _save_export_cfg(); } +void ProjectExportDialog::_filters_exclude_dir_edited(String what) { + + EditorImportExport::get_singleton()->set_export_custom_filter_exclude_dir(what); + _save_export_cfg(); +} + void ProjectExportDialog::_quality_edited(float what) { EditorImportExport::get_singleton()->set_export_image_quality(what); @@ -296,6 +303,7 @@ void ProjectExportDialog::_notification(int p_what) { convert_text_scenes->set_pressed(EditorImportExport::get_singleton()->get_convert_text_scenes()); filters->set_text(EditorImportExport::get_singleton()->get_export_custom_filter()); filters_exclude->set_text(EditorImportExport::get_singleton()->get_export_custom_filter_exclude()); + filters_exclude_dir->set_text(EditorImportExport::get_singleton()->get_export_custom_filter_exclude_dir()); if (EditorImportExport::get_singleton()->get_export_filter() != EditorImportExport::EXPORT_SELECTED) tree_vb->hide(); else @@ -1228,6 +1236,7 @@ void ProjectExportDialog::_bind_methods() { ObjectTypeDB::bind_method(_MD("_export_mode_changed"), &ProjectExportDialog::_export_mode_changed); ObjectTypeDB::bind_method(_MD("_filters_edited"), &ProjectExportDialog::_filters_edited); ObjectTypeDB::bind_method(_MD("_filters_exclude_edited"), &ProjectExportDialog::_filters_exclude_edited); + ObjectTypeDB::bind_method(_MD("_filters_exclude_dir_edited"), &ProjectExportDialog::_filters_exclude_dir_edited); ObjectTypeDB::bind_method(_MD("_export_action"), &ProjectExportDialog::_export_action); ObjectTypeDB::bind_method(_MD("_export_action_pck"), &ProjectExportDialog::_export_action_pck); ObjectTypeDB::bind_method(_MD("_quality_edited"), &ProjectExportDialog::_quality_edited); @@ -1340,6 +1349,9 @@ ProjectExportDialog::ProjectExportDialog(EditorNode *p_editor) { filters_exclude = memnew(LineEdit); vb->add_margin_child(TTR("Filters to exclude from export (comma-separated, e.g.: *.json, *.txt):"), filters_exclude); filters_exclude->connect("text_changed", this, "_filters_exclude_edited"); + filters_exclude_dir = memnew(LineEdit); + vb->add_margin_child(TTR("Filters to exclude directories from export (comma-separated, e.g.: addons, devs, test):"), filters_exclude_dir); + filters_exclude_dir->connect("text_changed", this, "_filters_exclude_dir_edited"); convert_text_scenes = memnew(CheckButton); convert_text_scenes->set_text(TTR("Convert text scenes to binary on export.")); diff --git a/editor/project_export.h b/editor/project_export.h index af6bc89cd7e..6aa5111471e 100644 --- a/editor/project_export.h +++ b/editor/project_export.h @@ -75,7 +75,7 @@ private: ConfirmationDialog *confirm_keystore; Button *button_reload; - LineEdit *filters, *filters_exclude; + LineEdit *filters, *filters_exclude, *filters_exclude_dir; HBoxContainer *plat_errors; Label *platform_error_string; @@ -155,6 +155,7 @@ private: void _filters_edited(String what); void _filters_exclude_edited(String what); + void _filters_exclude_dir_edited(String what); void _update_group_tree(); void _image_filter_changed(String);