Merge pull request #39434 from mrushyendra/export_update_files_master

Account for file deletion and renaming in Export Presets
This commit is contained in:
Rémi Verschelde 2020-06-11 09:30:16 +02:00 committed by GitHub
commit 4af5dfb12f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 1 deletions

View file

@ -90,6 +90,19 @@ Ref<EditorExportPlatform> EditorExportPreset::get_platform() const {
return platform;
}
void EditorExportPreset::update_files_to_export() {
Vector<String> to_remove;
for (Set<String>::Element *E = selected_files.front(); E; E = E->next()) {
if (!FileAccess::exists(E->get())) {
to_remove.push_back(E->get());
}
}
for (int i = 0; i < to_remove.size(); ++i) {
selected_files.erase(to_remove[i]);
}
EditorExport::singleton->save_presets();
}
Vector<String> EditorExportPreset::get_files_to_export() const {
Vector<String> files;
for (Set<String>::Element *E = selected_files.front(); E; E = E->next()) {
@ -1298,7 +1311,11 @@ void EditorExport::load_config() {
Vector<String> files = config->get_value(section, "export_files");
for (int i = 0; i < files.size(); i++) {
preset->add_export_file(files[i]);
if (!FileAccess::exists(files[i])) {
preset->remove_export_file(files[i]);
} else {
preset->add_export_file(files[i]);
}
}
}

View file

@ -94,6 +94,8 @@ public:
bool has(const StringName &p_property) const { return values.has(p_property); }
void update_files_to_export();
Vector<String> get_files_to_export() const;
void add_export_file(const String &p_path);

View file

@ -163,6 +163,7 @@ void ProjectExportDialog::_update_presets() {
if (preset->is_runnable()) {
name += " (" + TTR("Runnable") + ")";
}
preset->update_files_to_export();
presets->add_item(name, preset->get_platform()->get_logo());
}