Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project setting to control node name casing #7509

Merged
merged 1 commit into from
Jan 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions scene/main/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1309,6 +1309,17 @@ String Node::_generate_serial_child_name(Node *p_child) {
if (name=="") {

name = p_child->get_type();
// 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
Expand Down Expand Up @@ -2811,6 +2822,8 @@ void Node::_bind_methods() {

_GLOBAL_DEF("node/name_num_separator",0);
Globals::get_singleton()->set_custom_property_info("node/name_num_separator",PropertyInfo(Variant::INT,"node/name_num_separator",PROPERTY_HINT_ENUM, "None,Space,Underscore,Dash"));
_GLOBAL_DEF("node/name_casing",NAME_CASING_PASCAL_CASE);
Globals::get_singleton()->set_custom_property_info("node/name_casing",PropertyInfo(Variant::INT,"node/name_casing",PROPERTY_HINT_ENUM,"PascalCase,camelCase,snake_case"));


ObjectTypeDB::bind_method(_MD("_add_child_below_node","node:Node","child_node:Node","legible_unique_name"),&Node::add_child_below_node,DEFVAL(false));
Expand Down
6 changes: 6 additions & 0 deletions scene/main/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ class Node : public Object {

} data;

enum NameCasing {
NAME_CASING_PASCAL_CASE,
NAME_CASING_CAMEL_CASE,
NAME_CASING_SNAKE_CASE
};


void _print_tree(const Node *p_node);

Expand Down