summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-04-06 14:37:25 +0200
committerGitHub <noreply@github.com>2021-04-06 14:37:25 +0200
commit55faf1c874fae5b67928395d3a35889bbb4e458b (patch)
treec197bbdf91762c8b6a59363797031c6e9f4c8223 /editor
parent2d16ccaaa1e826005be8c49c2b1192dfdd5c0fca (diff)
parent09f38ea2150cbf6aa3915bd2f5734df7ef24c88f (diff)
Merge pull request #47651 from Calinou/export-improve-nonexistent-preset-errors
Improve error messages for missing export presets when using `--export`
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_node.cpp28
1 files changed, 19 insertions, 9 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 6a50976908..9ca46cfcc0 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -794,17 +794,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<EditorExportPlatform> platform = preset->get_platform();
const String export_path = export_defer.path.is_empty() ? preset->get_export_path() : export_defer.path;
if (export_path.is_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.
@@ -817,7 +827,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);
@@ -827,13 +837,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;
}
}