diff options
Diffstat (limited to 'editor/project_export.cpp')
-rw-r--r-- | editor/project_export.cpp | 59 |
1 files changed, 13 insertions, 46 deletions
diff --git a/editor/project_export.cpp b/editor/project_export.cpp index 9bd8c1e227..f39a494df8 100644 --- a/editor/project_export.cpp +++ b/editor/project_export.cpp @@ -752,12 +752,10 @@ bool ProjectExportDialog::_fill_tree(EditorFileSystemDirectory *p_dir, TreeItem p_item->set_metadata(0, p_dir->get_path()); bool used = false; - bool checked = true; for (int i = 0; i < p_dir->get_subdir_count(); i++) { TreeItem *subdir = include_files->create_item(p_item); if (_fill_tree(p_dir->get_subdir(i), subdir, current, p_only_scenes)) { used = true; - checked = checked && subdir->is_checked(0); } else { memdelete(subdir); } @@ -782,12 +780,10 @@ bool ProjectExportDialog::_fill_tree(EditorFileSystemDirectory *p_dir, TreeItem file->set_editable(0, true); file->set_checked(0, current->has_export_file(path)); file->set_metadata(0, path); - checked = checked && file->is_checked(0); + file->propagate_check(0); used = true; } - - p_item->set_checked(0, checked); return used; } @@ -806,54 +802,24 @@ void ProjectExportDialog::_tree_changed() { return; } - String path = item->get_metadata(0); - bool added = item->is_checked(0); + item->propagate_check(0); +} - if (path.ends_with("/")) { - _check_dir_recursive(item, added); - } else { +void ProjectExportDialog::_check_propagated_to_item(Object *p_obj, int column) { + Ref<EditorExportPreset> current = get_current_preset(); + if (current.is_null()) { + return; + } + TreeItem *item = Object::cast_to<TreeItem>(p_obj); + String path = item->get_metadata(0); + if (item && !path.ends_with("/")) { + bool added = item->is_checked(0); if (added) { current->add_export_file(path); } else { current->remove_export_file(path); } } - _refresh_parent_checks(item); // Makes parent folder checked if all files/folders are checked. -} - -void ProjectExportDialog::_check_dir_recursive(TreeItem *p_dir, bool p_checked) { - for (TreeItem *child = p_dir->get_first_child(); child; child = child->get_next()) { - String path = child->get_metadata(0); - - child->set_checked(0, p_checked); - if (path.ends_with("/")) { - _check_dir_recursive(child, p_checked); - } else { - if (p_checked) { - get_current_preset()->add_export_file(path); - } else { - get_current_preset()->remove_export_file(path); - } - } - } -} - -void ProjectExportDialog::_refresh_parent_checks(TreeItem *p_item) { - TreeItem *parent = p_item->get_parent(); - if (!parent) { - return; - } - - bool checked = true; - for (TreeItem *child = parent->get_first_child(); child; child = child->get_next()) { - checked = checked && child->is_checked(0); - if (!checked) { - break; - } - } - parent->set_checked(0, checked); - - _refresh_parent_checks(parent); } void ProjectExportDialog::_export_pck_zip() { @@ -1126,6 +1092,7 @@ ProjectExportDialog::ProjectExportDialog() { include_files = memnew(Tree); include_margin->add_child(include_files); include_files->connect("item_edited", callable_mp(this, &ProjectExportDialog::_tree_changed)); + include_files->connect("check_propagated_to_item", callable_mp(this, &ProjectExportDialog::_check_propagated_to_item)); include_filters = memnew(LineEdit); resources_vb->add_margin_child( |