Merge pull request #65137 from dalexeev/editor-naming

Rearrange `editor/naming/*` project settings
This commit is contained in:
Yuri Sizov 2023-01-24 22:26:03 +03:00 committed by GitHub
commit fab9926a95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 23 additions and 15 deletions

View File

@ -1286,6 +1286,10 @@ ProjectSettings::ProjectSettings() {
GLOBAL_DEF(PropertyInfo(Variant::STRING, "editor/script/templates_search_path", PROPERTY_HINT_DIR), "res://script_templates"); GLOBAL_DEF(PropertyInfo(Variant::STRING, "editor/script/templates_search_path", PROPERTY_HINT_DIR), "res://script_templates");
// For correct doc generation.
GLOBAL_DEF("editor/naming/default_signal_callback_name", "_on_{node_name}_{signal_name}");
GLOBAL_DEF("editor/naming/default_signal_callback_to_self_name", "_on_{signal_name}");
_add_builtin_input_map(); _add_builtin_input_map();
// Keep the enum values in sync with the `DisplayServer::ScreenOrientation` enum. // Keep the enum values in sync with the `DisplayServer::ScreenOrientation` enum.

View File

@ -698,10 +698,16 @@
<member name="editor/movie_writer/speaker_mode" type="int" setter="" getter="" default="0"> <member name="editor/movie_writer/speaker_mode" type="int" setter="" getter="" default="0">
The speaker mode to use in the recorded audio when writing a movie. See [enum AudioServer.SpeakerMode] for possible values. The speaker mode to use in the recorded audio when writing a movie. See [enum AudioServer.SpeakerMode] for possible values.
</member> </member>
<member name="editor/node_naming/name_casing" type="int" setter="" getter="" default="0"> <member name="editor/naming/default_signal_callback_name" type="String" setter="" getter="" default="&quot;_on_{node_name}_{signal_name}&quot;">
The format of the default signal callback name (in the Signal Connection Dialog). The following substitutions are available: [code]{NodeName}[/code], [code]{nodeName}[/code], [code]{node_name}[/code], [code]{SignalName}[/code], [code]{signalName}[/code], and [code]{signal_name}[/code].
</member>
<member name="editor/naming/default_signal_callback_to_self_name" type="String" setter="" getter="" default="&quot;_on_{signal_name}&quot;">
The format of the default signal callback name when a signal connects to the same node that emits it (in the Signal Connection Dialog). The following substitutions are available: [code]{NodeName}[/code], [code]{nodeName}[/code], [code]{node_name}[/code], [code]{SignalName}[/code], [code]{signalName}[/code], and [code]{signal_name}[/code].
</member>
<member name="editor/naming/node_name_casing" type="int" setter="" getter="" default="0">
When creating node names automatically, set the type of casing in this project. This is mostly an editor setting. When creating node names automatically, set the type of casing in this project. This is mostly an editor setting.
</member> </member>
<member name="editor/node_naming/name_num_separator" type="int" setter="" getter="" default="0"> <member name="editor/naming/node_name_num_separator" type="int" setter="" getter="" default="0">
What to use to separate node name from number. This is mostly an editor setting. What to use to separate node name from number. This is mostly an editor setting.
</member> </member>
<member name="editor/run/main_run_args" type="String" setter="" getter="" default="&quot;&quot;"> <member name="editor/run/main_run_args" type="String" setter="" getter="" default="&quot;&quot;">

View File

@ -30,6 +30,7 @@
#include "connections_dialog.h" #include "connections_dialog.h"
#include "core/config/project_settings.h"
#include "editor/doc_tools.h" #include "editor/doc_tools.h"
#include "editor/editor_help.h" #include "editor/editor_help.h"
#include "editor/editor_node.h" #include "editor/editor_node.h"
@ -242,9 +243,9 @@ StringName ConnectDialog::generate_method_callback_name(Node *p_source, String p
String dst_method; String dst_method;
if (p_source == p_target) { if (p_source == p_target) {
dst_method = String(EDITOR_GET("interface/editors/default_signal_callback_to_self_name")).format(subst); dst_method = String(GLOBAL_GET("editor/naming/default_signal_callback_to_self_name")).format(subst);
} else { } else {
dst_method = String(EDITOR_GET("interface/editors/default_signal_callback_name")).format(subst); dst_method = String(GLOBAL_GET("editor/naming/default_signal_callback_name")).format(subst);
} }
return dst_method; return dst_method;
@ -1238,9 +1239,6 @@ ConnectionsDock::ConnectionsDock() {
tree->connect("item_mouse_selected", callable_mp(this, &ConnectionsDock::_rmb_pressed)); tree->connect("item_mouse_selected", callable_mp(this, &ConnectionsDock::_rmb_pressed));
add_theme_constant_override("separation", 3 * EDSCALE); add_theme_constant_override("separation", 3 * EDSCALE);
EDITOR_DEF("interface/editors/default_signal_callback_name", "_on_{node_name}_{signal_name}");
EDITOR_DEF("interface/editors/default_signal_callback_to_self_name", "_on_{signal_name}");
} }
ConnectionsDock::~ConnectionsDock() { ConnectionsDock::~ConnectionsDock() {

View File

@ -3089,7 +3089,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
} }
String EditorNode::adjust_scene_name_casing(const String &root_name) { String EditorNode::adjust_scene_name_casing(const String &root_name) {
switch (GLOBAL_GET("editor/scene/scene_naming").operator int()) { switch (GLOBAL_GET("editor/naming/scene_name_casing").operator int()) {
case SCENE_NAME_CASING_AUTO: case SCENE_NAME_CASING_AUTO:
// Use casing of the root node. // Use casing of the root node.
break; break;
@ -6429,7 +6429,7 @@ void EditorNode::_feature_profile_changed() {
} }
void EditorNode::_bind_methods() { void EditorNode::_bind_methods() {
GLOBAL_DEF(PropertyInfo(Variant::INT, "editor/scene/scene_naming", PROPERTY_HINT_ENUM, "Auto,PascalCase,snake_case"), SCENE_NAME_CASING_SNAKE_CASE); GLOBAL_DEF(PropertyInfo(Variant::INT, "editor/naming/scene_name_casing", PROPERTY_HINT_ENUM, "Auto,PascalCase,snake_case"), SCENE_NAME_CASING_SNAKE_CASE);
ClassDB::bind_method("edit_current", &EditorNode::edit_current); ClassDB::bind_method("edit_current", &EditorNode::edit_current);
ClassDB::bind_method("edit_node", &EditorNode::edit_node); ClassDB::bind_method("edit_node", &EditorNode::edit_node);

View File

@ -2191,7 +2191,7 @@ void SceneTreeDock::_do_create(Node *p_parent) {
ERR_FAIL_COND(!child); ERR_FAIL_COND(!child);
String new_name = p_parent->validate_child_name(child); String new_name = p_parent->validate_child_name(child);
if (GLOBAL_GET("editor/node_naming/name_casing").operator int() != NAME_CASING_PASCAL_CASE) { if (GLOBAL_GET("editor/naming/node_name_casing").operator int() != NAME_CASING_PASCAL_CASE) {
new_name = adjust_name_casing(new_name); new_name = adjust_name_casing(new_name);
} }
child->set_name(new_name); child->set_name(new_name);

View File

@ -971,7 +971,7 @@ void SceneTreeEditor::_renamed() {
String raw_new_name = which->get_text(0); String raw_new_name = which->get_text(0);
if (raw_new_name.strip_edges().is_empty()) { if (raw_new_name.strip_edges().is_empty()) {
// If name is empty, fallback to class name. // If name is empty, fallback to class name.
if (GLOBAL_GET("editor/node_naming/name_casing").operator int() != NAME_CASING_PASCAL_CASE) { if (GLOBAL_GET("editor/naming/node_name_casing").operator int() != NAME_CASING_PASCAL_CASE) {
raw_new_name = Node::adjust_name_casing(n->get_class()); raw_new_name = Node::adjust_name_casing(n->get_class());
} else { } else {
raw_new_name = n->get_class(); raw_new_name = n->get_class();

View File

@ -946,7 +946,7 @@ String Node::validate_child_name(Node *p_child) {
#endif #endif
String Node::adjust_name_casing(const String &p_name) { String Node::adjust_name_casing(const String &p_name) {
switch (GLOBAL_GET("editor/node_naming/name_casing").operator int()) { switch (GLOBAL_GET("editor/naming/node_name_casing").operator int()) {
case NAME_CASING_PASCAL_CASE: case NAME_CASING_PASCAL_CASE:
return p_name.to_pascal_case(); return p_name.to_pascal_case();
case NAME_CASING_CAMEL_CASE: case NAME_CASING_CAMEL_CASE:
@ -2799,8 +2799,8 @@ void Node::unhandled_key_input(const Ref<InputEvent> &p_key_event) {
} }
void Node::_bind_methods() { void Node::_bind_methods() {
GLOBAL_DEF(PropertyInfo(Variant::INT, "editor/node_naming/name_num_separator", PROPERTY_HINT_ENUM, "None,Space,Underscore,Dash"), 0); GLOBAL_DEF(PropertyInfo(Variant::INT, "editor/naming/node_name_num_separator", PROPERTY_HINT_ENUM, "None,Space,Underscore,Dash"), 0);
GLOBAL_DEF(PropertyInfo(Variant::INT, "editor/node_naming/name_casing", PROPERTY_HINT_ENUM, "PascalCase,camelCase,snake_case"), NAME_CASING_PASCAL_CASE); GLOBAL_DEF(PropertyInfo(Variant::INT, "editor/naming/node_name_casing", PROPERTY_HINT_ENUM, "PascalCase,camelCase,snake_case"), NAME_CASING_PASCAL_CASE);
ClassDB::bind_static_method("Node", D_METHOD("print_orphan_nodes"), &Node::print_orphan_nodes); ClassDB::bind_static_method("Node", D_METHOD("print_orphan_nodes"), &Node::print_orphan_nodes);
ClassDB::bind_method(D_METHOD("add_sibling", "sibling", "force_readable_name"), &Node::add_sibling, DEFVAL(false)); ClassDB::bind_method(D_METHOD("add_sibling", "sibling", "force_readable_name"), &Node::add_sibling, DEFVAL(false));
@ -3022,7 +3022,7 @@ void Node::_bind_methods() {
} }
String Node::_get_name_num_separator() { String Node::_get_name_num_separator() {
switch (GLOBAL_GET("editor/node_naming/name_num_separator").operator int()) { switch (GLOBAL_GET("editor/naming/node_name_num_separator").operator int()) {
case 0: case 0:
return ""; return "";
case 1: case 1: