| 1192 | } |
| 1193 | |
| 1194 | void EditorNode::_fs_changed() { |
| 1195 | for (FileDialog *E : file_dialogs) { |
| 1196 | E->invalidate(); |
| 1197 | } |
| 1198 | |
| 1199 | for (EditorFileDialog *E : editor_file_dialogs) { |
| 1200 | E->invalidate(); |
| 1201 | } |
| 1202 | |
| 1203 | _mark_unsaved_scenes(); |
| 1204 | |
| 1205 | /// @todo FIXME: Move this to a cleaner location, it's hacky to do this in _fs_changed. |
| 1206 | String export_error; |
| 1207 | Error err = OK; |
| 1208 | // It's important to wait for the first scan to finish; otherwise, scripts or resources might not be imported. |
| 1209 | if (!export_defer.preset.is_empty() && !EditorFileSystem::get_singleton()->is_scanning()) { |
| 1210 | String preset_name = export_defer.preset; |
| 1211 | // Ensures export_project does not loop infinitely, because notifications may |
| 1212 | // come during the export. |
| 1213 | export_defer.preset = ""; |
| 1214 | Ref<EditorExportPreset> export_preset; |
| 1215 | for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); ++i) { |
| 1216 | export_preset = EditorExport::get_singleton()->get_export_preset(i); |
| 1217 | if (export_preset->get_name() == preset_name) { |
| 1218 | break; |
| 1219 | } |
| 1220 | export_preset.unref(); |
| 1221 | } |
| 1222 | |
| 1223 | if (export_preset.is_null()) { |
| 1224 | Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES); |
| 1225 | if (da->file_exists("res://export_presets.cfg")) { |
| 1226 | err = FAILED; |
| 1227 | export_error = vformat( |
| 1228 | "Invalid export preset name: %s.\nThe following presets were detected in this project's `export_presets.cfg`:\n\n", |
| 1229 | preset_name); |
| 1230 | for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); ++i) { |
| 1231 | // Write the preset name between double quotes since it needs to be written between quotes on the command line if it contains spaces. |
| 1232 | export_error += vformat(" \"%s\"\n", EditorExport::get_singleton()->get_export_preset(i)->get_name()); |
| 1233 | } |
| 1234 | } else { |
| 1235 | err = FAILED; |
| 1236 | export_error = "This project doesn't have an `export_presets.cfg` file at its root.\nCreate an export preset from the \"Project > Export\" dialog and try again."; |
| 1237 | } |
| 1238 | } else { |
| 1239 | Ref<EditorExportPlatform> platform = export_preset->get_platform(); |
| 1240 | const String export_path = export_defer.path.is_empty() ? export_preset->get_export_path() : export_defer.path; |
| 1241 | if (export_path.is_empty()) { |
| 1242 | err = FAILED; |
| 1243 | export_error = vformat("Export preset \"%s\" doesn't have a default export path, and none was specified.", preset_name); |
| 1244 | } else if (platform.is_null()) { |
| 1245 | err = FAILED; |
| 1246 | export_error = vformat("Export preset \"%s\" doesn't have a matching platform.", preset_name); |
| 1247 | } else { |
| 1248 | export_preset->update_value_overrides(); |
| 1249 | if (export_defer.pack_only) { // Only export .pck or .zip data pack. |
| 1250 | if (export_path.ends_with(".zip")) { |
| 1251 | if (export_defer.patch) { |
nothing calls this directly
no test coverage detected