瀏覽代碼

Merge pull request #110259 from ktxyz/add-name-to-invalid-name-error-output

Add name info to EditorAutoloadSettings invalid name message
Thaddeus Crews 4 周之前
父節點
當前提交
2db6704576
共有 1 個文件被更改,包括 7 次插入7 次删除
  1. 7 7
      editor/settings/editor_autoload_settings.cpp

+ 7 - 7
editor/settings/editor_autoload_settings.cpp

@@ -95,7 +95,7 @@ void EditorAutoloadSettings::_notification(int p_what) {
 bool EditorAutoloadSettings::_autoload_name_is_valid(const String &p_name, String *r_error) {
 	if (!p_name.is_valid_unicode_identifier()) {
 		if (r_error) {
-			*r_error = TTR("Invalid name.") + " " + TTR("Must be a valid Unicode identifier.");
+			*r_error = TTR("Must be a valid Unicode identifier.");
 		}
 
 		return false;
@@ -103,7 +103,7 @@ bool EditorAutoloadSettings::_autoload_name_is_valid(const String &p_name, Strin
 
 	if (ClassDB::class_exists(p_name)) {
 		if (r_error) {
-			*r_error = TTR("Invalid name.") + " " + TTR("Must not collide with an existing engine class name.");
+			*r_error = TTR("Must not collide with an existing engine class name.");
 		}
 
 		return false;
@@ -111,7 +111,7 @@ bool EditorAutoloadSettings::_autoload_name_is_valid(const String &p_name, Strin
 
 	if (ScriptServer::is_global_class(p_name)) {
 		if (r_error) {
-			*r_error = TTR("Invalid name.") + "\n" + TTR("Must not collide with an existing global script class name.");
+			*r_error = TTR("Must not collide with an existing global script class name.");
 		}
 
 		return false;
@@ -119,7 +119,7 @@ bool EditorAutoloadSettings::_autoload_name_is_valid(const String &p_name, Strin
 
 	if (Variant::get_type_by_name(p_name) < Variant::VARIANT_MAX) {
 		if (r_error) {
-			*r_error = TTR("Invalid name.") + " " + TTR("Must not collide with an existing built-in type name.");
+			*r_error = TTR("Must not collide with an existing built-in type name.");
 		}
 
 		return false;
@@ -128,7 +128,7 @@ bool EditorAutoloadSettings::_autoload_name_is_valid(const String &p_name, Strin
 	for (int i = 0; i < CoreConstants::get_global_constant_count(); i++) {
 		if (CoreConstants::get_global_constant_name(i) == p_name) {
 			if (r_error) {
-				*r_error = TTR("Invalid name.") + " " + TTR("Must not collide with an existing global constant name.");
+				*r_error = TTR("Must not collide with an existing global constant name.");
 			}
 
 			return false;
@@ -139,7 +139,7 @@ bool EditorAutoloadSettings::_autoload_name_is_valid(const String &p_name, Strin
 		for (const String &keyword : ScriptServer::get_language(i)->get_reserved_words()) {
 			if (keyword == p_name) {
 				if (r_error) {
-					*r_error = TTR("Invalid name.") + " " + TTR("Keyword cannot be used as an Autoload name.");
+					*r_error = TTR("Keyword cannot be used as an Autoload name.");
 				}
 
 				return false;
@@ -780,7 +780,7 @@ bool EditorAutoloadSettings::autoload_add(const String &p_name, const String &p_
 
 	String error;
 	if (!_autoload_name_is_valid(name, &error)) {
-		EditorNode::get_singleton()->show_warning(TTR("Can't add Autoload:") + "\n" + error);
+		EditorNode::get_singleton()->show_warning(TTR("Can't add Autoload:") + "\n" + vformat(TTR("%s is an invalid name."), p_name) + " " + error);
 		return false;
 	}