Skip to content

Commit 02a696c

Browse files
committed
Add name info to EditorAutoloadSettings invalid name message
1 parent 6c9aa4c commit 02a696c

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

editor/settings/editor_autoload_settings.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,33 +93,35 @@ void EditorAutoloadSettings::_notification(int p_what) {
9393
}
9494

9595
bool EditorAutoloadSettings::_autoload_name_is_valid(const String &p_name, String *r_error) {
96+
String invalid_name_msg = vformat(TTR("Invalid name: %s"), p_name);
97+
9698
if (!p_name.is_valid_unicode_identifier()) {
9799
if (r_error) {
98-
*r_error = TTR("Invalid name.") + " " + TTR("Must be a valid Unicode identifier.");
100+
*r_error = invalid_name_msg + " " + TTR("Must be a valid Unicode identifier.");
99101
}
100102

101103
return false;
102104
}
103105

104106
if (ClassDB::class_exists(p_name)) {
105107
if (r_error) {
106-
*r_error = TTR("Invalid name.") + " " + TTR("Must not collide with an existing engine class name.");
108+
*r_error = invalid_name_msg + " " + TTR("Must not collide with an existing engine class name.");
107109
}
108110

109111
return false;
110112
}
111113

112114
if (ScriptServer::is_global_class(p_name)) {
113115
if (r_error) {
114-
*r_error = TTR("Invalid name.") + "\n" + TTR("Must not collide with an existing global script class name.");
116+
*r_error = invalid_name_msg + "\n" + TTR("Must not collide with an existing global script class name.");
115117
}
116118

117119
return false;
118120
}
119121

120122
if (Variant::get_type_by_name(p_name) < Variant::VARIANT_MAX) {
121123
if (r_error) {
122-
*r_error = TTR("Invalid name.") + " " + TTR("Must not collide with an existing built-in type name.");
124+
*r_error = invalid_name_msg + " " + TTR("Must not collide with an existing built-in type name.");
123125
}
124126

125127
return false;
@@ -128,7 +130,7 @@ bool EditorAutoloadSettings::_autoload_name_is_valid(const String &p_name, Strin
128130
for (int i = 0; i < CoreConstants::get_global_constant_count(); i++) {
129131
if (CoreConstants::get_global_constant_name(i) == p_name) {
130132
if (r_error) {
131-
*r_error = TTR("Invalid name.") + " " + TTR("Must not collide with an existing global constant name.");
133+
*r_error = invalid_name_msg + " " + TTR("Must not collide with an existing global constant name.");
132134
}
133135

134136
return false;
@@ -139,7 +141,7 @@ bool EditorAutoloadSettings::_autoload_name_is_valid(const String &p_name, Strin
139141
for (const String &keyword : ScriptServer::get_language(i)->get_reserved_words()) {
140142
if (keyword == p_name) {
141143
if (r_error) {
142-
*r_error = TTR("Invalid name.") + " " + TTR("Keyword cannot be used as an Autoload name.");
144+
*r_error = invalid_name_msg + " " + TTR("Keyword cannot be used as an Autoload name.");
143145
}
144146

145147
return false;

0 commit comments

Comments
 (0)