diff --git a/editor/settings/editor_autoload_settings.cpp b/editor/settings/editor_autoload_settings.cpp index 2f6d6ab18755..cda05e837ea2 100644 --- a/editor/settings/editor_autoload_settings.cpp +++ b/editor/settings/editor_autoload_settings.cpp @@ -40,12 +40,15 @@ #include "editor/editor_node.h" #include "editor/editor_undo_redo_manager.h" #include "editor/gui/editor_file_dialog.h" +#include "editor/gui/editor_validation_panel.h" #include "editor/scene/scene_create_dialog.h" #include "editor/settings/project_settings_editor.h" +#include "editor/themes/editor_scale.h" #include "scene/gui/button.h" +#include "scene/gui/dialogs.h" +#include "scene/gui/line_edit.h" #include "scene/gui/tree.h" #include "scene/main/scene_tree.h" -#include "scene/main/window.h" #include "scene/resources/packed_scene.h" #define PREVIEW_LIST_MAX_SIZE 10 @@ -133,6 +136,14 @@ bool EditorAutoloadSettings::_autoload_name_is_valid(const String &p_name, Strin return true; } +void EditorAutoloadSettings::_validate_autoload_name() { + String error; + bool is_valid = _autoload_name_is_valid(name_edit->get_text(), &error); + if (!is_valid) { + name_validator->set_message(0, error, EditorValidationPanel::MSG_ERROR); + } +} + void EditorAutoloadSettings::_autoload_selected() { TreeItem *ti = tree->get_selected(); @@ -402,7 +413,7 @@ void EditorAutoloadSettings::init_autoloads() { } void EditorAutoloadSettings::_autoload_file_selected(const String &p_path) { - _add_autoload(p_path.get_file().get_basename(), p_path); + _try_add_autoload(p_path.get_file().get_basename(), p_path); } void EditorAutoloadSettings::_scene_file_selected(const String &p_path) { @@ -418,7 +429,7 @@ void EditorAutoloadSettings::_scene_file_selected(const String &p_path) { void EditorAutoloadSettings::_script_created(Ref