summaryrefslogtreecommitdiff
path: root/editor/project_export.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/project_export.cpp')
-rw-r--r--editor/project_export.cpp85
1 files changed, 36 insertions, 49 deletions
diff --git a/editor/project_export.cpp b/editor/project_export.cpp
index 0b748c12b6..f39a494df8 100644
--- a/editor/project_export.cpp
+++ b/editor/project_export.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -265,10 +265,25 @@ void ProjectExportDialog::_edit_preset(int p_index) {
export_templates_error->hide();
}
+ export_warning->hide();
export_button->set_disabled(true);
get_ok_button()->set_disabled(true);
-
} else {
+ if (error != String()) {
+ Vector<String> items = error.split("\n", false);
+ error = "";
+ for (int i = 0; i < items.size(); i++) {
+ if (i > 0) {
+ error += "\n";
+ }
+ error += " - " + items[i];
+ }
+ export_warning->set_text(error);
+ export_warning->show();
+ } else {
+ export_warning->hide();
+ }
+
export_error->hide();
export_templates_error->hide();
export_button->set_disabled(false);
@@ -737,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);
}
@@ -767,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;
}
@@ -791,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() {
@@ -1111,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(
@@ -1247,6 +1229,11 @@ ProjectExportDialog::ProjectExportDialog() {
export_error->hide();
export_error->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("error_color"), SNAME("Editor")));
+ export_warning = memnew(Label);
+ main_vb->add_child(export_warning);
+ export_warning->hide();
+ export_warning->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("warning_color"), SNAME("Editor")));
+
export_templates_error = memnew(HBoxContainer);
main_vb->add_child(export_templates_error);
export_templates_error->hide();