Update the validation logic for the package name:

- When using the project name, allow underscore (`_`) characters
- Send a warning instead of an error when the project name is modified to fit the package name format

(cherry picked from commit 0325568a9b)
This commit is contained in:
Fredia Huya-Kouadio 2023-11-09 10:26:18 -08:00 committed by Yuri Sizov
parent a8180680af
commit 307a6eba6b
1 changed files with 8 additions and 8 deletions

View File

@ -456,7 +456,7 @@ String EditorExportPlatformAndroid::get_valid_basename() const {
if (is_digit(c) && first) { if (is_digit(c) && first) {
continue; continue;
} }
if (is_ascii_alphanumeric_char(c)) { if (is_ascii_identifier_char(c)) {
name += String::chr(c); name += String::chr(c);
first = false; first = false;
} }
@ -533,13 +533,6 @@ bool EditorExportPlatformAndroid::is_package_name_valid(const String &p_package,
return false; return false;
} }
if (p_package.find("$genname") >= 0 && !is_project_name_valid()) {
if (r_error) {
*r_error = TTR("The project name does not meet the requirement for the package name format. Please explicitly specify the package name.");
}
return false;
}
return true; return true;
} }
@ -2435,6 +2428,13 @@ bool EditorExportPlatformAndroid::has_valid_project_configuration(const Ref<Edit
err += "\n"; err += "\n";
} }
String package_name = p_preset->get("package/unique_name");
if (package_name.find("$genname") >= 0 && !is_project_name_valid()) {
// Warning only, so don't override `valid`.
err += vformat(TTR("The project name does not meet the requirement for the package name format and will be updated to \"%s\". Please explicitly specify the package name if needed."), get_valid_basename());
err += "\n";
}
r_error = err; r_error = err;
return valid; return valid;
} }