diff --git a/editor/plugin_config_dialog.cpp b/editor/plugin_config_dialog.cpp index f55d77d7823..963203c0420 100644 --- a/editor/plugin_config_dialog.cpp +++ b/editor/plugin_config_dialog.cpp @@ -126,7 +126,51 @@ void PluginConfigDialog::_on_cancelled() { void PluginConfigDialog::_on_required_text_changed(const String &) { int lang_idx = script_option_edit->get_selected(); String ext = ScriptServer::get_language(lang_idx)->get_extension(); - get_ok_button()->set_disabled(script_edit->get_text().get_basename().is_empty() || script_edit->get_text().get_extension() != ext || name_edit->get_text().is_empty()); + + Ref valid_icon = get_theme_icon("StatusSuccess", "EditorIcons"); + Ref invalid_icon = get_theme_icon("StatusWarning", "EditorIcons"); + + // Set variables to assume all is valid + bool is_valid = true; + name_validation->set_texture(valid_icon); + subfolder_validation->set_texture(valid_icon); + script_validation->set_texture(valid_icon); + name_validation->set_tooltip(""); + subfolder_validation->set_tooltip(""); + script_validation->set_tooltip(""); + + // Change valid status to invalid depending on conditions. + Vector errors; + if (name_edit->get_text().is_empty()) { + is_valid = false; + name_validation->set_texture(invalid_icon); + name_validation->set_tooltip(TTR("Plugin name cannot not be blank.")); + } + if (script_edit->get_text().get_extension() != ext) { + is_valid = false; + script_validation->set_texture(invalid_icon); + script_validation->set_tooltip(vformat(TTR("Script extension must match chosen langauge extension (.%s)."), ext)); + } + if (script_edit->get_text().get_basename().is_empty()) { + is_valid = false; + script_validation->set_texture(invalid_icon); + script_validation->set_tooltip(TTR("Script name cannot not be blank.")); + } + if (subfolder_edit->get_text().is_empty()) { + is_valid = false; + subfolder_validation->set_texture(invalid_icon); + subfolder_validation->set_tooltip(TTR("Subfolder cannot be blank.")); + } else { + DirAccessRef dir = DirAccess::create(DirAccess::ACCESS_RESOURCES); + String path = "res://addons/" + subfolder_edit->get_text(); + if (dir->dir_exists(path) && !_edit_mode) { // Only show this error if in "create" mode. + is_valid = false; + subfolder_validation->set_texture(invalid_icon); + subfolder_validation->set_tooltip(TTR("Subfolder cannot be one which already exists.")); + } + } + + get_ok_button()->set_disabled(!is_valid); } String PluginConfigDialog::_to_absolute_plugin_path(const String &p_plugin_name) { @@ -162,19 +206,22 @@ void PluginConfigDialog::config(const String &p_config_path) { _edit_mode = true; active_edit->hide(); - Object::cast_to