1
0
mirror of https://github.com/godotengine/godot.git synced 2026-01-06 19:41:11 +00:00

Merge pull request #69801 from nongvantinh/fix-invalid-scene-name

Fixed scene name can be saved as extension only
This commit is contained in:
Rémi Verschelde
2023-02-17 00:35:00 +01:00
2 changed files with 21 additions and 6 deletions

View File

@@ -472,6 +472,14 @@ void EditorFileDialog::_action_pressed() {
}
}
// First check we're not having an empty name.
String file_name = file_text.strip_edges().get_file();
if (file_name.is_empty()) {
error_dialog->set_text(TTR("Cannot save file with an empty filename."));
error_dialog->popup_centered(Size2(250, 80) * EDSCALE);
return;
}
// Add first extension of filter if no valid extension is found.
if (!valid) {
int idx = filter->get_selected();
@@ -480,9 +488,15 @@ void EditorFileDialog::_action_pressed() {
f += "." + ext;
}
if (file_name.begins_with(".")) { // Could still happen if typed manually.
error_dialog->set_text(TTR("Cannot save file with a name starting with a dot."));
error_dialog->popup_centered(Size2(250, 80) * EDSCALE);
return;
}
if (dir_access->file_exists(f) && !disable_overwrite_warning) {
confirm_save->set_text(TTR("File exists, overwrite?"));
confirm_save->popup_centered(Size2(200, 80));
confirm_save->set_text(vformat(TTR("File \"%s\" already exists.\nDo you want to overwrite it?"), f));
confirm_save->popup_centered(Size2(250, 80) * EDSCALE);
} else {
_save_to_recent();
hide();