godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.14k stars 93 forks source link

Show generated code snippet after the signal connection dialog #3633

Open JA-Developer opened 2 years ago

JA-Developer commented 2 years ago

Describe the project you are working on

Hello. I was using VSCode with the Mono version of Godot Engine 3.4. I just created a project, added a button, and tried to connect a signal to it.

Describe the problem or limitation you are having in your project

I found that when I tried to connect a signal to a node using the Godot Editor it didn't work. After some research, I discovered that this is a bug that has not been solved yet. And, it happens in both mono and standard versions of godot.

Take a look at https://github.com/godotengine/godot/issues/41283

There were only two things I could do to solve the problem:

  1. Avoid using an external editor.
  2. Write the function code manually.

The second option is easy to do when the signals have few parameters, but it is a bit annoying when the signals have many parameters because you have to look at the description of the signal to know what parameters the function needs (which is not user friendly), as it's shown in the following picture:

image

Describe the feature / enhancement and how it helps to overcome the problem or limitation

After a new signal is created from the Godot editor interface, a dialog will be displayed with the code snippet created. I show an example in the following image:

image

I think the only problem with this solution is that people will have to click more when adding a new signal. I don't really think it's a big inconvenience, but, if anyone worries about it, this code snippet can also be displayed in the same window where the user creates the signal.

This will be useful because if no code is generated automatically, users will be able to copy and paste the code snippet into their file.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

When creating a new signal, users will need to perform the following steps:

  1. Select the signal:

image

  1. Connect the signal:

image

  1. If no code is generated automatically, copy and paste the code snippet:

image

If this enhancement will not be used often, can it be worked around with a few lines of script?

I guess users can't solve it using script but it can be solved as I mentioned before, it's not user friendly though.

Is there a reason why this should be core and not an add-on in the asset library?

I think this will improve the usability of the editor and temporarily solve the problem I mentioned earlier. So, this should be available to all users, even when they don't have any plugins installed.

Calinou commented 2 years ago

I think fixing the original bug is more straightforward at this point. If it's fixed, then this solution doesn't have much of a reason to exist.

JA-Developer commented 2 years ago

Thanks for the quick reply : D

I posted this idea because it seems to me that it is easier to implement and also gives developers an alternative way to use signals if it fails again in the future. I think this could also be useful if you are using an external editor that godot does not support (although this does not seem very likely). Also, I think it can be implemented in a better way than what I posted here, like putting this information in the same dialog where the signal is connected.

But I really don't know what Godot's development is like, so you're probably right, it's probably not worth it.

lenscas commented 1 year ago

I think fixing the original bug is more straightforward at this point. If it's fixed, then this solution doesn't have much of a reason to exist.

I disagree simply based on the amount of languages that people can use with Godot. There is no way that Godot will be able to generate the correct code, at the correct location for every language that has Godot bindings.

A dialog box makes it easy to copy/paste at least the name in those situations while still being quite decent UX for supported languages.