You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-12-02 16:48:55 +00:00
Fixed validation error with export preset names
This commit is contained in:
@@ -534,10 +534,33 @@ void ProjectExportDialog::_name_changed(const String &p_string) {
|
||||
Ref<EditorExportPreset> current = get_current_preset();
|
||||
ERR_FAIL_COND(current.is_null());
|
||||
|
||||
current->set_name(p_string);
|
||||
int current_index = presets->get_current();
|
||||
|
||||
String trimmed_name = p_string.strip_edges();
|
||||
if (trimmed_name.is_empty()) {
|
||||
ERR_PRINT_ED("Invalid preset name: preset name cannot be empty!");
|
||||
name->set_text(current->get_name());
|
||||
return;
|
||||
}
|
||||
|
||||
if (EditorExport::get_singleton()->has_preset_with_name(trimmed_name, current_index)) {
|
||||
ERR_PRINT_ED(vformat("Invalid preset name: a preset with the name '%s' already exists!", trimmed_name));
|
||||
name->set_text(current->get_name());
|
||||
return;
|
||||
}
|
||||
|
||||
current->set_name(trimmed_name);
|
||||
_update_presets();
|
||||
}
|
||||
|
||||
void ProjectExportDialog::_name_editing_finished() {
|
||||
if (updating) {
|
||||
return;
|
||||
}
|
||||
|
||||
_name_changed(name->get_text());
|
||||
}
|
||||
|
||||
void ProjectExportDialog::set_export_path(const String &p_value) {
|
||||
Ref<EditorExportPreset> current = get_current_preset();
|
||||
ERR_FAIL_COND(current.is_null());
|
||||
@@ -1506,7 +1529,8 @@ ProjectExportDialog::ProjectExportDialog() {
|
||||
|
||||
name = memnew(LineEdit);
|
||||
settings_vb->add_margin_child(TTR("Name:"), name);
|
||||
name->connect(SceneStringName(text_changed), callable_mp(this, &ProjectExportDialog::_name_changed));
|
||||
name->connect(SceneStringName(text_submitted), callable_mp(this, &ProjectExportDialog::_name_changed));
|
||||
name->connect(SceneStringName(focus_exited), callable_mp(this, &ProjectExportDialog::_name_editing_finished));
|
||||
|
||||
runnable = memnew(CheckButton);
|
||||
runnable->set_text(TTR("Runnable"));
|
||||
|
||||
Reference in New Issue
Block a user