Merge pull request #3494 from blackwc/exclude_export

add feature to exclude files from export
This commit is contained in:
Rémi Verschelde 2016-02-08 07:33:19 +01:00
commit 6546ee1d63
4 changed files with 51 additions and 14 deletions

View File

@ -162,6 +162,7 @@ EditorExportPlugin::EditorExportPlugin() {
/////////////////////////////////////////////////////////////////////////////////////////////////////
static void _add_to_list(EditorFileSystemDirectory *p_efsd,Set<StringName>& r_list) {
for(int i=0;i<p_efsd->get_subdir_count();i++) {
@ -170,13 +171,11 @@ static void _add_to_list(EditorFileSystemDirectory *p_efsd,Set<StringName>& r_li
}
for(int i=0;i<p_efsd->get_file_count();i++) {
r_list.insert(p_efsd->get_file_path(i));
}
}
struct __EESortDepCmp {
_FORCE_INLINE_ bool operator()(const StringName& p_l,const StringName& p_r) const {
@ -187,7 +186,7 @@ struct __EESortDepCmp {
static void _add_files_with_filter(DirAccess *da,const List<String>& p_filters,Set<StringName>& r_list) {
static void _edit_files_with_filter(DirAccess *da,const List<String>& p_filters,Set<StringName>& r_list,bool exclude) {
List<String> files;
@ -218,8 +217,17 @@ static void _add_files_with_filter(DirAccess *da,const List<String>& p_filters,S
for(const List<String>::Element *F=p_filters.front();F;F=F->next()) {
if (fullpath.matchn(F->get())) {
r_list.insert(fullpath);
print_line("Added: "+fullpath);
String act = "Added: ";
if (!exclude) {
r_list.insert(fullpath);
} else {
act = "Removed: ";
r_list.erase(fullpath);
}
print_line(act+fullpath);
}
}
}
@ -230,13 +238,13 @@ static void _add_files_with_filter(DirAccess *da,const List<String>& p_filters,S
if (E->get().begins_with("."))
continue;
da->change_dir(E->get());
_add_files_with_filter(da,p_filters,r_list);
_edit_files_with_filter(da,p_filters,r_list,exclude);
da->change_dir("..");
}
}
static void _add_filter_to_list(Set<StringName>& r_list,const String& p_filter) {
static void _edit_filter_list(Set<StringName>& r_list,const String& p_filter,bool exclude) {
if (p_filter=="")
return;
@ -250,11 +258,16 @@ static void _add_filter_to_list(Set<StringName>& r_list,const String& p_filter)
}
DirAccess *da = DirAccess::open("res://");
_add_files_with_filter(da,filters,r_list);
_edit_files_with_filter(da,filters,r_list,exclude);
memdelete(da);
}
static void _add_filter_to_list(Set<StringName>& r_list,const String& p_filter) {
_edit_filter_list(r_list,p_filter,false);
}
static void _remove_filter_from_list(Set<StringName>& r_list,const String& p_filter) {
_edit_filter_list(r_list,p_filter,true);
}
Vector<uint8_t> EditorExportPlatform::get_exported_file_default(String& p_fname) const {
@ -307,6 +320,8 @@ Vector<StringName> EditorExportPlatform::get_dependencies(bool p_bundles) const
cf+="*.flags";
_add_filter_to_list(exported,cf);
cf = EditorImportExport::get_singleton()->get_export_custom_filter_exclude();
_remove_filter_from_list(exported,cf);
}
@ -380,6 +395,9 @@ Vector<StringName> EditorExportPlatform::get_dependencies(bool p_bundles) const
cf+="*.flags";
_add_filter_to_list(exported,cf);
cf = EditorImportExport::get_singleton()->get_export_custom_filter_exclude();
_remove_filter_from_list(exported,cf);
}
@ -1530,13 +1548,17 @@ EditorImportExport::ExportFilter EditorImportExport::get_export_filter() const{
}
void EditorImportExport::set_export_custom_filter(const String& p_custom_filter){
export_custom_filter=p_custom_filter;
}
void EditorImportExport::set_export_custom_filter_exclude(const String& p_custom_filter){
export_custom_filter_exclude=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;
}
void EditorImportExport::set_export_image_action(ImageAction p_action) {
@ -1699,6 +1721,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");
String t=cf->get_value("export_filter","type");
if (t=="selected")
export_filter=EXPORT_SELECTED;
@ -1888,6 +1911,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);
String file_action_section = "export_filter_files";

View File

@ -285,7 +285,7 @@ protected:
Set<String> image_formats;
ExportFilter export_filter;
String export_custom_filter;
String export_custom_filter, export_custom_filter_exclude;
Map<StringName,FileAction> files;
Map<StringName,Ref<EditorExportPlatform> > exporters;
Map<StringName,ImageGroup> image_groups;
@ -332,7 +332,9 @@ public:
ExportFilter get_export_filter() const;
void set_export_custom_filter(const String& p_custom_filter);
void set_export_custom_filter_exclude(const String& p_custom_filter);
String get_export_custom_filter() const;
String get_export_custom_filter_exclude() const;
void set_export_image_action(ImageAction p_action);
ImageAction get_export_image_action() const;

View File

@ -217,6 +217,11 @@ void ProjectExportDialog::_filters_edited(String what) {
_save_export_cfg();
}
void ProjectExportDialog::_filters_exclude_edited(String what) {
EditorImportExport::get_singleton()->set_export_custom_filter_exclude(what);
_save_export_cfg();
}
void ProjectExportDialog::_quality_edited(float what) {
EditorImportExport::get_singleton()->set_export_image_quality(what);
@ -314,6 +319,7 @@ void ProjectExportDialog::_notification(int p_what) {
export_mode->select( EditorImportExport::get_singleton()->get_export_filter() );
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() );
if (EditorImportExport::get_singleton()->get_export_filter()!=EditorImportExport::EXPORT_SELECTED)
tree_vb->hide();
else
@ -1083,6 +1089,7 @@ void ProjectExportDialog::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_prop_edited"),&ProjectExportDialog::_prop_edited);
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("_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);
@ -1195,8 +1202,11 @@ ProjectExportDialog::ProjectExportDialog(EditorNode *p_editor) {
tree->set_column_min_width(1,90);
filters = memnew( LineEdit );
vb->add_margin_child("Filters to export non-resource files (Comma Separated, ie: *.json, *.txt):",filters);
vb->add_margin_child("Filters to export non-resource files (Comma Separated, eg: *.json, *.txt):",filters);
filters->connect("text_changed",this,"_filters_edited");
filters_exclude = memnew( LineEdit );
vb->add_margin_child("Filters to exclude from export (Comma Separated, eg: *.json, *.txt):",filters_exclude);
filters_exclude->connect("text_changed",this,"_filters_exclude_edited");
convert_text_scenes = memnew( CheckButton );
convert_text_scenes->set_text("Convert text scenes to binary on export");

View File

@ -75,7 +75,7 @@ private:
ConfirmationDialog *confirm;
Button *button_reload;
LineEdit *filters;
LineEdit *filters, *filters_exclude;
HBoxContainer *plat_errors;
Label *platform_error_string;
@ -155,6 +155,7 @@ private:
void _platform_selected();
void _filters_edited(String what);
void _filters_exclude_edited(String what);
void _update_group_tree();
void _image_filter_changed(String);