Account for file deletion and renaming in Export Presets
Ensure that presets are updated with the latest files when starting up or opening the Project Export dialog. Fixes the error where Godot would attempt to export deleted files that were previously selected.
This commit is contained in:
parent
ffbea8aad1
commit
44094b082d
|
@ -90,6 +90,19 @@ Ref<EditorExportPlatform> EditorExportPreset::get_platform() const {
|
||||||
return platform;
|
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> EditorExportPreset::get_files_to_export() const {
|
||||||
Vector<String> files;
|
Vector<String> files;
|
||||||
for (Set<String>::Element *E = selected_files.front(); E; E = E->next()) {
|
for (Set<String>::Element *E = selected_files.front(); E; E = E->next()) {
|
||||||
|
@ -1298,9 +1311,13 @@ void EditorExport::load_config() {
|
||||||
Vector<String> files = config->get_value(section, "export_files");
|
Vector<String> files = config->get_value(section, "export_files");
|
||||||
|
|
||||||
for (int i = 0; i < files.size(); i++) {
|
for (int i = 0; i < files.size(); i++) {
|
||||||
|
if (!FileAccess::exists(files[i])) {
|
||||||
|
preset->remove_export_file(files[i]);
|
||||||
|
} else {
|
||||||
preset->add_export_file(files[i]);
|
preset->add_export_file(files[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
preset->set_include_filter(config->get_value(section, "include_filter"));
|
preset->set_include_filter(config->get_value(section, "include_filter"));
|
||||||
preset->set_exclude_filter(config->get_value(section, "exclude_filter"));
|
preset->set_exclude_filter(config->get_value(section, "exclude_filter"));
|
||||||
|
|
|
@ -94,6 +94,8 @@ public:
|
||||||
|
|
||||||
bool has(const StringName &p_property) const { return values.has(p_property); }
|
bool has(const StringName &p_property) const { return values.has(p_property); }
|
||||||
|
|
||||||
|
void update_files_to_export();
|
||||||
|
|
||||||
Vector<String> get_files_to_export() const;
|
Vector<String> get_files_to_export() const;
|
||||||
|
|
||||||
void add_export_file(const String &p_path);
|
void add_export_file(const String &p_path);
|
||||||
|
|
|
@ -163,6 +163,7 @@ void ProjectExportDialog::_update_presets() {
|
||||||
if (preset->is_runnable()) {
|
if (preset->is_runnable()) {
|
||||||
name += " (" + TTR("Runnable") + ")";
|
name += " (" + TTR("Runnable") + ")";
|
||||||
}
|
}
|
||||||
|
preset->update_files_to_export();
|
||||||
presets->add_item(name, preset->get_platform()->get_logo());
|
presets->add_item(name, preset->get_platform()->get_logo());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue