diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2022-09-22 08:27:06 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2022-09-22 08:27:06 +0200 |
commit | 08bd94e4ba4a9070ff78531e202833ca7e0f1e93 (patch) | |
tree | c9ec19fdd9dc8ba710d501f3f3646790a9567e52 | |
parent | d96b7d767a1f7f8a5be37b80077e276bb174005f (diff) | |
parent | 3a2abf7486f00005248ece35dc2c0b67afe3119e (diff) |
Merge pull request #66236 from KoBeWi/empty_words
Automatically use class name for empty renames
-rw-r--r-- | editor/scene_tree_editor.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index 6fff2ab7cb..0b1e9719b7 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -30,6 +30,7 @@ #include "scene_tree_editor.h" +#include "core/config/project_settings.h" #include "core/object/message_queue.h" #include "core/string/print_string.h" #include "editor/editor_file_system.h" @@ -942,14 +943,16 @@ void SceneTreeEditor::_renamed() { Node *n = get_node(np); ERR_FAIL_COND(!n); - // Empty node names are not allowed, so resets it to previous text and show warning - if (which->get_text(0).strip_edges().is_empty()) { - which->set_text(0, n->get_name()); - EditorNode::get_singleton()->show_warning(TTR("No name provided.")); - return; + String raw_new_name = which->get_text(0); + if (raw_new_name.strip_edges().is_empty()) { + // If name is empty, fallback to class name. + if (GLOBAL_GET("editor/node_naming/name_casing").operator int() != NAME_CASING_PASCAL_CASE) { + raw_new_name = Node::adjust_name_casing(n->get_class()); + } else { + raw_new_name = n->get_class(); + } } - String raw_new_name = which->get_text(0); String new_name = raw_new_name.validate_node_name(); if (new_name != raw_new_name) { |