You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-07 12:30:27 +00:00
Allow configuring the script filename casing rule
Defaults to "Auto", which detects the casing based on the preference of the currently selected language (C# for example prefers PascalCase whereas GDScript prefers snake_case).
This commit is contained in:
@@ -3089,17 +3089,40 @@ 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 &p_root_name) {
|
||||
switch (GLOBAL_GET("editor/naming/scene_name_casing").operator int()) {
|
||||
case SCENE_NAME_CASING_AUTO:
|
||||
// Use casing of the root node.
|
||||
break;
|
||||
case SCENE_NAME_CASING_PASCAL_CASE:
|
||||
return root_name.to_pascal_case();
|
||||
return p_root_name.replace("-", "_").to_pascal_case();
|
||||
case SCENE_NAME_CASING_SNAKE_CASE:
|
||||
return root_name.replace("-", "_").to_snake_case();
|
||||
return p_root_name.replace("-", "_").to_snake_case();
|
||||
case SCENE_NAME_CASING_KEBAB_CASE:
|
||||
return p_root_name.to_snake_case().replace("_", "-");
|
||||
}
|
||||
return root_name;
|
||||
return p_root_name;
|
||||
}
|
||||
|
||||
String EditorNode::adjust_script_name_casing(const String &p_file_name, ScriptLanguage::ScriptNameCasing p_auto_casing) {
|
||||
int editor_casing = GLOBAL_GET("editor/naming/script_name_casing");
|
||||
if (editor_casing == ScriptLanguage::SCRIPT_NAME_CASING_AUTO) {
|
||||
// Use the script language's preferred casing.
|
||||
editor_casing = p_auto_casing;
|
||||
}
|
||||
|
||||
switch (editor_casing) {
|
||||
case ScriptLanguage::SCRIPT_NAME_CASING_AUTO:
|
||||
// Script language has no preference, so do not adjust.
|
||||
break;
|
||||
case ScriptLanguage::SCRIPT_NAME_CASING_PASCAL_CASE:
|
||||
return p_file_name.replace("-", "_").to_pascal_case();
|
||||
case ScriptLanguage::SCRIPT_NAME_CASING_SNAKE_CASE:
|
||||
return p_file_name.replace("-", "_").to_snake_case();
|
||||
case ScriptLanguage::SCRIPT_NAME_CASING_KEBAB_CASE:
|
||||
return p_file_name.to_snake_case().replace("_", "-");
|
||||
}
|
||||
return p_file_name;
|
||||
}
|
||||
|
||||
void EditorNode::_request_screenshot() {
|
||||
|
||||
Reference in New Issue
Block a user