diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index b9eeec508c..22ff41ae64 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -706,17 +706,27 @@ void EditorNode::_fs_changed() { } preset.unref(); } + if (preset.is_null()) { - export_error = vformat( - "Invalid export preset name: %s. Make sure `export_presets.cfg` is present in the current directory.", - preset_name); + DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES); + if (da->file_exists("res://export_presets.cfg")) { + export_error = vformat( + "Invalid export preset name: %s.\nThe following presets were detected in this project's `export_presets.cfg`:\n\n", + preset_name); + for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); ++i) { + // Write the preset name between double quotes since it needs to be written between quotes on the command line if it contains spaces. + export_error += vformat(" \"%s\"\n", EditorExport::get_singleton()->get_export_preset(i)->get_name()); + } + } else { + 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."; + } } else { Ref platform = preset->get_platform(); const String export_path = export_defer.path.empty() ? preset->get_export_path() : export_defer.path; if (export_path.empty()) { - export_error = vformat("Export preset '%s' doesn't have a default export path, and none was specified.", preset_name); + export_error = vformat("Export preset \"%s\" doesn't have a default export path, and none was specified.", preset_name); } else if (platform.is_null()) { - export_error = vformat("Export preset '%s' doesn't have a matching platform.", preset_name); + export_error = vformat("Export preset \"%s\" doesn't have a matching platform.", preset_name); } else { Error err = OK; if (export_defer.pack_only) { // Only export .pck or .zip data pack. @@ -729,7 +739,7 @@ void EditorNode::_fs_changed() { String config_error; bool missing_templates; if (!platform->can_export(preset, config_error, missing_templates)) { - ERR_PRINT(vformat("Cannot export project with preset '%s' due to configuration errors:\n%s", preset_name, config_error)); + ERR_PRINT(vformat("Cannot export project with preset \"%s\" due to configuration errors:\n%s", preset_name, config_error)); err = missing_templates ? ERR_FILE_NOT_FOUND : ERR_UNCONFIGURED; } else { err = platform->export_project(preset, export_defer.debug, export_path); @@ -739,13 +749,13 @@ void EditorNode::_fs_changed() { case OK: break; case ERR_FILE_NOT_FOUND: - export_error = vformat("Project export failed for preset '%s', the export template appears to be missing.", preset_name); + export_error = vformat("Project export failed for preset \"%s\". The export template appears to be missing.", preset_name); break; case ERR_FILE_BAD_PATH: - export_error = vformat("Project export failed for preset '%s', the target path '%s' appears to be invalid.", preset_name, export_path); + export_error = vformat("Project export failed for preset \"%s\". The target path \"%s\" appears to be invalid.", preset_name, export_path); break; default: - export_error = vformat("Project export failed with error code %d for preset '%s'.", (int)err, preset_name); + export_error = vformat("Project export failed with error code %d for preset \"%s\".", (int)err, preset_name); break; } }