Name nodes added from drag & drop by name_casing
(cherry picked from commit 07a8f0fe38
)
This commit is contained in:
parent
d46d66020e
commit
f807c7e569
2 changed files with 22 additions and 7 deletions
|
@ -6279,7 +6279,22 @@ bool CanvasItemEditorViewport::_cyclical_dependency_exists(const String &p_targe
|
||||||
}
|
}
|
||||||
|
|
||||||
void CanvasItemEditorViewport::_create_nodes(Node *parent, Node *child, String &path, const Point2 &p_point) {
|
void CanvasItemEditorViewport::_create_nodes(Node *parent, Node *child, String &path, const Point2 &p_point) {
|
||||||
child->set_name(path.get_file().get_basename());
|
// Adjust casing according to project setting. The file name is expected to be in snake_case, but will work for others.
|
||||||
|
String name = path.get_file().get_basename();
|
||||||
|
switch (ProjectSettings::get_singleton()->get("editor/node_naming/name_casing").operator int()) {
|
||||||
|
case NAME_CASING_PASCAL_CASE:
|
||||||
|
name = name.capitalize().replace(" ", "");
|
||||||
|
break;
|
||||||
|
case NAME_CASING_CAMEL_CASE:
|
||||||
|
name = name.capitalize().replace(" ", "");
|
||||||
|
name[0] = name.to_lower()[0];
|
||||||
|
break;
|
||||||
|
case NAME_CASING_SNAKE_CASE:
|
||||||
|
name = name.capitalize().replace(" ", "_").to_lower();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
child->set_name(name);
|
||||||
|
|
||||||
Ref<Texture> texture = Ref<Texture>(Object::cast_to<Texture>(ResourceCache::get(path)));
|
Ref<Texture> texture = Ref<Texture>(Object::cast_to<Texture>(ResourceCache::get(path)));
|
||||||
Size2 texture_size = texture->get_size();
|
Size2 texture_size = texture->get_size();
|
||||||
|
|
||||||
|
|
|
@ -64,6 +64,12 @@ public:
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum NameCasing {
|
||||||
|
NAME_CASING_PASCAL_CASE,
|
||||||
|
NAME_CASING_CAMEL_CASE,
|
||||||
|
NAME_CASING_SNAKE_CASE
|
||||||
|
};
|
||||||
|
|
||||||
struct Comparator {
|
struct Comparator {
|
||||||
bool operator()(const Node *p_a, const Node *p_b) const { return p_b->is_greater_than(p_a); }
|
bool operator()(const Node *p_a, const Node *p_b) const { return p_b->is_greater_than(p_a); }
|
||||||
};
|
};
|
||||||
|
@ -138,12 +144,6 @@ private:
|
||||||
|
|
||||||
} data;
|
} data;
|
||||||
|
|
||||||
enum NameCasing {
|
|
||||||
NAME_CASING_PASCAL_CASE,
|
|
||||||
NAME_CASING_CAMEL_CASE,
|
|
||||||
NAME_CASING_SNAKE_CASE
|
|
||||||
};
|
|
||||||
|
|
||||||
Ref<MultiplayerAPI> multiplayer;
|
Ref<MultiplayerAPI> multiplayer;
|
||||||
|
|
||||||
void _print_tree_pretty(const String &prefix, const bool last);
|
void _print_tree_pretty(const String &prefix, const bool last);
|
||||||
|
|
Loading…
Reference in a new issue