diff options
author | Ray Koopa <raykoopa@users.noreply.github.com> | 2017-01-12 19:13:09 +0100 |
---|---|---|
committer | RĂ©mi Verschelde <rverschelde@gmail.com> | 2017-01-12 20:47:25 +0100 |
commit | a971186c266de2df818a7f3dc063a49b0ad51bd8 (patch) | |
tree | 1631817b24617cb2b2c43f7db6e566b1d81163e6 /scene | |
parent | 6dd7d2c1f79eb2ac8f08785b9d903a01286184f8 (diff) |
Project setting to control node name casing
(cherry picked from commit 87fd54b2f18928213021fef7f330d0c314cf7ac7)
Diffstat (limited to 'scene')
-rw-r--r-- | scene/main/node.cpp | 14 | ||||
-rw-r--r-- | scene/main/node.h | 6 |
2 files changed, 19 insertions, 1 deletions
diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 32cefa6085..d24edea991 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -1384,6 +1384,17 @@ String Node::_generate_serial_child_name(Node *p_child) { if (name=="") { name = p_child->get_class(); + // Adjust casing according to project setting. The current type name is expected to be in PascalCase. + switch (Globals::get_singleton()->get("node/name_casing").operator int()) { + case NAME_CASING_PASCAL_CASE: + break; + case NAME_CASING_CAMEL_CASE: + name[0] = name.to_lower()[0]; + break; + case NAME_CASING_SNAKE_CASE: + name = name.camelcase_to_underscore(true); + break; + } } // Extract trailing number @@ -2890,7 +2901,8 @@ void Node::_bind_methods() { _GLOBAL_DEF("editor/node_name_num_separator",0); GlobalConfig::get_singleton()->set_custom_property_info("editor/node_name_num_separator",PropertyInfo(Variant::INT,"editor/node_name_num_separator",PROPERTY_HINT_ENUM, "None,Space,Underscore,Dash")); - + _GLOBAL_DEF("node/name_casing",NAME_CASING_PASCAL_CASE); + GlobalConfig::get_singleton()->set_custom_property_info("node/name_casing",PropertyInfo(Variant::INT,"node/name_casing",PROPERTY_HINT_ENUM,"PascalCase,camelCase,snake_case")); ClassDB::bind_method(_MD("_add_child_below_node","node:Node","child_node:Node","legible_unique_name"),&Node::add_child_below_node,DEFVAL(false)); diff --git a/scene/main/node.h b/scene/main/node.h index e27404d46e..14fd19a76f 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -147,6 +147,12 @@ private: } data; + enum NameCasing { + NAME_CASING_PASCAL_CASE, + NAME_CASING_CAMEL_CASE, + NAME_CASING_SNAKE_CASE + }; + void _print_tree(const Node *p_node); |