You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-20 14:45:44 +00:00
Automatically use class name for empty renames
This commit is contained in:
@@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
#include "scene_tree_editor.h"
|
#include "scene_tree_editor.h"
|
||||||
|
|
||||||
|
#include "core/config/project_settings.h"
|
||||||
#include "core/object/message_queue.h"
|
#include "core/object/message_queue.h"
|
||||||
#include "core/string/print_string.h"
|
#include "core/string/print_string.h"
|
||||||
#include "editor/editor_file_system.h"
|
#include "editor/editor_file_system.h"
|
||||||
@@ -942,14 +943,16 @@ void SceneTreeEditor::_renamed() {
|
|||||||
Node *n = get_node(np);
|
Node *n = get_node(np);
|
||||||
ERR_FAIL_COND(!n);
|
ERR_FAIL_COND(!n);
|
||||||
|
|
||||||
// Empty node names are not allowed, so resets it to previous text and show warning
|
String raw_new_name = which->get_text(0);
|
||||||
if (which->get_text(0).strip_edges().is_empty()) {
|
if (raw_new_name.strip_edges().is_empty()) {
|
||||||
which->set_text(0, n->get_name());
|
// If name is empty, fallback to class name.
|
||||||
EditorNode::get_singleton()->show_warning(TTR("No name provided."));
|
if (GLOBAL_GET("editor/node_naming/name_casing").operator int() != NAME_CASING_PASCAL_CASE) {
|
||||||
return;
|
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();
|
String new_name = raw_new_name.validate_node_name();
|
||||||
|
|
||||||
if (new_name != raw_new_name) {
|
if (new_name != raw_new_name) {
|
||||||
|
|||||||
Reference in New Issue
Block a user