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

Add alternative name styles for signals and resource names #724

Conversation

valkyrienyanko
Copy link
Contributor

@valkyrienyanko valkyrienyanko commented Oct 16, 2024

What does this PR do?

Redot defaults to using _snake_case for signal / script names with no alternatives.

This PR provides alternatives such as _snake_case, snake_case, camelCase, PascalCase that can be set in the editor settings.

image

This PR changes names for

  • Signal Names
  • Resource Names (scripts / scenes / shaders)

Todo

  • Separate coding_language_style into 2 or more options for setting signal names and resource names separately
  • Maybe edit register_editor_types.cpp around lines 280 - 283 to account for these new PR changes

There could be a new option "Naming Style" that adds the options "_camel_case, camel_case, PascalCase, snakeCase" OR this could be defined in the editor settings.
image

Should a new "Naming Style" dropdown be added here as well or stay in editor settings?
image

Should a new "Naming Style" dropdown be added here or be in editor settings?
image

Known Issues

  • Camel case does not camel the last word in signal names

Note

This PR description originally talked about automatically changing the signal names so their PascalCase for mono projects and _snake_case for GDScript projects but as @Spartan322 pointed out this is not the correct way to do this. So now this PR lets the user choose what styles they want.

@Spartan322
Copy link
Member

Spartan322 commented Oct 16, 2024

This is not the correct way to do this, it should not be changed based on whether you compile with the "mono" module or not, its language dependent, a more valuable consideration would be a global editor setting which templates the default project settings for each new create project, or a more targeted solution would be allowing each language to define these things for itself. (worst case scenario would be separating the editor/naming section into hardcoded GDScript and dotnet sections)

@valkyrienyanko
Copy link
Contributor Author

a more valuable consideration would be a global editor setting

Global editor setting sounds good. I'm visualizing a dropdown with settings like "PascalCase", "cameCase", "snake_case", etc.

There could be another editor setting that changes the formatting of creating new scene names. So for example if you selected PascalCase then it would be Player.tscn instead of player.tscn.

So there would be 2 editor settings both with the same dropdown options. One for changing the signal name formatting and the other for changing the new scene formatting.

image

@SkogiB
Copy link
Contributor

SkogiB commented Oct 17, 2024

a more valuable consideration would be a global editor setting

Global editor setting sounds good. I'm visualizing a dropdown with settings like "PascalCase", "cameCase", "snake_case", etc.

There could be another editor setting that changes the formatting of creating new scene names. So for example if you selected PascalCase then it would be Player.tscn instead of player.tscn.

So there would be 2 editor settings both with the same dropdown options. One for changing the signal name formatting and the other for changing the new scene formatting.

image

Having options for broader case swapping would be nice, keep us posted on that. We'd have to propose it to Godot and I'm sure they'd reject it

@valkyrienyanko valkyrienyanko changed the title Generate PascalCase Signal Method Names for Mono Projects Add alternative name styles for signals and resource names Oct 31, 2024
@valkyrienyanko valkyrienyanko force-pushed the pascal-case-for-signal-names branch from cceae43 to 447509f Compare October 31, 2024 21:48
Change signal names based on editor option
Add coding_language_style to editor settings
Remove / change original Godot code
@valkyrienyanko
Copy link
Contributor Author

image

Just found out that these features were already implemented into the engine so I'm going to close this PR.

@SkogiB
Copy link
Contributor

SkogiB commented Nov 2, 2024

well shit lmao

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants